Thanks for the assistance, I did find a solution and the page about
Colors was insightful.
I should have used a different word than 'gradient'. I created the
effect on individual bars instead of BG color.
The individual bars are solid colors, and the 'gradient' effect is
spread across bars based on the y-value (height):
___
| | ___
| | | | ___
| | | | | | ___
| | | | | | | |
yellow orange red dark red
>From the colors page, I was trying to get around this:
--"In the following chart, the third data set, Bar, is drawn in
the first color. If only one color is specified, all data sets use
that color."
-- http://code.google.com/apis/chart/colors.html#chart_colors
So I added a dataset for each color of bar:
for (int k=0; k<intensityHexColors.length; k++){
double n1 = k * MAX_VALUE/intensityHexColors.length;
double n2 = (k + 1) * MAX_VALUE/intensityHexColors.length - .001;
NumberFormat nf = NumberFormat.getFormat("#.##");
data.addColumn(ColumnType.NUMBER, nf.format(n1) + " - " +
nf.format(n2));
}
Then when I add data, I add it top the appropriate dataset, based on
the y-value:
int intensityIdx = getIntensityHexIndex(val);
data.setValue(month, intensityIdx, val);
And this part is important for display - I changed the chart to
stacked, so zero values are invisible.
options.setStacked(true);
Otherwise the zero y-values will still take up width, and make the
other bars too skinny.
Good luck to anyone else trying to achieve the same result and feel
free to add further solutions.
On Jan 2, 6:17 am, "m.zielke" <[email protected]> wrote:
> Just found this hint in the Google-Chart
> documentationhttp://code.google.com/apis/chart/colors.html#linear_gradientthat
> should do the trick nicely
>
> On Jan 2, 8:14 am, pasqual <[email protected]> wrote:
>
> > I am wondering if there is a way to color bars by value, preferably
> > using gradient logic. I am using GWT so I would prefer something
> > compatible (unfortunately no Image Bar Chart yet)
>
> > What I have so far renders all of the bars red like the sample.
> > I would like to color them varying shades based on their values
> > (Similar to TableColorFormat.addRange()).
>
> > Any insight is appreciated.
>
> > Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en
-~----------~----~----~----~------~----~------~--~---