c# - Adding series to OxyPlot chart programmatically: nothing displayed -
i'm trying use oxyplot in scenario i'm setting chart type, , adding 1 or more series programmatically. end:
- in xaml view, add
plotviewcontrol. - in code, class has
plotmodelproperty (notifying changes), ,addseriesmethod. whenever invoked, setup plot model if not yet configured (i create newplotmodelobject , addlinearaxis), create random datalineseries, , addseriescollection of plot model. finally, invokeinvalidateplot(true)on force redraw.
yet, nothing displayed when execute code, raises no error.
i googled around bit code samples found refer typical scenario xaml view binds bound datasource; here i'm recreating plotmodel each time, according chart type , series count. can find dummy repro solution here: http://1drv.ms/1r8efbc . compile , run, , click add series. suggest solution?
the bound property plotmodel never updated due to:
private void setuppiechart() { if (_plot == null) _plot = new plotmodel(); else _plot.axes.clear(); } change following , should work:
private void setuppiechart() { if (plotmodel == null) plotmodel = new plotmodel(); else plotmodel.axes.clear(); } since :
private plotmodel _plot; public plotmodel plotmodel { { return _plot; } set { _plot = value; onpropertychanged(); // <=== update here } }
Comments
Post a Comment