MSCharts Last Axis Label Hiding

I'm using MSCharts and am using dates for the axes and couldn't help but notice that the axis label is hidden for the last grid line. The image below shows this.

破碎的图表轴

The code that I am using for this is:

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

Does anybody have any idea why those labels are hidden? According to the code, the gridlines are in the right place, (Every 3 months) but the axis labels simply not showing, and this is in fact the only place modifying this code


LabelStyle.IsEndLabelVisible controls whether the first and last label are displayed.

Here is the MSDN entry.

I'm guessing that somewhere in the code you didn't post is something along these lines:

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

You'll want to change that to true or remove it entirely because it defaults to true.

链接地址: http://www.djcxy.com/p/61040.html

上一篇: c3 js:我如何在X上按年分组

下一篇: MSCharts最后一个轴标签隐藏