pie chart

3 posts, 0 answers
  1. Oliver
    Oliver avatar
    33 posts
    Member since:
    Jan 2011

    Posted 05 Sep 2012 Link to this post

    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;
                radChart1.DefaultSeriesDefinition = (ISeriesDefinition)getChartType();
                radChart1.ItemsSource = null;
                radChart1.DefaultView.ChartLegend.UseAutoGeneratedItems = true;
                radChart1.DefaultSeriesDefinition.LegendDisplayMode = LegendDisplayMode.SeriesLabel; 
                DataTable dtSource = dt;
                radChart1.ItemsSource = dtSource;
  2. Petar Marchev
    Petar Marchev avatar
    968 posts

    Posted 10 Sep 2012 Link to this post

    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.

    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
  4. Oliver
    Oliver avatar
    33 posts
    Member since:
    Jan 2011

    Posted 11 Sep 2012 Link to this post

    Hi Petar,

    Thanks for the reply. Is all looking great.
Back to Top