Silverlight 图表工具包:生成的 LineSeries 抛出异常
我有以下问题:
在我们的应用程序中,我们有一个报告列表,其中包含在运行时定义的子类别...
报告的总体结果显示在 ColumnSeries 中,效果很好。现在我必须在 LineSeries 中显示子类别的结果以进行直接比较,这是行不通的。 这就是我到目前为止所拥有的(在后面的代码中):
foreach (var item in ReportListViewModel.ReportSections)
{
var series = new LineSeries();
series.SetBinding(DataPointSeries.ItemsSourceProperty, new Binding("ItemList"));
series.IndependentValuePath = "Date";
series.DependentValuePath = item.BindingPath; // points to an existing entry in a Dictionary<string, double>
series.Title = item.Text;
chart.Series.Add(series);
}
它工作正常,但是一旦加载数据,我就会得到一个 InvalidOperationException ,指出没有找到合适的轴来绘制值。
以下工作完全正常(即使它不完全是我需要的):
foreach (...)
{
...
series.DependentValuePath = "Result" // Result is the dependent property of the ColumnSeries, and I tested it just to make sure it isn't me
...
}
I have the following problem:
In our application we have a list of reports with sub categories defined at runtime...
The overall results of the report are shown in a ColumnSeries, which works fine. Now I have to show the results of the sub categories in a LineSeries for direct comparison, which won't work.
This is what I have so far (in code behind):
foreach (var item in ReportListViewModel.ReportSections)
{
var series = new LineSeries();
series.SetBinding(DataPointSeries.ItemsSourceProperty, new Binding("ItemList"));
series.IndependentValuePath = "Date";
series.DependentValuePath = item.BindingPath; // points to an existing entry in a Dictionary<string, double>
series.Title = item.Text;
chart.Series.Add(series);
}
It works fine, but once the data is loaded, I get a InvalidOperationException stating that no suitable axis for plotting the values is found.
The following works totally fine (even though it isn't exactly what I need):
foreach (...)
{
...
series.DependentValuePath = "Result" // Result is the dependent property of the ColumnSeries, and I tested it just to make sure it isn't me
...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否保证在
ItemList
中第一项的Sections
字典中实际上有一个“Personality”条目。如果没有条目,那么您看到的错误就是您将得到的错误。线系列使用项目源中第一项的值来确定要使用的适当轴。如果该值为空,它将失败,并出现类似于您所描述的异常(您问题中的异常是错误的精确措辞?)。Have you guaranteed that in the
Sections
dictionary of the first item in theItemList
there is actually an entry for "Personality". If there is no entry then the error you are seeing is what you would get. The Line Series uses the values of the first item in the item source to determine appropriate axes to use. If the value is null it will fail with an exception similar to the one you describe (the one in your question is the exact phrasing for the error?).我不知道有什么不同,但现在可以了......
I don't know what's different, but now it works...