jquery - Google Charts Custom Color Binding -
is possible bind data specific colors in google charting api...
suppose have 2 pie-charts in fiddle.. want bind data specific colors -
eg - eat should red, sleep should green in charts...
and if specific item not appear in particular chart color corresponding missing value should not appear in chart...
i have tried
slices: [{color: 'black', {}, {}, {color: 'red'}] as as
slices: {0: {color: 'black'}, 3: {color: 'red'}} but not able handle missing values....
setup array of colors want use each category. can fill in array of colors use current pie chart being drawn based on in pie chart, looping through each item , adding correlated color. set in jsfiddle. used generic colors, can use hex colors want. did not account situations category not have associated color, need check if issue.
colors = {'work':'blue', 'eat':'red', 'commute':'yellow', 'watch tv':'green', 'sleep':'purple',}; function colorsarray(data){ var array = []; (var i=0;i<data.length;i++){ array.push(colors[data[i]['c'][0]['v']]); } console.log(array) return array } you can check out fiddle here: http://jsfiddle.net/qquse/130/
Comments
Post a Comment