For some reason I am struggling to create a very simple Pie Chart with your control (mainly due to lacking documentation I feel).
I have the following data structure:
public
class GraphDataView
{
public decimal Consumption { get; set; }
public DateTime DateTime { get; set; }
public string DataType { get; set; }
}
Now I'd like to construct a Pie Chart that displays the sum of the Consumption value for each DataType. This should be pretty straightforward to chart but I keep getting an NullReference exception. I am setting up the Pie Chart like this:
SeriesMapping
summaryMapping = new SeriesMapping();
summaryMapping.SeriesDefinition =
new PieSeriesDefinition();
summaryMapping.ItemMappings.Add(
new ItemMapping("Consumption", DataPointMember.YValue, ChartAggregateFunction.Sum));
summaryMapping.ItemMappings.Add(
new ItemMapping("DataType", DataPointMember.Label));
summaryChart.SeriesMappings.Add(summaryMapping);
List
<GraphDataView> allConsumptionReadings = new List<GraphDataView>();
allConsumptionReadings.AddRange(aitConsumption);
allConsumptionReadings.AddRange(ai3Consumption);
summaryChart.ItemsSource = allConsumptionReadings;
When I go to set the ItemsSource to a List of my data objects I get the following exception:
{System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Windows.Data.ObjectDataBinder.GetValue(Object bindingSource, String propertyPath)}
The "allConsumptionReadings" collection is filled with 23 GraphDataView objects, so this isn't the problem.
Any ideas?
Neil