Reputation: 338
I'm using the 2010 release of the WPF Toolkit for DataVisualization.
If I want to create a LineSeries chart programmatically, this is what I did before. This code works and plots the data successfully:
public class TrendData {
public string Group;
public IEnumerable<KeyValuePair<DateTime, decimal>> Series;
}
...
//somewhere within my chart update method
foreach (TrendData line in DataCollection) {
LineSeries l = new LineSeries() {
DependentValuePath = "Value",
IndependentValuePath = "Key",
Title = line.Group,
ItemsSource = line.Series
};
Chart.Series.Add(l);
}
This works without issue. However, I want to stored other values with the data points, because I want to display additional information on mouseover of a DataPoint. So I naively tried this:
public class TrendData {
public string Group;
public IEnumerable<PointData> Series;
}
public class PointData {
public DateTime time;
public decimal rate;
public int x;
}
...
//somewhere within my chart update method
foreach (TrendData line in DataCollection) {
LineSeries l = new LineSeries() {
DependentValuePath = "rate",
IndependentValuePath = "time",
Title = line.Group,
ItemsSource = line.Series
};
Chart.Series.Add(l);
}
This doesn't work, instead giving me an InvalidOperationException: "No suitable axis is available for plotting the dependent value."
from DataPointSeries.
Ideas? Am I doing this completely wrong?
Upvotes: 0
Views: 2268
Reputation: 338
Turns out this works absolutely perfectly. I just had a typo in my code elsewhere that was causing this.
Upvotes: 1