Encapsulates functionality for plotting data as a line chart.
Inheritance: IPlot
        public NormalizingPlotter(NPlot.Windows.PlotSurface2D plotSurface, TimeSpan displayPeriod)
            : base(plotSurface)
        {
            this.DisplayPeriod = displayPeriod;
            HeartRate heartRate = HeartRate.Instance;

            NormalizerFilter normalizerFilter = new NormalizerFilter(TimeSpan.FromSeconds(1.5));
            LightStoneDevice.Instance.RawHeartSignalOutput.Add(normalizerFilter);

            int bufferSize = (int)(m_DisplayPeriod.Ticks / LightStoneDevice.SamplingInterval.Ticks);
            m_PointBuffer = TimeSpanBuffer<double>.Synchronized(m_DisplayPeriod, bufferSize);
            normalizerFilter.Output.Add(m_PointBuffer);

            this.PlotSurface.Clear();

            m_LinePlot = new LinePlot();
            m_LinePlot.Pen = new Pen(Color.Red, 2.0f);
            this.PlotSurface.Add(m_LinePlot);

            this.PlotSurface.XAxis1 = new DateTimeAxis(this.PlotSurface.XAxis1);
            this.PlotSurface.XAxis1.NumberFormat = "hh:mm:ss";

            this.PlotSurface.Title = "Normalized Heart Signal";
            this.PlotSurface.XAxis1.Label = "Time";
            this.PlotSurface.YAxis1.Label = "Magnitude";

            Refresh();
        }
        private void TrackPartitionControl_Load(object sender, EventArgs e)
        {
            _labelDescription.Text = string.Format("From: {0:00}  To: {1:00}  Count: {2} ", _partition.MinFigure, _partition.MaxFigure, _partition.TotalNumberOfFigures);

            _graph.Clear();
            var sp = new LinePlot();
              //  var sp = new BarPlot();

            DataSet ds = _partition.CreateFrequenciesDataSet();
            sp.DataSource = ds;
            sp.AbscissaData = "Track";
            sp.OrdinateData = "Frequency";
            sp.Color = Color.Red;
            sp.Label = "Signal Frequency";
            _graph.Add(sp);

            var la = new LabelAxis(_graph.XAxis1);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                la.AddLabel((string)row["TrackName"], (double)row["Track"]);
            }
            la.TicksLabelAngle = (float)90.0f;
            la.TicksBetweenText = true;
            _graph.XAxis1 = la;

            _graph.Invalidate();
        }
        protected override void OnCreateControl()
        {
            if (!this.DesignMode)
            {
                HeartRate heartRate = HeartRate.Instance;

                int initialBufferSize = (int)base.DisplayPeriod.TotalSeconds * 60;
                m_PointBuffer = TimeSpanBuffer<TimeSpan>.Synchronized(base.DisplayPeriod, initialBufferSize);
                HeartRate.Instance.RRIntervalOutput.Add(m_PointBuffer);

                base.PlotSurface.Clear();

                m_LinePlot = new LinePlot();
                m_LinePlot.Pen = new Pen(Color.Red, 2.0f);
                base.PlotSurface.Add(m_LinePlot);

                base.PlotSurface.XAxis1 = new DateTimeAxis(base.PlotSurface.XAxis1);
                base.PlotSurface.XAxis1.NumberFormat = "mm:ss";

                base.PlotSurface.Title = "R-R Interval Over Time";
                base.PlotSurface.XAxis1.Label = "Time";
                base.PlotSurface.YAxis1.Label = "R-R [msec]";

                RefreshGraph();

                base.StartTimer(200);
            }
            base.OnCreateControl();
        }
        protected override void OnCreateControl()
        {
            if (!this.DesignMode)
            {
                HeartRate heartRate = HeartRate.Instance;

                NormalizerFilter normalizerFilter = new NormalizerFilter(TimeSpan.FromSeconds(1.5));
                LightStoneDevice.Instance.RawHeartSignalOutput.Add(normalizerFilter);

                int bufferSize = (int)(this.DisplayPeriod.Ticks / LightStoneDevice.SamplingInterval.Ticks);
                m_PointBuffer = TimeSpanBuffer<double>.Synchronized(this.DisplayPeriod, bufferSize);
                normalizerFilter.Output.Add(m_PointBuffer);

                base.PlotSurface.Clear();

                m_LinePlot = new LinePlot();
                m_LinePlot.Pen = new Pen(Color.Red, 2.0f);
                base.PlotSurface.Add(m_LinePlot);

                base.PlotSurface.XAxis1 = new DateTimeAxis(base.PlotSurface.XAxis1);
                base.PlotSurface.XAxis1.NumberFormat = "mm:ss";

                base.PlotSurface.Title = "Normalized Heart Signal";
                base.PlotSurface.XAxis1.Label = "Time";
                base.PlotSurface.YAxis1.Label = "Magnitude";

                RefreshGraph();

                base.StartTimer(100);
            }
            base.OnCreateControl();
        }
Beispiel #5
0
        public PointPlotSample()
            : base()
        {
            infoText = "";
            infoText += "Sinc Function Example. Demonstrates - \n";
            infoText += " * Charting LinePlot and PointPlot at the same time. \n";
            infoText += " * Adding a legend.";

            plotCanvas.Clear(); // clear everything. reset fonts. remove plot components etc.

            System.Random r = new Random();
            double[] a = new double[100];
            double[] b = new double[100];
            double mult = 0.00001f;
            for (int i=0; i<100; ++i) {
                a[i] = ((double)r.Next(1000)/5000.0f-0.1f)*mult;
                if (i == 50) {
                    b[i] = 1.0f*mult;
                }
                else {
                    b[i] = Math.Sin ((((double)i-50.0)/4.0))/(((double)i-50.0)/4.0);
                    b[i] *= mult;
                }
                a[i] += b[i];
            }

            Marker m = new Marker (Marker.MarkerType.Cross1, 6, Colors.Blue);
            PointPlot pp = new PointPlot (m);
            pp.OrdinateData = a;
            pp.AbscissaData = new StartStep (-500.0, 10.0);
            pp.Label = "Random";
            plotCanvas.Add (pp);

            LinePlot lp = new LinePlot ();
            lp.OrdinateData = b;
            lp.AbscissaData = new StartStep( -500.0, 10.0 );
            lp.LineColor = Colors.Red;
            lp.LineWidth = 2;
            plotCanvas.Add (lp);

            plotCanvas.Title = "Sinc Function";
            plotCanvas.YAxis1.Label = "Magnitude";
            plotCanvas.XAxis1.Label = "Position";

            Legend legend = new Legend();
            legend.AttachTo (XAxisPosition.Top, YAxisPosition.Left);
            legend.VerticalEdgePlacement = Legend.Placement.Inside;
            legend.HorizontalEdgePlacement = Legend.Placement.Inside;
            legend.YOffset = 8;

            plotCanvas.Legend = legend;
            plotCanvas.LegendZOrder = 1; // default zorder for adding idrawables is 0, so this puts legend on top.

            PackStart (plotCanvas.Canvas, true);
            Label la = new Label (infoText);
            PackStart (la);
        }
 protected override Image DoCreateChartImage()
 {
     var surface = new PlotSurface2D(Parameters.ChartWidth, Parameters.ChartHeight);
     var plot = new LinePlot
         {
             OrdinateData = Parameters.SeriaData.Select(t => t.Key).ToArray(),
             AbscissaData = Parameters.SeriaData.Select(t => t.Value).ToArray()
         };
     surface.Add(plot);
     surface.Refresh();
     return surface.Bitmap;
 }
