[reportlab-users] [patch] value labels for PieChart

Robin Becker robin at reportlab.com
Mon Sep 25 06:59:20 EDT 2006


Gael Chardon wrote:
> Hello,
> herefater a little patch that add a new feature to PieChart class.
> It optionally draw a value (typically the percent) on each slice.
> 
> The idea:
> - User sets percentFormat slice attribute to a string or a function ;
> - Optionally user can set percentFontName, percentFontSize, 
> percentFontColor.
> - If percentFormat is a string then it is used to format the percent 
> value (a float) that represent the slice.
> - If percentFormat is callable, the function is called  for every slice 
> with two arguments: the current slice value and the sum. The funcion 
> should returns the string to draw.
> 
> See sample4() in diff file
> 
> Hope it helps.
......

I'm less happy about this patch. We already have a lot of labelling on pie 
charts and nothing prevents the label text from being(or including) a 
percentage. If what you want is really just another label that's internal to the 
slice (and implicitly the ability to have both an external and internal label) 
then that's a more acceptable kind of patch. I don't think it acceptable to 
predetermine the textual value of the label ie I might want to internally mark 
the slices with the actual value (or a country flag etc etc) and perhaps have no 
external labels.

The labeling code is pretty disastrous already for which I apologize.

We probably need more general notions like annotate properties for each wedge to 
allow you to do this sort of thing.
-- 
Robin Becker


More information about the reportlab-users mailing list