This is a migrated thread and some comments may be shown as answers.

Simple Pie Chart...

2 Answers 85 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Neil Alderson
Top achievements
Rank 1
Neil Alderson asked on 18 Jan 2010, 05:59 PM
Dear Telerik,

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

2 Answers, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 20 Jan 2010, 04:50 PM
Hello Neil Alderson,

Unfortunately, data grouping and aggregation is still not supported for the Pie series type. You will need to manually aggregate your data prior to data binding. Our developers will consider implementing this functionality in a future version of the control.

Please accept our apologies for this inconvenience.

Regards,
Velin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Neil Alderson
Top achievements
Rank 1
answered on 21 Jan 2010, 09:16 AM
Ok no problem. I solved this by aggregating the sumation into new business objects and used these for the Pie chart.

Thanks,
Tags
Chart
Asked by
Neil Alderson
Top achievements
Rank 1
Answers by
Velin
Telerik team
Neil Alderson
Top achievements
Rank 1
Share this question
or