Encapsulates a Grid IDrawable object. Instances of this can be added to a PlotSurface2D to produce a grid.
Наследование: IDrawable
Пример #1
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();
        }
Пример #2
0
        public PlotParticles()
        {
            infoText = "";
            infoText += "Particles Example. Demonstrates - \n";
            infoText += " * How to chart multiple data sets against multiple axes at the same time.";

            plotSurface.Clear();

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

            // in this example we synthetize a particle distribution
            // in the x-x' phase space and plot it, with the rms Twiss
            // ellipse and desnity distribution
            const int Particle_Number = 500;
            float [] x = new float[Particle_Number];
            float [] y = new float[Particle_Number];
            // Twiss parameters for the beam ellipse
            // 5 mm mrad max emittance, 1 mm beta function
            float alpha, beta, gamma, emit;
            alpha = -2.0f;
            beta = 1.0f;
            gamma = (1.0f + alpha * alpha) / beta;
            emit = 4.0f;

            float da, xmax, xpmax;
            da = -alpha / gamma;
            xmax = (float)Math.Sqrt(emit / gamma);
            xpmax = (float)Math.Sqrt(emit * gamma);

            Random rand = new Random();

            // cheap randomizer on the unit circle
            for (int i = 0; i<Particle_Number; i++)
            {
                float r;
                do
                {
                    x[i] = (float)(2.0f * rand.NextDouble() - 1.0f);
                    y[i] = (float)(2.0f * rand.NextDouble() - 1.0f);
                    r = (float)Math.Sqrt(x[i] * x[i] + y[i] * y[i]);
                } while (r > 1.0f);
            }

            // transform to the tilted twiss ellipse
            for (int i =0; i<Particle_Number; ++i)
            {
                y[i] *= xpmax;
                x[i] = x[i] * xmax + y[i] * da;
            }
            plotSurface.Title = "Beam Horizontal Phase Space and Twiss ellipse";

            PointPlot pp = new PointPlot();
            pp.OrdinateData = y;
            pp.AbscissaData = x;
            pp.Marker = new Marker(Marker.MarkerType.FilledCircle ,4, new Pen(Color.Blue));
            plotSurface.Add(pp, XAxisPosition.Bottom, YAxisPosition.Left);

            // set axes
            LinearAxis lx = (LinearAxis) plotSurface.XAxis1;
            lx.Label = "Position - x [mm]";
            lx.NumberOfSmallTicks = 2;
            LinearAxis ly = (LinearAxis) plotSurface.YAxis1;
            ly.Label = "Divergence - x' [mrad]";
            ly.NumberOfSmallTicks = 2;

            // Draws the rms Twiss ellipse computed from the random data
            float [] xeli=new float [40];
            float [] yeli=new float [40];

            float a_rms, b_rms, g_rms, e_rms;

            Twiss(x, y, out a_rms, out b_rms, out g_rms, out e_rms);
            TwissEllipse(a_rms, b_rms, g_rms, e_rms, ref xeli, ref yeli);

            LinePlot lp = new LinePlot();
            lp.OrdinateData = yeli;
            lp.AbscissaData = xeli;
            plotSurface.Add(lp, XAxisPosition.Bottom, YAxisPosition.Left);
            lp.Pen = new Pen( Color.Red, 2.0f );
            // Draws the ellipse containing 100% of the particles
            // for a uniform distribution in 2D the area is 4 times the rms
            float [] xeli2 = new float [40];
            float [] yeli2 = new float [40];
            TwissEllipse(a_rms, b_rms, g_rms, 4.0F * e_rms, ref xeli2, ref yeli2);

            LinePlot lp2 = new LinePlot();
            lp2.OrdinateData = yeli2;
            lp2.AbscissaData = xeli2;
            plotSurface.Add( lp2, XAxisPosition.Bottom, YAxisPosition.Left );
            Pen p2 = new Pen( Color.Red, 2.0f );
            float [] pattern = { 5.0f, 40.0f };
            p2.DashPattern = pattern;
            lp2.Pen = p2;

            // now bin the particle position to create beam density histogram
            float range, min, max;
            min = (float)lx.WorldMin;
            max = (float)lx.WorldMax;
            range = max - min;

            const int Nbin = 30;
            float [] xbin = new float[Nbin+1];
            float [] xh = new float[Nbin+1];

            for (int j=0; j<=Nbin; ++j){
                xbin[j] = min + j * range;
                if (j < Nbin) xh[j] = 0.0F;
            }
            for (int i =0; i<Particle_Number; ++i) {
                if (x[i] >= min && x[i] <= max) {
                    int j;
                    j = Convert.ToInt32(Nbin * (x[i] - min) / range);
                    xh[j] += 1;
                }
            }
            StepPlot sp= new StepPlot();
            sp.OrdinateData = xh;
            sp.AbscissaData = new StartStep( min, range / Nbin );
            sp.Center = true;
            plotSurface.Add(sp, XAxisPosition.Bottom, YAxisPosition.Right);
            // axis formatting
            LinearAxis ly2 = (LinearAxis)plotSurface.YAxis2;
            ly2.WorldMin = 0.0f;
            ly2.Label = "Beam Density [a.u.]";
            ly2.NumberOfSmallTicks = 2;
            sp.Pen = new Pen( Color.Green, 2 );

            // Finally, refreshes the plot
            plotSurface.Refresh();
        }
