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

Message ListMessage List     Post MessagePost Message

  Zoom In and Zoom out on button click
Posted by Sharan on Feb-26-2019 23:38
Hello,


I need to implement Zoom functionality for button click event to update multiple Y axis range.Is there any solution or sample please share with me .


I added below code in Button event but its not working as expected(Viewport and range not updating)

int _zoomInCount = 1;
private void OnBtnZoomInClicked(object sender, System.Windows.RoutedEventArgs e)
{
            chartViewer.setFullRange(axis, (double)Minvalue - _zoomInCount, (double)Maxvalue + _zoomInCount);
            _zoomInCount++;
}



Regards,
Sharan

  Re: Zoom In and Zoom out on button click
Posted by Peter Kwan on Feb-27-2019 23:14
Hi Sharan,

You may tell ChartDirector to redraw the chart, otherwise the chart will not be redrawn. It is because ChartDirector cannot know if you have already finished updating the viewport, so it cannot redraw the chart until your code tells it to redraw it.

A typical example is at:

https://www.advsofteng.com/doc/cdnet.htm#xyzoomscroll.htm

In the above sample code, the user can uses the slider to update the viewport. When the user moves the slider, in the "zoomBar_ValueChanged" event handler, there are multiple lines of code to update the viewport. After the viewport update is completed, it calls WPFChartViewer.updateViewPort to trigger a ViewPortChanged event. actual redrawn is performed in the ViewPortChanged event handler (WPFChartViewer1_ViewPortChanged).

For your case, instead of using a slider, you can use pushbuttons to modify the viewport. Just remember to add a line of code to cause the chart to redraw. (If your code are based on the Zooming and Scrolling sample code, the chart is redrawn in the ViewPortChanged event handler, so using updateViewPort can cause the chart to redraw.)

Usually, for zooming and scrolling, the user would update the viewport (ViewPortLeft and ViewPortWidth) to pan or zoom in/out. Of course, it is also possible to update the full range if you want to.

Regards
Peter Kwan