C# 将LineSeries值绑定到对象字段
我正在使用2010版的WPF工具包进行数据可视化 如果我想以编程方式创建线系列图表,这就是我以前所做的。此代码工作并成功绘制数据:C# 将LineSeries值绑定到对象字段,c#,wpf,wpftoolkit,C#,Wpf,Wpftoolkit,我正在使用2010版的WPF工具包进行数据可视化 如果我想以编程方式创建线系列图表,这就是我以前所做的。此代码工作并成功绘制数据: public class TrendData { public string Group; public IEnumerable<KeyValuePair<DateTime, decimal>> Series; } ... //somewhere within my chart update method foreach (T
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);
}
公共类趋势数据{
公共字符串组;
公共数列;
}
...
//在我的图表更新方法中的某个地方
foreach(数据采集中的趋势数据行){
LineSeries l=新的LineSeries(){
DependentValuePath=“值”,
IndependentValuePath=“Key”,
Title=line.Group,
ItemsSource=line.Series
};
图.系列.增加(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);
}
公共类趋势数据{
公共字符串组;
公共数列;
}
公共类点数据{
公共日期时间;
公共十进制率;
公共int x;
}
...
//在我的图表更新方法中的某个地方
foreach(数据采集中的趋势数据行){
LineSeries l=新的LineSeries(){
DependentValuePath=“速率”,
IndependentValuePath=“时间”,
Title=line.Group,
ItemsSource=line.Series
};
图.系列.增加(l);
}
这不起作用,反而给了我一个invalidoOperationException:“没有合适的轴可用于绘制依赖值。”
来自DataPointSeries
想法?我这样做完全错了吗?事实证明,这是完全正确的。我只是在其他地方的代码中有一个输入错误导致了这一点 由于DependentValueBinding中的一个输入错误,我也出现了这个错误。