Пример #1
0
        private void CreateGraph_FilteredPointList( ZedGraphControl z1 )
        {
            // Get a reference to the GraphPane
            GraphPane myPane = z1.GraphPane;

            // The data will have 10000 points, generated randomly
            const int count = 100000;
            Random rand = new Random();

            // FilteredPointList stores the data as ordinary arrays
            double[] x = new double[count];
            double[] y = new double[count];

            // Loop to calculate all the data values
            for ( int i = 0; i < count; i++ )
            {
                // data are random
                double val = rand.NextDouble();
                double time = Math.Pow( (double) i, 1.5 ) / 1e6;
                x[i] = time + 2.0;
                y[i] = Math.Log( time * 1e6 ) * ( 1 + ( val - 0.5 ) * 0.1 );
            }

            // FilteredPointList requires that the data are monotonically increasing in X
            // FilteredPointList stores its data internally as an ordinary array.  The X, Y arrays
            // below are saved as references (not copies).
            FilteredPointList list = new FilteredPointList( x, y );

            // Create a curve, and show only the symbols with no lines
            LineItem myCurve = z1.GraphPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );
            myCurve.Line.IsVisible = false;

            // The IsApplyHighLowLogic property does not work properly.  This option has been removed as
            // of ZedGraph version 5.1.4.  In the meantime, you should disable it as follows
            //list.IsApplyHighLowLogic = false;

            // Set the range of data of interest.  In effect you can limit the plotted data to only a
            // certain window within the total data range.  In this case, I set the minimum and maximum
            // bounds to include all data points.  Also, all points are initially visible since the
            // maxPts is set to a large value.
            list.SetBounds( 2, 2.5, 5000 );

            // Pretty it up
            //myPane.Title.Text = "FilteredPointList Example\n100,000 Points Total, Filtered to 400 Points Visible";
            myPane.Title.Text = "FilteredPointList Example\n100,000 Points Total, 2.5 seconds of data";
            myPane.Title.FontSpec.Size = 18;
            myPane.XAxis.Title.Text = "Time Span, seconds";
            myPane.YAxis.Title.Text = "Signal Strength";
            myPane.YAxis.Scale.Min = 0;
            myPane.Legend.IsVisible = false;
            myPane.Fill = new Fill( Color.WhiteSmoke, Color.Lavender, 0F );
            myPane.Chart.Fill = new Fill( Color.FromArgb( 255, 255, 245 ),
               Color.FromArgb( 255, 255, 190 ), 90F );
            z1.IsAntiAlias = true;

            z1.AxisChange();
        }