3
我正在使用MSCharts,並且正在使用軸的日期,並且忍不住注意到軸標籤對於最後一個網格線是隱藏的。下圖顯示了這一點。MSCharts最後一軸標籤隱藏
,我使用這個代碼是:
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個月),但軸標籤根本不顯示,而實際上這是修改此代碼的唯一位置
真棒,這真的很好,非常感謝這麼多! –