This is a migrated thread and some comments may be shown as answers.

Issue with formatting with CustomFormat property in Chart

3 Answers 80 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael Kniskern
Top achievements
Rank 1
Michael Kniskern asked on 28 Dec 2012, 02:01 AM
I am trying to format the YAxis and YAxis2 scale as a percentage on a Stacked Bar 100 chart object and it is not working as expected.  I am applying the Office 2007 skin to the chart and trying to set the custom formatting after the InitializeComponent method.

Here is my source code:

this.compareCityAvgReport.PlotArea.YAxis.AutoScale = false;
this.compareCityAvgReport.PlotArea.YAxis.LabelStep = 1;
this.compareCityAvgReport.PlotArea.YAxis.AddRange(0, 100, 10);
this.compareCityAvgReport.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Reporting.Charting.Styles.ChartValueFormat.Percent;
this.compareCityAvgReport.PlotArea.YAxis.Appearance.CustomFormat = "#%";
 
this.compareCityAvgReport.PlotArea.YAxis2.Visible = Telerik.Reporting.Charting.Styles.ChartAxisVisibility.True;
this.compareCityAvgReport.PlotArea.YAxis2.AutoScale = false;
this.compareCityAvgReport.PlotArea.YAxis2.AddRange(0, 100, 10);
this.compareCityAvgReport.PlotArea.YAxis2.Appearance.Color = System.Drawing.Color.Black;
this.compareCityAvgReport.PlotArea.YAxis2.Appearance.ValueFormat = Telerik.Reporting.Charting.Styles.ChartValueFormat.Percent;
this.compareCityAvgReport.PlotArea.YAxis2.Appearance.CustomFormat = "#%";

I aslo want to get rid on the 2.5 increment marker and just have the 10 increment maker in the report.  I have marked up the image attached to this post with what I want to accomplish.

3 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 01 Jan 2013, 01:56 PM
Hello Michael,

Since you need percentage (0-100), there is no need to use the AddRange method. Please consider the following approach:
this.chart1.PlotArea.YAxis.AutoScale = false;
this.chart1.PlotArea.YAxis.MinValue = 0;
this.chart1.PlotArea.YAxis.MaxValue = 100;
this.chart1.PlotArea.YAxis.LabelStep = 10; //or whatever step you wish
this.chart1.PlotArea.YAxis.Appearance.CustomFormat = "#\\%"; //format string - escaping the %, since we do not want our numbers to be multiplied by 100 again, as they are in the 0-100 range already.

The minor ticks can be made invisible:
this.chart1.PlotArea.YAxis.Appearance.MinorTick.Visible = false;

 
All the best,
Elian
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Michael Kniskern
Top achievements
Rank 1
answered on 02 Jan 2013, 06:03 PM
The code you provided in your last reply worked for the YAxis2 of my chart, but it does not work for the YAxis.  Please reference image attached to this thread post.
0
Elian
Telerik team
answered on 04 Jan 2013, 08:33 AM
Hi Michael,

Copying the code provided in the last post and simply replacing YAxis with YAxis2 should do the trick. On our sides both axes get values 0-100% with step 10% and look correctly.
Please make sure that everything is set up correctly and if the problem persists, please open a support thread and attach a sample runnable project so we can review it and advise you accordingly. 
 
All the best,
Elian
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
Michael Kniskern
Top achievements
Rank 1
Answers by
Elian
Telerik team
Michael Kniskern
Top achievements
Rank 1
Share this question
or