[Quantproject-developers] QuantProject/b5_Presentation/Charting Chart.cs,1.1,1.2
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2004-07-07 20:25:35
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Charting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21677/b5_Presentation/Charting Modified Files: Chart.cs Log Message: - New external graphic library is used now (DateTime axis are supported) Index: Chart.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Charting/Chart.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Chart.cs 24 Jan 2004 19:09:49 -0000 1.1 --- Chart.cs 7 Jul 2004 20:25:26 -0000 1.2 *************** *** 22,25 **** --- 22,26 ---- using System; using System.Collections; + using System.Data; using System.Drawing; using scpl; *************** *** 70,101 **** } #region "OnPaint" ! private void onPaint_addLinePlot( ChartPlot chartPlot ) ! { ! int npt=chartPlot.History.Count; ! int startIndex = chartPlot.History.IndexOfKeyOrPrevious( chartPlot.StartDateTime ); ! int endIndex = chartPlot.History.IndexOfKeyOrPrevious( chartPlot.EndDateTime ); ! int plotLength = endIndex - startIndex + 1; ! float [] x = new float[ plotLength ]; ! float [] y = new float[ plotLength ]; ! float step=1.0F; ! for ( int i=startIndex ; i<=endIndex ; i++ ) ! { ! x[i-startIndex]=i*step; ! y[i-startIndex]=(float)chartPlot.History.GetByIndex( i ); ! } ! LinePlot lp=new LinePlot( new ArrayAdapter(x,y) ); ! Pen p=new Pen( chartPlot.Color ); ! lp.Pen=p; ! // base.Clear(); ! this.Add(lp); ! } ! protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Console.WriteLine( "Chart.OnPaint()" ); foreach ( ChartPlot chartPlot in this.chartPlots ) ! onPaint_addLinePlot( chartPlot ); base.OnPaint( e ); } --- 71,132 ---- } #region "OnPaint" ! private void onPaint_addLinePlot_ok( ChartPlot chartPlot ) ! { ! int npt=chartPlot.History.Count; ! int startIndex = chartPlot.History.IndexOfKeyOrPrevious( chartPlot.StartDateTime ); ! int endIndex = chartPlot.History.IndexOfKeyOrPrevious( chartPlot.EndDateTime ); ! int plotLength = endIndex - startIndex + 1; ! ! DataTable dataTable = new DataTable(); ! dataTable.Columns.Add( "X" , DateTime.Now.GetType() ); ! dataTable.Columns.Add( "Y" , System.Type.GetType( "System.Single" ) ); ! for ( int i=startIndex ; i<=endIndex ; i++ ) ! { ! DataRow dataRow = dataTable.NewRow(); ! dataRow[ "X" ] = (DateTime)chartPlot.History.GetKey( i ); ! dataRow[ "Y" ] = (float)chartPlot.History.GetByIndex( i ); ! dataTable.Rows.Add( dataRow ); ! } ! LinePlot lp = new LinePlot(); ! lp.DataSource = dataTable; ! lp.AbscissaData = "X"; ! lp.ValueData = "Y"; ! Pen p=new Pen( chartPlot.Color ); ! lp.Pen=p; ! ! // base.Clear(); ! this.Add(lp); ! } ! private void onPaint_addLinePlot( ChartPlot chartPlot ) ! { ! int npt=chartPlot.History.Count; ! int startIndex = chartPlot.History.IndexOfKeyOrPrevious( chartPlot.StartDateTime ); ! int endIndex = chartPlot.History.IndexOfKeyOrPrevious( chartPlot.EndDateTime ); ! int plotLength = endIndex - startIndex + 1; ! float [] x = new float[ plotLength ]; ! float [] y = new float[ plotLength ]; ! ! float step=1.0F; ! for ( int i=startIndex ; i<=endIndex ; i++ ) ! { ! x[i-startIndex]=i*step; ! y[i-startIndex]=(float)chartPlot.History.GetByIndex( i ); ! } ! ! // LinePlot lp=new LinePlot( new ArrayAdapter(x,y) ); commentata per avere compilazione; rimuovi commenti per farlo funzionare con la vecchia scpl ! Pen p=new Pen( chartPlot.Color ); ! // lp.Pen=p; ! ! // base.Clear(); ! // this.Add(lp); ! } ! protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Console.WriteLine( "Chart.OnPaint()" ); foreach ( ChartPlot chartPlot in this.chartPlots ) ! onPaint_addLinePlot_ok( chartPlot ); base.OnPaint( e ); } |