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 dataPoint to datPoints 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.data[0].addTo(“dataPoints”, {y: 29, label: “Apple” });

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.data[0].addTo("dataPoints", {y: 29, label: "Apple" });
Try it Yourself by Editing the Code below.

  Also See:    



In order to provide better support,we have closed the comments and switched completely to our Forums.
If you have any questions, please feel free to ask in our forums.