javascript - Target specific google chart data set -
say if google chart data array looks below, there way target specific data set google charts , something. if data = "13 dec 11 tue" point of 56 should use different color rest...
["13 dec 11 tue",56], ["14 dec 11 wed",168], ["15 dec 11 thu",181], ["16 dec 11 fri",163], ["17 dec 11 sat",172] ...
yes, possible, requires coding in javascript , cannot done innately within google visualization save within tables using colorformatter. assuming want in chart, need write code it.
option 1: create array of colors
you can use series
configuration option of charts set color of how each series displayed.
for instance, if have 3 series, can set following option turn second 1 red:
series: [{}, {color: 'red'}, {}]
this set no options series 1 , 3, change color of series 2 red.
so can loop through data javascript, , create array of colors assign various series. instance, if want value in column 1 higher 10 red, follows:
var colorarray = {}; for(i=0;i<data.getnumberofrows;i++) { if(data.getdatavalue(i, 1)>10) colorarray.push({color: 'red'}); else colorarray.push({}); };
then set options as:
options = {series = colorarray};
note: above code has not been checked, has errors since typed out. if doesn't work, correct code, logic appropriate.
option 2: move series
by default, each different column of data have different color. can create similar loop checks value of each item, , moves series. create different loop goes through values want check, , if finds you're looking for, move value in new series.
this more complex, give more flexibility depending on want (since have entirely different series, can customize different line size, or markers, or bar width, or whatever).
whatever pick do, best thing play , find , that's easiest code data.
Comments
Post a Comment