Home Forums Chart Support Method call for Zoom / pan Function in Canvas Js Reply To: Method call for Zoom / pan Function in Canvas Js

#26734

@santhoshnarendra,

You can perform button click programmatically to switch to pan mode by default & hide the zoom/pan button using CSS to do so. Below is the code-snippet for the same.

-----CSS----
.canvasjs-chart-toolbar> button:first-child {
  display: none !important;
}
----JS----
var parentElement = document.getElementsByClassName("canvasjs-chart-toolbar");
var childElement = document.getElementsByTagName("button");
if(childElement[0].getAttribute("state") === "pan"){
  childElement[0].click();
}

Please take a look at this JSFiddle for complete code.


Vishwas R
Team CanvasJS