5 Answers, 1 is accepted
Do all objects for a group have the same color? If yes, then you could group the data and use the series Color method to set the color for the series based on the value in an object from the group. I attached a small sample project that shows this approach.Regards,
Yes, all objects of a group have the same color.
I'm getting the data for the chart by calling the action using the DataSource option. So the code for my chart looks something like the following:
The view model has a field Color. How do I use that in the code to set the series color?
There isn't a way to use the dataSource to pass the data and specify the color for each group. You should either bind the data on the server as demonstrated in the attached project or load the data via Ajax and then set the series to the chart options.Regards,
And my json is:
Hope it helps
A truly life saver! :D I had this very same problem and I was getting mad not being able to solve it. Your solution worked great and it is very interesting because:
1 - colorField is not officially suported for line charts but it works with your solution though
2 -groupColor is not in the official docs :O