[reportlab-users] Can we change the color of each bar in a vertical bar chart

Dinu Gherman reportlab-users@reportlab.com
Fri, 25 Apr 2003 18:30:29 +0200


saravanan annamalai:

> I tried to change the color of bars in my barchart...i tried
> the following
> =A0=A0=A0 bc.bars[1].fillColor =3D colors.red
> =A0=A0=A0 bc.bars.fillColor =3D colors.blue
> but its not getting effected....can anybody help...

That doesn't work, because the indices apply to bar "series" as a
whole. One-dimensional data means you have one series (with one
color) multi-dimentsional data means you have more than one series
and one different color per series. If you want individual bar col-
ouring within one series you need to hack your own Chart subclass,
possibly by overlaying multiple single barcharts with only one iso-
lated bar each, like I did in my Telco sample here:

   http://python.net/~gherman/tmp/TelcoInvoice.pdf

Fun, isn't it? ;-)

Dinu

--
Dinu C. Gherman
......................................................................
"When an elephant is in trouble even a frog will kick him."
(Hindu Proverb)