Пример #3
0
        public void Draw()
        {
            this.plot.PlotBackColor = Color.White;
            this.plot.BackColor = Color.White;

            ArrayList xs1 = new ArrayList();

            ArrayList times = new ArrayList();

            int split = 1;
            long lap = 0;
            float max = 0;
            float min = 32767 * 32767;
            long nlaps = 0;
            long totaltime = 0;

            this.plot.Clear();

            if (((long[])splits[winner]).Length < nsplits)
                return;

            for (int i = nsplits; i < ((long[])splits[winner]).Length; ++i)
            {
                lap += ((long[])splits[winner])[i];
                if (i != 0) lap -= ((long[])splits[winner])[i - 1];
                if (split == nsplits)
                {
                    //times.Add("     " + timetostr(lap));
                    string time = "  " + timetostr(lap, true) + "  :  ";
                    for (int s = nsplits - 1; s >= 0; --s)
                    {
                        if (i == nsplits && s == nsplits)
                            time += timetostr(((long[])splits[winner])[i - s], false);
                        else
                            time += timetostr(((long[])splits[winner])[i - s] - ((long[])splits[winner])[i - 1 - s], false);
                        if (s != 0)
                            time += " , ";
                    }

                    time += "  ";
                    times.Add(time);
                    totaltime += lap;

                    ++nlaps;
                    if (max < lap) max = lap;
                    if (min > lap) min = lap;
                    xs1.Add((double)lap);
                    split = 1;
                    lap = 0;
                }
                else split++;
            }

            if (nlaps != 0)
                this.winner_avgtime = totaltime / nlaps;

            if (nlaps == 0)
                return;

            Grid mygrid = new Grid();
            mygrid.VerticalGridType = Grid.GridType.Coarse;
            mygrid.HorizontalGridType = Grid.GridType.Coarse;
            mygrid.MajorGridPen = new Pen(Color.LightGray, 1f);

            this.plot.Add(mygrid);

            for (int i = 0; i < xs1.Count; ++i)
            {
                double[] abscissa = { 0 };
                double[] ordinate = { 0 };

                if ((double)xs1[i] < winner_avgtime)
                {
                    abscissa[0] = (i);
                    ordinate[0] = ((double)xs1[i]) / 10000.0;
                    HistogramPlot hp = new HistogramPlot();
                    hp.OrdinateData = ordinate;
                    hp.AbscissaData = abscissa;

                    hp.RectangleBrush = new RectangleBrushes.Horizontal(Color.FromArgb(106, 205, 84), Color.FromArgb(235, 255, 213));
                    hp.Pen.Color = Color.FromArgb(0, 150, 0);
                    hp.Filled = true;
                    hp.ShowInLegend = false;
                    this.plot.Add(hp);
                }

                if ((double)xs1[i] >= winner_avgtime)
                {
                    abscissa[0] = i;
                    if (Settings.LimitLapTimes && (((double)xs1[i] - winner_avgtime) > (winner_avgtime - min) * Settings.LimitMultiplier))
                        ordinate[0] = (winner_avgtime + (winner_avgtime - min) * Settings.LimitMultiplier) / 10000.0;
                    else
                        ordinate[0] = ((double)xs1[i]) / 10000.0;

                    HistogramPlot hp = new HistogramPlot();
                    hp.OrdinateData = ordinate;
                    hp.AbscissaData = abscissa;

                    if (Settings.LimitLapTimes && (((double)xs1[i] - winner_avgtime) > (winner_avgtime - min) * Settings.LimitMultiplier))
                    {
                        hp.RectangleBrush = new RectangleBrushes.Horizontal(Color.FromArgb(190, 39, 92), Color.FromArgb(235, 124, 177));
                    }
                    else
                    {
                        hp.RectangleBrush = new RectangleBrushes.Horizontal(Color.FromArgb(235, 84, 137), Color.FromArgb(255, 230, 210));
                    }
                    hp.Pen.Color = Color.FromArgb(150, 0, 0);
                    hp.Filled = true;
                    hp.ShowInLegend = false;
                    this.plot.Add(hp);
                }

            }

            //int xmax = ((long[])splits[winner]).Length / nsplits;

            LabelAxis la = new LabelAxis(this.plot.XAxis1);
            la.TicksBetweenText = false;
            la.TicksCrossAxis = false;
            la.LargeTickSize = 0;
            la.TickTextFont = Settings.lapTimesFont;

            for (int i = 0; i < times.Count; ++i)
                la.AddLabel((string)times[i], i);

            la.TicksLabelAngle = -90.0f;
            this.plot.XAxis1 = la;

            la = new LabelAxis((LabelAxis)la.Clone());
            la.TicksBetweenText = false;
            la.TicksCrossAxis = true;
            la.LargeTickSize = 2;
            la.TicksLabelAngle = -90.0f;
            la.TickTextNextToAxis = false;
            la.TickTextFont = Settings.commonFont;

            for (int i = 0; i < times.Count; ++i)
            {
                la.AddLabel(System.Convert.ToString(i + 2), i);
            }
            la.LabelFont = Settings.commonFont;
            this.plot.XAxis2 = la;

            this.plot.YAxis1.TicksCrossAxis = true;

            this.plot.YAxis1.Label = ((string)this.players[this.player]);
            this.plot.YAxis1.LabelFont = Settings.titleFont;
            this.plot.YAxis1.LabelOffset = 20;
            this.plot.YAxis1.NumberFormat = "";
            this.plot.YAxis1.TicksCrossAxis = false;
            if (Settings.LimitToGlobalBestLap) this.plot.YAxis1.WorldMin = (double)this.bestlap / 10000.0;
            ((LinearAxis)this.plot.YAxis1).NumberOfSmallTicks = 4;
            ((LinearAxis)this.plot.YAxis1).LargeTickStep = 1;
            ((LinearAxis)this.plot.YAxis1).TicksLabelAngle = -90f;

            HorizontalLine hl = new HorizontalLine((float)winner_avgtime / 10000, Color.Gray);
            hl.Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            this.plot.Add(hl);

            this.laps = (int)nlaps;

            //            this.plot.YAxis1.WorldMax += 1;
            if (this.plot.YAxis1.WorldMax - this.plot.YAxis1.WorldMin <= 0.1)
                this.plot.YAxis1.WorldMax += 1;
            this.plot.Refresh();
            //            System.Console.WriteLine(System.Convert.ToString(this.plot.YAxis1.WorldMin) + " " + System.Convert.ToString(this.plot.YAxis1.WorldMax));
        }
		private void RefreshRetrievePlot()
		{
			_retrieveSpeedPlot.Clear();
			PointPlot plot = new PointPlot();

			List<DateTime> timePoints;
			List<double> retrieveMbPerSecond;
			ComputePlotAverage(out timePoints, out retrieveMbPerSecond);

			plot.AbscissaData = timePoints;
			plot.DataSource = retrieveMbPerSecond;

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

			_retrieveSpeedPlot.Add(grid);
			_retrieveSpeedPlot.Add(plot);

			_retrieveSpeedPlot.ShowCoordinates = true;
			_retrieveSpeedPlot.YAxis1.Label = "Mb/sec";
			_retrieveSpeedPlot.YAxis1.LabelOffsetAbsolute = true;
			_retrieveSpeedPlot.YAxis1.LabelOffset = 40;
			_retrieveSpeedPlot.Padding = 5;

			//Align percent plot axes.
			DateTimeAxis ax = new DateTimeAxis(_retrieveSpeedPlot.XAxis1);
			ax.HideTickText = false;
			_retrieveSpeedPlot.XAxis1 = ax;

			_retrieveSpeedPlot.Refresh();
		}
Пример #5
0
        public void Draw()
        {
            this.plot.Clear();

            Grid testGrid = new Grid();
            testGrid.VerticalGridType = Grid.GridType.Coarse;
            testGrid.HorizontalGridType = Grid.GridType.Coarse;
            testGrid.MajorGridPen = new Pen(Color.LightGray, 1f);
            this.plot.Add(testGrid);

            xmax = ((long[])splits[winner]).Length / nsplits;
            int tickstep = 1;
            if (xmax <= 30)
                tickstep = 1;
            else
                if (xmax > 30 && xmax <= 60)
                    tickstep = 2;
                else
                    if (xmax > 60)
                        tickstep = 3;

            LinearAxis lx1 = new LinearAxis();

            /*			if (tickstep > 1)
                            lx1.NumberOfSmallTicks = 0;
                        else
                            lx1.NumberOfSmallTicks = nsplits -1;
            */
            lx1.NumberOfSmallTicks = 0;
            lx1.LargeTickStep = tickstep;
            lx1.HideTickText = true;
            lx1.WorldMin = 0;
            lx1.WorldMax = xmax;
            lx1.TicksCrossAxis = true;
            this.plot.XAxis1 = lx1;

            LinearAxis lx2 = new LinearAxis(this.plot.XAxis1);
            lx2.Label = Settings.LapByLapGraphXAxisLabel;
            lx2.NumberOfSmallTicks = 0;
            lx2.LargeTickStep = tickstep;
            lx2.WorldMin = 0;
            lx2.WorldMax = xmax;
            lx2.HideTickText = false;
            lx2.LabelFont = Settings.commonFont;
            this.plot.XAxis2 = lx2;
            this.plot.XAxis1.LargeTickSize = 0;

            LinearAxis ly1 = new LinearAxis();
            ly1.Label = Settings.LapByLapGraphYAxisLabel;
            ly1.NumberOfSmallTicks = 0;
            ly1.Reversed = true;
            ly1.LargeTickStep = 1;
            ly1.WorldMin = 0.5f;
            ly1.WorldMax = players.Count + 0.5f;
            ly1.LabelFont = Settings.commonFont;
            ly1.TicksCrossAxis = true;
            this.plot.YAxis1 = ly1;

            LinearAxis ly2 = new LinearAxis();
            ly2.NumberOfSmallTicks = 0;
            ly2.Reversed = true;
            ly2.LargeTickStep = 1;
            ly2.WorldMin = 0.5f;
            ly2.WorldMax = players.Count + 0.5f;
            ly2.LabelFont = Settings.commonFont;
            ly2.TickTextNextToAxis = false;
            ly2.Label = "";
            ly2.TicksCrossAxis = true;
            this.plot.YAxis2 = ly2;

            this.plot.Title = Settings.LapByLapGraphTitle;
            this.plot.TitleFont = Settings.titleFont;

            Legend lg = new Legend();
            lg.Font = Settings.commonFont;
            lg.XOffset = 30;
            lg.BorderStyle = Settings.legendBorderType;
            this.plot.Legend = lg;

            this.plot.PlotBackColor = Color.White;
            this.plot.BackColor = Color.White;

            //			double minx = 0;

            for (int i = 0; i < players.Count; ++i)
            //			for (int i=winner; i<= winner; ++i)
            {
                int[] positions = new int[((long[])splits[i]).Length];
                double[] laps = new double[((long[])splits[i]).Length];
                int splitN = 0;
                int l = 0;

                for (int split = 0; split < ((long[])splits[winner]).Length; ++split)
                {

                    if (split < positions.Length)
                    {
                        double prop = 0;
                        for (int pr = 0; pr < splitN; ++pr)
                            prop += winner_avgsplitsproportions[pr + 1];
                        laps[split] = (double)l + prop;
                    }

                    int pos = 1;

                    for (int p = 0; p < players.Count; ++p)
                        if (p != i && ((long[])(splits[i])).Length > split && ((long[])(splits[p])).Length > split && ((long[])(splits[p]))[split] < ((long[])(splits[i]))[split])
                            ++pos;

                    if (split < positions.Length)
                        positions[split] = pos;

                    ++splitN;
                    if (splitN == nsplits)
                    {
                        splitN = 0;
                        ++l;
                    }

                }

                LinePlot lp = new LinePlot();
                //				lp.DataSource = positions;
                lp.AbscissaData = laps;
                lp.OrdinateData = positions;

                lp.Pen = new Pen(Colors.GetColor(i), 2.0f);
                int start = i + 1;
                int end = start;
                if (positions.Length - 1 >= 0)
                    end = positions[positions.Length - 1];

                if (Settings.LapByLapGraphDisplayPositions)
                    lp.Label = String.Format("{0:00}-{1:00} {2:g}", start, end, players[i].ToString());
                else
                    lp.Label = String.Format("{0:g}", players[i].ToString());

                this.plot.Add(lp);
                this.plot.YAxis1.WorldMin = 0;
                this.plot.YAxis2.WorldMin = 0;

                /*
                                Marker mk = new Marker();
                                mk.Color = System.Drawing.Color.Red;
                //                mk.Type = Marker.MarkerType.FlagUp;
                                mk.Type = Marker.MarkerType.FlagUp;
                                mk.Size = 15;
                                int[] abs = {1,2,3,4,5,6,7,8,9,10};
                                int[] ord = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
                                abs.Add
                                PointPlot pp = new PointPlot(mk);
                                pp.ShowInLegend = false;
                                pp.AbscissaData = abs;
                                pp.OrdinateData = ord;
                                this.plot.Add(pp);
                */

                this.plot.XAxis1.WorldMax = xmax;
                this.plot.XAxis2.WorldMax = xmax;

            }

            this.plot.YAxis1.WorldMax = players.Count + 0.5f;

            lx1.WorldMin = 0;
            lx1.WorldMax = xmax;
            lx2.WorldMin = 0;
            lx2.WorldMax = xmax;

            this.plot.Refresh();
        }
Пример #6
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);
        }
Пример #7
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();
        }
        /// <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();
        }
Пример #9
0
        private void RefreshPlot(plotType pType, bool legend, string title, string XLabel, int margin)
        {
            NPlot.Windows.PlotSurface2D surf = null;

            if (pType == plotType.Speed)
                surf = SpeedPlot;
            if (pType == plotType.Climb)
                surf = ClimbPlot;

            _numPlots = 0;
            foreach (int i in AircraftList.CheckedIndices)
            {
                DrawAircraft(pType, AircraftList.Items[i].ToString());
            }

            if (_numPlots == 0)
                return;

            if (legend)
                AttachLegend(surf);

            surf.Title = title;
            surf.XAxis1.Label = XLabel;
            surf.YAxis1.Label = "feet";

            surf.YAxis1.WorldMin = 0;
            surf.XAxis1.WorldMin -= margin;
            surf.XAxis1.WorldMax += margin;

            Grid grid = new Grid();
            grid.VerticalGridType = Grid.GridType.Fine;
            grid.HorizontalGridType = Grid.GridType.Fine;
            grid.MajorGridPen = new Pen(Color.LightGray, 0.5f);

            surf.Add(grid);
            surf.Refresh();
        }
