Home Forums Chart Support Button to zoom Reply To: Button to zoom



You can programmatically zoom into certain region by setting viewportMinimum and viewportMaximum. If you like to set zoom into certain region after clicking the button, you can do so by changing viewportMinimum & viewportMaximum on clicking the button. Below is the code-snippet for the same.

document.getElementById("zoomBtn").addEventListener("click", function(){
  chart.axisX[0].set("viewportMinimum", new Date(2002, 01, 01), false);
  chart.axisX[0].set("viewportMaximum", new Date(2006, 01, 01));

Please take a look at this JSFiddle for complete code.
Chart Zooming using Buttons

Also take a look at this jsfiddle, where viewportMinimum and viewportMaximum are changed based on dropdown options.

Vishwas R
Team CanvasJS