[reportlab-users] HorizontalBarChart(), align, categoryAxis.categoryNames
Robin Becker
robin at reportlab.com
Tue Nov 26 05:16:55 EST 2013
Hi Helga,
you can try something like this
> from reportlab.graphics.charts.barcharts import HorizontalBarChart
> from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin
>
> class Drawing_000(_DrawingEditorMixin,Drawing):
> def __init__(self,width=400,height=200,*args,**kw):
> Drawing.__init__(self,width,height,*args,**kw)
> self._add(self,HorizontalBarChart(),name='chart',validate=None,desc=None)
> self.chart.y = 20
> self.chart.x = 100
> self.chart.width = self.width -self.chart.x -10
> self.chart.height = self.height -self.chart.y -10
> self.chart.categoryAxis.style='stacked'
> self.chart.categoryAxis.categoryNames = 'AAAA','BBBBBBBBBBB','CC','DDDDDDDDDDDDDDD'
> self.chart.categoryAxis.labels.fontName = 'Helvetica'
> self.chart.categoryAxis.labels.fontSize = 6
> self.chart.categoryAxis.labels.boxTarget='lo'
> self.chart.categoryAxis.labels.boxAnchor='w'
> self.chart.categoryAxis.labels.dx = -90
>
> if __name__=="__main__": #NORUNTESTS
> Drawing_000().save(formats=['pdf'],outDir='.',fnRoot=None)
effectively we turn the boxAnchor the wrong way and then adjust the anchor
position with the generic label dx
On 26/11/2013 09:47, Helga Peters wrote:
> Hello,
>
> I am working on a stacked HorizontalBarChart and was wondering whether it
> is possible to align the categoryAxis.categoryNames to the left, lets say
> against the red line in example below ?
>
> [image: Inline afbeelding 1]
> Thanks in advance,
--
Robin Becker
More information about the reportlab-users
mailing list