Пример #10
0
        public void Draw()
        {
            this.plot.Clear();

            Grid testGrid = new Grid();
            testGrid.VerticalGridType = Grid.GridType.Coarse;
            testGrid.HorizontalGridType = Grid.GridType.Coarse;
            testGrid.MajorGridPen = new Pen(Color.LightGray, 1f);

            this.plot.Add(testGrid);

            int tickstep = 1;

            int xmax = ((long[])splits[winner]).Length / nsplits;

            if (xmax <= 30)
                tickstep = 1;
            else
                if (xmax > 30 && xmax <= 60)
                    tickstep = 2;
                else
                    if (xmax > 60)
                        tickstep = 3;

            LinearAxis lx1 = new LinearAxis();
            lx1.NumberOfSmallTicks = 0;
            lx1.LargeTickStep = tickstep;
            lx1.HideTickText = true;
            lx1.WorldMin = 1;
            lx1.WorldMax = xmax;
            this.plot.XAxis1 = lx1;

            LinearAxis lx2 = new LinearAxis(lx1);
            lx2.Label = Settings.RaceProgressGraphXAxisLabel;
            lx2.NumberOfSmallTicks = 0;
            lx2.LargeTickStep = tickstep;
            lx2.WorldMin = 1;
            lx2.WorldMax = xmax;
            lx2.HideTickText = false;
            lx2.LabelFont = Settings.commonFont;
            this.plot.XAxis2 = lx2;

            LinearAxis ly1 = new LinearAxis();
            ly1.NumberOfSmallTicks = 0;
            ly1.Reversed = true;
            ly1.LargeTickStep = 10;
            ly1.WorldMin = -5;
            ly1.WorldMax = 5;
            ly1.LabelFont = Settings.commonFont;
            ly1.HideTickText = true;
            this.plot.YAxis1 = ly1;

            this.plot.Title = Settings.RaceProgressGraphTitle;
            this.plot.TitleFont = Settings.titleFont;

            Legend lg = new Legend();
            lg.Font = Settings.commonFont;
            lg.BorderStyle = Settings.legendBorderType;
            lg.XOffset = 60;

            this.plot.Legend = lg;

            this.plot.PlotBackColor = Color.White;
            this.plot.BackColor = Color.White;

            this.plot.Add(new HorizontalLine(0.0, Color.Black));

            for (int p = 0; p < players.Count; ++p)
                if (((long[])splits[p]).Length >= nsplits)
                {
                    double[] x = new double[((long[])splits[p]).Length - nsplits + 2];
                    double[] y = new double[((long[])splits[p]).Length - nsplits + 2];
                    x[0] = 1;
                    y[0] = 0;

                    int l = 1;
                    int i = 0;
                    int split = 0;
                    double lap;

                    while (i < ((long[])splits[p]).Length - nsplits + 1)
                    {
                        double prop = 0;
                        for (int pr = 0; pr < split; ++pr)
                            prop += winner_avgsplitsproportions[pr + 1];
                        lap = (double)l + prop;

                        x[i + 1] = lap;

                        long splitsum = 0;

                        for (int sps = 0; sps <= split; ++sps) splitsum += winner_avgsplits[sps];

                        long real = ((long[])splits[p])[i + nsplits - 1];
                        long avg = (winner_avgtime * (l) + splitsum);
                        long difference = real - avg;
                        y[i + 1] = difference;

                        y[i + 1] /= 10000;

                        if (y[i + 1] > Settings.graphMinMax)
                            y[i + 1] = Settings.graphMinMax;

                        ++split;
                        if (split == nsplits)
                        {
                            split = 0;
                            ++l;
                        }
                        ++i;

                    }

                    LinePlot lp = new LinePlot();
                    lp.AbscissaData = x;
                    lp.OrdinateData = y;
                    lp.Pen = new Pen(Colors.GetColor(p), 1f);
                    lp.Label = String.Format("{0}", players[p].ToString());

                    this.plot.Add(lp);

                    LinearAxis ly2 = new LinearAxis(plot.YAxis1);
                    ly2.Label = "";
                    ly2.Label = Settings.RaceProgressGraphYAxisLabel;
                    ly2.NumberOfSmallTicks = ly1.NumberOfSmallTicks;
                    ly2.LargeTickStep = ly1.LargeTickStep;
                    ly2.TickTextNextToAxis = false;
                    ly2.LabelFont = Settings.commonFont;
                    ly2.HideTickText = false;
                    this.plot.YAxis2 = ly2;

                    if (this.plot.YAxis1.WorldMin < 400)
                    {

                    }

                    this.plot.Refresh();

                }
        }
Пример #11
0
        private void InitPlot(out NPlot.Bitmap.PlotSurface2D npSurface, out Font AxisFont, out Font TickFont, out NPlot.Grid p, int width, int height)
        {
            npSurface = new NPlot.Bitmap.PlotSurface2D(width, height);
            npSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            //Font definitions:
            AxisFont = new Font("Arial", 10);
            TickFont = new Font("Arial", 8);

            //Prepare PlotSurface:
            npSurface.Clear();
            npSurface.Title = this.Title;
            npSurface.BackColor = System.Drawing.Color.White;

            //Left Y axis grid:
            p = new Grid();
            npSurface.Add(p, NPlot.PlotSurface2D.XAxisPosition.Bottom, NPlot.PlotSurface2D.YAxisPosition.Left);
        }
Пример #12
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!
        }
