binding chart to datagrid

4 posts, 0 answers
  1. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 14 Dec 2010 Link to this post

    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
  2. Evgeni "Zammy" Petrov
    Admin
    Evgeni "Zammy" Petrov avatar
    168 posts

    Posted 21 Dec 2010 Link to this post

    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
  3. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 21 Dec 2010 Link to this post

    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
  4. Evgeni "Zammy" Petrov
    Admin
    Evgeni "Zammy" Petrov avatar
    168 posts

    Posted 23 Dec 2010 Link to this post

    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
Back to Top