Beispiel #7
0
        protected void Import(DATA concatdata, int duration)
        {
            InitializeComponent();

            this.data = concatdata;
            //assume both devices same size
            this.n_samples = (concatdata.Count == 0) ? 0 : concatdata[0].Count / n_channels;

            if (this.n_samples == 0)
            {
                return;
            }

            npplot = new LinePlot();
            dataX  = new float[n_samples];
            dataY  = new float[n_samples];

            //Combo items
            List <string> options = new List <string>();

            for (int i = 0; i < n_channels; i++)
            {
                options.Add("Channel " + (i + 1));
            }
            comboBox1.DataSource    = options;
            comboBox1.SelectedIndex = 0;

            List <string> devices = new List <string>();

            for (int i = 0; i < concatdata.Count; i++)
            {
                devices.Add("Device " + (i + 1));
            }
            comboBox2.DataSource    = devices;
            comboBox2.SelectedIndex = 0;

            //Add event handler here to stop being called before initialised
            comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
            comboBox2.SelectedIndexChanged += comboBox2_SelectedIndexChanged;

            //X values
            float scale = (float)duration / (float)n_samples;

            for (int i = 0; i < n_samples; i++)
            {
                dataX[i] = i * scale;
            }

            SetChannel(0, 0);

            Cursor.Current = Cursors.Arrow;
        }
Beispiel #8
0
        public PlotWavelet()
        {
            infoText = "";
            infoText += "Wavelet Example. Demonstrates - \n";
            infoText += " * Reversing axes, setting number of tick marks on axis explicitly.";

            plotSurface.Clear();

            // Create a new line plot from array data via the ArrayAdapter class.
            LinePlot lp = new LinePlot();
            lp.DataSource = makeDaub(256);
            lp.Color = Color.Green;
            lp.Label = "Daubechies Wavelet"; // no legend, but still useful for copy data to clipboard.

            Grid myGrid = new Grid();
            myGrid.VerticalGridType = Grid.GridType.Fine;
            myGrid.HorizontalGridType = Grid.GridType.Coarse;
            plotSurface.Add(myGrid);

            // And add it to the plot surface
            plotSurface.Add( lp );
            plotSurface.Title = "Reversed / Upside down Daubechies Wavelet";

            // Ok, the above will produce a decent default plot, but we would like to change
            // some of the Y Axis details. First, we'd like lots of small ticks (10) between
            // large tick values. Secondly, we'd like to draw a grid for the Y values. To do
            // this, we create a new LinearAxis (we could also use Label, Log etc). Rather than
            // starting from scratch, we use the constructor that takes an existing axis and
            // clones it (values in the superclass Axis only are cloned). PlotSurface2D
            // automatically determines a suitable axis when we add plots to it (merging
            // current requirements with old requirements), and we use this as our starting
            // point. Because we didn't specify which Y Axis we are using when we added the
            // above line plot (there is one on the left - YAxis1 and one on the right - YAxis2)
            // PlotSurface2D.Add assumed we were using YAxis1. So, we create a new axis based on
            // YAxis1, update the details we want, then set the YAxis1 to be our updated one.
            LinearAxis myAxis = new LinearAxis( plotSurface.YAxis1 );
            myAxis.NumberOfSmallTicks = 2;
            plotSurface.YAxis1 = myAxis;

            // We would also like to modify the way in which the X Axis is printed. This time,
            // we'll just modify the relevant PlotSurface2D Axis directly.
            plotSurface.XAxis1.WorldMax = 100.0f;

            plotSurface.PlotBackColor = Color.OldLace;
            plotSurface.XAxis1.Reversed = true;
            plotSurface.YAxis1.Reversed = true;

            // Force a re-draw of the control.
            plotSurface.Refresh();
        }
Beispiel #9
0
        /// <summary>
        /// Create a 2-dimensional surface plot of the specified statistic data.
        /// </summary>
        /// <param name="ordinateData">The Y-axis data values.</param>
        /// <param name="abscissaData">The X-axis data values.</param>
        /// <returns>The plot image bitmap.</returns>
		private static Bitmap Plot(IList ordinateData, IList abscissaData)
		{

			PlotSurface2D plotSurface2D = new PlotSurface2D(200, 200);
		    plotSurface2D.SmoothingMode = SmoothingMode.HighQuality;

		    LinePlot linePlot = new LinePlot(ordinateData, abscissaData);
			linePlot.ShadowColor = Color.Beige;
			linePlot.Pen = new Pen(Color.Blue);
			linePlot.Pen.Width = 1.0f;
			plotSurface2D.Add(linePlot);
			plotSurface2D.Refresh();
			return plotSurface2D.Bitmap;
		}
Beispiel #10
0
        public PlotABC()
        {
            infoText = "";
            infoText += "ABC (logo for australian broadcasting commission) Example. Demonstrates - \n";
            infoText += " * How to set the background of a plotsurface as an image. \n";
            infoText += " * EqualAspectRatio axis constraint \n";
            infoText += " * Plot Zoom with Mouse Wheel, and mouse position Focus point";

            plotSurface.Clear();
            const int size = 200;
            float [] xs = new float [size];
            float [] ys = new float [size];
            for (int i=0; i<size; i++)
            {
                xs[i] = (float)Math.Sin((double)i/(double)(size-1)*2.0*Math.PI);
                ys[i] = (float)Math.Cos((double)i/(double)(size-1)*6.0*Math.PI);
            }

            LinePlot lp = new LinePlot();
            lp.OrdinateData = ys;
            lp.AbscissaData = xs;
            Pen linePen = new Pen( Color.Yellow, 2.0f );
            lp.Pen = linePen;
            plotSurface.Add(lp);
            plotSurface.Title = "AxisConstraint.EqualScaling in action...";

            // Image downloaded from http://squidfingers.com. Thanks!
            Assembly a = Assembly.GetExecutingAssembly();
            System.IO.Stream file =
                a.GetManifestResourceStream( "SwfTest.Resources.pattern01.jpg" );
            System.Drawing.Image im = System.Drawing.Image.FromStream( file );
            plotSurface.PlotBackImage = new Bitmap( im );

            plotSurface.AddInteraction (new PlotZoom());
            plotSurface.AddInteraction (new KeyActions());
            plotSurface.AddAxesConstraint (new AxesConstraint.AspectRatio( 1.0, XAxisPosition.Top, YAxisPosition.Left ) );

            plotSurface.XAxis1.WorldMin = plotSurface.YAxis1.WorldMin;
            plotSurface.XAxis1.WorldMax = plotSurface.YAxis1.WorldMax;
            plotSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            // make sure plot surface colors are as we expect - the wave example changes them.
            //plotSurface.PlotBackColor = Color.White;
            plotSurface.XAxis1.Color = Color.Black;
            plotSurface.YAxis1.Color = Color.Black;

            plotSurface.Refresh();
        }
Beispiel #11
0
        public HistogramSample()
            : base()
        {
            infoText = "";
            infoText += "Gaussian Example. Demonstrates - \n";
            infoText += "  * HistogramPlot and LinePlot" ;

            plotCanvas.Clear();

            System.Random r = new Random ();

            int len = 35;
            double[] a = new double [len];
            double[] b = new double [len];

            for (int i=0; i<len; ++i) {
                a[i] = Math.Exp (-(double)(i-len/2)*(double)(i-len/2)/50.0);
                b[i] = a[i] + (r.Next(10)/50.0f)-0.05f;
                if (b[i] < 0) {
                    b[i] = 0;
                }
            }

            HistogramPlot sp = new HistogramPlot ();
            sp.DataSource = b;
            sp.BorderColor = Colors.DarkBlue;
            sp.Filled = true;
            sp.FillColor = Colors.Gold; //Gradient (Colors.Lavender, Color.Gold );
            sp.BaseWidth = 0.5;
            sp.Label = "Random Data";

            LinePlot lp = new LinePlot ();
            lp.DataSource = a;
            lp.LineColor = Colors.Blue;
            lp.LineWidth = 3;
            lp.Label = "Gaussian Function";
            plotCanvas.Add (sp);
            plotCanvas.Add (lp);
            plotCanvas.Legend = new Legend ();
            plotCanvas.YAxis1.WorldMin = 0.0;
            plotCanvas.Title = "Histogram Plot";

            PackStart (plotCanvas.Canvas, true);
            Label la = new Label (infoText);
            PackStart (la);
        }
