ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Dynamic chart: zooming, scrolling, multiple axes
Posted by Lofi on Jul-02-2013 14:07
The zooming and panning feature of ChartDirector is awesome and it could bring huge value to my application. However, it's not an easy task to do. I've digged through the samples and couldn't find what I needed. All the examples have hardcoded numbers in them (e. g. the axis-distance is 50 pixels). Maybe someone can help me.

* I want to click on a line and select "set as left/right axis". How can I do this? ChartDirector has setUseYAxis. The problem is that ChartDirector doesn't consider the axis width (label etc) automatically in that case. It needs a position for the axis which I don't know because of its dynamic nature. I could as well have 4 lines and 3 of them have an axis on the right side of the chart.

*  I want to zoom only the y-axis when the mouse is over the y-axis, zoom only the x-axis when the mouse is over the x-axis and zoom both the x- and y-axis when the mouse is over the plot area. Is that possible when you have e. g. multiple axis (2 left, 2 right) and how do I detect on which axis I am?

Thank you very much!

  Re: Dynamic chart: zooming, scrolling, multiple axes
Posted by Lofi on Jul-02-2013 14:30
Please ignore the first part with the multiple axis. It worked as usual with axis.getThickness() and axis.setOffset(). I just had a bug in my code ... :-)

  Re: Dynamic chart: zooming, scrolling, multiple axes
Posted by Peter Kwan on Jul-03-2013 02:10
Hi Lofi,

When the mouse moves, there are mouse move events, and you can determine where is the mouse. Your code can also know where are the axes (as your code puts them on the chart). So your code should have sufficient information to determine if the mouse is over the x-axis or y-axis or neither. Based on this information, you may change the allowable zoom/scroll direction (see setZoomDirection and setScrollDirection).

Hope this can help.

Regards
Peter Kwan

  Re: Dynamic chart: zooming, scrolling, multiple axes
Posted by Lofi on Jul-05-2013 13:31
Hello Peter,

thank you, I got it working with 1 axis. How can I reset the syncLinearAxisWithViewPort assignments?

Example: 3 lines, 3 axis. I'm on the plotarea with the mouse. I set:

syncLinearAxisWithViewPort( "id1", axis1);
syncLinearAxisWithViewPort( "id2", axis2);
syncLinearAxisWithViewPort( "id3", axis3);

I can zoom all 3 axis together.

Now when I'm on axis 2 with the mouse, I only want to zoom axis 2. I have to set only

syncLinearAxisWithViewPort( "id2", axis2);

but axis1 and axis3 are still set in the viewer. Using

syncLinearAxisWithViewPort( "id1", null);
syncLinearAxisWithViewPort( "id2", axis2);
syncLinearAxisWithViewPort( "id3", null);

gives a Nullpointer Exception.

Thank you & best regards
Lofi