Sets the colorSet of the Chart. Color Set is an array of colors that are used to render data. 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.
Default: “colorset1” or as defined in the selected themeCanvasJS provides a way to add custom colorSet to the library. Color Sets added in this manner are global and they can be used by any chart in the page.
Syntax: CanvasJS.addColorSet(colorSetName, colorSetArray)
var chart = new CanvasJS.Chart("container", { . colorSet: "customColorSet1", . . }); chart.render();
Also See:
23 Comments
Pingback: CanvasJS Charts are out of Beta! - CanvasJS
With this service is there a way to specify the color of the lines connecting data markers on a line chart?
You can add the option color to the dataSet to force a colorfor a line
There are not many ‘Doughnut’ chart specific options in here.
I am trying to find a way to remove the white border it adds around each section?
Can I set a specific color to data point and not use the color set?
yes it is possible: https://canvasjs.com/docs/charts/chart-options/data/datapoints/color/
when i copy this code and execute it in offline,I’m not able to view any pie chart….
i think its because of that js file included in script…..
How can i get thet file and create a comlete pie chart offline….
Dhanveer,
You can download CanvasJS from here.
yes Tomer: var colors = [“#0066FF”, “#7385AA”, “#ACD373”, “#DF656A”];
dataPoints.push({label:report[i].description,y:report[i].mtd,color:colors[i]});
THNAKS THAT really worked
i cant able to use it along with jquery..
If there is jQuery library, the chart wont display. Please give a solution.
Thanks in advance…
Amar,
We have some examples here which are working fine with jQuery.
In case it is not working at your end, please re-create the issue using jsfiddle so that we can have a look.
I Want to change the colorSet Dynamically please direct here:
Problem: Im getting the JSON vlaue form a DB and i want to convert to array and render the chart.
like..
$rootScope.setupData.colorset; //JSON ARRAY VALUE “[#ffffff,#00000″]”
im trying to JSON.parse () and eval() i didn’t go.t
and i tried .
CanvasJS.addColorSet(“customColor”,//colorSet Array
$rootScope.setupData.colorset);
Please Soon send me right manner to represent the colorset..
Can this colorset work in line graph? I need a color when graph goes up and different color when graph goes down?
Thanks that helped
It is possible to put images or some illustrative image instead of background color
Mitzael Serna,
You can set image as background as shown in this example.
Can i set a gradient in colorset array?
how can i give my own colors.. instead of wt they gave… and one more thing i dont want to pass colors through json
for each slice i want to give seperate colors… is it possible ??
Naresh,
You can set color to set different colors to each dataPoint.
I am getting value of x axis in negative while odd no of coloumn is use like (3,5,7) no of bars
Viraj,
We are unable to create the issue, can you please create a jsfiddle, so that we can look into it and help you out.