How to Refresh SharpPlot with new Data ?

General APL language issues
Post Reply
User avatar
PGilbert
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

How to Refresh SharpPlot with new Data ?

Post by PGilbert »

If I do the following:
      ⎕USING∪←',sharpplot.dll' ',system.drawing.dll'
sp1←⎕NEW Causeway.SharpPlot
sp1.DrawLineGraph(,⊂⍳10)(⍳10)
vw1←⎕NEW Causeway.SharpPlotViewer sp1
vw1.Show ⍬


I get a plot as expected. Now I would like to 'Refresh' this plot with some new data like:

      sp1.DrawLineGraph(,⊂⍳20)(⍳20)  ⍝ I want to redraw the plot with that new X and Y
vw1.Refresh ⍝ Does not work
vw1.Update ⍝ Does not work


But the plot stays the same. What is the method to change the X and Y values of a plot in an existing opened window ?

Thanks in advance.
Nicolas|Dyalog
Posts: 17
Joined: Wed Sep 10, 2008 9:39 am

Re: How to Refresh SharpPlot with new Data ?

Post by Nicolas|Dyalog »

SharpPlot is a state machine. So if you call DrawLineGraph for a second time, it will draw a second chart on top of the first.
The philosophy behind this is the ability to create arbitrarily complex charts. The behaviour that you were expecting would mean that SharpPlot can only draw a single chart.

If you ever want to "undo" something, you have to start it all over again.

Similarly, to update the viewer, you need to reassign the SharpPlot instance

      ⎕USING∪←',sharpplot.dll' ',system.drawing.dll'
sp1←⎕NEW Causeway.SharpPlot
sp1.DrawLineGraph(,⊂⍳10)(⍳10)
vw1←⎕NEW Causeway.SharpPlotViewer sp1
vw1.Show ⍬

sp1.DrawLineGraph(,⊂0.5×⍳10)(⍳10) ⍝ draw a second line graph
vw1.SharpPlot←sp1 ⍝ update viewer

sp2←⎕NEW Causeway.SharpPlot ⍝ create a new SharpPlot instance
sp2.DrawLineGraph(,⊂0.5×⍳10)(⍳10)
vw1.SharpPlot←sp2
User avatar
PGilbert
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to Refresh SharpPlot with new Data ?

Post by PGilbert »

Merci Nicolas, cela réponds bien à ma question.
Post Reply