[reportlab-users] Can we change the color of each bar in a vertical bar chart
Robin Becker
reportlab-users@reportlab.com
Fri, 25 Apr 2003 17:43:47 +0100
..
....
> 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
well for once Dinu has mis-remembered :)
you can actually use sequences as arguments to the bars thing.
eg
#Autogenerated by ReportLab guiedit do not edit
import reportlab
from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin
from reportlab.lib.colors import blue
from fidelity.epscharts.webbuttons import yellow
class Drawing_003(_DrawingEditorMixin,Drawing):
def __init__(self,width=400,height=200,*args,**kw):
apply(Drawing.__init__,(self,width,height)+args,kw)
self._add(self,reportlab.graphics.charts.barcharts.HorizontalBarChart(),name='chart',validate=None,desc=None)
self.chart.bars[(0,1)].fillColor = yellow
self.chart.bars[(0, 0)].fillColor = blue
if __name__=="__main__": #NORUNTESTS
Drawing_003().save(formats=['pdf'],outDir='.',fnRoot=None)
--
Robin Becker