|
Customazable labes alon Y axis |
Posted by Sai on Nov-16-2012 18:06 |
|
To customixe label alon Y axis I have tried following code in drawchart function
c->yAxis()->setFormatCondition(">", 1000*1000);
c->yAxis()->setLabelFormat("{={value}/1000000}M");
c->yAxis()->setFormatCondition(">", 1000);
c->yAxis()->setLabelFormat("{={value}/1000}K");
c->yAxis()->setFormatCondition("else");
c->yAxis()->setLabelFormat("{={value}}");
but these conditions consider the range
For e.g.
if my range is 0 to 2000
it gives output 0,0.2K,0.4K...,1K,..1.5K,...2K
But my expected output is 0,200,400,600,...1K,...1.5K,...2K
even I tried following code but in drawchart function but this code adds the label at bottom only
////Customize Label
c->layout();
DoubleArray ticks = c->yAxis()->getTicks();
for (int i = 0; i < ticks.len; i++)
{
double AbsTick = ticks[i];
CString szLable;
if (AbsTick < 1000)
{
szLable.Format("%d",AbsTick);
c->yAxis()->addLabel(0, szLable);
szLabelArr.push_back(szLable);
}
else if (AbsTick < (1000*1000))
{
szLable.Format("%0.1fK",AbsTick/1000.0);
c->yAxis()->addLabel(0, szLable);
szLabelArr.push_back(szLable);
}
else /*if (AbsTick < (1000*1000))*/
{
szLable.Format("%0.1fM",AbsTick/1000000.0);
c->yAxis()->addLabel(0, szLable);
szLabelArr.push_back(szLable);
}
}
//Customize Label
So please help me to add customize label at Y axis
Regards,
Sai |
Re: Customazable labes alon Y axis |
Posted by Peter Kwan on Nov-17-2012 00:56 |
|
Hi Sai,
The setFormatCondition sets the formats for all labels on the axis. If the format chosen is "{={value}/1000}K", then it will apply this format to all labels.
If you want to use different formats for different labels, you would need to use custom formatting. Your existing custom formatting code does not work because of the following line, which adds the label at y= 0 only.
c->yAxis()->addLabel(0, szLable);
It should be:
//Add the label at the position of the tick
c->yAxis()->addLabel(AbsTick, szLable);
Hope this can help.
Regards
Peter Kwan |
|