|
Axis labels using a callback |
Posted by Ian P. Christian on Mar-05-2007 10:51 |
|
I want to format a axis in imperial weight measurements, so rather then showing 123lbs, it should show 8st 12lbs (I know they aren't equal, I'm too lazy to do the math).
The only way I can think of doing this is via a callback, however I imagine for technical reasons, this might not be possible - is it? |
Re: Axis labels using a callback |
Posted by Peter Kwan on Mar-05-2007 12:50 |
|
Hi Ian,
You may use something like (in VB/VBScript):
Call c.yAxis().setLabelFormat("{=({value}-{value}%14)/14|0}st {={value}%14}lbs")
Hope this can help.
Regards
Peter Kwan |
Re: Axis labels using a callback |
Posted by Ian P. Christian on Mar-05-2007 12:58 |
|
ah of course, putting the maths in the label, didn't think of that, Thanks a lot!
Whilst I'm here though... assuming I couldn't do this for some reason (assume it's not just basic maths going into the label formatting) , is it possible to set a callback? |
Re: Axis labels using a callback |
Posted by Peter Kwan on Mar-05-2007 13:24 |
|
Hi Ian,
The details depend on why there are labels on the axis in the first place.
If the axis scale (and hence the labels) are provided by your code, you can always set them to whatever you like (eg. using Axis.setLinearScale2).
If the axis scale and labels are automatically determined by ChartDirector using auto-scaling, then after add all data sets, you may call BaseChart.layout to auto-scale the axis, then call "Axis.getTicks" to determine the label positions chosen by ChartDirector, then use Axis.addLabel to set an alternative label (which can be whatever you like, so you can format them anyway you like) to those positions.
Hope this can help.
Regards
Peter Kwan |
|