|
@ in axis label format |
Posted by Naveen on Nov-01-2016 22:47 |
|
Hi Peter,
I think there is a bug in the axis labeling. I am trying to add prefixes to my labels (K,M,B,T) with the following code:
power = int(np.log(maxv)/np.log(1000))
prefix = PREFIXES.get(power)
label_format = "{={value}/%f|@,.}%s"%(np.power(1000,power),prefix)
However, in some cases the x.5 labels are incorrect ([using_at.png]). If i use the following format:
label_format = "{={value}/%f|1,.}%s"%(np.power(1000,power),prefix)
I see correct values in the labels ([using_one.png]).
|
Re: @ in axis label format |
Posted by Peter Kwan on Nov-02-2016 00:28 |
|
Hi Naveen,
If you use the @ as the number of decimal places, it will be replace by the number of decimal places determined by ChartDirector. This is determined before formatting.
For your case, before label formatting, the labels values are 2500, 2000, 1500, 1000, 500, 0. So the appropriate number of decimal place is 0. Therefore @ is equivalent to 0. So {={value}/%f|@,.} becomes {={value}/%f|0,.} and there is no decimal place.
I am not sure how you determine when to use "K" formatting. If it is possible for the labels to contain decimal values after dividing by 1000, you may need to configure the proper number of decimal place, or do not specific the decimal place at all to let ChartDirector display the value as is.
You may use Axis.setFormatCondition to verify if the label positions are all multiples of 1000 by checking if the "align" condition for 1000. For example, you can configure divide by 1000 with no decimal place if all label positions are multiples of 1000, otherwise use 1 decimal place.
http://www.advsofteng.com/doc/cdpython.htm#Axis.setFormatCondition.htm
Hope this can help.
Regards
Peter Kwan |
|