2013-07-29 89 views
3

我正在使用MSCharts,并且正在使用轴的日期,并且忍不住注意到轴标签对于最后一个网格线是隐藏的。下图显示了这一点。MSCharts最后一轴标签隐藏

Broken Chart Axis

,我使用这个代码是:

Public Function buildXAxis(ByVal chartArea As ChartArea, ByVal min As DateTime, ByVal max As DateTime) As Axis 
     Dim xAxis As New Axis(chartArea, AxisName.X) 'Chart Area is passed into the function 
     With xAxis 
      .Interval = 3 'This is the interval, so the next visible label should be 7/1/2013 
      .IntervalType = DateTimeIntervalType.Months 
      .IntervalAutoMode = IntervalAutoMode.FixedCount 
      .Maximum = max.ToOADate 'In this instance, it is 7/29/2013 
      .Minimum = min.ToOADate 'In this instance, it is 1/29/2013 
      .TitleAlignment = Drawing.StringAlignment.Center 
      .TitleForeColor = Drawing.Color.FromArgb(129, 127, 124) 
      .TextOrientation = TextOrientation.Auto 
      .LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep45 
      Dim xLabelStyle As New LabelStyle 
      xLabelStyle.TruncatedLabels = False 
      xLabelStyle.IsStaggered = False 
      xLabelStyle.Format = "d" 
      .LabelStyle = xLabelStyle 
      .MajorGrid.LineColor = Drawing.Color.FromArgb(129, 127, 124) 
      .MinorGrid.LineColor = Drawing.Color.FromArgb(129, 127, 124) 
      .MajorTickMark.LineColor = Drawing.Color.FromArgb(129, 127, 124) 
      .MinorTickMark.LineColor = Drawing.Color.FromArgb(129, 127, 124) 
     End With 
     Return xAxis 
    End Function 

有谁知道为什么这些标签是隐藏什么想法?根据代码,网格线位于正确的位置(每3个月),但轴标签根本不显示,而实际上这是修改此代码的唯一位置

回答

4

LabelStyle.IsEndLabelVisible控制是否第一个和最后一个标签被显示。

Here is the MSDN entry.

我猜测,在代码的某个地方,你没有张贴是沿着这些路线的东西:

Dim chartingArea As New ChartArea 
chartingArea.AxisX.LabelStyle.IsEndLabelVisible = False 

你要改变,要真正或完全是因为将其删除它默认为true。

+0

真棒,这真的很好,非常感谢这么多! –