Can't update OxyPlot graph after initialisation

蹲街弑〆低调 提交于 2019-12-01 08:45:24

Although the Chart ObservableCollection will be providing appropriate notifications, I don't think the chart/plot itself will necessarily be responding to those notifications, so it may well not know it needs to be redrawn.

I'm not familiar with OxyPlot, but I had a quick crack at following a tutorial, and from a quick scan of the Plot class, I found a method called InvalidatePlot(), which seems to force the plot to redraw itself - it may well be the case that you need to call that if you're intend on making changes to the plot data. It certainly worked when I tried it in a small sample project.

I didn't find a huge amount of example usage, however these links may help:

http://oxyplot.codeplex.com/discussions/398856

http://oxyplot.codeplex.com/discussions/352003

And this is the example referred to in the second of those links:

http://oxyplot.codeplex.com/SourceControl/latest#Source/Examples/WPF/WpfExamples/Examples/CoupledAxesDemo/

Edit:

It looks like the intended approach may well be to create a PlotModel and bind the Model property of your plot to it, you can then notify the UI when the PlotModel changes:

oxyplot.codeplex.com/SourceControl/latest#Source/Examples/WPF/WpfExamples/Examples/RealtimeDemo/

You can do:

<oxy:Plot InvalidateFlag="{Binding DataPoints.Count, Delay=20}">
    <oxy:Plot.Series>
        <oxy:LineSeries ItemsSource="{Binding DataPoints}"/>
    </oxy:Plot.Series>
</oxy:Plot>

In your case the Delay is not needed but it can be useful at times.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!