Home Forums Chart Support Adding a custom button in toolbar or beside the tool bar zoom/span.

Adding a custom button in toolbar or beside the tool bar zoom/span.

Viewing 2 posts - 1 through 2 (of 2 total)
  • #61046

    Hi,Is it possible to add a custom button to the CanvasJS chart toolbar (like next to the existing Zoom or Reset buttons) to trigger our own functionality — for example, auto-scaling the chart’s Y-axis?

    #61050

    @aizaz,

    You can add a custom button to the CanvasJS toolbar using DOM manipulation (e.g., append a button to .canvasjs-chart-toolbar). After chart.render(), you can create a button element, style it to match the toolbar and append it. Ensure the chart is rendered first, as the toolbar won’t exist otherwise. Please find the code-snippet below.

    var toolbar = document.getElementsByClassName("canvasjs-chart-toolbar")[0];
    var button = document.createElement("button");
    toolbar.appendChild(button);

    Please take a look at this JSFiddle for a working example.
    chart with custom toolbar button


    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.