I have a pretty simple chart: X-axis is a range of datetimes (30 minute intervals) and the Y-axis is just a double. There are two series: MainSeries
and CheckSeries
.
No matter what I do, the chart will only show a single value:
This is how I am constructing my chart:
Dim MainSeries As New GColumnSeries With {
.Title = "Main",
.ColumnPadding = 1,
.Fill = New SolidColorBrush(Color.FromArgb(blue.A, blue.R, blue.G, blue.B)),
.Values = New GearedValues(Of Double)(MainValues)
}
Dim CheckSeries As New GColumnSeries With {
.Title = "Check",
.ColumnPadding = 1,
.Fill = New SolidColorBrush(Color.FromArgb(grey.A, grey.R, grey.G, grey.B)),
.Values = New GearedValues(Of Double)(CheckValues)
}
chtMain.Series = New SeriesCollection From {
MainSeries,
CheckSeries
}
chtMain.AxisX.Add(New Axis With {
.Title = "DateTime",
.Labels = LogDates,
.Unit = 1,
.MinRange = 48,
.MaxRange = 340
})
'Tried adding this to AxisX but doesn't make any difference
'.LabelFormatter = Function(value) New DateTime(CLng(value * TimeSpan.FromMinutes(30).Ticks)).ToString("t"),
chtMain.AxisY.Add(New Axis With {
.Title = "Consumption",
.LabelFormatter = Function(value) value.ToString("N"),
.MinValue = 0,
.MaxValue = yAxisMax + 10
})
Each series has 289 values in my test example. You can also notice that the Y-axis maximum is set appropriately for the other data which isn't visible. Otherwise I'd expect the maximum to be around 50.
I've tried all combinations of Unit
, MinRange
, MaxRange
on the X-axis and none of them made any difference whatsoever.
Any ideas?
I eventually hit the right combination of properties.
The AxisX.LabelFormatter
needed to be a function which converted to a DateTime
in half-hour increments, but I also had to to MinValue
and MaxValue
without MinRange
or MaxRange
. It appears the Range
properties overwrite the Value
properties.
So my X-axis now looks like this:
chtMain.AxisX.Add(New Axis With {
.Title = "DateTime",
.Labels = LogDates,
.LabelFormatter = Function(value) New DateTime(CLng(value)).ToString("dd/MM/yy HH:mm"),
.MinValue = 0,
.MaxValue = 48
})