Menu

#9 adding title to ?ValueAxis

open
nobody
None
5
2003-07-30
2003-07-30
No

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

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.