Пример #13
0
        private void UpdateBorePlot()
        {
            if (bore == null)
            {
                this.Clear();
                this.Refresh();
                return;
            }

            List<decimal> xValues = new List<decimal>();
            List<decimal> yValues = new List<decimal>();
            decimal maxRadius = 0;
            decimal totalLength = bore.Length;

            for (int i = 0; i < bore.BoreDimensions.Count; i++)
            {
                if (bore.BoreDimensions[i].Radius > maxRadius)
                    maxRadius = bore.BoreDimensions[i].Radius;

                xValues.Add(bore.BoreDimensions[i].Position);
                yValues.Add(bore.BoreDimensions[i].Radius);
            }

            for (int i = bore.BoreDimensions.Count - 1; i > -1; i--)
            {
                xValues.Add(bore.BoreDimensions[i].Position);
                yValues.Add(bore.BoreDimensions[i].Radius * -1);
            }

            xValues.Add(bore.BoreDimensions[0].Position);
            yValues.Add(bore.BoreDimensions[0].Radius);

            this.Clear();
            this.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            Grid grid = new Grid();
            grid.HorizontalGridType = Grid.GridType.Fine;
            grid.VerticalGridType = Grid.GridType.None;
            this.Add(grid);

            LinePlot boreLinePlot = new LinePlot(yValues, xValues);
            boreLinePlot.Label = "Bore";
            boreLinePlot.Pen = new Pen(Color.Black, 2);
            boreLinePlot.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            this.Add(boreLinePlot);

            this.XAxis2 = new LinearAxis(this.XAxis1.WorldMin, this.XAxis1.WorldMax);
            this.YAxis1.Hidden = true;

            if (ShowWaveformPlot)
            {
                LinePlot waveformPlot = AddWaveformPlot();
                if (waveformPlot != null)
                {
                    this.AddAxesConstraint(new BoreAndWaveformStackedPlotAxesConstraint(boreLinePlot, waveformPlot));
                    this.Refresh();
                    return;
                }
            }

            this.AddAxesConstraint(new BoreOnlyAxesConstraint(boreLinePlot));
            this.XAxis2.Hidden = true;
            this.Refresh();
        }
Пример #14
0
        public void RefreshPlots(NPlot.Windows.PlotSurface2D graphSurface)
        {
            graphSurface.Clear();

            if (_plots.Count == 0)
            {
                graphSurface.Hide();
                return;
            }

            foreach (XYData plot in _plots)
            {
                LinePlot lp = new LinePlot();
                lp.Color = plot.PlotColour;
                lp.AbscissaData = plot.xData;
                lp.OrdinateData = plot.yData;
                lp.Label = plot.PlotName;
                graphSurface.Add(lp);
            }

            graphSurface.Title = "Pilot Trends";
            Grid grid = new Grid();
            grid.VerticalGridType = Grid.GridType.Fine;
            grid.HorizontalGridType = Grid.GridType.Fine;
            grid.MajorGridPen = new Pen(Color.LightGray, 0.5f);
            graphSurface.Add(grid);

            graphSurface.Refresh();

            Legend leg = new Legend();
            leg.AttachTo(PlotSurface2D.XAxisPosition.Top, PlotSurface2D.YAxisPosition.Right);
            leg.HorizontalEdgePlacement = Legend.Placement.Inside;
            leg.VerticalEdgePlacement = Legend.Placement.Outside;
            leg.XOffset = 10;
            leg.YOffset = 10;
            graphSurface.Legend = leg;
            graphSurface.LegendZOrder = 10;

            graphSurface.YAxis1.WorldMin = 0;
            graphSurface.XAxis1.Label = "Tour Number";
            graphSurface.XAxis1.WorldMin -= 1;
            graphSurface.XAxis1.WorldMax += 1;

            graphSurface.Show();
            graphSurface.Refresh();
        }
Пример #15
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();
        }
Пример #16
0
        public PlotLabelAxis()
        {
            infoText = "";
            infoText += "Internet Usage Example. Demonstrates - \n";
            infoText += " * Label Axis with angled text. \n";
            infoText += " * RectangleBrushes.";

            plotSurface.Clear();

            Grid mygrid = new Grid();
            mygrid.VerticalGridType = Grid.GridType.Coarse;
            Pen majorGridPen = new Pen( Color.LightGray );
            float[] pattern = { 1.0f, 2.0f };
            majorGridPen.DashPattern = pattern;
            mygrid.MajorGridPen = majorGridPen;
            plotSurface.Add( mygrid );

            float[] xs = {20.0f, 31.0f, 27.0f, 38.0f, 24.0f, 3.0f, 2.0f };
            float[] xs2 = {7.0f, 10.0f, 42.0f, 9.0f, 2.0f, 79.0f, 70.0f };
            float[] xs3 = {1.0f, 20.0f, 20.0f, 25.0f, 10.0f, 30.0f, 30.0f };

            HistogramPlot hp = new HistogramPlot();
            hp.DataSource = xs;
            hp.BaseWidth = 0.6f;
            hp.RectangleBrush =
                new RectangleBrushes.HorizontalCenterFade( Color.FromArgb(255,255,200), Color.White );
            hp.Filled = true;
            hp.Label = "Developer Work";

            HistogramPlot hp2 = new HistogramPlot();
            hp2.DataSource = xs2;
            hp2.Label = "Web Browsing";
            hp2.RectangleBrush = RectangleBrushes.Horizontal.FaintGreenFade;
            hp2.Filled = true;
            hp2.StackedTo( hp );

            HistogramPlot hp3 = new HistogramPlot();
            hp3.DataSource = xs3;
            hp3.Label = "P2P Downloads";
            hp3.RectangleBrush = RectangleBrushes.Vertical.FaintBlueFade;
            hp3.Filled = true;
            hp3.StackedTo( hp2 );

            plotSurface.Add( hp );
            plotSurface.Add( hp2 );
            plotSurface.Add( hp3 );

            plotSurface.Legend = new Legend();

            LabelAxis la = new LabelAxis( plotSurface.XAxis1 );
            la.AddLabel( "Monday", 0.0f );
            la.AddLabel( "Tuesday", 1.0f );
            la.AddLabel( "Wednesday", 2.0f );
            la.AddLabel( "Thursday", 3.0f );
            la.AddLabel( "Friday", 4.0f );
            la.AddLabel( "Saturday", 5.0f );
            la.AddLabel( "Sunday", 6.0f );
            la.Label = "Days";
            la.TickTextFont = new Font( "Courier New", 8 );
            la.TicksBetweenText = true;

            plotSurface.XAxis1 = la;
            plotSurface.YAxis1.WorldMin = 0.0;
            plotSurface.YAxis1.Label = "MBytes";
            ((LinearAxis)plotSurface.YAxis1).NumberOfSmallTicks = 1;

            plotSurface.Title = "Internet useage for user:\n johnc 09/01/03 - 09/07/03";

            plotSurface.XAxis1.TicksLabelAngle = 30.0f;

            plotSurface.PlotBackBrush = RectangleBrushes.Vertical.FaintRedFade;
            plotSurface.Refresh();
        }
