Legend functionality specific to Legends associated with a PlotSurface2D.
Наследование: LegendBase
Пример #1
0
        private void SetAxes(NPlot.Bitmap.PlotSurface2D npSurface, Font AxisFont, Font TickFont)
        {
            //X axis
            npSurface.XAxis1.Label               = "Time";
            npSurface.XAxis1.NumberFormat        = "{0:####0.0}";
            npSurface.XAxis1.TicksLabelAngle     = 90;
            npSurface.XAxis1.TickTextNextToAxis  = true;
            npSurface.XAxis1.FlipTicksLabel      = true;
            npSurface.XAxis1.LabelOffset         = 110;
            npSurface.XAxis1.LabelOffsetAbsolute = true;
            npSurface.XAxis1.LabelFont           = AxisFont;
            npSurface.XAxis1.TickTextFont        = TickFont;

            //Y axis
            npSurface.YAxis1.Label        = this.Title;
            npSurface.YAxis1.NumberFormat = "{0:####0.0}";
            npSurface.YAxis1.LabelFont    = AxisFont;
            npSurface.YAxis1.TickTextFont = TickFont;

            //Legend definition:
            NPlot.Legend npLegend = new NPlot.Legend();
            npLegend.AttachTo(NPlot.PlotSurface2D.XAxisPosition.Top, NPlot.PlotSurface2D.YAxisPosition.Right);
            npLegend.VerticalEdgePlacement   = Legend.Placement.Inside;
            npLegend.HorizontalEdgePlacement = Legend.Placement.Outside;
            npLegend.BorderStyle             = NPlot.LegendBase.BorderType.Line;
            npLegend.XOffset         = -5;
            npLegend.YOffset         = -20;
            npLegend.BackgroundColor = Color.White;

            npSurface.Legend = npLegend;

            //Update PlotSurface:
            npSurface.Refresh();
        }
Пример #2
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);
        }
Пример #3
0
        private void CreateLineGraph(float min, float max)
        {
            //Font definitions:
            Font TitleFont = new Font("Arial", 12);
            Font AxisFont  = new Font("Arial", 10);
            Font TickFont  = new Font("Arial", 8);

            //Legend definition:
            NPlot.Legend npLegend = new NPlot.Legend();

            //Prepare PlotSurface:
            //npSurface.Clear();
            npSurface.Title = "Channel Voltages";
            //npSurface.BackColor = System.Drawing.Color.AliceBlue;

            //Left Y axis grid:
            NPlot.Grid p = new Grid();
            npSurface.Add(p, NPlot.PlotSurface2D.XAxisPosition.Bottom,
                          NPlot.PlotSurface2D.YAxisPosition.Left);

            npplot.DataSource = dataY;
            npplot.Color      = Color.Blue;
            npSurface.Add(npplot, NPlot.PlotSurface2D.XAxisPosition.Bottom,
                          NPlot.PlotSurface2D.YAxisPosition.Left);
            //Y axis

            npSurface.YAxis1.Label        = "Voltage";
            npSurface.YAxis1.WorldMax     = max;
            npSurface.YAxis1.WorldMin     = min;
            npSurface.YAxis1.NumberFormat = "{0:####0.0}";
            npSurface.YAxis1.LabelFont    = AxisFont;
            npSurface.YAxis1.TickTextFont = TickFont;

            //Update PlotSurface:
            npSurface.Refresh();

            //Save PlotSurface to MemoryStream, stream output as GIF file:

            /*Response.Buffer = true;
             * Response.ContentType = "image/gif";
             *
             * MemoryStream memStream = new MemoryStream();
             *
             * npSurface.Bitmap.Save(memStream, System.Drawing.Imaging.ImageFormat.Gif);
             * memStream.WriteTo(Response.OutputStream);
             * Response.End();
             */
        }
