[reportlab-users] Set verticalbarchart label x, y positions depending on value

Matt Bartolome mattxbart at gmail.com
Fri Aug 17 19:14:37 EDT 2018


Hi, I have a stacked vertical bar chart where I need to either manually
place labels or iterate over the existing labels and move them based on
their position (crossing my fingers that there is a simpler way). The
problem I have is that my stacked bar chart has overlapping labels when the
y values are close to zero because of the scale of my chart.

My barLabels settings are like so:

self.chart.barLabelFormat = lambda x: '${0}'.format(x) if x > 0 else None
self.chart.barLabels.boxAnchor = 'w'
self.chart.barLabels.boxFillColor = None
self.chart.barLabels.boxStrokeColor = None
self.chart.barLabels.fontName = fontName
self.chart.barLabels.fontSize = 6
self.chart.barLabels.dy = 5
self.chart.barLabels.dx = -8
self.chart.barLabels.boxTarget = 'mid'

I was hoping there was a setting to avoid overlap, but if that doesn't
exist I would like to loop over the x,y positions of the existing labels
and create my own simple labels to replace them but I can't figure out how
to do that.

Thanks,
Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20180817/a5fbc0a1/attachment.html>


More information about the reportlab-users mailing list