Home forums Using CanvasJS Zoom / Pan button default to pan with multiple charts Reply To: Zoom / Pan button default to pan with multiple charts

#11754

Vishwas R
Keymaster

Crees,

When you have multiple charts in a page, there will be multiple childElement (zoom/pan buttons). So automatically clicking all childElement will solve the issue.

var parentElement = document.getElementsByClassName("canvasjs-chart-toolbar");
var childElement = document.getElementsByTagName("button");
for(var i=0;i<childElement.length;i++){
  if(childElement[i].getAttribute("state") === "pan"){
    childElement[i].click();
  }
}

Here is updated example.