Beispiel #12
0
        public PlotCircular()
        {
            infoText = "";
            infoText += "Circular Example. Demonstrates - \n";
            infoText += "  * PiAxis, Horizontal and Vertical Lines. \n";
            infoText += "  * Placement of legend";

            plotSurface.Clear();
            plotSurface.Add( new HorizontalLine( 0.0, Color.LightGray ) );
            plotSurface.Add( new VerticalLine( 0.0, Color.LightGray ) );

            const int N = 400;
            const double start = -Math.PI * 7.0;
            const double end = Math.PI * 7.0;

            double[] xs = new double[N];
            double[] ys = new double[N];

            for (int i=0; i<N; ++i)
            {
                double t = ((double)i*(end - start)/(double)N + start);
                xs[i] = 0.5 * (t - 2.0 * Math.Sin(t));
                ys[i] = 2.0 * (1.0 - 2.0 * Math.Cos(t));
            }

            LinePlot lp = new LinePlot( ys, xs );
            lp.Pen = new Pen( Color.DarkBlue, 2.0f );
            lp.Label = "Circular Line"; // no legend, but still useful for copy data to clipboard.
            plotSurface.Add( lp );

            plotSurface.XAxis1 = new PiAxis( plotSurface.XAxis1 );

            plotSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            plotSurface.Legend = new Legend();
            plotSurface.Legend.AttachTo( XAxisPosition.Bottom, YAxisPosition.Right);
            plotSurface.Legend.HorizontalEdgePlacement = Legend.Placement.Inside;
            plotSurface.Legend.VerticalEdgePlacement = Legend.Placement.Inside;
            plotSurface.Legend.XOffset = -10;
            plotSurface.Legend.YOffset = -10;

            plotSurface.Refresh();
        }
        public SimplePlotter(NPlot.Windows.PlotSurface2D plotSurface, int bufferSize)
            : base(plotSurface)
        {
            m_BufferSize = bufferSize;
            m_PointBuffer = CircularBuffer<Sample>.Synchronized(bufferSize);
            LightStoneDevice.Instance.RawOutput.Add(m_PointBuffer);
            m_BufferWrapper = new BufferWrapper(m_PointBuffer);

            this.PlotSurface.Clear();

            m_LinePlot = new LinePlot();
            m_LinePlot.Pen = new Pen(Color.Red, 2.0f);
            this.PlotSurface.Add(m_LinePlot);

            this.PlotSurface.Title = "Heart Signal";
            this.PlotSurface.XAxis1.Label = "Time";
            this.PlotSurface.YAxis1.Label = "Magnitude";

            Refresh();
        }
Beispiel #14
0
        private void Form1_Load(object sender, EventArgs e)
        {
            ushort[] ys1 = new ushort[] { 0, 31, 48, 45, 42, 40, 43, 50, 36, 52, 31, 43, 54, 98, 150, 168, 37, 24, 23, 45, 19, 112, 44, 49, 55, 52, 44, 38, 16, 35, 34, 36, 41, 43, 39, 47, 47, 39, 48, 44, 41, 45, 44, 49, 49, 51, 64, 41, 49, 94, 149, 252, 37, 37, 24, 41, 21, 187, 44, 59, 52, 56, 53, 51, 25, 37, 33, 47, 45, 49, 41, 64, 43, 48, 32, 54, 40, 45, 45, 63, 37, 42, 46, 64, 66, 112, 137, 114, 30, 24, 23, 33, 100, 252, 45, 55, 49, 54, 37, 27, 0, 39, 42, 54, 31, 90, 951, 1316, 1702, 2092, 354, 67, 43, 46, 43, 61, 45, 45, 42, 1978, 2559, 1516, 87, 77, 99, 143, 141, 103, 70, 973, 3605, 3132, 1275, 43, 48, 50, 41, 38, 45, 54, 653, 1131, 2479, 1791, 499, 94, 74, 43, 48, 38, 44, 36, 40, 601, 39, 26, 41, 34, 33, 66, 89, 208, 353, 270, 256, 25, 27, 46, 74, 47, 1620, 1055, 352, 156, 1155, 1009, 72, 69, 76, 43, 350, 1328, 2169, 1220, 39, 37, 48, 45, 48, 44, 46, 38, 45, 152, 94, 33, 173, 417, 1437, 1629, 0, 2162, 545, 41, 47, 74, 46, 48, 50, 62, 47, 26, 281, 5383, 6401, 3751, 1347, 246, 494, 47, 40, 34, 58, 41, 40, 31, 30, 59, 289, 948, 6850, 9269, 9516, 4576, 73, 113, 87, 140, 254, 58, 47, 8759, 17580, 14441, 7098, 946, 60, 26, 29, 27, 43, 42, 497, 15540, 18649, 17498, 14921, 11183, 5316, 45, 35, 29, 45, 30, 40, 48, 5966, 8135, 11836, 19808, 23439, 14853, 85, 144, 250, 55, 675, 827, 51, 47, 48, 47, 34, 27, 23, 25, 38, 15011, 23951, 20665, 13975, 8545, 6139, 1031, 27, 44, 21, 31, 28, 8254, 0, 12191, 11354, 11333, 4787, 67, 40, 26, 15, 17, 17501, 26507, 26587, 29186, 31856, 25380, 5137, 49, 54, 78, 70, 40, 44, 36, 15663, 30639, 38779, 38215, 27257, 9947, 25, 34, 34, 33, 32, 34, 44, 7652, 21039, 20980, 10572, 58, 73, 92, 85, 15, 21, 34, 30, 10604, 19543, 9712, 43, 48, 61, 65, 217, 459, 51, 2197, 15410, 20152, 6090, 49, 43, 50, 52, 39, 35, 41, 2342, 29692, 41287, 32959, 14446, 57, 44, 58, 88, 83, 80, 19, 19, 132, 19275, 27414, 27080, 24200, 23165, 20930, 11833, 70, 61, 66, 41, 45, 41, 74, 39, 18481, 0, 49405, 42033, 19701, 52, 44, 31, 24, 38, 110, 215, 46, 5855, 30781, 40964, 39394, 33416, 25807, 15313, 215, 77, 59, 40, 43, 28, 61, 64, 9017, 23048, 34453, 37799, 25799, 2865, 63, 41, 47, 40, 63, 28, 50, 838, 21286, 29928, 23564, 11482, 191, 244, 42, 51, 87, 103, 62, 57, 38, 7404, 11095, 13090, 14167, 16140, 14212, 6672, 31, 50, 73, 168, 364, 47, 42, 43, 13919, 28232, 32319, 24274, 8878, 44, 30, 40, 34, 30, 33, 45, 9891, 33253, 42922, 38582, 24088, 7343, 56, 34, 36, 31, 40, 39, 67, 10512, 29604, 38052, 36728, 28767, 16124 };
            ushort[] ys2 = new ushort[] { 0, 31, 48, 45, 42, 40, 43, 50, 36, 52, 31, 43, 54, 98, 150, 168, 37, 24, 23, 45, 19, 112, 44, 49, 55, 52, 44, 38, 16, 35, 34, 36, 41, 43, 39, 47, 47, 39, 48, 44, 41, 45, 44, 49, 49, 51, 64, 41, 49, 94, 149, 252, 37, 37, 24, 41, 21, 187, 44, 59, 52, 56, 53, 51, 25, 37, 33, 47, 45, 49, 41, 64, 43, 48, 32, 54, 40, 45, 45, 63, 37, 42, 46, 64, 66, 112, 137, 114, 30, 24, 23, 33, 100, 252, 45, 55, 49, 54, 37, 27, 0, 39, 42, 54, 31, 90, 951, 1316, 1702, 2092, 354, 67, 43, 46, 43, 61, 45, 45, 42, 1978, 2559, 1516, 87, 77, 99, 143, 141, 103, 70, 973, 3605, 3132, 1275, 43, 48, 50, 41, 38, 45, 54, 653, 1131, 2479, 1791, 499, 94, 74, 43, 48, 38, 44, 36, 40, 601, 39, 26, 41, 34, 33, 66, 89, 208, 353, 270, 256, 25, 27, 46, 74, 47, 1620, 1055, 352, 156, 1155, 1009, 72, 69, 76, 43, 350, 1328, 2169, 1220, 39, 37, 48, 45, 48, 44, 46, 38, 45, 152, 94, 33, 173, 417, 1437, 1629, 0, 2162, 545, 41, 47, 74, 46, 48, 50, 62, 47, 26, 281, 5383, 6401, 3751, 1347, 246, 494, 47, 40, 34, 58, 41, 40, 31, 30, 59, 289, 948, 6850, 9269, 9516, 4576, 73, 113, 87, 140, 254, 58, 47, 8759, 17580, 14441, 7098, 946, 60, 26, 29, 27, 43, 42, 497, 15540, 18649, 17498, 14921, 11183, 5316, 45, 35, 29, 45, 30, 40, 48, 5966, 8135, 11836, 19808, 23439, 14853, 85, 144, 250, 55, 675, 827, 51, 47, 48, 47, 34, 27, 23, 25, 38, 15011, 23951, 20665, 13975, 8545, 6139, 1031, 27, 44, 21, 31, 28, 8254, 0, 12191, 11354, 11333, 4787, 67, 40, 26, 15, 17, 17501, 26507, 26587, 29186, 31856, 25380, 5137, 49, 54, 78, 70, 40, 44, 36, 15663, 30639, 38779, 38215, 27257, 9947, 25, 34, 34, 33, 32, 34, 44, 7652, 21039, 20980, 10572, 58, 73, 92, 85, 15, 21, 34, 30, 10604, 19543, 9712, 43, 48, 61, 65, 217, 459, 51, 2197, 15410, 20152, 6090, 49, 43, 50, 52, 39, 35, 41, 2342, 29692, 41287, 32959, 14446, 57, 44, 58, 88, 83, 80, 19, 19, 132, 19275, 27414, 27080, 24200, 23165, 20930, 11833, 70, 61, 66, 41, 45, 41, 74, 39, 18481, 0, 49405, 42033, 19701, 52, 44, 31, 24, 38, 110, 215, 46, 5855, 30781, 40964, 39394, 33416, 25807, 15313, 215, 77, 59, 40, 43, 28, 61, 64, 9017, 23048, 34453, 37799, 25799, 2865, 63, 41, 47, 40, 63, 28, 50, 838, 21286, 29928, 23564, 11482, 191, 244, 42, 51, 87, 103, 62, 57, 38, 7404, 11095, 13090, 14167, 16140, 14212, 6672, 31, 50, 73, 168, 364, 47, 42, 43, 13919, 28232, 32319, 24274, 8878, 44, 30, 40, 34, 30, 33, 45, 9891, 33253, 42922, 38582, 24088, 7343, 56, 34, 36, 31, 40, 39, 67, 10512, 29604, 38052, 36728, 28767, 16124 };
            ushort[] xs = new ushort[ys1.Length];

            //for (int j = 0; j < 5; j++)
                for (int i = 1; i < ys1.Length - 1; i++)
                {
                    ys1[i] = (ushort)((ys1[i] * 4 + ys1[i - 1] * 2 + ys1[i + 1] * 2) / 8);
                }

            LinePlot lp = new LinePlot( ys1, new StartStep(100, -1) );
            lp.Pen = new Pen(Color.Blue);
            LinePlot lp2 = new LinePlot(ys2, new StartStep(100, -1));
            lp2.Pen = new Pen(Color.Red);

            this.plotSurface2D1.Add(lp);
            this.plotSurface2D1.Add(lp2);
        }
