Home Forums Chart Support Pan instead of zoom by default

Pan instead of zoom by default

Viewing 3 posts - 1 through 3 (of 3 total)
  • #32962

    When both panning and zooming are enabled, dragging a cursor on a plot by default will zoom in. Is there a way to change it such that dragging a cursor on a plot will instead pan by default?

    #32963

    I think I got this functionality by putting this after the render line:

    if (document.querySelector('button[state="pan"]')) {
      document.querySelector('button[state="pan"]').click();
    }
    #32970

    @joshuasosa,

    Glad that you figured it out. Also, you can enable pan mode as default option by simulating the click event on pan button as shown in this code snippet.

    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 an example on chart with pan functionality as default mode.

    Chart with pan as default mode

    —-
    Manoj Mohan
    Team CanvasJS

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.