Sets the colorSet of StockChart. Color Set is an array of colors that are used to set the color of individual dataSeries in a sequence. Various predefined Color Sets are bundled along with the library. You can either choose from the pre-defined Color Sets or define your own Color Set as shown in this tutorial.
Default: “colorset1”CanvasJS provides a way to add custom colorSet to the library. Color Sets added in this manner are globally available and can be used by any dataSeries in the StockChart.
Syntax: CanvasJS.addColorSet(colorSetName, colorSetArray)
CanvasJS.addColorSet("customColorSet1", [//colorSet Array "#4661EE", "#EC5657", "#1BCDD1", "#8FAABB", "#B08BEB", "#3EA0DD", "#F5A52A", "#23BFAA", "#FAA586", "#EB8CC6", ]);
Once a Color Set is added, you can refer it by its name – similar to pre-defined ones. Below is the syntax showing how to refer it.
var stockChart = new CanvasJS.StockChart("container", { . . colorSet: "customColorSet1", . }); stockChart.render();
Also See: