Exemple #1
0
        public Image drawChart(List <int> xTime, List <double> yVel)
        {
            Bitmap bm = new Bitmap(PanelSize.Width, PanelSize.Height);

            using (Graphics g = Graphics.FromImage(bm)) {
                NPlot.Bitmap.PlotSurface2D plotSurface = new NPlot.Bitmap.PlotSurface2D(bm);

                NPlot.LinePlot linePlot = new NPlot.LinePlot(yVel, xTime);
                linePlot.Color = Color.Green;

                plotSurface.Add(linePlot);

                NPlot.Legend legende = new NPlot.Legend();

                NPlot.Grid grid = new NPlot.Grid();

                grid.HorizontalGridType = NPlot.Grid.GridType.Coarse;
                grid.VerticalGridType   = NPlot.Grid.GridType.Fine;
                plotSurface.Add(grid);


                Rectangle rectBounds = new Rectangle(0, 0, PanelSize.Width, PanelSize.Height);
                plotSurface.Draw(g, rectBounds);
            }

            return(bm);
        }
Exemple #2
0
        public Image drawChart(List <long> xTime, List <double> yVel)
        {
            Bitmap bm = new Bitmap(PanelSize.Width, PanelSize.Height);

            using (Graphics g = Graphics.FromImage(bm)) {
                NPlot.Bitmap.PlotSurface2D plotSurface = new NPlot.Bitmap.PlotSurface2D(bm);
                plotSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                NPlot.LinePlot linePlot = new NPlot.LinePlot(yVel, xTime);
                linePlot.Color = Color.Red;

                plotSurface.Add(linePlot);

                plotSurface.YAxis1.AutoScaleTicks = Autozoom;
                if (!Autozoom)
                {
                    plotSurface.YAxis1.WorldMax = YMax;
                    plotSurface.YAxis1.WorldMin = YMin;
                }

                plotSurface.Title        = Title;
                plotSurface.XAxis1.Label = XLabel;
                plotSurface.YAxis1.Label = YLabel;

                NPlot.Legend legende = new NPlot.Legend();

                NPlot.Grid grid = new NPlot.Grid();

                grid.HorizontalGridType = NPlot.Grid.GridType.Fine;
                grid.VerticalGridType   = NPlot.Grid.GridType.Fine;
                plotSurface.Add(grid);


                Rectangle rectBounds = new Rectangle(0, 0, PanelSize.Width, PanelSize.Height);
                plotSurface.Draw(g, rectBounds);
            }

            return(bm);
        }
