I have Google visualization where I want to set the specific colors of each pie slice/bar based on a column in the datatable.
i.e. I have a table of the number of people who voted for their favorite color:
*Input table*
id Color Num Votes
1 'Red' 10
2 'Blue' 100
3 'Green' 50
How do I set the colors on the pie chart so that the slice for 'Red' is colored red, etc? However, due to the data set, I cannot guarantee that the rows will be in a certain order so cannot create an array of colors.
I think I need to use a formatter, but cannot get it to work.
var formatter = new google.visualization.ColorFormat();
formatter.addRange('Blue', 'Blue', 'blue', 'blue');
formatter.format(data, 1);
Thanks in advance