解决 MsChart 设置 X轴间距和网格匹配

 DateTime dt = DateTime.Now;

//设置量程            

chartLine.ChartAreas[0].AxisX.Minimum = dt.ToOADate();            

chartLine.ChartAreas[0].AxisX.Maximum = dt.AddMonths(1).ToOADate();

//设置间隔类型           

 chartLine.ChartAreas[0].AxisX.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Days;            

chartLine.ChartAreas[0].AxisX.Interval = 4;

//设置时间格式            

chartLine.ChartAreas[0].AxisX.LabelStyle.Format = "yyyy-MM-dd";            

chartLine.ChartAreas[0].AxisX.MajorGrid.Interval = 4;

//设置网格间距类型            

chartLine.ChartAreas[0].AxisX.MajorGrid.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Days;            

chartLine.ChartAreas[0].AxisX.MajorGrid.Enabled = true;

 

若设置与实际设置效果不匹配

请查看是否有下面这句话

chartArea1.AxisX.LabelStyle.Interval =

删除即可

posted @ 2014-09-03 16:04  释迦苦僧  阅读(1761)  评论(0编辑  收藏  举报