addTo(String arrayName, Object options [, Number index = array.length [, Boolean updateChart = true]])

Adds a new element of given type to the specified array. For example, it can be used to add new Axis to axisY array.

Parameters:
        propertyName: Name of the property
        options: Option for the new element
        index: Index of the array where the new element is to be added. Defaults to the length (end) of array.
        updateChart: When true, Updates the chart automatically after setting the value. Defaults to true.

Example: chart.addTo(“axisY”, { title: “Axis Y 2 Title” },2);
Note:
  • Chart should be rendered before you can use this method.
  • Chart renders automatically after addTo() operation.
var  chart =  new  CanvasJS.Chart("container",
{
     .
     .
     .
});
chart.render();

chart.addTo("axisY", {title: "Axis Y 2 Title"}, 2);
Try Editing The Code

  Also See:    


If you have any questions, please feel free to ask in our forums.Ask Question