[reportlab-users] BarChart barLabelCallout ?
Robin Becker
reportlab-users@reportlab.com
Sun, 8 Dec 2002 10:45:19 +0000
In article <LKENLBBMDHMKBECHIAIACELICPAA.andy@reportlab.com>, Andy
Robinson <andy@reportlab.com> writes
>> Hi,
>>
>> I found a new attribute in BarChart:
>>
>> barLabelCallOut = AttrMapValue(None, desc='Callout
>> function(label)\nlabel._callOutInfo
>> =
>> (self,g,rowNo,colNo,x,y,width,height,x00,y00,x0,y0)'),
>>
>> Can anybody explain ?
>>
>
Actually I think this was used for another customer who needed
customisation. The idea is to have a chartwide function that
is passed the label just after it is created and added to the group, g.
The label has all the above info set on it in the _callOutInfo
attribute.
I think we already handle plus/minus position changing, and the
barchartlabel class knows how to change its anchors.
Pat Johnson's problem was how to change the way labels are displayed
when negative (ie red and absolute value in parentheses).
Ideally we should use some kind of oo to be able to do this kind of
thing. Properly thought out the class of the barlabels etc could be made
into another attribute, but it's not obvious whether the drawing part of
such a label belongs to the chart or the label itself.
>I think this was in response to Pat Johnson's enquiry
>that she wanted positive bars to be labelled e.g. '3.14'
>in black text, and negaive ones to be e.g. '(3.14)' in
>red text. Robin added a callback mechanism so you could
>write your own function which drew a label, and thereby
>permit radically different labels for positive and negative
>amounts. It is not beautiful, but it's hard to see a better
>way.
>
>- Andy
--
Robin Becker