ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  X,Y axis big number problem
Posted by Serron on Jul-10-2012 19:54
Attachments:
Hi there,

I would like to know if there is any way that I can replace the numeric number with alpha
numeric.


For example,
1,000 --> 1K
1,000,000 --> 1M
1,000,000,000 --> 1B
1,000,000,000,000 --> 1T

thanks.
Y-value.png

  Re: X,Y axis big number problem
Posted by Peter Kwan on Jul-11-2012 02:16
Hi Serron,

You may refer to the following thread for some examples:

http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1267527586#N1267596777

Regards
Peter Kwan

  Re: X,Y axis big number problem
Posted by Serron on Jul-11-2012 20:12
Attachments:
Hi Peter,

thank you.
but I got a problem on the negative value.
the negative sign "-" is gone.
I do make sure the "string.Format" does pass the "-" to addLabel function.
Any suggestion?

my code:
double[] ticks = c.yAxis().getTicks();
if (ticks == null || ticks.Length == 0) { return false; }
for (int i = 0; i < ticks.Length; i++)
{
    double AbsTick = Math.Abs(ticks[i]);

    if (AbsTick == 0)
    {c.yAxis().addLabel(0, "0");}
    else if (AbsTick < 0.001)
    {c.yAxis().addLabel(ticks[i], string.Format("{0}μ", ticks[i] * 1000000));}
    else if (AbsTick < 1)
    {c.yAxis().addLabel(ticks[i], string.Format("{0}m", ticks[i] * 1000));}
    else if (AbsTick < 1000)
    {c.yAxis().addLabel(ticks[i], string.Format("{0}", ticks[i]));}
    else if (AbsTick < 1000000)
    {c.yAxis().addLabel(ticks[i], string.Format("{0}K", ticks[i] / 1000));}
    else if (AbsTick < 1000000000)
    {c.yAxis().addLabel(ticks[i], string.Format("{0}M", ticks[i] / 1000000));}
    else if (AbsTick < 1000000000000)
    {c.yAxis().addLabel(ticks[i], string.Format("{0}B", ticks[i] / 1000000000));}
    else
    {c.yAxis().addLabel(AbsTick, string.Format("{0}T", ticks[i] / 1000000000000));}
}
return true;
negative.png

  Re: X,Y axis big number problem
Posted by Peter Kwan on Jul-12-2012 05:04
Hi Serron,

In ChartDirector, if the first character of an axis label is "-", it is used to mean that the label is associated with a minor tick, and the "-" is not actually displayed. If you look at your labels carefully, you can see that the ticks for the negative labels are shorter.

For your case, you would need to prepend "\\\\" as the first character to display the negative sign. I suggest you change your code to:

    string myLabel;

    if (AbsTick == 0)
    {myLabel = "0";}
    else if (AbsTick < 0.001)
    {myLabel = string.Format("{0}μ", ticks[i] * 1000000);}
    else if (AbsTick < 1)
    {myLabel = string.Format("{0}m", ticks[i] * 1000);}
    .....

    if (myLabel[0] == '-')
        myLabel = "\\\\" + myLabel;
    c.yAxis().addLabel(ticks[i], myLabel);

Hope this can help.

Regards
Peter Kwan

  Re: X,Y axis big number problem
Posted by Serron on Jul-12-2012 08:24
Hi Peter,

Thank you very much.
Problem solved..