Simon Renardson
Simon Renardson

Reputation: 41

Points wrapping to start of OxyPlot chart

I have a program which receives a datestamp and a value from an access (.mbd) database and saves them to two lists (dates and dataPoints, respectively). When I use an OxyPlot chart with DateTimeAxis to plot the points, it doubles up on some points which are the same time, but a different date. Is there a way to make OxyPlot take dates into account as well?

public void CreatePlot(List<float> dataPoints, List<DateTime> dates, DateTime fromDate, DateTime toDate, string craneName)
    {
        PlotView plotView = new PlotView();
        this.Controls.Add(plotView);

        PlotModel plotModel = new PlotModel();
        DateTimeAxis xAxis = new DateTimeAxis();
        xAxis.Position = AxisPosition.Bottom;
        //xAxis.Minimum = DateTimeAxis.ToDouble(fromDate);
        //xAxis.Maximum = DateTimeAxis.ToDouble(toDate);
        //Console.WriteLine(xAxis.Minimum.ToString());
        //Console.WriteLine(xAxis.Maximum.ToString());
        plotModel.Axes.Add(xAxis);
        LinearAxis yAxis = new LinearAxis();
        plotModel.Axes.Add(yAxis);
        LineSeries lineSeries = new LineSeries();
        for (int i = 0; i < dataPoints.Count; i++)
        {
            lineSeries.Points.Add(new OxyPlot.DataPoint(DateTimeAxis.ToDouble(dates[i]), dataPoints[i]));
            LogFileHandling.LogWrite(dates[i].ToString() + dataPoints[i].ToString());
        }
        plotModel.Series.Add(lineSeries);
        plotView.Model = plotModel;
    }

Exported chart

Upvotes: 0

Views: 246

Answers (1)

Simon Renardson
Simon Renardson

Reputation: 41

Never mind, it was the data coming from the database that was causing the issue. Performing a compact and repair on it fixed it.

Upvotes: 1

Related Questions