Beispiel #15
0
        public PlotGaussian()
        {
            infoText = "";
            infoText += "Gaussian Example. Demonstrates - \n";
            infoText += "  * HistogramPlot and LinePlot." ;

            plotSurface.Clear();

            System.Random r = new Random();

            int len = 35;
            double[] a = new double[len];
            double[] b = new double[len];

            for (int i=0; i<len; ++i)
            {
                a[i] = (double)Math.Exp(-(double)(i-len/2)*(double)(i-len/2)/50.0f);
                b[i] = a[i] + (r.Next(10)/50.0f)-0.05f;
                if (b[i] < 0.0f) {
                    b[i] = 0;
                }
            }

            HistogramPlot sp = new HistogramPlot();
            sp.DataSource = b;
            sp.Pen = Pens.DarkBlue;
            sp.Filled = true;
            sp.RectangleBrush = new RectangleBrushes.HorizontalCenterFade( Color.Lavender, Color.Gold );
            sp.BaseWidth = 0.5f;
            sp.Label = "Random Data";
            LinePlot lp = new LinePlot();
            lp.DataSource = a;
            lp.Pen = new Pen( Color.Blue, 3.0f );
            lp.Label = "Gaussian Function";
            plotSurface.Add( sp );
            plotSurface.Add( lp );
            plotSurface.Legend = new Legend();
            plotSurface.YAxis1.WorldMin = 0.0f;
            plotSurface.Title = "Histogram Plot";
            plotSurface.Refresh();
        }
		void Refresh(object sender, EventArgs e)
		{
			_plotSurface.Clear();
			_plotSurface.BackColor = Color.Black;

			if (!_component.ComputeProfile())
			{
				_plotSurface.Refresh();
				return;
			}

			LinePlot linePlot = new LinePlot();
			linePlot.AbscissaData = _component.PixelIndices;
			linePlot.OrdinateData = _component.PixelValues;
			linePlot.Pen = new Pen(ClearCanvasStyle.ClearCanvasBlue);

			_plotSurface.Add(linePlot);
			_plotSurface.PlotBackColor = Color.Black;
			_plotSurface.XAxis1.Color = Color.White;
			_plotSurface.YAxis1.Color = Color.White;
			_plotSurface.Refresh();
		}
Beispiel #17
0
        /// <summary>
        /// Might need Refresh () afterwards!
        /// </summary>
        /// <param name="table2D">
        /// A <see cref="Table2D"/>
        /// </param>
        public void Draw(Table2D table2D)
        {
            float[] valuesY = table2D.GetValuesYasFloats ();

            // clear everything. reset fonts. remove plot components etc.
            this.plotSurface2D.Clear ();
            plotSurface2D.Padding = 0;
            plotSurface2D.SmoothingMode = SmoothingMode;

            // y-values, x-values (!)
            LinePlot lp = new LinePlot (valuesY, table2D.ValuesX);
            lp.Pen = pen;

            PointPlot pp = new PointPlot (marker);
            pp.AbscissaData = table2D.ValuesX;
            pp.OrdinateData = valuesY;

            Grid myGrid = new Grid ();
            myGrid.VerticalGridType = Grid.GridType.Coarse;
            myGrid.HorizontalGridType = Grid.GridType.Coarse;

            plotSurface2D.Add (myGrid);
            plotSurface2D.Add (lp);
            plotSurface2D.Add (pp);

            plotSurface2D.TitleFont = titleFont;
            plotSurface2D.Title = table2D.Title;

            plotSurface2D.XAxis1.LabelFont = labelFont;
            plotSurface2D.XAxis1.Label = AxisText (table2D.NameX, table2D.UnitX);
            // could use ex: plotSurface2D.YAxis1.NumberFormat = "0.000";
            plotSurface2D.XAxis1.TickTextFont = tickTextFont;

            plotSurface2D.YAxis1.LabelFont = labelFont;
            plotSurface2D.YAxis1.Label = AxisText (table2D.Title, table2D.UnitY);
            plotSurface2D.YAxis1.TickTextFont = tickTextFont;

            // Refresh () not part of interface!
        }
		private void Refresh(object sender, EventArgs e)
		{
			_plotSurface.Clear();
			_plotSurface.BackColor = Color.Black;

			if (!_component.ComputeProfile())
			{
				_plotSurface.Refresh();
				return;
			}

			LinePlot linePlot = new LinePlot();
			linePlot.AbscissaData = _component.PixelIndices;
			linePlot.OrdinateData = _component.PixelValues;
			linePlot.Pen = new Pen(Application.CurrentUITheme.Colors.StandardColorBase);

			_plotSurface.Add(linePlot);
			_plotSurface.PlotBackColor = Color.Black;
			_plotSurface.XAxis1.Color = Color.White;
			_plotSurface.YAxis1.Color = Color.White;
			_plotSurface.Refresh();
		}
        public GraphItemAdapter(string name, Color color, double windowSize, DataItemAdapter dataItemAdapter)
        {
            // store values
            this.dataItemAdapter = dataItemAdapter;
            this.name = name;

            // get the source units
            this.sourceUnits = UnitConverter.GetUnit(dataItemAdapter.DataItemUnits);

            // create the queues
            plotQueue = new TimeWindowQueue(windowSize);
            recvQueue = new TimeWindowQueue(windowSize);

            // create the plot object
            plot = new LinePlot(plotQueue.ValueList, plotQueue.TimestampList);
            plot.Color = color;
            plot.Label = name;

            // subscribe to relevant events
            Services.RunControlService.RenderCycle += RunControlService_RenderCycle;
            dataItemAdapter.DataValueReceived += dataItemAdapter_DataValueReceived;
        }
        public void RefreshSpeed()
        {
            List<double> xVal = new List<double>();
            List<double> yVal = new List<double>();

            for (int x = 0; x < 100000; x++)
            {
                xVal.Add(x);
                yVal.Add(1 - x);
            }
            Stopwatch sw = new Stopwatch();
            Stopwatch sw2 = new Stopwatch();
            LinePlot p1 = new LinePlot(yVal, xVal);

            PlotSurface2D plot = new PlotSurface2D(640, 480);

            sw.Start();

            plot.Add(p1);
            plot.Add(p1);
            plot.Add(p1);
            plot.Add(p1);
            plot.Add(p1);
            plot.Add(p1);
            plot.Add(p1);
            plot.Add(p1);
            plot.Add(p1);
            plot.Add(p1);

            sw2.Start();
            plot.Refresh();
            sw2.Stop();
            sw.Stop();

            Console.WriteLine(sw2.Elapsed.TotalSeconds.ToString() + " seconds to refresh");
            Console.WriteLine(sw.Elapsed.TotalSeconds.ToString() + " seconds To add and refresh");
        }