Exemple #3
0
        // Erzeugt in einem Bitmap den zu plotenden Graphen

        public Image drawChart()
        {
            Bitmap bm = new Bitmap(PanelSize.Width, PanelSize.Height);

            using (Graphics g = Graphics.FromImage(bm))
            {
                //Rectangle allRect = new Rectangle(0, 0, PanelSize.Width, PanelSize.Height);
                //g.FillRectangle(Brushes.White, allRect);

                NPlot.Bitmap.PlotSurface2D plotSurface = new NPlot.Bitmap.PlotSurface2D(bm);
                plotSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                // Achsen definieren

                if (_XAxisBottomType == AxisType.linear)
                {
                    plotSurface.XAxis1 = new NPlot.LinearAxis();
                }
                if (_XAxisBottomType == AxisType.log10)
                {
                    plotSurface.XAxis1 = new NPlot.LogAxis();
                }
                else if (_XAxisBottomType == AxisType.label)
                {
                    NPlot.LabelAxis      lA      = new NPlot.LabelAxis();
                    IEnumerator <string> elabels = _XAxisBottomLabels.GetEnumerator();
                    elabels.Reset();
                    IEnumerator <double> evalues = _XAxisBottomSeries.GetEnumerator();
                    evalues.Reset();
                    double minValue = double.MaxValue;
                    double maxValue = double.MinValue;
                    while (elabels.MoveNext() && evalues.MoveNext())
                    {
                        lA.AddLabel(elabels.Current, evalues.Current);
                        minValue = Math.Min(minValue, evalues.Current);
                        maxValue = Math.Max(maxValue, evalues.Current);
                    }
                    double puffer = (maxValue - minValue) * 0.05;
                    lA.WorldMin        = minValue - puffer;
                    lA.WorldMax        = maxValue + puffer;
                    plotSurface.XAxis1 = lA;
                }

                if (_XAxisBottomType != AxisType.undef)
                {
                    plotSurface.XAxis1.Label        = XAxis1Label;
                    plotSurface.XAxis1.TickTextFont = TickTextFont;
                    plotSurface.XAxis1.LabelFont    = LabelFont;
                }

                if (_XAxisTopType == AxisType.linear)
                {
                    plotSurface.XAxis2 = new NPlot.LinearAxis();
                }
                else if (_XAxisTopType == AxisType.log10)
                {
                    plotSurface.XAxis2 = new NPlot.LogAxis();
                }
                else if (_XAxisTopType == AxisType.label)
                {
                    NPlot.LabelAxis      lA      = new NPlot.LabelAxis();
                    IEnumerator <string> elabels = _XAxisTopLabels.GetEnumerator();
                    elabels.Reset();
                    IEnumerator <double> evalues = _XAxisTopSeries.GetEnumerator();
                    evalues.Reset();
                    while (elabels.MoveNext() && evalues.MoveNext())
                    {
                        lA.AddLabel(elabels.Current, evalues.Current);
                    }
                    plotSurface.XAxis2 = lA;
                }

                if (_XAxisTopType != AxisType.undef)
                {
                    plotSurface.XAxis2.Label        = XAxis2Label;
                    plotSurface.XAxis2.TickTextFont = TickTextFont;
                    plotSurface.XAxis2.LabelFont    = LabelFont;
                }

                if (_YAxisLeftType == AxisType.linear)
                {
                    plotSurface.YAxis1 = new NPlot.LinearAxis();
                }
                else if (_YAxisLeftType == AxisType.log10)
                {
                    plotSurface.YAxis1 = new NPlot.LogAxis();
                }
                else if (_YAxisLeftType == AxisType.label)
                {
                    NPlot.LabelAxis      lA      = new NPlot.LabelAxis();
                    IEnumerator <string> elabels = _YAxisLeftLabels.GetEnumerator();
                    elabels.Reset();
                    IEnumerator <double> evalues = _YAxisLeftSeries.GetEnumerator();
                    evalues.Reset();
                    while (elabels.MoveNext() && evalues.MoveNext())
                    {
                        lA.AddLabel(elabels.Current, evalues.Current);
                    }
                    plotSurface.YAxis1 = lA;
                }

                if (plotSurface.YAxis1 != null)
                {
                    plotSurface.YAxis1.AutoScaleTicks = Autozoom;
                    plotSurface.YAxis1.Label          = YAxis1Label;
                    plotSurface.YAxis1.LabelFont      = LabelFont;
                    plotSurface.YAxis1.TickTextFont   = TickTextFont;
                    if (!Autozoom)
                    {
                        plotSurface.YAxis1.WorldMax = YMax;
                        plotSurface.YAxis1.WorldMin = YMin;
                    }
                }

                if (_YAxisRightType == AxisType.linear)
                {
                    plotSurface.YAxis2 = new NPlot.LinearAxis();
                }
                else if (_YAxisRightType == AxisType.log10)
                {
                    plotSurface.YAxis2 = new NPlot.LogAxis();
                }
                else if (_YAxisRightType == AxisType.label)
                {
                    NPlot.LabelAxis      lA      = new NPlot.LabelAxis();
                    IEnumerator <string> elabels = _YAxisRightLabels.GetEnumerator();
                    elabels.Reset();
                    IEnumerator <double> evalues = _YAxisRightSeries.GetEnumerator();
                    evalues.Reset();
                    while (elabels.MoveNext() && evalues.MoveNext())
                    {
                        lA.AddLabel(elabels.Current, evalues.Current);
                    }
                    plotSurface.YAxis2 = lA;
                }

                if (plotSurface.YAxis2 != null)
                {
                    plotSurface.YAxis2.AutoScaleTicks = Autozoom;
                    plotSurface.YAxis2.Label          = YAxis2Label;
                    plotSurface.YAxis2.LabelFont      = LabelFont;
                    plotSurface.YAxis2.TickTextFont   = TickTextFont;
                    if (!Autozoom)
                    {
                        plotSurface.YAxis2.WorldMax = YMax;
                        plotSurface.YAxis2.WorldMin = YMin;
                    }
                }

                // Graphen hinzufügen

                foreach (MyPlot my in plots)
                {
                    plotSurface.Add(my.plot, my.XAxisPosition, my.YAxisPosition);
                }

                // Titel und Achsbeschrigtungen hinzufügen
                plotSurface.Title     = Title;
                plotSurface.TitleFont = TitleFont;

                // Legende hinzufügen
                NPlot.Legend legende = new NPlot.Legend();
                plotSurface.Legend = legende;

                // Gitternetzlinien hinzufügen
                NPlot.Grid grid = new NPlot.Grid();

                grid.HorizontalGridType = NPlot.Grid.GridType.Fine;
                grid.VerticalGridType   = NPlot.Grid.GridType.Coarse;
                plotSurface.Add(grid);


                Rectangle rectBounds = new Rectangle(0, 0, PanelSize.Width, PanelSize.Height);
                plotSurface.Draw(g, rectBounds);
            }

            return(bm);
        }