我正在使用 2010 版的 WPF Toolkit for DataVisualization。
如果我想以编程方式创建 LineSeries 图表,这就是我之前所做的。此代码有效并成功绘制数据:
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);
}
这没有问题。但是,我想将其他值与数据点一起存储,因为我想在鼠标悬停数据点时显示其他信息。所以我天真地尝试了这个:
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);
}
这不起作用,而是给我一个InvalidOperationException: "No suitable axis is available for plotting the dependent value."
来自 DataPointSeries。
想法?我这样做完全错了吗?