User1559292362 posted
Hi faremax,
for some reason X axes always adding an extra day even though I am not assigning any values to it
I create a demo and reproduce you issue on my side, you need to modify the value of Chart1.ChartAreas(0).AxisX.IntervalType to DateTimeIntervalType.Auto. then setting the value IsMarginVisible to false, like this:
Dim x As DateTime() = New DateTime(3) {}
Dim y As Decimal() = New Decimal(3) {}
x(0) = Now.AddDays(-3)
y(0) = ds.Tables(0).Rows(0).Item(0)
x(1) = Now.AddDays(-2)
y(1) = ds.Tables(1).Rows(0).Item(0)
x(2) = Now.AddDays(-1)
y(2) = ds.Tables(2).Rows(0).Item(0)
x(3) = Now
y(3) = ds.Tables(3).Rows(0).Item(0)
Chart1.Series(0).Points.DataBindXY(x, y)
Chart1.Series(0).XValueType = ChartValueType.DateTime
Chart1.Series(0).YValueType = ChartValueType.Double
Chart1.Series(0).ChartType = SeriesChartType.Column
Chart1.Series(0).Name = "Sales (amt)"
Chart1.Series(0).IsValueShownAsLabel = True
Chart1.Series(0).Label = "$" & "#VALY"
Chart1.ChartAreas(0).AxisY.LabelStyle.Format = "C"
Chart1.ChartAreas(0).AxisY.Interval = 100
Chart1.ChartAreas(0).AxisY.IntervalType = DateTimeIntervalType.Number
Chart1.ChartAreas(0).AxisX.LabelStyle.Format = "dddd"
Chart1.ChartAreas(0).AxisX.Interval = 1
Chart1.ChartAreas(0).AxisX.IntervalType = DateTimeIntervalType.Auto
Chart1.ChartAreas(0).AxisX.IsMarginVisible = False
Chart1.ChartAreas(0).AxisX.MajorGrid.Enabled = True
Chart1.ChartAreas(0).AxisY.MajorGrid.Enabled = True
Best regards,
Cole Wu