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

pie chart

2 Answers 29 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 06 Sep 2012, 03:17 AM
For pie chart, I'm grouping a field and aggregating on another. What I'm getting is individual layer on top of each other instead of the different slices for the grouped field.

Any ideas why?

Here is my code:

            seriesMapping seriesMapping = new SeriesMapping();
             foreach (IGroupDescriptor descriptor in chartGrid.GroupDescriptors)
            {
                seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor(getDataMemberName(descriptor)));
            }
            seriesMapping.ItemMappings.Add(new ItemMapping(lastGrouping , DataPointMember.XCategory));
            seriesMapping.ItemMappings.Add(new ItemMapping(lastGrouping , DataPointMember.LegendLabel));
            ChartAggregateFunction aggFunc = getChartAggregation(lbxFunction);
            mapping = new ItemMapping(lbxSumm.SelectedValue.ToString(), DataPointMember.YValue, aggFunc);
            DataColumn col = dt.Columns[lbxSumm.SelectedValue.ToString()];
            if (col != null) mapping.FieldType = col.DataType;
            seriesMapping.ItemMappings.Add(mapping);
            radChart1.DefaultSeriesDefinition = (ISeriesDefinition)getChartType();
            radChart1.ItemsSource = null;
            radChart1.SeriesMappings.Clear();
            radChart1.DefaultView.ChartLegend.UseAutoGeneratedItems = true;
            radChart1.DefaultSeriesDefinition.LegendDisplayMode = LegendDisplayMode.SeriesLabel; 
            DataTable dtSource = dt;
            radChart1.SeriesMappings.Add(seriesMapping);
            radChart1.ItemsSource = dtSource;

2 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 10 Sep 2012, 08:35 AM
Hello Oliver,

I think you only need to set the ShouldFlattenSeries property of the GroupingSettings to true:
seriesMapping.GroupingSettings.ShouldFlattenSeries = true;

This property is false by default and it creates a series for each value that is grouped by. When the property is true - it only creates one series. To better understand this you can use BarSeries instead and set this property to true and false to see the difference. Let us know if we can assist you any further.

Regards,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Oliver
Top achievements
Rank 1
answered on 11 Sep 2012, 08:01 AM
Hi Petar,

Thanks for the reply. Is all looking great.
Tags
Chart
Asked by
Oliver
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Oliver
Top achievements
Rank 1
Share this question
or