|
Y-Axis AutoScale Abbreviation? |
Posted by Mike Cotrone on Dec-16-2015 23:53 |
|
Hello,
I am measuring bit rates on my Y-Axis. I have given the user the ability to change this
scale in the format of kbps, mpbs, and gbps.
I was wondering if there is a way to auto abbreviate output for example if the y-axis
autoscale currently has 20000 can we do an auto abbreviation to 20k by chance?
I am trying to limit the amount of space that auto-scale will eat moving left in my graph.
I have attached a screen shot of my graph to show.
Thank you in advance!
Mike
|
Re: Y-Axis AutoScale Abbreviation? |
Posted by Peter Kwan on Dec-17-2015 00:41 |
|
Hi Mike,
Yes. There are two approaches depending on which style you want:
(a) Use the best unit for a label. However, it means different labels can have different
units. For example, if the labels are:
0, 500, 1000, 1500, 2000
they may become:
0, 500, 1K, 1.5K, 2K
Note that some labels use "K", while some do not.
(b) Use the same unit for all labels. In this case, the above labels may be unchanged, or
become the followings, depending on when you would like to switch to the "K" unit:
0K, 0.5K, 1K, 1.5K, 2K
Some people may prefer to simply use:
0, 0.5, 1, 1,5. 2
and then in the Axis tile, they may have "in km" or "in thousands", etc..
For method (b) above, one way to do this is:
//use K as unit if the maximum value is 2000 or above
c.yAxis().setFormatCondition(">=", 2000);
c.yAxis().setLabelFormat("{={value}/1000}K");
Another example:
//use K as the unit if all labels are exact multiples of 1000
c.yAxis().setFormatCondition("align", 1000);
c.yAxis().setLabelFormat("{={value}/1000}K");
Hope this can help.
Regards
Peter Kwan |
Re: Y-Axis AutoScale Abbreviation? |
Posted by Mike Cotrone on Dec-17-2015 01:42 |
|
Thank you Peter! I will try it now and certainly report back.
Thank you again for your prompt reply! |
Re: Y-Axis AutoScale Abbreviation? |
Posted by Mike Cotrone on Dec-17-2015 23:40 |
|
Peter,
This is working great for me when I have a Y Axis autoscale for values of 10,000 and
above. What is happening for values underneath 10k is that I am not getting any Y-Axis at
all until it hits 10k+. I am sure I am missing some If logic? If not I can certainly perform
this w/ my coding language.
// SETUP Y-AXIS
Call c.yAxis.SetColors(-1)
Call c.yAxis.setAutoScale(30, 30, 0)
Call c.yAxis().setFormatCondition(">=", 10000)
Call c.yAxis().setLabelFormat("{={value}/1000}K")
Call c.yAxis.setLabelStyle("HelveticaNeueDeskInterface.ttc", 8*f)
Call c.yAxis.setOffset(-4,0)
Thank you
Mike |
Re: Y-Axis AutoScale Abbreviation? |
Posted by Peter Kwan on Dec-19-2015 02:51 |
|
Hi Mike,
Sorry, I forgot to add an "Else" condition to catch all other cases:
Call c.yAxis.SetColors(-1)
Call c.yAxis.setAutoScale(30, 30, 0)
Call c.yAxis.setLabelStyle("HelveticaNeueDeskInterface.ttc", 8*f)
Call c.yAxis.setOffset(-4,0)
Call c.yAxis().setFormatCondition(">=", 10000)
Call c.yAxis().setLabelFormat("{={value}/1000}K")
Call c.yAxis().setFormatCondition("Else")
Call c.yAxis().setLabelFormat("{value}")
Hope this can help.
Regards
Peter Kwan |
|