开发者

MS Chart C# - Why the Chart don't show the first Monthname?

I have a Ms Chart on a simple Form and the follow Testcode:

ChartArea myAreachar开发者_C百科t2 = new ChartArea();
myAreachart2.AxisX.IntervalType = DateTimeIntervalType.Months;
myAreachart2.AxisX.Minimum = new DateTime(2011, 1, 1).ToOADate();
myAreachart2.AxisX.Maximum = new DateTime(2011, 12, 31).ToOADate();
myAreachart2.AxisX.IsLabelAutoFit = false;
myAreachart2.AxisX.LabelStyle.IsEndLabelVisible = false;
myAreachart2.AxisX.LabelStyle.Format = "MMMM";
chart2.ChartAreas.Add(myAreachart2);

chart2.Series.Add("Default");
chart2.Series[0].XValueType = ChartValueType.DateTime
chart2.Series[0].BorderWidth = 4;
chart2.Series[0].Color = Color.Black;

chart2.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

chart2.Series[0].Points.AddXY(new DateTime(2011, 1, 1), 100);
chart2.Series[0].Points.AddXY(new DateTime(2011, 2, 1), 200);
chart2.Series[0].Points.AddXY(new DateTime(2011, 3, 1), 300);
chart2.Series[0].Points.AddXY(new DateTime(2011, 4, 1), 400);
chart2.Series[0].Points.AddXY(new DateTime(2011, 5, 1), 500);

The result is a Chart with the Values and on the x-Axis are the monthnames as Labels. But not on january. The monthname will not be displayed. (There ist nothing.)

Please help me ? :-) I seach a lot of websites an examples, but i can't find any solution.

Thank you very much.


Might be because you set:

myAreachart2.AxisX.LabelStyle.IsEndLabelVisible = false;

From MSDN:

LabelStyle.IsEndLabelVisible Property
Gets or sets a flag that determines whether the labels are shown at axis ends.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