Re: HorizontalBarChart(), align, categoryAxis.categoryNames

Robin Becker <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.