'vb.net: chart axis.X showing label is strange
Hope someone can help. Have a chart in vb.net winforms embeded which shows weeks on the axis.X. Interval is 8/30/2021 to 9/9/2022. AxisX.Interval is set to 1. From start to week(Now) only every 5th label is showing which is for me ok. But after week(now) every week is shown. How can I make this for the whole x-axixs equal - say show every 5th label? x-axis in weeks of my chart
newchart(chart1) 'clear if already exists
Dim chartArea1 As New ChartArea("Default")
chart1.AntiAliasing = AntiAliasingStyles.None
chart1.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal
chart1.ChartAreas.Add(chartArea1)
chart1.ChartAreas("Default").CursorX.IsUserEnabled = False
chart1.ChartAreas("Default").CursorX.IsUserSelectionEnabled = False
chart1.ChartAreas("Default").BackGradientStyle = GradientStyle.None
chart1.ChartAreas("Default").Position.Auto = False
chart1.ChartAreas("Default").Position.X = 0
chart1.ChartAreas("Default").Position.Y = 10
chart1.ChartAreas("Default").Position.Width = ChartAreasWidth
chart1.ChartAreas("Default").Position.Height = ChartAreasHeight - 4
chart1.ChartAreas("Default").AxisX.ScaleView.Zoomable = True
chart1.ChartAreas("Default").AxisX.ScrollBar.IsPositionedInside = True
chart1.ChartAreas("Default").AxisX.MajorGrid.Enabled = False
chart1.ChartAreas("Default").AxisX.MajorGrid.LineWidth = 1
chart1.ChartAreas("Default").AxisX.IntervalType = DateTimeIntervalType.Weeks
chart1.ChartAreas("Default").AxisX.Interval = 1
chart1.ChartAreas("Default").AxisX.LabelAutoFitStyle = LabelAutoFitStyles.DecreaseFont
chart1.ChartAreas("Default").AxisX.LabelAutoFitMinFontSize = 7
chart1.ChartAreas("Default").AxisX.LabelStyle.Font = My.Settings.fontbold8
chart1.ChartAreas("Default").AxisX.LabelStyle.Angle = 90
chart1.ChartAreas("Default").AxisX.MajorTickMark.Enabled = True
chart1.ChartAreas("Default").AxisX.MinorTickMark.Enabled = False
chart1.ChartAreas("Default").AxisX.Minimum = startDate.ToOADate()
chart1.ChartAreas("Default").AxisX.Maximum = endDate.ToOADate()
chart1.ChartAreas("Default").AxisX.IsMarginVisible = False
'chart1.ChartAreas("Default").AxisX.CustomLabels.Add(New CustomLabel(startDate.ToOADate(), endDate.ToOADate(), "", 1, LabelMarkStyle.None)) 'maybe this way
chart1.ChartAreas("Default").AxisY.MinorTickMark.Enabled = True
chart1.ChartAreas("Default").AxisY.MinorTickMark.TickMarkStyle = TickMarkStyle.InsideArea
chart1.ChartAreas("Default").AxisY.MajorGrid.LineWidth = 1
chart1.ChartAreas("Default").AxisY.MajorGrid.LineColor = Color.Black
chart1.ChartAreas("Default").AxisY.LabelStyle.Font = My.Settings.fontbold8
chart1.ChartAreas("Default").AxisY.LabelStyle.Format = "C0"
chart1.ChartAreas("Default").AxisY.LabelAutoFitStyle = LabelAutoFitStyles.DecreaseFont
chart1.ChartAreas("Default").AxisY.LabelAutoFitMinFontSize = 7
chart1.ChartAreas("Default").AxisY.Minimum = 0
chart1.ChartAreas("Default").AxisY2.LineDashStyle = ChartDashStyle.Solid
chart1.ChartAreas("Default").AxisY2.LineWidth = 1
chart1.ChartAreas("Default").AxisY2.LineColor = Color.Black
chart1.ChartAreas("Default").AxisY2.Enabled = AxisEnabled.True
chart1.ChartAreas("Default").AxisY2.MajorTickMark.Enabled = False
chart1.ChartAreas("Default").AxisY2.LabelStyle.ForeColor = Color.Transparent
chart1.ChartAreas("Default").AxisY2.LabelStyle.Font = My.Settings.fontbold8
chart1.ChartAreas("Default").AxisY2.MajorGrid.Enabled = False
chart1.ChartAreas("Default").AxisY2.LabelAutoFitStyle = LabelAutoFitStyles.DecreaseFont
chart1.ChartAreas("Default").AxisY2.LabelAutoFitMinFontSize = 7
chart1.ChartAreas("Default").BackColor = Color.White
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|