Beispiel #21
0
        public void UpdatePlot()
        {
            m_nsPlot.Clear();
            m_nsPlot.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
            m_nsPlot.BackColor = Color.FromKnownColor(KnownColor.Control);

            NPlot.Grid grid = new NPlot.Grid();
            grid.VerticalGridType = NPlot.Grid.GridType.Coarse;
            grid.HorizontalGridType = NPlot.Grid.GridType.Coarse;

            grid.MinorGridPen = new Pen(Color.LightSlateGray, 1.0f);
            grid.MajorGridPen = new Pen(Color.SlateGray, 1.0f);
            Color LINE = Color.RoyalBlue;
            Color VERT = Color.LightSkyBlue;
            Color MARK = Color.SteelBlue;

            m_nsPlot.Add(grid);

            LinePlot combLine = new LinePlot();
            combLine.Pen = new Pen(LINE, 2);

            List<decimal> combX = new List<decimal>();
            List<decimal> combY = new List<decimal>();

            RBF.RBFSpline rbf = FitRBF();
            double[] p = new double[1];
            double s = 0; int CNT = 50;
            for (int i = 0; i < CNT; i++)
            {
                s = BLAS.interpolant(i, CNT);
                rbf.BsVal(s, ref p);
                combX.Add(Convert.ToDecimal(s));
                combY.Add(Convert.ToDecimal(p[0]));
            }

            combLine.AbscissaData = combX;
            combLine.DataSource = combY;
            m_nsPlot.Add(combLine);

            combX = new List<decimal>();
            combY = new List<decimal>();
            List<double> vertsX;
            List<double> vertsY;
            foreach (Vect2 v in CombPnts)
            {
                //add comb point for marker
                combX.Add(Convert.ToDecimal(v[0]));
                combY.Add(Convert.ToDecimal(v[1]));

                //create vertical comb line
                vertsX = new List<double>(2);
                vertsY = new List<double>(2);
                vertsX.Add(v[0]);
                vertsX.Add(v[0]);
                vertsY.Add(v[1]);
                vertsY.Add(0);
                LinePlot ver = new LinePlot(vertsY, vertsX);
                ver.Pen = new Pen(VERT, 2f);
                m_nsPlot.Add(ver);

            }

            PointPlot combPoints = new PointPlot(new Marker(Marker.MarkerType.Circle, 12));
            combPoints.AbscissaData = combX;
            combPoints.DataSource = combY;
            combPoints.Marker.Pen = new Pen(MARK, 1f);
            m_nsPlot.Add(combPoints);

            //combPoints = new PointPlot(new Marker(Marker.MarkerType.Cross1, 7));
            //combPoints.AbscissaData = combX;
            //combPoints.DataSource = combY;
            //combPoints.Marker.Pen = new Pen(MARK, 1f);
            //m_nsPlot.Add(combPoints);

            m_nsPlot.ShowCoordinates = true;
            //curvePlot.AutoScaleAutoGeneratedAxes = true;

            m_nsPlot.RightMenu = NPlot.Windows.PlotSurface2D.DefaultContextMenu;
            //m_plot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false));

            //m_plot.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));
            //m_plot.YAxis1.Label = "";
            //m_plot.YAxis1.LabelFont = new Font(this.Font, FontStyle.Bold);
            //m_plot.YAxis1.LabelOffsetAbsolute = true;
            //m_plot.XAxis1.Label = "";
            //m_plot.XAxis1.LabelFont = new Font(this.Font, FontStyle.Bold);
            //m_plot.YAxis1.LabelOffset = 30;
            m_nsPlot.XAxis1.HideTickText = false;
            m_nsPlot.Refresh();
            //m_plot.Padding = 5;

            //			m_plot.TitleFont = new Font(this.Font, FontStyle.Bold);
        }
Beispiel #22
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="lp1">LinePlot that provides bounds to filled region [upper or lower]</param>
 /// <param name="lp2">LinePlot that provides bounds to filled region [upper or lower]</param>
 /// <remarks>TODO: make this work with other plot types.</remarks>
 public FilledRegion( LinePlot lp1, LinePlot lp2 )
 {
     lp1_ = lp1;
     lp2_ = lp2;
 }
        public void DrawCurve(LineList lineList, int startNum, int endNum)
        {
            this.LineListSets.Add(lineList);

            this.startNum = startNum;
            this.endNum = endNum;

            string YAxisLable = string.Empty;

            LinePlot linePlot = new LinePlot();

            linePlot.OrdinateData = lineList.Y;//高度-时间曲线纵坐标
            linePlot.AbscissaData = lineList.X;//高度-时间曲线横坐标
            linePlot.Label = lineList.LineName;

            switch (this.LineListSets.Count)
            {
                case 1:
                    linePlot.Color = Color.Blue;
                    break;
                case 2:
                    linePlot.Color = Color.Black;
                    break;
                case 3:
                    linePlot.Color = Color.Purple;
                    break;
                case 4:
                    linePlot.Color = Color.Green;
                    break;
                default:
                    linePlot.Color = Color.Brown;
                    break;
            }

            linePlot.Pen.Width = 2.0f;
            linePlot.Shadow = true;//画线时加阴影

            //YAxisLable = (lineList.LineName + "(" + lineList.LineUnit + ")");

            plotSurface2D1.Add(linePlot);

            plotSurface2D1.XAxis1.Color = Color.Black;

            plotSurface2D1.YAxis1.Color = Color.Black;

            plotSurface2D1.XAxis1.Label = "绝对时间(s)";
            plotSurface2D1.XAxis1.LabelOffset = 0;//轴注释与轴间距

            plotSurface2D1.YAxis1.LabelOffset = 0;
            plotSurface2D1.YAxis1.Label += YAxisLable;

            this.lineCount = this.LineListSets.Count;
        }