Пример #4
0
        public PlotMarkerSample()
            : base()
        {
            infoText = "";
            infoText += "Markers Example. Demonstrates - \n";
            infoText += " * PointPlot and the available marker types \n";
            infoText += " * Legends, and how to place them.";

            plotCanvas.Clear();

            double[] y = new double[1] {1.0};
            foreach (object i in Enum.GetValues (typeof(Marker.MarkerType))) {
                Marker m = new Marker( (Marker.MarkerType)Enum.Parse(typeof(Marker.MarkerType), i.ToString()), 8 );
                m.FillColor = Colors.Red;
                double[] x = new double[1];
                x[0] = (double) m.Type;
                PointPlot pp = new PointPlot();
                pp.OrdinateData = y;
                pp.AbscissaData = x;
                pp.Marker = m;
                pp.Label = m.Type.ToString();
                plotCanvas.Add (pp);
            }
            plotCanvas.Title = "Markers";
            plotCanvas.YAxis1.Label = "Index";
            plotCanvas.XAxis1.Label = "Marker";
            plotCanvas.YAxis1.WorldMin = 0.0;
            plotCanvas.YAxis1.WorldMax = 2.0;
            plotCanvas.XAxis1.WorldMin -= 1.0;
            plotCanvas.XAxis1.WorldMax += 1.0;

            Legend legend = new Legend();
            legend.AttachTo( XAxisPosition.Top, YAxisPosition.Right );
            legend.VerticalEdgePlacement = Legend.Placement.Outside;
            legend.HorizontalEdgePlacement = Legend.Placement.Inside;
            legend.XOffset = 5; // note that these numbers can be negative.
            legend.YOffset = 0;
            plotCanvas.Legend = legend;

            PackStart (plotCanvas.Canvas, true);
            Label la = new Label (infoText);
            PackStart (la);
        }
Пример #5
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 Init()
        {
            drawables_ = new ArrayList();
            xAxisPositions_ = new ArrayList();
            yAxisPositions_ = new ArrayList();
            zPositions_ = new ArrayList();
            ordering_ = new SortedList();
            FontFamily fontFamily = FontFamily.GenericSansSerif;
            TitleFont = new Font(fontFamily, 14, FontStyle.Regular);
            padding_ = 10;
            title_ = "";
            autoScaleTitle_ = false;
            autoScaleAutoGeneratedAxes_ = false;
            xAxis1_ = null;
            xAxis2_ = null;
            yAxis1_ = null;
            yAxis2_ = null;
            pXAxis1Cache_ = null;
            pYAxis1Cache_ = null;
            pXAxis2Cache_ = null;
            pYAxis2Cache_ = null;
            titleBrush_ = new SolidBrush( Color.Black );
            plotBackColor_ = Color.White;

            this.legend_ = null;

            axesConstraints_ = new ArrayList();
        }
Пример #7
0
        private void Init()
        {
            drawables = new ArrayList ();
            xAxisPositions = new ArrayList ();
            yAxisPositions = new ArrayList ();
            zPositions = new ArrayList ();
            ordering = new SortedList ();

            try {
                TitleFont = Font.FromName ("Tahoma 14");
            }
            catch (System.ArgumentException) {
                throw new NPlotException("Error: Tahoma font is not installed on this system");
            }

            padding = 10;
            title = "";
            autoScaletitle = false;
            autoScaleAutoGeneratedAxes = false;
            xAxis1 = null;
            xAxis2 = null;
            yAxis1 = null;
            yAxis2 = null;
            pXAxis1Cache = null;
            pYAxis1Cache = null;
            pXAxis2Cache = null;
            pYAxis2Cache = null;
            titleColor = Colors.Black;
            plotBackColor = Colors.White;

            legend = null;
            axesConstraints = new ArrayList ();
        }
Пример #8
0
        public void PlotMarkers()
        {
            string[] lines = {
                "Markers Example. Demonstrates - ",
                "  * PointPlot and the available marker types",
                "  * Legends, and how to place them." };
            infoBox.Lines = lines;

            plotSurface.Clear();

            double[] y = new double[1] {1.0f};
            foreach (object i in Enum.GetValues(typeof(Marker.MarkerType)))
            {
                Marker m = new Marker( (Marker.MarkerType)Enum.Parse(typeof(Marker.MarkerType), i.ToString()), 8 );
                double[] x = new double[1];
                x[0] = (double) m.Type;
                PointPlot pp = new PointPlot();
                pp.OrdinateData = y;
                pp.AbscissaData = x;
                pp.Marker = m;
                pp.Label = m.Type.ToString();
                plotSurface.Add( pp );
            }
            plotSurface.Title = "Markers";
            plotSurface.YAxis1.Label = "Index";
            plotSurface.XAxis1.Label = "Marker";
            plotSurface.YAxis1.WorldMin = 0.0f;
            plotSurface.YAxis1.WorldMax = 2.0f;
            plotSurface.XAxis1.WorldMin -= 1.0f;
            plotSurface.XAxis1.WorldMax += 1.0f;

            Legend legend = new Legend();
            legend.AttachTo( PlotSurface2D.XAxisPosition.Top, PlotSurface2D.YAxisPosition.Right );
            legend.VerticalEdgePlacement = Legend.Placement.Outside;
            legend.HorizontalEdgePlacement = Legend.Placement.Inside;
            legend.XOffset = 5; // note that these numbers can be negative.
            legend.YOffset = 0;
            plotSurface.Legend = legend;

            plotSurface.Refresh();
        }
