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
...
}
Have you guaranteed that in the Sections
dictionary of the first item in the ItemList
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...
foreach (var item in ReportListViewModel.ReportSections)
{
var series = new LineSeries();
series.SetBinding(DataPointSeries.ItemsSourceProperty, new Binding("ItemList"));
series.IndependentValuePath = "Date";
series.DependentValuePath = item.BindingPath;
series.Title = item.Text;
chart.Series.Add(series);
}
精彩评论