[reportlab-users] setting title for ?ValueAxis
Berthold Höllmann
reportlab-users@reportlab.com
Wed, 30 Jul 2003 14:39:33 +0200
Hello,
The different *Axis class descriptions in the "Grapics Guide" name a
property "title" as not implemented. I've written "makeTitle"
functions that work with "xValueAxis" and "yValueAxis". "ValueAxis"s
"draw" method would need an additional line:
g.add(self.makeTitle())
"ValueAxis" would need three more three more "_attrMap" entries:
fontName = AttrMapValue(isString),
fontSize = AttrMapValue(isNumber),
title=AttrMapValue(isString, desc='Axis title')
and it's "__init__" method would need the additional lines:
self.fontName = STATE_DEFAULTS['fontName']
self.fontSize = STATE_DEFAULTS['fontSize']
self.title = ""
makeTitle for "xValueAxis":
def makeTitle(self):
lab = Label()
lab.boxAnchor = 'n'
lab.fontName = self.fontName
lab.fontSize = self.fontSize
lab.dx = (self.scale(self._valueMax) + self.scale(self._valueMin))/2.
lab.dy = -self.fontSize
lab.setText(self.title)
return lab
and for "yValueAxis":
def makeTitle(self):
lab = Label()
lab.boxAnchor = 's'
lab.fontName = self.fontName
lab.fontSize = self.fontSize
lab.dx = -self.fontSize
lab.dy = (self.scale(self._valueMax) + self.scale(self._valueMin))/2.
lab.setText(self.title)
lab.angle = 90
return lab
(also submitted to sourceforge patches)
Regards
Berthold
--
Dipl.-Ing. Berthold Höllmann __ Address:
hoel@GL-Group.com G / \ L Germanischer Lloyd
phone: +49-40-36149-7374 -+----+- Vorsetzen 32/35 P.O.Box 111606
fax : +49-40-36149-7320 \__/ D-20459 Hamburg D-20416 Hamburg