How to Refresh SharpPlot with new Data ?

General APL language issues

How to Refresh SharpPlot with new Data ?

Postby PGilbert on Thu Jan 20, 2022 3:31 pm

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.
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to Refresh SharpPlot with new Data ?

Postby Nicolas|Dyalog on Tue Jan 25, 2022 1:08 pm

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
Nicolas|Dyalog
 
Posts: 17
Joined: Wed Sep 10, 2008 9:39 am

Re: How to Refresh SharpPlot with new Data ?

Postby PGilbert on Tue Jan 25, 2022 1:25 pm

Merci Nicolas, cela réponds bien à ma question.
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest