[reportlab-users] color individual bars
Fri, 26 Jul 2002 23:08:38 +0200
I read thru the mail-archive of this month and found several article
about coloring bars. My intention is to color each bar with an
individual color. Context from the mail-archive was that it should be
possible, but I walked thru the examples and the barcharts.py while
I thing it won't work as expected.
lenData = len(self.data)
reversePlotOrder = self.reversePlotOrder
for rowNo in range(lenData):
if reversePlotOrder: rowNo = lenData-1 - rowNo
row = self._barPositions[rowNo]
styleCount = len(self.bars)
styleIdx = rowNo % styleCount
rowStyle = self.bars[styleIdx]
for colNo in range(len(row)):
barPos = row[colNo]
lenData is the count of data rows
rowNo is the current number of data row which is drawn
styleCount is the count of bars definition
If lenData is 1, and in the one row are the data it is impossible to
each bar with an individual color since styleIdx will always be 0 and
rowStyle will always be self.bars -> All bars will be the same color!
On the other way I found that each barLabel can be individual defined
since self.barLabels[(rowNo, colNo)] will be defined for each row and
I thing that something like bars[(rowNo, colNo)] should be implemented
in the BarChart or in a derived class, if really individual bar colors
should be useable.
Does anybody agree with this ?