[vtkusers] Chart question
Marcus D. Hanwell
marcus.hanwell at kitware.com
Fri Nov 19 14:13:39 EST 2010
On Fri, Nov 19, 2010 at 10:03 AM, Eric E. Monson <emonson at cs.duke.edu> wrote:
> Hey David,
>
> My feeling is that there isn't a nice, clean way to do this right now. I would be tempted to subclass vtkAxis and add in a custom event which would allow you to watch for when the max and min values change (which are in the data coordinates) and then recalculate your data based on that, feeding in a new input table to the plot. Because the ChartXY axes are kept in a private data storage, it may force you to re-implement a lot of the ChartXY methods just to change the axis class, though...
We could add the event to vtkAxis, I had not considered this use case.
I could also add a private header with all of the private members of
vtkChartXY, and examine what could just be in the main class to reduce
the burden on anyone making a derived chart class.
>
> Since you would have to deal with panning, rubber-band zooming and mouse wheel zooming, it might be a pain, but in principle you could just observe all of the important mouse events for the chart's interactor and then check whether the axis ranges have changed.
Possibly a new event in the chart classes? I could see that being
generally useful.
>
> I'm having a little trouble thinking through, though, what will happen with the auto axis ticks and plot bounds when you're constantly changing the input data... You'll want it to do auto-nice axis ticks and labels rather than doing it manually, but I'm not sure if the default behavior will be to try to rescale the axis ranges to the data range (which may be fine for you in one direction but not the other), and whether that will cause some weird jumpiness or whether it will be okay...
I think you would have to set the bounds, as the charts query the
input data for their bounds, with some special treatment for NaN etc.
>
> Probably Marcus will have some better ideas.
>
I had thought about plotting mathematical functions, and using a Plot
object derived from vtkPlotLine, where it could either cache the
function's output, or just recalculate the values over the range. The
plots already get access to the vtkAxis and so can query the axis
bounds on paint/update calls.
My approach would be a subclass of vtkPlot, where I generated the data
based on the axis range either in the update of paint method. Let me
know if you need any more details, and it would not require you to
derive from the chart class.
Marcus
More information about the vtkusers
mailing list