1. Home
  2. Docs
  3. Basic Concepts
  4. Setting the view portion
  5. Interactive pan and zoom

Interactive pan and zoom

When displaying a chart , we would sometime like to allow the end user to control the view portion. This can be done by using the following user interaction options.

Allowing the user to pan through the chart

In order to allow the user to pan through the chart , you can set the panning check box:

Or you can set it from code :

graph.HorizontalPanning = true;

Sometime you would like to know when the user has performed a pan operation. For example in order to block them from passing a certain point on the chart. For this purpose , you can use the MousePan event:

            graph.MousePan.AddListener(listener);
void listener()
{
 if(graph.HorizontalScrolling <0) // limit the horizontal panning
      graph.HorizontalScrolling = 0;
}

Allowing the User to Zoom In and Out

If you want to allow the user to zoom using the mouse wheel. you can use the GraphZoom script. It is located under Tutorials/Zoom. you can drag into your graph/candle object.

  • Error Margin should not be changed under any normal use case
  • Zoom Speed sets the speed of the zoom using the mouse wheel

Also , when using this feature , make sure Automatic view is turned off

Making your own user interactions

You can also make you interactions with the view portion. You can look at the GraphZoom script under the folder Tutorials/zoom as a reference to how it can be done. The key to developing you own interaction is doing these things: