ChartValueFormat.percent do not work

Thread is closed for posting
4 posts, 0 answers
  1. Paulo
    Paulo avatar
    56 posts
    Member since:
    Apr 2012

    Posted 27 Apr 2012 Link to this post

    I need to format YAxis with percent format. If I put a percent format and addRange, don't work my graph. Below a example:

    radChart.PlotArea.YAxis.AutoScale = false;
    radChart
    .PlotArea.YAxis.AddRange(1,100,1);
    radChart
    .PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.Percent;
    radChart
    .PlotArea.YAxis.Appearance.CustomFormat = "#.###";

    If I remove the lines below, the scale start 0 and end 10.000,00 with step of 1.000,00. 

    radChart.PlotArea.YAxis.AutoScale = false;
     radChart.PlotArea.YAxis.Appearance.CustomFormat = "#.###"; 
    radChart.PlotArea.YAxis.AddRange(1,100,1);  


    How do I do to work with AddRange()  and percent(I need to show percent simbol(%) in YAxis with my range values). 

    Thanks.



  2. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 02 May 2012 Link to this post

    Hi Paulo,

    You should set the ValueFormat and CustomFormat before turning the AutoScale proeprty of the axis to false:

    RadChart1.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.Percent;
    RadChart1.PlotArea.YAxis.Appearance.CustomFormat = "#.###";
    RadChart1.PlotArea.YAxis.AutoScale = false;
    RadChart1.PlotArea.YAxis.AddRange(0, 50, 3);
    RadChart1.AutoLayout = true;

    Additionally you may need to set the AutoLayout property of the chart to true as it will automatically arrange the chart elements so that there is enough space for the axis labels to be fully readable:

    RadChart1.AutoLayout = true;

    Kind regards,
    Evgenia
    the Telerik team

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Paulo
    Paulo avatar
    56 posts
    Member since:
    Apr 2012

    Posted 08 May 2012 Link to this post

    Ok, Evgenia, but I have:

    RadChart1.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.Percent;

    RadChart1.PlotArea.YAxis.Appearance.CustomFormat = "#.###";

    RadChart1.PlotArea.YAxis.AutoScale = false;

    RadChart1.PlotArea.YAxis.AddRange(930, 1000, 10);

    RadChart1.AutoLayout = true;

    YAxis scale is:
    930.000,00% 100.000,00% and not 930,00% - 1000,00%

    How can I do to remove from Yaxis(*1000)?

  5. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 11 May 2012 Link to this post

    Hello Paulo,

     This unwanted behavior is caused by the fact that the Percent ValueFormat acts as if you have used a "P" standard numeric format string. It multiles the number by 100 and adds a percent symbol at the end.
    Instead I suggest that you use our CustomFormat property only with the following custom format string:

    RadChart1.PlotArea.YAxis.Appearance.CustomFormat = "#,###\\%";

    This way you format the numbers as you like and the % symbol is escaped.

    Kind regards,
    Evgenia
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top