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

Adds a new element of given type to the specified array. For example, it can be used to add a new Chart to “charts” Array.

        propertyName: Name of the property
        options: Option for the new element
        index: Index of the array where the new element has to be added. Defaults to the length of array.
        updateStockChart: When true, updates the StockChart after setting the value. Default value is true.

Example: stockChart.addTo(“subtitles”, { text: “StockChart Sub Titles” });

  • StockChart should be rendered before you can use addTo method.
  • StockChart re-renders automatically after addTo method. It is recommended to disable the auto update by setting updateStockChart to false till the last step if you have multiple properties. Otherwise the performance might be affected because of rendering StockChart repeatedly.

var stockChart = new CanvasJS.StockChart("container",
 subtitles: []

stockChart.addTo("subtitles", { text: "StockChart Subtitles"});

Try it Yourself by Editing the Code below.

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