Пример #9
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();
        }
Пример #10
0
 private void AttachLegend(NPlot.Windows.PlotSurface2D surf)
 {
     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;
     surf.Legend = leg;
     surf.LegendZOrder = 10;
 }
Пример #11
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();

                }
        }
Пример #12
0
        public void PlotMarkers()
        {
            plotSurface.Clear();

            double[] y = new double[1] {1.0f};
            foreach (object i in Enum.GetValues(typeof(Marker.MarkerType)))
            {
                Marker m = new Marker( (Marker.MarkerType)Enum.Parse(typeof(Marker.MarkerType), i.ToString()), 8 );
                double[] x = new double[1];
                x[0] = (double) m.Type;
                PointPlot pp = new PointPlot();
                pp.OrdinateData = y;
                pp.AbscissaData = x;
                pp.Marker = m;
                pp.Label = m.Type.ToString();
                plotSurface.Add( pp );
            }
            plotSurface.Title = "Markers";
            plotSurface.YAxis1.Label = "Index";
            plotSurface.XAxis1.Label = "Marker";
            plotSurface.YAxis1.WorldMin = 0.0f;
            plotSurface.YAxis1.WorldMax = 2.0f;
            plotSurface.XAxis1.WorldMin -= 1.0f;
            plotSurface.XAxis1.WorldMax += 1.0f;

            Legend legend = new Legend();
            legend.AttachTo( PlotSurface2D.XAxisPosition.Top, PlotSurface2D.YAxisPosition.Right );
            legend.VerticalEdgePlacement = Legend.Placement.Outside;
            legend.HorizontalEdgePlacement = Legend.Placement.Inside;
            plotSurface.Legend = legend;

            plotSurface.Refresh();
        }
Пример #13
0
        private void PlotSincFunction()
        {
            plotSurface.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] = (double)Math.Sin((((double)i-50.0f)/4.0f))/(((double)i-50.0f)/4.0f);
                    b[i] *= mult;
                }
                a[i] += b[i];
            }

            Marker m = new Marker(Marker.MarkerType.Cross1,6,new Pen(Color.Blue,2.0F));
            PointPlot pp = new PointPlot( m );
            pp.OrdinateData = a;
            pp.AbscissaData = new StartStep( -500.0, 10.0 );
            pp.Label = "Random";
            plotSurface.Add(pp);

            LinePlot lp = new LinePlot();
            lp.OrdinateData = b;
            lp.AbscissaData = new StartStep( -500.0, 10.0 );
            lp.Pen = new Pen( Color.Red, 2.0f );
            plotSurface.Add( lp );

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

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

            plotSurface.Legend = new Legend();

            plotSurface.Refresh();
        }
