Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net DataVisualization.Charting Formatting values on Y-Axis

Does anybody know how to format and control the values shown on the Y-Axis of a .Net 4 DataVisualization.Charting chart?

I have values on the Y-Axis and dates on the X-Axis. The values on the Y-Axis are showing multiple decimal points and I want to apply a custom formatter to them so that I can show them in any format I want. So for example I can show 1+3/4 instead of 1.75.

I am doing all of the chart generation in code using a Chart object from the System.Web.UI.DataVisualization.Charting namespace.

like image 210
Guy Avatar asked Aug 21 '10 06:08

Guy


2 Answers

You have to set the Format property of LabelStyle in the respective axis.

In your case, like below.

ChartArea.AxisY.LabelStyle.Format = "{0.00}";

Please refer the links below for further details.

(Refer the answer by Kishore)
http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/8f843a18-c72e-4cc1-9fcc-7ad0d9e39c15#5fcef069-7ea7-4d73-9611-90bf9e14ede3

HTH

like image 163
Prince Ashitaka Avatar answered Sep 20 '22 14:09

Prince Ashitaka


I found the answer, there's a Customize delegate that can be setup which is called after all data members have been calculated and before the chart is rendered. If you attach your delegate to the Chart's Customize event you'll be able to do all the customization you want in there.

this.Chart1.Customize +=new EventHandler(this.Chart1_Customize); 
like image 32
Guy Avatar answered Sep 22 '22 14:09

Guy