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

#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