I am using this function to create a bar chart using Reportlab
def make_drawing():
from reportlab.lib import colors
from reportlab.graphics.shapes import Drawing
from reportlab.graphics.charts.barcharts import HorizontalBarChart
drawing = Drawing(400, 200)
data = [
(13, 5, 20, 22, 37, 98, 19, 4),
]
names = ["Cat %s" % i for i in xrange(1, len(data[0])+1)]
bc = HorizontalBarChart()
bc.x = 20
bc.y = 50
bc.height = 200
bc.width = 400
bc.data = data
bc.strokeColor = colors.white
bc.valueAxis.valueMin = 0
bc.valueAxis.valueMax = 100
bc.valueAxis.valueStep = 10
bc.categoryAxis.labels.boxAnchor = 'ne'
bc.categoryAxis.labels.dx = -10
bc.categoryAxis.labels.fontName = 'Helvetica'
bc.categoryAxis.categoryNames = names
drawing.add(bc)
return drawing
By default the bar chart color is set to red
I add these two lines after setting bc.categoryAxis.categoryNames
bc.bars[0].fillColor = colors.blue
bc.bars[1].fillColor = colors.red
In the hope to set the first bar to color blue. However all the bars are now in color blue.