Reputation: 123
I have several series in one chart and I want the X-axis to show every day at 00:00 in the night as shown in the first picture below.
But when I add one series that is getting its date from a database, it changes to another time or format that I don't want (See picture 2).
This is the code that I'm using.
Dim theDate As Date
rows = dv.Table.Rows.Count
For i As Integer = 0 To rows - 1
Debug.WriteLine(dv(i)(0))
theDate = DateTime.ParseExact(dv(i)(0), "dd-MMM-yy HH:mm:ss.f", CultureInfo.CurrentCulture)
Debug.WriteLine(theDate)
'MsgBox(theDate.ToString("dd-MMM HH:MM", CultureInfo.InvariantCulture))
With chrCurrent
.ChartAreas("chr" + type).AxisX.LabelStyle.Format = DateTimeIntervalType.Days
.ChartAreas("chr" + type).AxisX.LabelStyle.Format = "dd-MMM HH:mm"
.Series("ser" + type).Points.AddXY(theDate, dv(i)(1))
End With
Next
For i As Integer = 0 To 7 'Past 7 days
With chrCurrent
.Series("serHighHighLimit").Points.AddXY((DateSerial(Now.Year, Now.Month, Now.Day - i)), (limitRedHigh))
Next
PICTURE 1:
PICTURE 2:
Upvotes: 0
Views: 618
Reputation: 1670
try this to set your X axis minimum value. You probably want to set it to the minimum date of your time series stripped of the hours, minutes and seconds
.ChartAreas("chr" + type).AxisX.Minimum = #2/27/2014 00:00:0#
Upvotes: 1