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.13
I 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.
使用“ 0.00”作为格式字符串,“ ##。##”将在末尾去除零
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.