0

Oxyplot xaxis exception

Isaac Sherman 7 lat temu Ostatnio zmodyfikowane przez kkc 7 lat temu 3

Hi!  I'm new to Oxyplot, but I'm trying to understand why this exception happens.  There are a few different ways of triggering it, as documented in http://discussion.oxyplot.org/topics/226-oxyplot-paint-exception-xaxis-not-defined/ and elsewhere.  There are numerous ways to trigger it, but it seems they center around removing some element and redrawing before everything is quite ready.  In my case, I was changing a series dynamically, and the simplest way was to clear the Plot.Series collection, start with a new LineSeries, build it, and then add it to the collection.  This throws the exception until I scale or zoom.  On the other hand, if I clear the series itself (I know I only have the one series in this plot, so no issue there) and then add the points, voila- I get no exception.  


void ThrowsException(){

            littlePlot.Series.Clear();

            LineSeries littleSeries = new LineSeries();

            //Add Points here

           littlePlot.Series.Add(littleSeries);

           littlePlotView.Refresh();//Throws Exception

}

void WorksFine(){

            LineSeries littleSeries = littlePlot.Series[0] as LineSeries;
            littleSeries.Points.Clear();

            //Add Points here

            littlePlotView.Refresh();//Draws properly!

}


Is this a bug?  Or is this intended?  I can see arguments for both.


Thanks!

+1

I can't quite answer you question but I do something which is a bit similar. I update the plots dynamically too as I've to real-time measurements from a smart meter on mobile devices and I've multiple series in the plot. I use area series and I update the data set (Points) of the series by removing a few measurements and adding a few. It's important to invalidate the PlotModel to reflect the data changes in the chart. Also I use various gestures which work absolutely fine and I even update the chart after each pan / zoom and the chart is very responsive. I'm not very sure about refreshing the plotView though. Never tried that.

Thanks for the help- just wanted to follow up.  Adding the line 

littlePlot.InvalidatePlot(true);

before the .Refresh() command in  ThrowsException() fixes it.  Good to know, thanks!

No problem. Glad it worked.