Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ColumnChart google visualization column color change

Does anyone know if I can hack google's visualization ColumnChart api chart somehow, to make a single column stand out with a different color, like so:

alt text

I know you can do it with ImageChart, so I don't need that (it fires no events and has no x/y labels).

Can I traverse the result with javascript somehow and change the CSS style, if it is truly rendered in SVG?

like image 293
Andriy Drozdyuk Avatar asked Nov 30 '22 18:11

Andriy Drozdyuk


2 Answers

A really cheap hack (that works quite well) is the following:

In the Options for your Chart, do: isStacked(true);

Now pass data in two separate series: one that's zero everywhere except at your off-colored bar, and one that's zero only at the off-colored bar. The "stacked" bars yield just the effect your posted in your screenshot.

like image 98
Bosh Avatar answered Dec 05 '22 07:12

Bosh


Well using jQuery I was able to get to my iframe for the graph. It's not pretty, but it works. It's also shorter than using prototype:

$('#google-chart iframe').contents().find("#chartArea g>g>rect")[2].attributes['5'].value = "#eea746";                                         

In the code above attributes['5'] refers to the "fill" attribute of the rect object.

like image 34
Andriy Drozdyuk Avatar answered Dec 05 '22 05:12

Andriy Drozdyuk