I can't find examples to custom format YAxis Appearence...
I have YAxis to format from 0, 10, 20, 30.... to 0%, 10%, 20%, 30%... and the result of this
chart1.PlotArea.YAxis.Appearance.ValueFormat = style.ChartValueFormat.Percent;
is 0.000,00%, 10.000,00%, 20.000,00%, 30.000,00%...
In YAxis2 to format from 10, 20, 30... to 10.000, 20.000, 30.000... and I have 10000, 20000, 30000...
Need help, with priority on percentage!
Thanks,
15 Answers, 1 is accepted
Generally the chart is using the standard .NET format functionality and as elaborated in Standard Numeric Format Strings MSDN article:
The percent ("P") format specifier multiplies a number by 100 and converts it to a string that represents a percentage.
However you can utilize custom format as the following one:
chart.PlotArea.YAxis.Appearance.CustomFormat =
"#0%"
For more information check out Custom Numeric Format Strings MSDN article.Best wishes,
Peter
the Telerik team
Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!
It worked perfect. Now I have total control on Axis.
But now I got an issue.. When I use chart1.PlotArea.YAxis2.LabelStep = 2; some numbers of my YAxis2 goes to TopLeft of Chart...
Can you please see the example attached images?
Try setting the AutoLayout property of the chart to True, which should take care of such malformations.
Kind regards,
Steve
the Telerik team
Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!
It doesn't help. I can see the AutoLayout property is active because the size of PlotArea and XAxisLabel also change the margins, but the issue with the numbers on TopLeft still...
Another problem I have, also related with this topic is to concatenate a string to the YAxis.
I.E.:
I have 0 / 0,5 / 1 / 1,5 / 2 / 2,5 ... and so on. If I use CustomFormat I can use "#0K" or something similar "0.0K" ..., but I can´t get the same result for numbers..
Instead, the chart give me this: 0,0 / 0,5 / 1,0 / 1,5 / 2,0 / 2,5 ...
We were able to reproduce the problem locally and it is caused by LabelStep of the YAxis bigger than 1. To avoid the problem, set the LabelStep of the YAxis to 1. There is no workaround that we can offer at this time and the problem is forwarded to our chart developers for fixing.
Sorry for the temporary inconvenience.
Regards,
Steve
the Telerik team
Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!
Just a quick follow up - if you set AutoScale=false and set the step manually, this problem should not occur.
Kind regards,
Steve
the Telerik team
Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!
Reporting to my attached image, if i pass the YAxis2 label to Millions with this code:
"
chart1.PlotArea.YAxis2.AutoScale = false;
chart1.PlotArea.YAxis2.MinValue = 0;
chart1.PlotArea.YAxis2.MaxValue = 3000000;
chart1.PlotArea.YAxis2.LabelStep = 1000000;
chart1.PlotArea.YAxis2.Appearance.CustomFormat = "#0M";
...
in the binding section i divide the value for desired scale (K, M...)
"
Makes report running without stop... Without this it runs in 5 secs.
Many thanks.
The problem should be in the properties you set. chart1.PlotArea.YAxis2.LabelStep = 1000000; the LabelStep sets how many ticks the label should be put on, there is another property Step, which is what you are looking for. Try setting the properties the following way:
chart1.PlotArea.YAxis2.LabelStep = 1;
chart1.PlotArea.YAxis2.Step = 1000000;
Elian
the Telerik team
Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!
Thank you.
How can I do this?
chart1.PlotArea.YAxis2.Appearance.CustomFormat = "F1 K"; (the result is always "F1 K")
but chart1.PlotArea.YAxis2.Appearance.CustomFormat = "#0 K"; (the result is the zero decimal points + K - "1 K", "1 K", "2 K", "2 K"....
I need to use the 1st format F1 ("1.0 K", "1.5 K", "2.0 K", "2.5 K") but how can I concatenate the "K" to the result??
That is not possible using the standard formats ("F", "D" ... ) However "F" == "0#.0" - which is the corresponding custom format giving a number with 1 digit after the decimal separator. So in your case "0#.0K" should give you the result you want.
All the best,Elian
the Telerik team
Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!
And can I get the max value of Yaxis2 after chart is loaded? and depending on this max, divide all serie per 1000 or 1000000 depending of case?