Пример #17
0
        private void InitializePlots()
        {
            object plot = new object();

               for (int j = 1; j < 7; j++)
               {
                    switch (j)
                    {
                         case 1:
                              plot = plotSurface2D1;
                              break;
                         case 2:
                              plot = plotSurface2D2;
                              break;
                         case 3:
                              plot = plotSurface2D3;
                              break;
                         case 4:
                              plot = plotSurface2D4;
                              break;
                         case 5:
                              plot = plotSurface2D5;
                              break;
                         case 6:
                              plot = plotSurface2D6;
                              break;
                    }

                    NPlot.Windows.PlotSurface2D plotter = (NPlot.Windows.PlotSurface2D)plot;

                    plotter.Clear();
                    plotter.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;

                    NPlot.Grid grid = new NPlot.Grid();
                    grid.VerticalGridType = NPlot.Grid.GridType.Coarse;
                    grid.HorizontalGridType = NPlot.Grid.GridType.Coarse;
                    grid.MinorGridPen = new Pen(Color.Blue, 1.0f);
                    grid.MajorGridPen = new Pen(Color.LightGray, 1.0f);

                    plotter.Add(grid);

                    StepPlot stepBalance = new StepPlot();
                    stepBalance.Pen = new Pen(Color.Green, 2);

                    List<Int32> balanceAxis = new List<Int32>();

                    List<decimal> balanceAmount = new List<decimal>();

                    for (int i = 0; i < 10; i++)
                         balanceAxis.Add(0);

                    stepBalance.AbscissaData = balanceAxis;
                    stepBalance.DataSource = balanceAmount;
                    plotter.Add(stepBalance);
                    plotter.ShowCoordinates = true;
                    plotter.AutoScaleAutoGeneratedAxes = true;
                    plotter.RightMenu = NPlot.Windows.PlotSurface2D.DefaultContextMenu;
                    plotter.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false));
                    plotter.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
                    plotter.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag());

                    //Refresh surfaces.
                    plotter.Refresh();
               }
        }
Пример #18
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();
        }
Пример #19
0
        void p1BRW_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (p1BRW.CancellationPending == true)
                    Algo.Stop();

               m_progBar.Value = e.ProgressPercentage;
               if (e.UserState == null)
                    return;

               List<int> bestChromo = (List<int>)e.UserState;

               if (bestChromo.Count > 0)
               {
                    List<double[]> GAPnts = new List<double[]>();
                    double[] result = EvalChromosome(ref bestChromo, ref GAPnts);

                    object curve = new object();
                    object plot = new object();

                    for (int j = 0; j < 1; j++)
                    {
                         switch (j + 1)
                         {
                              case 1:
                                   curve = p1Curve;
                                   plot = plotSurface2D1;
                                   break;
                              case 2:
                                   curve = p2Curve;
                                   plot = plotSurface2D2;
                                   break;
                              case 3:
                                   curve = p3Curve;
                                   plot = plotSurface2D3;
                                   break;
                              case 4:
                                   curve = p4Curve;
                                   plot = plotSurface2D4;
                                   break;
                              case 5:
                                   curve = p5Curve;
                                   plot = plotSurface2D5;
                                   break;
                              case 6:
                                   curve = p6Curve;
                                   plot = plotSurface2D6;
                                   break;
                         }

                         RBFCurve oldRBF = curve as RBFCurve;
                         CustomBasis GeneticBasis = new CustomBasis(16.383 / 2.0 - result[0], 16.383 / 2.0 - result[1], 16.383 / 2.0 - result[2], 16.383 / 2.0 - result[3]);
                         //List<double[]> fitpoints = new List<double[]>(oldRBF.OriginalFitPoints);
                         List<double[]> fitpoints = new List<double[]>(GAPnts);

                         if (RemoveExtraFitPoints)
                         {
                              fitpoints.RemoveAt(1);
                              fitpoints.RemoveAt(2);
                         }

                         RBFCurve GaRBF = new RBFCurve(null, "GA RBF", fitpoints, GeneticBasis, new Linear(null), 0.0);
                         NPlot.Windows.PlotSurface2D plotter = (NPlot.Windows.PlotSurface2D)plot;

                         plotter.Clear();
                         plotter.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;

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

                         plotter.Add(grid);

                         int length = oldRBF.FitPoints.Count * 5;
                         //Create a step plot instance for the balance chart.
                         LinePlot speed = new LinePlot();
                         LinePlot speed2 = new LinePlot();
                         PointPlot pplot = new PointPlot();
                         PointPlot pplot2 = new PointPlot();

                         pplot2.Marker = new Marker(Marker.MarkerType.Cross1, 10, System.Drawing.Color.Red);

                         speed.Pen = new Pen(Color.Blue, 1);

                         //Create the lists from which to pull data.
                         List<Int32> countaxis = new List<Int32>();
                         List<Int32> Pplotcountaxis = new List<Int32>();
                         List<Int32> Pplotcountaxis2 = new List<Int32>();
                         List<decimal> speedlist = new List<decimal>();
                         List<decimal> speedlist2 = new List<decimal>();

                         for (int i = 0; i < length; i++)
                              countaxis.Add(i);

                         for (int i = 0; i < oldRBF.FitPoints.Count; i++)
                              Pplotcountaxis.Add((int)oldRBF.OriginalFitPoints[i][0]);

                         for (int i = 0; i < GaRBF.FitPoints.Count; i++)
                              Pplotcountaxis2.Add((int)GaRBF.OriginalFitPoints[i][0]);

                         //Populate the balanceAmount list
                         double[] pnt;
                         List<decimal> pointsList = oldRBF.OriginalFitPoints.ConvertAll(new Converter<double[], decimal>((double[] dd) => { return Convert.ToDecimal(dd[1]); }));
                         List<decimal> pointsList2 = GaRBF.OriginalFitPoints.ConvertAll(new Converter<double[], decimal>((double[] dd) => { return Convert.ToDecimal(dd[1]); }));

                         for (int i = 0; i < length; i++)
                         {
                              pnt = new double[] { (double)i, 0 };
                              oldRBF.Value(ref pnt);
                              speedlist.Add(Convert.ToDecimal(pnt[1]));
                              pnt = new double[] { (double)i, 0 };
                              GaRBF.Value(ref pnt);
                              speedlist2.Add(Convert.ToDecimal(pnt[1]));
                         }

                         pplot.AbscissaData = Pplotcountaxis;
                         pplot.DataSource = pointsList;
                         pplot2.AbscissaData = Pplotcountaxis2;
                         pplot2.DataSource = pointsList2;
                         speed.AbscissaData = countaxis;
                         speed.DataSource = speedlist;
                         speed2.AbscissaData = countaxis;
                         speed2.DataSource = speedlist2;

                         //Add stepBalance to plotSurfaceBalance.

                         plotter.Add(speed);
                         plotter.Add(speed2);
                         plotter.Add(pplot);
                         plotter.Add(pplot2);

                         //Balance plot general settings.
                         plotter.ShowCoordinates = true;

                         plotter.AutoScaleAutoGeneratedAxes = true;
                         plotter.AddAxesConstraint(new AxesConstraint.AxisPosition(NPlot.PlotSurface2D.YAxisPosition.Left, 60));

                         plotter.YAxis1.Label = "Y";
                         plotter.YAxis1.LabelFont = new Font(this.Font, FontStyle.Bold);
                         plotter.YAxis1.LabelOffsetAbsolute = true;
                         plotter.XAxis1.Label = "X";
                         plotter.XAxis1.LabelFont = new Font(this.Font, FontStyle.Bold);
                         plotter.YAxis1.LabelOffset = 40;
                         plotter.XAxis1.HideTickText = false;
                         plotter.Padding = 5;

                         plotter.RightMenu = NPlot.Windows.PlotSurface2D.DefaultContextMenu;
                         plotter.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false));
                         plotter.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
                         plotter.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag());

                         plotter.Title = GeneticBasis.ToString();
                         plotter.TitleFont = new Font(this.Font, FontStyle.Bold);
                         //}

                         //Refresh surfaces.
                         plotter.Refresh();
                    }
                    Application.DoEvents();
               }
        }
