Menu

#18 (c#)There is any way to draw AbscissaData in the same order which in reading?

open
None
5
2018-09-25
2018-09-25
No

Hello all,

Sorry if I did submit the ticket in the correct location or to the corect person but I'm a new member and I'm quite new using c#.
I'm wondering if there is any possibility to draw the AbscissaData in the same order which in reading in c#?
For IDrawable I'm using Grid and data which is coming for AbscissaData is a DateTime[] struct.
Ex: DateTime[] ={ 2018-09-25 11:25:35, 2018-09-26 11:26:35, 2018-09-24 11:25:35, 2018-09-23 11:27:35}

For the moment, the x-coordinates are displayed chronologically , meaning 2018-09-23 11:27:35, 2018-09-24 11:25:35, 2018-09-25 11:25:35, 2018-09-26 11:26:35 but I want it to be dispalyed in the same order which is reading.
Bellow you can find my method where I'm plotting the data.

Could please help me? I'm missing some method that I can use? Any hint would be very helpful
Many thanks,
Loreadana

GraphOneSerie(DateTime[] oDate, string[] variable, DateTime[] reboot, NPlot.Windows.PlotSurface2D npSurface, string text)
{
PointPlot npPlot1 = new PointPlot();
PointPlot npReboots = new PointPlot();

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

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

        //Prepare PlotSurface:
        npSurface.Clear();
        npSurface.Title = "OBU";
        npSurface.PlotBackColor = Color.White;
        npSurface.DateTimeToolTip = true;

        //Left Y axis grid:

        Grid p = new Grid();
        npSurface.Add(p, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
        npPlot1.AbscissaData = oDate;
        npPlot1.OrdinateData = variable;
        npPlot1.Label = text;
        npPlot1.Marker.Color = Color.Blue;
        npPlot1.Marker.Filled = true;

        // reboots series
        double[] vector = new double[reboot.Length];
        double[] thefirst = Array.ConvertAll(variable, double.Parse);

        for (int i = 0; i < reboot.Length; i++)
            vector[i] = thefirst.Max();

        npReboots.AbscissaData = reboot;
        npReboots.OrdinateData = vector;
        npReboots.Label = "Reboot";
        npReboots.Marker = new Marker(Marker.MarkerType.None, 0)
        {
            Pen = new Pen(Color.Red, 1),
            DropLine = true
        };

        npSurface.Add(npPlot1, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
        npSurface.Add(npReboots, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
        //X axis

        npSurface.XAxis1.Label = "Date";
        npSurface.XAxis1.NumberFormat = "yyyy-MM-dd" + "\n" + "hh:mm:ss";
        // npSurface.XAxis1.TicksLabelAngle = 40;
        npSurface.XAxis1.TickTextNextToAxis = true;
        npSurface.XAxis1.FlipTicksLabel = true;
        npSurface.XAxis1.LabelOffset = 40;
        npSurface.XAxis1.LabelOffsetAbsolute = true;
        npSurface.XAxis1.LabelFont = AxisFont;
        npSurface.XAxis1.TickTextFont = TickFont;

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

        //Add legend:
        npLegend.AttachTo(PlotSurface2D.XAxisPosition.Top, PlotSurface2D.YAxisPosition.Right);
        npLegend.VerticalEdgePlacement = Legend.Placement.Inside;
        npLegend.HorizontalEdgePlacement = Legend.Placement.Outside;
        npLegend.BorderStyle = LegendBase.BorderType.Line;
        npLegend.NumberItemsHorizontally = 4;
        npSurface.Legend = npLegend;

        //Update PlotSurface:
        npSurface.Refresh();
    }

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.