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

Message ListMessage List     Post MessagePost Message

  Restore Zooming
Posted by jboy on Jul-24-2009 23:12
Hi... I'm new to ChartDirector. I made a zoomable chart. I want to have a restore button to so that it will go back to its original zoom. Any response would be much appreciated. Thank You!

  Re: Restore Zooming
Posted by Peter Kwan on Jul-25-2009 05:00
Hi jboy,

There should be many methods. The followings are some of them I can think of:

(a) When the page first load, you can save the original visible range using Javascript (assuming you are writing a web application). For example, in the "Zooming and Scrolling Demonstration (1)" (web version), you can save the Start Year, Start Month, Start Day, End Year, End Month and End Day by reading them from the HTML controls. Then when the user press the "Restore Button", you can transfer the original values back to the controls, then perform a partialUpdate (perform the same action as if the "Update Chart" button is clicked).

(b) Your "Restore Button" can simply set a custom flag (see setCustomAttr/getCustomAttr) before triggering a partialUpdate. On the server side, if it detects this flag, the server should set the chart visible range back to the default range.

Hope this can help.

Regards
Peter Kwan

  Re: Restore Zooming
Posted by jboy on Jul-25-2009 05:14
yes. I tried saving the initial state using setCustomAttr and then use it if restore event is fired. It works. It was restored but when I click the zoom in again, it just continue zooming from the last zoom in state.

  Re: Restore Zooming
Posted by Peter Kwan on Jul-27-2009 15:39
Hi jboy,

In a Zoomable and Scrollable Chart, there can be many controls trying to store and manipulate the zoom state.

For example, in the "Zooming and Scrolling Demonstration" sample code, the chart itself  has a viewport (configurable using setViewPortLeft, setViewPortTop, ....) that stores the zoom state. The user can manipulate this zoom state by dragging or clicking on the chart.

There are also the "Start Time" and "End Time" HTML drop down list boxes that stores the zoom state. The user can manipulate this zoom state by selecting on the drop down list box and clicking "Update Chart".

Now there is also your "Reset" button that can manipulate the zoom state by pressing on it.

When the server receives a request, it must determine which control is trying to manipulate the zoom state, and then synchronize the other controls with that control.

For example, if your button is manipulating the zoom state back to its initial value, the server must synchronize the viewport (using setViewPortLeft, setViewPortTop, etc), and also the "Start Date" and "End Date" drop down list boxes, and any other controls in your chart that can store the zoom state.

So if you are using the setCustmAttr method, has you included code in the server or browser side to synchronize the viewport to the initial state?

I think in the original "Zooming and Scrolling Demonstration" sample code, if you set the viewPortStartDate and viewPortEndDate, there are code in the  drawChart method will automatically synchronize the viewport with the viewPortStartDate and viewPortEndDate, and there are code in the processPartialUpdate to synchronize the "Start Date" and "End Date" drop down list boxes.

I can create an example for you based on the "Zooming and Scrolling Demonstration" sample code. If you need the example, please inform me which programming language and development framework you are using.

Hope this can help.

Regards
Peter Kwan

  Re: Restore Zooming
Posted by jboy on Jul-28-2009 09:44
I got it already. Thank you Peter for your replies... :D