colorSet: String

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”
Options: “colorSet1”, “colorSet2”, “colorSet3”

Defining a custom Color Set:

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

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",

Try it Yourself by Editing the Code below.

  Also See:    

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