Beispiel #24
0
        public PlotLogLin()
        {
            infoText = "";
            infoText += "LogLin Example. Demonstrates - \n";
            infoText += "  * How to chart data against log axes and linear axes at the same time.";

            plotSurface.Clear();

            // draw a fine grid.
            Grid fineGrid = new Grid();
            fineGrid.VerticalGridType = Grid.GridType.Fine;
            fineGrid.HorizontalGridType = Grid.GridType.Fine;
            plotSurface.Add( fineGrid );

            const int npt = 101;
            float[] x = new float[npt];
            float[] y = new float[npt];
            float step = 0.1f;
            for (int i=0; i<npt; ++i)
            {
                x[i] = i*step - 5.0f;
                y[i] = (float)Math.Pow( 10.0, x[i] );
            }
            float xmin = x[0];
            float xmax = x[npt-1];
            float ymin = (float)Math.Pow( 10.0, xmin );
            float ymax = (float)Math.Pow( 10.0, xmax );

            LinePlot lp = new LinePlot();
            lp.OrdinateData = y;
            lp.AbscissaData = x;
            lp.Pen = new Pen( Color.Red );
            plotSurface.Add( lp );

            LogAxis loga = new LogAxis( plotSurface.YAxis1 );
            loga.WorldMin = ymin;
            loga.WorldMax = ymax;
            loga.AxisColor = Color.Red;
            loga.LabelColor = Color.Red;
            loga.TickTextColor = Color.Red;
            loga.LargeTickStep = 1.0f;
            loga.Label = "10^x";
            plotSurface.YAxis1 = loga;

            LinePlot lp1 = new LinePlot();
            lp1.OrdinateData = y;
            lp1.AbscissaData = x;
            lp1.Pen = new Pen( Color.Blue );
            plotSurface.Add( lp1, XAxisPosition.Bottom, YAxisPosition.Right );
            LinearAxis lin = new LinearAxis( plotSurface.YAxis2 );
            lin.WorldMin = ymin;
            lin.WorldMax = ymax;
            lin.AxisColor = Color.Blue;
            lin.LabelColor = Color.Blue;
            lin.TickTextColor = Color.Blue;
            lin.Label = "10^x";
            plotSurface.YAxis2 = lin;

            LinearAxis lx = (LinearAxis)plotSurface.XAxis1;
            lx.WorldMin = xmin;
            lx.WorldMax = xmax;
            lx.Label = "x";

            //((LogAxis)plotSurface.YAxis1).LargeTickStep = 2;

            plotSurface.Title = "Mixed Linear/Log Axes";

            //plotSurface.XAxis1.LabelOffset = 20.0f;

            plotSurface.Refresh();
        }
Beispiel #25
0
	static public void PlotTest(IPlotSurface2D plotSurface)
	{
		plotSurface.Clear();
		
		plotSurface.Title = "My Title";
		
		double[] a = {0, 2, 1, 4, double.NaN, double.NaN, 5, 8, 7, 9};
		LinePlot lp = new LinePlot();
		lp.DataSource = a;
		lp.Label = "My Label";
		
		plotSurface.Add( lp );
		
		// plotSurface.Add( lp );
		
		plotSurface.Legend = new Legend();
		plotSurface.Legend.NeverShiftAxes = true;
		plotSurface.Legend.HorizontalEdgePlacement = Legend.Placement.Inside;
		plotSurface.Legend.VerticalEdgePlacement = Legend.Placement.Inside;
		plotSurface.Legend.XOffset = -10;
		plotSurface.Legend.YOffset = 10;
		//plotSurface.AddAxesConstraint( new AxesConstraint.EqualSpacing() );
		
		((LinearAxis)plotSurface.XAxis1).Offset = 10.0;
		((LinearAxis)plotSurface.XAxis1).Scale = 27.0;
		//((LinearAxis)plotSurface.XAxis1).TicksIndependentOfPhysicalExtent = true;
		//((LinearAxis)plotSurface.YAxis1).TicksIndependentOfPhysicalExtent = true;
		
		//plotSurface.Refresh();
	}
Beispiel #26
0
        public PlotLogLog()
        {
            infoText = "";
            infoText += "LogLog Example. Demonstrates - \n";
            infoText += " * How to chart data against log axes and linear axes at the same time. \n";
            infoText += " * Plot Drag (Vertical) - try clicking and dragging in the Plot area \n";
            infoText += " * Plot Drag (Vertical) - try Ctrl + clicking and dragging in the Plot area";

            // log log plot
            plotSurface.Clear();

            Grid mygrid = new Grid();
            mygrid.HorizontalGridType = Grid.GridType.Fine;
            mygrid.VerticalGridType = Grid.GridType.Fine;
            plotSurface.Add(mygrid);

            int npt = 101;
            float [] x = new float[npt];
            float [] y = new float[npt];

            float step=0.1f;

            // plot a power law on the log-log scale
            for (int i=0; i<npt; ++i)
            {
                x[i] = (i+1)*step;
                y[i] = x[i]*x[i];
            }
            float xmin = x[0];
            float xmax = x[npt-1];
            float ymin = y[0];
            float ymax = y[npt-1];

            LinePlot lp = new LinePlot();
            lp.OrdinateData = y;
            lp.AbscissaData = x;
            lp.Pen = new Pen( Color.Red );
            plotSurface.Add( lp );
            // axes
            // x axis
            LogAxis logax = new LogAxis( plotSurface.XAxis1 );
            logax.WorldMin = xmin;
            logax.WorldMax = xmax;
            logax.AxisColor = Color.Red;
            logax.LabelColor = Color.Red;
            logax.TickTextColor = Color.Red;
            logax.LargeTickStep = 1.0f;
            logax.Label = "x";
            plotSurface.XAxis1 = logax;
            // y axis
            LogAxis logay = new LogAxis( plotSurface.YAxis1 );
            logay.WorldMin = ymin;
            logay.WorldMax = ymax;
            logay.AxisColor = Color.Red;
            logay.LabelColor = Color.Red;
            logay.TickTextColor = Color.Red;
            logay.LargeTickStep = 1.0f;
            logay.Label = "x^2";
            plotSurface.YAxis1 = logay;

            LinePlot lp1 = new LinePlot();
            lp1.OrdinateData = y;
            lp1.AbscissaData = x;
            lp1.Pen = new Pen( Color.Blue );
            plotSurface.Add( lp1, XAxisPosition.Top, YAxisPosition.Right );
            // axes
            // x axis (lin)
            LinearAxis linx = (LinearAxis) plotSurface.XAxis2;
            linx.WorldMin = xmin;
            linx.WorldMax = xmax;
            linx.AxisColor = Color.Blue;
            linx.LabelColor = Color.Blue;
            linx.TickTextColor = Color.Blue;
            linx.Label = "x";
            plotSurface.XAxis2 = linx;
            // y axis (lin)
            LinearAxis liny = (LinearAxis) plotSurface.YAxis2;
            liny.WorldMin = ymin;
            liny.WorldMax = ymax;
            liny.AxisColor = Color.Blue;
            liny.LabelColor = Color.Blue;
            liny.TickTextColor = Color.Blue;
            liny.Label = "x^2";
            plotSurface.YAxis2 = liny;

            plotSurface.Title = "x^2 plotted with log(red)/linear(blue) axes";
            plotSurface.AddInteraction ( new PlotDrag(false,true));

            plotSurface.Refresh();
        }
Beispiel #27
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="lp1">LinePlot that provides bounds to filled region [upper or lower]</param>
 /// <param name="lp2">LinePlot that provides bounds to filled region [upper or lower]</param>
 /// <remarks>TODO: make this work with other plot types.</remarks>
 public FilledRegion(LinePlot lp1, LinePlot lp2)
 {
     lp1_ = lp1;
     lp2_ = lp2;
 }
Beispiel #28
0
        public PlotMockup()
        {
            infoText = "";
            infoText +=   "THE TEST (can your charting library handle this?) - \n";
            infoText +=   "NPlot demonstrates it can handle real world charting requirements.";

            // first of all, generate some mockup data.
            DataTable info = new DataTable( "Store Information" );
            info.Columns.Add( "Index", typeof(int) );
            info.Columns.Add( "IndexOffsetLeft", typeof(float) );
            info.Columns.Add( "IndexOffsetRight", typeof(float) );
            info.Columns.Add( "StoreName", typeof(string) );
            info.Columns.Add( "BarBase", typeof(float) );
            info.Columns.Add( "StoreGrowth", typeof(float) );
            info.Columns.Add( "AverageGrowth", typeof(float) );
            info.Columns.Add( "ProjectedSales", typeof(float) );

            float barBase = 185.0f;
            Random r = new Random();
            for (int i=0; i<18; ++i)
            {
                DataRow row = info.NewRow();
                row["Index"] = i;
                row["IndexOffsetLeft"] = (float)i - 0.1f;
                row["IndexOffsetRight"] = (float)i + 0.1f;
                row["StoreName"] = "Store " + (i+1).ToString();
                row["BarBase"] = barBase;
                row["StoreGrowth"] = barBase + ( (r.NextDouble() - 0.1) * 20.0f );
                row["AverageGrowth"] = barBase + ( (r.NextDouble() - 0.1) * 15.0f );
                row["ProjectedSales"] = barBase + ( r.NextDouble() * 15.0f );
                info.Rows.Add( row );
                barBase += (float)r.NextDouble() * 4.0f;
            }

            plotSurface.Clear();

            plotSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            // generate the grid
            Grid grid = new Grid();
            grid.VerticalGridType = Grid.GridType.Coarse;
            grid.HorizontalGridType = Grid.GridType.None;
            grid.MajorGridPen = new Pen( Color.Black, 1.0f );
            plotSurface.Add( grid );

            // generate the trendline
            LinePlot trendline = new LinePlot();
            trendline.DataSource = info;
            trendline.AbscissaData = "Index";
            trendline.OrdinateData = "BarBase";
            trendline.Pen = new Pen( Color.Black, 3.0f );
            trendline.Label = "Trendline";
            plotSurface.Add( trendline );

            // draw store growth bars
            BarPlot storeGrowth = new BarPlot();
            storeGrowth.DataSource = info;
            storeGrowth.AbscissaData = "IndexOffsetLeft";
            storeGrowth.OrdinateDataTop = "StoreGrowth";
            storeGrowth.OrdinateDataBottom = "BarBase";
            storeGrowth.Label = "Store Growth";
            storeGrowth.FillBrush = NPlot.RectangleBrushes.Solid.Black;
            //storeGrowth.BorderPen = new Pen( Color.Black, 2.0f );
            plotSurface.Add( storeGrowth );

            // draw average growth bars
            BarPlot averageGrowth = new BarPlot();
            averageGrowth.DataSource = info;
            averageGrowth.AbscissaData = "IndexOffsetRight";
            averageGrowth.OrdinateDataBottom = "BarBase";
            averageGrowth.OrdinateDataTop = "AverageGrowth";
            averageGrowth.Label = "Average Growth";
            averageGrowth.FillBrush = NPlot.RectangleBrushes.Solid.Gray;
            //averageGrowth.BorderPen = new Pen( Color.Black, 2.0f );
            plotSurface.Add( averageGrowth );

            // generate the projected sales step line.
            StepPlot projected = new StepPlot();
            projected.DataSource = info;
            projected.AbscissaData = "Index";
            projected.OrdinateData = "ProjectedSales";
            projected.Pen = new Pen( Color.Orange, 3.0f );
            projected.HideVerticalSegments = true;
            projected.Center = true;
            projected.Label = "Projected Sales";
            projected.WidthScale = 0.7f;
            plotSurface.Add( projected );

            // generate the minimum target line.
            HorizontalLine minimumTargetLine = new HorizontalLine( 218, new Pen( Color.Green, 3.5f ) );
            minimumTargetLine.Label = "Minimum Target";
            minimumTargetLine.LengthScale = 0.98f;
            minimumTargetLine.ShowInLegend = true; // off by default for lines.
            plotSurface.Add( minimumTargetLine );

            // generate the preferred target line.
            HorizontalLine preferredTargetLine = new HorizontalLine( 228, new Pen( Color.Blue, 3.5f ) );
            preferredTargetLine.Label = "Preferred Target";
            preferredTargetLine.LengthScale = 0.98f;
            preferredTargetLine.ShowInLegend = true; // off by default for lines.
            plotSurface.Add( preferredTargetLine );

            // make some modifications so that chart matches requirements.
            // y axis.
            plotSurface.YAxis1.TicksIndependentOfPhysicalExtent = true;
            plotSurface.YAxis1.TickTextNextToAxis = false;
            //plotSurface.YAxis1.TicksAngle = 3.0f * (float)Math.PI / 2.0f; // Not required if TicksAngle bug #2000693 fixed
            ((LinearAxis)plotSurface.YAxis1).LargeTickStep = 10.0;
            ((LinearAxis)plotSurface.YAxis1).NumberOfSmallTicks = 0;

            // x axis
            plotSurface.XAxis1.TicksIndependentOfPhysicalExtent = true;
            plotSurface.XAxis1.TickTextNextToAxis = false;
            //plotSurface.XAxis1.TicksAngle = (float)Math.PI / 2.0f; // Not required if TicksAngle bug #2000693 fixed
            LabelAxis la = new LabelAxis( plotSurface.XAxis1 );
            for (int i=0; i<info.Rows.Count; ++i)
            {
                la.AddLabel( (string)info.Rows[i]["StoreName"], Convert.ToInt32(info.Rows[i]["Index"]) );
            }
            la.TicksLabelAngle = (float)90.0f;
            la.TicksBetweenText = true;
            plotSurface.XAxis1 = la;

            plotSurface.XAxis2 = (Axis)plotSurface.XAxis1.Clone();
            plotSurface.XAxis2.HideTickText = true;
            plotSurface.XAxis2.LargeTickSize = 0;

            Legend l = new Legend();
            l.NumberItemsVertically = 2;
            l.AttachTo( XAxisPosition.Bottom, YAxisPosition.Left );
            l.HorizontalEdgePlacement = NPlot.Legend.Placement.Outside;
            l.VerticalEdgePlacement = NPlot.Legend.Placement.Inside;
            l.XOffset = 5;
            l.YOffset = 50;
            l.BorderStyle = NPlot.LegendBase.BorderType.Line;

            plotSurface.Legend = l;

            plotSurface.Title =
                "Sales Growth Compared to\n" +
                "Average Sales Growth by Store Size - Rank Order Low to High";

            plotSurface.Refresh();
        }
		private void InitializeLinePlots(Color[] colors)
		{
			m_LinePlots = new LinePlot[colors.Length];
			for (int i = 0; i < colors.Length; i++)
			{
				LinePlot linePlot = new LinePlot();
				linePlot.Pen = new Pen(colors[i], 2.0f);
				m_LinePlots[i] = linePlot;
				m_PlotSurface2D.Add(linePlot);
			}
		}
        /// <summary>
        /// Update (replot) the graphs
        /// </summary>
        public void PlotGraphs()
        {
            if (surface == null)
            {
                surface = new NPlot.Windows.PlotSurface2D();
                tabPageGraphs.Controls.Add(surface);
                surface.Dock = DockStyle.Fill;

                surface2 = new NPlot.Windows.PlotSurface2D();
                surface2.Height = 150;
                tabPageGraphs.Controls.Add(surface2);
                surface2.Dock = DockStyle.Bottom;
            }

            surface.Clear();

            //Add a background grid for better chart readability.
            Grid grid = new Grid();
            grid.VerticalGridType = Grid.GridType.Coarse;
            grid.HorizontalGridType = Grid.GridType.Coarse;
            grid.MajorGridPen = new Pen(Color.LightGray, 1.0f);
            surface.Add(grid);

            LinePlot lp1 = new LinePlot();
            lp1.DataSource = controller.Stats.EvaluationItterations.History;
            lp1.Color = Color.Black;
            lp1.Label = "Itterations";
            surface.Add(lp1);

            LinePlot lp2 = new LinePlot();
            lp2.DataSource = controller.Stats.Nodes.History;
            lp2.Pen = new Pen(Color.Green, 2.0f);
            lp2.Label = "Nodes";
            surface.Add(lp2);

            LinePlot lp3 = new LinePlot();
            lp3.DataSource = controller.Stats.Duplicates.History;
            lp3.Pen = new Pen(Color.Orange, 1.0f);
            lp3.Label = "Duplicates";
            surface.Add(lp3);

            LinePlot lp4 = new LinePlot();
            lp4.DataSource = controller.Stats.DeadNodes.History;
            lp4.Pen = new Pen(Color.Red, 1.5f);
            lp4.Label = "Dead";
            surface.Add(lp4);

            LinePlot lp6 = new LinePlot();
            lp6.DataSource = controller.Stats.AvgEvalList.History;
            lp6.Pen = new Pen(Color.Brown, 1.3f);
            lp6.Label = "Eval List";
            surface.Add(lp6);

            LinePlot lp7 = new LinePlot();
            lp7.DataSource = controller.Stats.NodesFwd.History;
            lp7.Pen = new Pen(Color.Brown, 1.0f);
            lp7.Pen.DashStyle = DashStyle.Dash;
            lp7.Label = "Nodes Fwd";
            surface.Add(lp7);

            LinePlot lp8 = new LinePlot();
            lp8.DataSource = controller.Stats.NodesRev.History;
            lp8.Pen = new Pen(Color.Cyan, 1.0f);
            lp8.Pen.DashStyle = DashStyle.Dash;
            lp8.Label = "Nodes Rev";
            surface.Add(lp8);

            surface.XAxis1.Label = "Elapsed Time (sec)";
            surface.YAxis1.Label = "Total";
            surface.Legend = new Legend();

            surface.SmoothingMode = SmoothingMode.HighQuality;
            surface.Title = "Solver | Node Information";

            surface.Refresh();

            surface2.Clear();
            StepPlot lp5 = new StepPlot();
            lp5.Pen = new Pen(Color.Fuchsia, 2f);
            lp5.DataSource = controller.Stats.NodesPerSecond.History;
            lp5.Label = "Nodes/s";
            surface2.Add(lp5);

            surface2.XAxis1.Label = "Elapsed Time (sec)";
            surface2.YAxis1.Label = "Rate (node/sec)";
            surface2.Legend = new Legend();
            surface2.SmoothingMode = SmoothingMode.HighQuality;
            surface2.Refresh();
        }
        public void ReDrawCurve()
        {
            this.InitCurve();
            string YAxisLable = string.Empty;
            int lineCount = 1;//主要用来改变颜色
            foreach (LineList lineList in this.LineListSets)
            {
                LinePlot linePlot = new LinePlot();

                linePlot.OrdinateData = lineList.Y;//高度-时间曲线纵坐标
                linePlot.AbscissaData = lineList.X;//高度-时间曲线横坐标
                linePlot.Label = lineList.LineName;

                //if (this.LineListSets.Count == 1)
                //    linePlot.Color = Color.Blue;
                //else
                //    linePlot.Color = Color.Black;

                switch (lineCount)
                {
                    case 1:
                        linePlot.Color = Color.Blue;
                        break;
                    case 2:
                        linePlot.Color = Color.Black;
                        break;
                    case 3:
                        linePlot.Color = Color.Purple;
                        break;
                    case 4:
                        linePlot.Color = Color.Cyan;
                        break;
                    default:
                        linePlot.Color = Color.Brown;
                        break;
                }
                lineCount++;

                linePlot.Pen.Width = 2.0f;
                linePlot.Shadow = true;//画线时加阴影

                //YAxisLable = (lineList.LineName + "(" + lineList.LineUnit + ")");

                plotSurface2D1.Add(linePlot);

                plotSurface2D1.XAxis1.Color = Color.Black;

                plotSurface2D1.YAxis1.Color = Color.Black;

                plotSurface2D1.XAxis1.Label = "绝对时间(s)";
                plotSurface2D1.XAxis1.LabelOffset = 0;//轴注释与轴间距

                plotSurface2D1.YAxis1.LabelOffset = 0;
                plotSurface2D1.YAxis1.Label += YAxisLable;
            }
            this.lineCount = this.LineListSets.Count;

            AddVerticalLines(this.VerticalLines);

            this.Refresh();
        }
