我正在reportlab中创建一个图表。我将容器图纸的宽度设置为400,图表的宽度设置为350。但是,当图表实际绘制标签或图例时,它们是否超出了图纸的范围?
无论如何,如果我将图表宽度设置为350,是否可以确保图表实际上保持在350范围内?
def hor_bar_chart(self, catNames, data, maxTick):
drawing = Drawing(400, 200)
bc = HorizontalBarChart()
bc.x = 120
bc.y = 50
bc.height = 125
bc.width = 350
bc.data = data
bc.categoryAxis.labels.fontName = self.font_name
bc.categoryAxis.labels.fontSize = 8
bc.categoryAxis.categoryNames = catNames
bc.categoryAxis.labels.boxAnchor = 'e'
bc.categoryAxis.tickLeft = 2
bc.valueAxis.labels.fontName = self.font_name
bc.valueAxis.valueMin = 0
bc.valueAxis.valueMax = maxTick + (maxTick * 0.1)
bc.strokeColor = colors.black
drawing.add(bc)
for i in range(len(data)):
bc.bars[i].fillColor = self.COLOR_DARK_BLUE
bc.bars[i].strokeColor = self.COLOR_DARK_BLUE
return drawing