Home Forums Chart Support Synchronized Charts Reply To: Synchronized Charts

#33500

@nerviozzo96,

Yes, it is possible to sync zoom / pan button across multiple charts. You can achieve this by triggering the click event on the zoom / pan button on all charts when a user clicks on it in one of the charts as shown below:

function syncZoomPanButtonClick() {
  var toolbars = document.getElementsByClassName("canvasjs-chart-toolbar");
  for(var j = 0; j < toolbars.length; j++) {
    toolbars[j].firstChild.addEventListener("click", function(e) {
      for(var j = 0; j < toolbars.length; j++){
        if(this != toolbars[j].firstChild && e.isTrusted === true) {
          toolbars[j].firstChild.click();
        }
      }
    });
  }
}

Please take a look at this JSFiddle for a working example with sample code.

Sync zoom / pan button across multiple charts


Shashi Ranjan
Team CanvasJS