Пример #14
0
        private void SetAxes(NPlot.Bitmap.PlotSurface2D npSurface, Font AxisFont, Font TickFont)
        {
            //X axis
            npSurface.XAxis1.Label = "Time";
            npSurface.XAxis1.NumberFormat = "{0:####0.0}";
            npSurface.XAxis1.TicksLabelAngle = 90;
            npSurface.XAxis1.TickTextNextToAxis = true;
            npSurface.XAxis1.FlipTicksLabel = true;
            npSurface.XAxis1.LabelOffset = 110;
            npSurface.XAxis1.LabelOffsetAbsolute = true;
            npSurface.XAxis1.LabelFont = AxisFont;
            npSurface.XAxis1.TickTextFont = TickFont;

            //Y axis
            npSurface.YAxis1.Label = this.Title;
            npSurface.YAxis1.NumberFormat = "{0:####0.0}";
            npSurface.YAxis1.LabelFont = AxisFont;
            npSurface.YAxis1.TickTextFont = TickFont;

            //Legend definition:
            NPlot.Legend npLegend = new NPlot.Legend();
            npLegend.AttachTo(NPlot.PlotSurface2D.XAxisPosition.Top, NPlot.PlotSurface2D.YAxisPosition.Right);
            npLegend.VerticalEdgePlacement = Legend.Placement.Inside;
            npLegend.HorizontalEdgePlacement = Legend.Placement.Outside;
            npLegend.BorderStyle = NPlot.LegendBase.BorderType.Line;
            npLegend.XOffset = -5;
            npLegend.YOffset = -20;
            npLegend.BackgroundColor = Color.White;

            npSurface.Legend = npLegend;

            //Update PlotSurface:
            npSurface.Refresh();
        }
Пример #15
0
        private void Init()
        {
            drawables_ = new ArrayList();
            xAxisPositions_ = new ArrayList();
            yAxisPositions_ = new ArrayList();
            zPositions_ = new ArrayList();
            ordering_ = new SortedList();

            try
            {
                TitleFont = DefaultTitleFont;
            }
            catch (System.ArgumentException)
            {
                throw new NPlotException("Error: Arial font is not installed on this system");
            }

            padding_ = 10;
            title_ = "";
            autoScaleTitle_ = false;
            autoScaleAutoGeneratedAxes_ = false;
            xAxis1_ = null;
            xAxis2_ = null;
            yAxis1_ = null;
            yAxis2_ = null;
            pXAxis1Cache_ = null;
            pYAxis1Cache_ = null;
            pXAxis2Cache_ = null;
            pYAxis2Cache_ = null;
            titleBrush_ = new SolidBrush( Color.Black );
            plotBackColor_ = Color.White;

            this.legend_ = null;

            smoothingMode_ = System.Drawing.Drawing2D.SmoothingMode.None;

            axesConstraints_ = new ArrayList();
        }
Пример #16
0
        private void Init()
        {
            drawables_ = new ArrayList();
            xAxisPositions_ = new ArrayList();
            yAxisPositions_ = new ArrayList();
            zPositions_ = new ArrayList();
            ordering_ = new SortedList();
            FontFamily fontFamily = new FontFamily("Arial");
            TitleFont = new Font(fontFamily, 14, FontStyle.Regular, GraphicsUnit.Pixel);
            padding_ = 10;
            title_ = "";
            autoScaleTitle_ = false;
            autoScaleAutoGeneratedAxes_ = false;
            xAxis1_ = null;
            xAxis2_ = null;
            yAxis1_ = null;
            yAxis2_ = null;
            pXAxis1Cache_ = null;
            pYAxis1Cache_ = null;
            pXAxis2Cache_ = null;
            pYAxis2Cache_ = null;
            titleBrush_ = new SolidBrush( Color.Black );
            plotBackColor_ = Color.White;

            this.legend_ = null;

            smoothingMode_ = System.Drawing.Drawing2D.SmoothingMode.None;

            axesConstraints_ = new ArrayList();
        }
Пример #17
0
        private void PlotSincFunction()
        {
            string[] lines = {
                "Sinc Function Example. Demonstrates - ",
                "  * Charting line and point plot at the same time.",
                "  * Adding a legend." };

            infoBox.Lines = lines;

            plotSurface.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] = (double)Math.Sin((((double)i-50.0f)/4.0f))/(((double)i-50.0f)/4.0f);
                    b[i] *= mult;
                }
                a[i] += b[i];
            }

            Marker m = new Marker(Marker.MarkerType.Cross1,6,new Pen(Color.Blue,2.0F));
            PointPlot pp = new PointPlot( m );
            pp.OrdinateData = a;
            pp.AbscissaData = new StartStep( -500.0, 10.0 );
            pp.Label = "Random";
            plotSurface.Add(pp);

            LinePlot lp = new LinePlot();
            lp.OrdinateData = b;
            lp.AbscissaData = new StartStep( -500.0, 10.0 );
            lp.Pen = new Pen( Color.Red, 2.0f );
            plotSurface.Add(lp);

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

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

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

            plotSurface.Refresh();
        }
Пример #18
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();
        }