for a asp.net project, in a scatter plot, i am trying to implement ZoomIn with selectbox.
but i want both ZoomIn and selectbox as independent, so i can zoomin and analyze the data and then either zoomout and repeat this on another region and then finally select few data points using selectbox to take further action.
i am able to do these in 2 different charts but not able to combine them in 1 chart. as the handler is same for both events.
can you please provide some guidance and if possible any example.
Do you mean that if the user clicks on the chart, you want it to be treated as "Zoom In", while if the user click and drag a rectangle, you want it to be handled as "Selection"?
Currently, if the mouse usage is set to zoom in, both click and "click and drag" will trigger the ViewPortChanged event. Your code probably is handling that event, and you would like to distinguish whether it is a click or "click and drag".
You may consider the following method:
(a) In addition to ViewPortChanged, also attach a handler to "ChartMouseDown". In the event handler, just store the mouse coordinates (obtained using viewer.getChartMouseX() and viewer.getChartMouseY()).
(b) In the "ViewPortChanged" event handler, also get the mouse coordinates. When comparing with the coordinates in (a), you can know how far the mouse has moved. If it is less than the minimum drag amount (default is 5 pixels), ChartDirector will treat it as a click, otherwise it is a "click and drag". See:
Note that the minimum drag depends on the zoom direction. If the chart is set to zoom horizontally only, you only need to consider the x-coordinates. If it is a bidirectional zoom, it will be a click zoom only if both the change in x and change in y are less than the minimum drag.