Ive got a MS Chart control and it works just fine except that I can't figure out how to "format" the Y-Axis. I am adding a lot of double numbers into a Serie but when the double numb are actually whole numbers (20.000000.....) the Y-Axis on my chart shows 20.
example: this serie :
12.32 11.00 10.13 would actually show up like this: 12.32 11 10.13I have tried formatting the data as I insert it into the serie like this:
serie.Points.AddXY(date.ToString(),double[i].ToString("##.##"));
but that doesn't seem to work.
I've tried to search for a place to format it in Chart开发者_开发知识库.Series[0].* and Chart.ChartAreas[0].* but I didn't find it there.
Use "0.00" as format string, "##.##" will strip zeros at the end
serie.Points.AddXY(date.ToString(),double[i].ToString("0.00"));
I know this might come too late, but here's my advice.
You can find out more about numeric format for strings, here and here.
I think you need fixed point ("F") format specifier used like this:
chart1.ChartAreas["Default"].AxisY.LabelStyle.Format = "F2";
Also you should add numbers to your data points' Y values, not strings. Hope that helps.
精彩评论