Пример #20
0
        private void InitPlot(out NPlot.Bitmap.PlotSurface2D npSurface, out Font AxisFont, out Font TickFont, out NPlot.Grid p, int width, int height)
        {
            npSurface = new NPlot.Bitmap.PlotSurface2D(width, height);
            npSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            //Font definitions:
            AxisFont = new Font("Arial", 10);
            TickFont = new Font("Arial", 8);

            //Prepare PlotSurface:
            npSurface.Clear();
            npSurface.Title     = this.Title;
            npSurface.BackColor = System.Drawing.Color.White;

            //Left Y axis grid:
            p = new Grid();
            npSurface.Add(p, NPlot.PlotSurface2D.XAxisPosition.Bottom, NPlot.PlotSurface2D.YAxisPosition.Left);
        }
Пример #21
0
        private void SetPlots(int p, List<double[]> fitPoints)
        {
            object plot = new object();
               object curve = new object();
               IBasisFunction basis = new RBFBasis.ThinPlateSpline(null);

               switch (Basis)
               {
                    case BasisType.Cubic:
                         basis = new RBFBasis.PolyHarmonic3(null);
                         break;
                    case BasisType.Gaussian:
                         basis = new RBFBasis.Gaussian(null);
                         break;
                    case BasisType.Line:
                         basis = new RBFBasis.CustomBasis(null, 0, 0, 1, 0);
                         break;
                    case BasisType.Parabolic:
                         basis = new RBFBasis.ThinPlateSpline2(null);
                         break;
                    case BasisType.CubicParabolic:
                         if (p % 2 == 0)
                              basis = new RBFBasis.PolyHarmonic3(null);
                         else
                              basis = new RBFBasis.CustomBasis(null, 1, 1, -1, 0);
                         break;
               }

               switch (p)
               {
                    case 1:
                         plot = plotSurface2D1;
                         //basis = new RBFBasis.Exponential(null);
                         p1Curve = new RBFCurve(null, "RBF " + p, fitPoints, basis, new RBFPolynomials.Linear(null), 0.0);
                         curve = p1Curve;
                         break;
                    case 2:
                         plot = plotSurface2D2;
                         //basis = new RBFBasis.Exponential(null);
                         p2Curve = new RBFCurve(null, "RBF " + p, fitPoints, basis, new RBFPolynomials.Linear(null), 0.0);
                         curve = p2Curve;
                         break;
                    case 3:
                         plot = plotSurface2D3;
                         //basis = new RBFBasis.Exponential(null);
                         p3Curve = new RBFCurve(null, "RBF " + p, fitPoints, basis, new RBFPolynomials.Linear(null), 0.0);
                         curve = p3Curve;
                         break;
                    case 4:
                         plot = plotSurface2D4;
                         //basis = new RBFBasis.Exponential(null);
                         p4Curve = new RBFCurve(null, "RBF " + p, fitPoints, basis, new RBFPolynomials.Linear(null), 0.0);
                         curve = p4Curve;
                         break;
                    case 5:
                         plot = plotSurface2D5;
                         //basis = new RBFBasis.Exponential(null);
                         p5Curve = new RBFCurve(null, "RBF " + p, fitPoints, basis, new RBFPolynomials.Linear(null), 0.0);
                         curve = p5Curve;
                         break;
                    case 6:
                         plot = plotSurface2D6;
                         // basis = new RBFBasis.Exponential(null);
                         p6Curve = new RBFCurve(null, "RBF " + p, fitPoints, basis, new RBFPolynomials.Linear(null), 0.0);
                         curve = p6Curve;
                         break;
               }

               if (Max[0] < fitPoints.Max(pt => pt[0]))
                    Max[0] = fitPoints.Max(pt => pt[0]);
               if (Max[1] < fitPoints.Max(pt => pt[1]))
                    Max[1] = fitPoints.Max(pt => pt[1]);

               if (Min[0] > fitPoints.Min(pt => pt[0]))
                    Min[0] = fitPoints.Min(pt => pt[0]);
               if (Min[1] > fitPoints.Min(pt => pt[1]))
                    Min[1] = fitPoints.Min(pt => pt[1]);

               NPlot.Windows.PlotSurface2D plotter = (NPlot.Windows.PlotSurface2D)plot;
               RBFCurve RBF = (RBFCurve)curve;

               //RBF = new RBFCurve(null, "RBF " + p, fitPoints, basis, new RBFPolynomials.Linear(null), 0.0);

               plotter.Clear();
               plotter.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;

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

               plotter.Add(grid);

               int length = fitPoints.Count * 5;
               //Create a step plot instance for the balance chart.
               LinePlot speed = new LinePlot();
               PointPlot pplot = new PointPlot();

               speed.Pen = new Pen(Color.Blue, 1);

               //Create the lists from which to pull data.
               List<Int32> countaxis = new List<Int32>();
               List<Int32> Pplotcountaxis = new List<Int32>();
               List<decimal> speedlist = new List<decimal>();

               for (int i = 0; i < length; i++)
                    countaxis.Add(i);

               for (int i = 0; i < fitPoints.Count; i++)
                    Pplotcountaxis.Add((int)fitPoints[i][0]);
               //Populate the balanceAmount list
               double[] pnt;
               List<decimal> pointsList = fitPoints.ConvertAll(new Converter<double[], decimal>((double[] dd) => { return Convert.ToDecimal(dd[1]); }));

               for (int i = 0; i < length; i++)
               {
                    pnt = new double[] { (double)i, 0 };
                    RBF.Value(ref pnt);
                    speedlist.Add(Convert.ToDecimal(pnt[1]));
               }

               //foreach (double value in pent.Speeds)
               //{
               //     speedlist.Add(Convert.ToDecimal(value) / 1200);
               //}
               pplot.AbscissaData = Pplotcountaxis;
               pplot.DataSource = pointsList;
               speed.AbscissaData = countaxis;
               speed.DataSource = speedlist;

               //Add stepBalance to plotSurfaceBalance.

               plotter.Add(speed);
               plotter.Add(pplot);

               //Balance plot general settings.
               plotter.ShowCoordinates = true;
               //plotter.YAxis1.WorldMax = 10;
               //plotter.YAxis1.WorldMin = 0;
               //this.YAxis1.
               plotter.AutoScaleAutoGeneratedAxes = true;
               plotter.AddAxesConstraint(new AxesConstraint.AxisPosition(NPlot.PlotSurface2D.YAxisPosition.Left, 60));

               //Label Label1 = new Label();
               //Label1.Font = new Font(Label1.Font, FontStyle.Bold);

               //plotter.YAxis1.

               plotter.YAxis1.Label = "Y";
               plotter.YAxis1.LabelFont = new Font(this.Font, FontStyle.Bold);
               plotter.YAxis1.LabelOffsetAbsolute = true;
               plotter.XAxis1.Label = "X";
               plotter.XAxis1.LabelFont = new Font(this.Font, FontStyle.Bold);
               plotter.YAxis1.LabelOffset = 40;
               plotter.XAxis1.HideTickText = false;
               plotter.Padding = 5;

               plotter.RightMenu = NPlot.Windows.PlotSurface2D.DefaultContextMenu;
               plotter.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false));
               plotter.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
               plotter.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag());

               plotter.Title = basis.Label;
               plotter.TitleFont = new Font(this.Font, FontStyle.Bold);
               //}

               //Refresh surfaces.
               plotter.Refresh();
        }
