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 stripLine to stripLines 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.axisX[0].addTo(“stripLines”, { value:50 }, 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.axisX[0].addTo("stripLines", {value: 30}, 2);
Try Editing The Code

  Also See:    


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