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

Robin Becker robin at reportlab.com
Mon Sep 25 10:44:37 EDT 2006


Gael Chardon wrote:
........
>> ......
>>
>> 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.
> 
> Ok, I understand your point of view.
> Let me explain my needs with my "real life" example.
> My application produces charts of "population" count per site, so I 
> generate a barchart where the count value for each site is drawn using 
> the BarChart.barLabelFormat, and the site name is drawn with the 
> BarChart.categoryAxis.labels.
> My idea was to reproduce this kind of chart with a PieChart, this way 
> PieChart.labels will be the site name and percentFormat (yes this not a 
> good name) will be used to draw the count value (percent and value).
> 
> Maybe an annotate or "inside label" properties is a better approach, but 
> I think it is pretty useful to provide the current value and sum to the 
> user formatting function.
.......

No problem. I think the reason we don't provide such useful information to these 
  labels is that the actual label values are assumed to be pre-computed (outside 
the chart). If you look at the other labelling stuff you'll see that we allow 
all sorts of things to be done to the labels in terms of ordering/positioning, 
but the text comes directly from an array parallel to the data. That may be a 
poor design for the labelling, but it's the one we've got :(

If you pass all the calculations into the individual labels then they may get it 
wrong. Consider how to properly display percentages to 1 decimal place eg

100 != 33.3 + 33.3 + 33.3

typically this is fixed at the outer level so even if all three values are equal 
we might actually display 33.3% 33.4% 33.3%.
-- 
Robin Becker


More information about the reportlab-users mailing list