Beispiel #32
0
        public PlotDataset()
        {
            infoText = "";
            infoText += "Stock Dataset Sample. Demonstrates - \n";
            infoText += " * CandlePlot, FilledRegion, LinePlot and ArrowItem IDrawables \n";
            infoText += " * DateTime axes \n";
            infoText += " * Horizontal Drag Interaction - try dragging (and Ctrl-dragging) the plot surface \n";
            infoText += " * Axis Drag Interaction - try dragging in the horizontal and vertical Axis areas";

            plotSurface.Clear();
            // [NOTIMP] plotSurface.DateTimeToolTip = true;

            // obtain stock information from xml file
            DataSet ds = new DataSet();
            System.IO.Stream file =
                Assembly.GetExecutingAssembly().GetManifestResourceStream( "GtkTest.Resources.asx_jbh.xml" );
            ds.ReadXml( file, System.Data.XmlReadMode.ReadSchema );
            DataTable dt = ds.Tables[0];
            // DataView dv = new DataView( dt );

            // create CandlePlot.
            CandlePlot cp = new CandlePlot();
            cp.DataSource = dt;
            cp.AbscissaData = "Date";
            cp.OpenData = "Open";
            cp.LowData = "Low";
            cp.HighData = "High";
            cp.CloseData = "Close";
            cp.BearishColor = Color.Red;
            cp.BullishColor = Color.Green;
            cp.Style = CandlePlot.Styles.Filled;

            // calculate 10 day moving average and 2*sd line
            ArrayList av10 = new ArrayList();
            ArrayList sd2_10 = new ArrayList();
            ArrayList sd_2_10 = new ArrayList();
            ArrayList dates = new ArrayList();
            for (int i=0; i<dt.Rows.Count-10; ++i)
            {
                float sum = 0.0f;
                for (int j=0; j<10; ++j)
                {
                    sum += (float)dt.Rows[i+j]["Close"];
                }
                float average = sum / 10.0f;
                av10.Add( average );
                sum = 0.0f;
                for (int j=0; j<10; ++j)
                {
                    sum += ((float)dt.Rows[i+j]["Close"]-average)*((float)dt.Rows[i+j]["Close"]-average);
                }
                sum /= 10.0f;
                sum = 2.0f*(float)Math.Sqrt( sum );
                sd2_10.Add( average + sum );
                sd_2_10.Add( average - sum );
                dates.Add( (DateTime)dt.Rows[i+10]["Date"] );
            }

            // and a line plot of close values.
            LinePlot av = new LinePlot();
            av.OrdinateData = av10;
            av.AbscissaData = dates;
            av.Color = Color.LightGray;
            av.Pen.Width = 2.0f;

            LinePlot top = new LinePlot();
            top.OrdinateData = sd2_10;
            top.AbscissaData = dates;
            top.Color = Color.LightSteelBlue;
            top.Pen.Width = 2.0f;

            LinePlot bottom = new LinePlot();
            bottom.OrdinateData = sd_2_10;
            bottom.AbscissaData = dates;
            bottom.Color = Color.LightSteelBlue;
            bottom.Pen.Width = 2.0f;

            FilledRegion fr = new FilledRegion( top, bottom );
            fr.RectangleBrush = new RectangleBrushes.Vertical( Color.FromArgb(255,255,240), Color.FromArgb(240,255,255) );
            plotSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            plotSurface.Add( fr );

            plotSurface.Add( new Grid() );

            plotSurface.Add( av );
            plotSurface.Add( top );
            plotSurface.Add( bottom );
            plotSurface.Add( cp );

            // now make an arrow...
            ArrowItem arrow = new ArrowItem( new PointD( ((DateTime)dt.Rows[60]["Date"]).Ticks, 2.28 ), -80, "An interesting flat bit" );
            arrow.ArrowColor = Color.DarkBlue;
            arrow.PhysicalLength = 50;

            plotSurface.Add (arrow);

            plotSurface.Title = "AU:JBH";
            plotSurface.XAxis1.Label = "Date / Time";
            plotSurface.XAxis1.WorldMin += plotSurface.XAxis1.WorldLength / 4.0;
            plotSurface.XAxis1.WorldMax -= plotSurface.XAxis1.WorldLength / 2.0;
            plotSurface.YAxis1.Label = "Price [$]";

            plotSurface.XAxis1 = new TradingDateTimeAxis( plotSurface.XAxis1 );

            plotSurface.AddInteraction (new PlotDrag(true,false));
            plotSurface.AddInteraction (new AxisDrag());

            // make sure plot surface colors are as we expect - the wave example changes them.
            plotSurface.PlotBackColor = Color.White;
            plotSurface.XAxis1.Color = Color.Black;
            plotSurface.YAxis1.Color = Color.Black;

            plotSurface.Refresh();
        }