[reportlab-users] Piechart labels

Robin Becker robin at reportlab.com
Wed Oct 10 12:17:47 EDT 2007


Simon Riek wrote:

> I am experimenting with pie-charts also atm and tried to work with

> pointers but when I set the pointerLabelMode to not None, I get very weird

> results. The piechart is deformed and the labels are drawn all over the

> place with no obvious rules for placement (doesn't matter if simpleLabels

> or not, nor does checkLabelOverlap seem to matter). Does anyone have a

> working example for pointers?

>

> Thanks in advance

>

> Simon

......
not ideal, but working; this stuff was a nightmare and still doesn't work all
that well.

######################
from reportlab.graphics.charts.piecharts import Pie
from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin

class Drawing_001(_DrawingEditorMixin,Drawing):
def __init__(self,width=400,height=200,*args,**kw):
apply(Drawing.__init__,(self,width,height)+args,kw)
self._add(self,Pie(),name='pie',validate=None,desc=None)
self.pie.pointerLabelMode='LeftRight'
self.pie.labels = ['a','b','c','d']
self.pie.sameRadii = True
self.pie.pointerLabelMode='LeftAndRight'
self.pie.slices.labelRadius = 1.2
self.pie.labels = ['a', 'b', 'c', 'deee']
self.pie.simpleLabels = 0
self.pie.slices.label_pointer_elbowLength = 5
self.pie.slices.label_pointer_edgePad = 5
self.pie.slices.label_pointer_piePad = 4
self.pie.slices.label_textAnchor='boxauto'
self.pie.width = 200
self.pie.height = 200
self.pie.pointerLabelMode='LeftRight'

if __name__=="__main__": #NORUNTESTS
Drawing_001().save(formats=['pdf'],outDir='.',fnRoot=None)
######################
--
Robin Becker


More information about the reportlab-users mailing list