Hello,
I'm trying to format a chart that has a status or category on the Y axis, and a time on the X axis. Please see attached image for an example of what I'm talking about. I've tried a couple different scenarios, but I'm having trouble adding CategoricalDataPoints to my LineSeries. I'm currently trying to use the RadCartesianChart, which I'm not even sure is the most appropriate. Could anyone provide some guidance on if I'm using the right chart, axes, etc...and maybe a small example of adding data to the series programatically?
This is what I have so far, which I know is not well written, just trying to get a POC working. The CategoricalDataPoint is expecting a double as the value, but I actually just have a category.
I'm trying to format a chart that has a status or category on the Y axis, and a time on the X axis. Please see attached image for an example of what I'm talking about. I've tried a couple different scenarios, but I'm having trouble adding CategoricalDataPoints to my LineSeries. I'm currently trying to use the RadCartesianChart, which I'm not even sure is the most appropriate. Could anyone provide some guidance on if I'm using the right chart, axes, etc...and maybe a small example of adding data to the series programatically?
This is what I have so far, which I know is not well written, just trying to get a POC working. The CategoricalDataPoint is expecting a double as the value, but I actually just have a category.
RadCartesianChart chart =
new
RadCartesianChart();
chart.HorizontalAxis =
new
DateTimeContinuousAxis();
chart.VerticalAxis =
new
CategoricalAxis();
LineSeries line =
new
LineSeries();
line.Stroke =
new
SolidColorBrush(Colors.Orange);
line.StrokeThickness = 2;
SqlCeConnection con =
new
SqlCeConnection(connectionString); ;
con.Open();
using
(SqlCeCommand command =
new
SqlCeCommand(
"SELECT Log.contact as contact, Status.name as status, Log.time as time FROM Log INNER JOIN Status ON Log.status_id = Status.id WHERE (Log.contact = 'Bob')"
, con))
{
SqlCeDataReader reader = command.ExecuteReader();
while
(reader.Read())
{
DateTime time = Convert.ToDateTime(reader[
"time"
]);
string
person = Convert.ToString(reader[
"contact"
]);
string
status = Convert.ToString(reader[
"status"
]);
if
(time.DayOfYear == DateTime.Now.DayOfYear - 1)
{
line.DataPoints.Add(
new
CategoricalDataPoint() { Value = time, Category = status });
}
}
}