Пример #22
0
        public void InitSystemPlot()
        {
            try
            {
                plotSurface.Clear();
                this.plotSurface.RightMenu = PlotSurface2D.DefaultContextMenu;

                plotSurface.Add( lineAvail );
                plotSurface.Add( lineUsage );

                plotSurface.PlotBackColor = plotSurface.BackColor;
                plotSurface.SmoothingMode = SmoothingMode.AntiAlias;

                plotSurface.Title = "CPU Power - Availability & Usage";
                //plotSurface.TitleFont = new Font(new FontFamily("Microsoft Sans Serif" ), 9.75f, FontStyle.Bold);

                plotSurface.XAxis1.WorldMin = -60.0f;
                plotSurface.XAxis1.WorldMax = 0.0f;
                plotSurface.XAxis1.Label = "Seconds";
                //plotSurface.XAxis1.LabelFont = new Font(new FontFamily("Microsoft Sans Serif" ), 9.75f, FontStyle.Bold);
                //plotSurface.XAxis1.TickTextFont = new Font(new FontFamily("Microsoft Sans Serif" ), 9.75f, FontStyle.Bold);

                plotSurface.YAxis1.WorldMin = 0.0;
                plotSurface.YAxis1.WorldMax= 100.0;
                plotSurface.YAxis1.Label = "Power [%]";
                //plotSurface.YAxis1.LabelFont = new Font(new FontFamily("Microsoft Sans Serif" ), 9.75f, FontStyle.Bold);
                //plotSurface.YAxis1.TickTextFont = new Font(new FontFamily("Microsoft Sans Serif" ), 9.75f, FontStyle.Bold);

                Grid gridPlotSurface = new Grid();
                gridPlotSurface.HorizontalGridType = Grid.GridType.None;
                gridPlotSurface.VerticalGridType = Grid.GridType.Fine;
                gridPlotSurface.MajorGridPen.Color = Color.DarkGray;
                plotSurface.Add(gridPlotSurface);

                plotSurface.Legend = new Legend();
                plotSurface.Legend.NeverShiftAxes = false;
                plotSurface.Legend.AttachTo( NPlot.PlotSurface2D.XAxisPosition.Bottom , NPlot.PlotSurface2D.YAxisPosition.Left);
                plotSurface.Legend.HorizontalEdgePlacement = Legend.Placement.Inside;
                plotSurface.Legend.VerticalEdgePlacement = Legend.Placement.Inside;

                lineAvail.Label = "usage";
                lineAvail.Pen   = new Pen(Color.Crimson, 2.0f);

                lineUsage.Label = "avail";
                lineUsage.Pen   = new Pen(Color.SteelBlue, 2.0f);

                plotSurface.AddInteraction(new PlotSurface2D.Interactions.HorizontalDrag());
                plotSurface.AddInteraction(new PlotSurface2D.Interactions.VerticalDrag());
                plotSurface.AddInteraction(new PlotSurface2D.Interactions.AxisDrag(true));

                plotSurface.PlotBackColor = Color.White;
                plotSurface.BackColor = SystemColors.Control;
                plotSurface.XAxis1.Color = Color.Black;
                plotSurface.YAxis1.Color = Color.Black;

                plotSurface.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Couldnot initialize graph. Error: "+ex.Message,"Console Error",MessageBoxButtons.OK,MessageBoxIcon.Error );
            }
        }
Пример #23
0
        private void UpdateEkarGraph(DataSet ekarDs, DataSet averageEkar)
        {
            const float penWidth = 2.0F;
            _ekarGraphCtrl.Clear();
            var pp = new PointPlot();
            pp.Marker = new Marker(Marker.MarkerType.Cross1, 6, new Pen(Color.Red, penWidth));
            pp.Marker.Pen = new Pen(Color.Red, penWidth);
            pp.Marker.DropLine = true;
            pp.DataSource = ekarDs;
            pp.AbscissaData = "Count";
            pp.OrdinateData = "Ekar";

            var mygrid = new Grid();
            mygrid.HorizontalGridType = Grid.GridType.Fine;
            mygrid.VerticalGridType = Grid.GridType.Fine;
            _ekarGraphCtrl.Add(mygrid);
            _ekarGraphCtrl.Add(pp);
            _ekarGraphCtrl.Padding = 1;
            _ekarGraphCtrl.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));
            _ekarGraphCtrl.XAxis1.IncreaseRange(0.10);
            var pp1 = new PointPlot();
            pp1.Marker = new Marker(Marker.MarkerType.FilledSquare, 1, new Pen(Color.Blue, 2.0F));
            pp1.Marker.DropLine = false;
            pp1.AbscissaData = "Count";
            pp1.OrdinateData = "AvEkar";
            pp1.DataSource = averageEkar;
            _ekarGraphCtrl.Add(pp1);
            _ekarGraphCtrl.Refresh();
        }