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

binding chart to datagrid

3 Answers 68 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Rick Mueller
Top achievements
Rank 1
Rick Mueller asked on 14 Dec 2010, 10:43 PM
hello,
have a grid with a column with Checkboxes.

If selected the employee is active
not, then de-active etc.

I would like to have a pie chart showing Percentages of Active vs de-active.

I have a combobox that filters the grid by active, de-active, show all etc.

Do have to filter the gird to show all to get the chart to display accordingly, or is there a different way?

Regards,
Rick

3 Answers, 1 is accepted

Sort by
0
Evgeni "Zammy" Petrov
Telerik team
answered on 21 Dec 2010, 08:27 AM
Hi Rick Mueller,

 You can achieve this by using GroupDescriptors.
Here is a sample code : 

SeriesMapping seriesMapping = new SeriesMapping();
seriesMapping.ItemMappings.Add(new ItemMapping(null, DataPointMember.YValue,ChartAggregateFunction.Count));
seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("Active"));
seriesMapping.GroupingSettings.ShouldFlattenSeries = true;
seriesMapping.SeriesDefinition = new PieSeriesDefinition()
{
     ItemLabelFormat = "#%{P}"
}
RC1.SeriesMappings.Add(seriesMapping);

This will create a PieChart with the count of items for Active property.
Will make the label be formatted as percentage.

Kind regards,
Evgeni "Zammy" Petrov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Rick Mueller
Top achievements
Rank 1
answered on 21 Dec 2010, 03:31 PM
Evgeni,

Thank you for your response, but I don't see the logic that wires up the grid.

I put your code into my sample and the chart showed no details.

THoughts?
Rick
0
Evgeni "Zammy" Petrov
Telerik team
answered on 23 Dec 2010, 05:41 PM
Hi Rick Mueller,

There is no logic for wiring the grid, I have only shown how to use the RadChart to display the information in a way you requested. 

What you need to do is take the objects mapped to the rows and display them in the chart. If the business objects have no property Active mapped to the grid, you can create brand new objects with Active property. 
After that you can use the code I have offered previously to display the information in RadChart.

If you face any difficulties with this task do not hesitate to contact us again.

Best wishes,
Evgeni "Zammy" Petrov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
Chart
Asked by
Rick Mueller
Top achievements
Rank 1
Answers by
Evgeni "Zammy" Petrov
Telerik team
Rick Mueller
Top achievements
Rank 1
Share this question
or