StackedBarSeries in xaml

2 posts, 0 answers
  1. Stuart
    Stuart avatar
    30 posts
    Member since:
    Jun 2010

    Posted 14 Feb 2011 Link to this post

    Hi

    I'm trying to set up a stackedbarseriesdefinition chart but no combination of xaml seems to work for me.

    My data is

    qtr    sector        data
    q1    ents            23.5
    q2    ents            34
    q3    ents            25
    q1    shopping     15
    q2    shopping     17

    etc

    and my xaml is

    <telerik:RadChart.SeriesMappings>
                    <telerik:SeriesMapping>
                        <telerik:SeriesMapping.GroupingSettings>
                            <telerik:GroupingSettings StackGroupFieldName="sector">
                                <telerik:GroupingSettings.GroupDescriptors>
                                    <telerik:ChartGroupDescriptor Member="sector"></telerik:ChartGroupDescriptor>
                                </telerik:GroupingSettings.GroupDescriptors>
                            </telerik:GroupingSettings>
                        </telerik:SeriesMapping.GroupingSettings>
                        <telerik:SeriesMapping.SeriesDefinition>
                            <telerik:StackedBarSeriesDefinition>
                            </telerik:StackedBarSeriesDefinition>
                        </telerik:SeriesMapping.SeriesDefinition>
                        <telerik:SeriesMapping.ItemMappings>
                            <telerik:ItemMapping DataPointMember="XCategory"  FieldName="qtr"/>
                            <telerik:ItemMapping DataPointMember="YValue" FieldName="data"/>
                        </telerik:SeriesMapping.ItemMappings>
                    </telerik:SeriesMapping>                
                </telerik:RadChart.SeriesMappings>
                <telerik:RadChart.DefaultView>
                    <telerik:ChartDefaultView>
                        <telerik:ChartDefaultView.ChartTitle>
                            <telerik:ChartTitle />
                        </telerik:ChartDefaultView.ChartTitle>                   
                    </telerik:ChartDefaultView>
                </telerik:RadChart.DefaultView>
            </telerik:RadChart>

    but it keeps displaying a chart with each sector bar alongside each other within each qtr as opposed to what I want which is per qtr a stack of all the sector values for that qtr. Does anyone know what I need to change?

    Thanks    
  2. Missing user
    Missing user avatar

    Posted 17 Feb 2011 Link to this post

    Hi Stuart,

    You can try to set the GroupSettings.StackGroupFieldName to "qtr". For example:

    <telerik:RadChart x:Name="radChart1">
        <telerik:RadChart.SeriesMappings>
            <telerik:SeriesMapping>
                <telerik:SeriesMapping.GroupingSettings>
                    <telerik:GroupingSettings StackGroupFieldName="qtr">
                        <telerik:GroupingSettings.GroupDescriptors>
                            <telerik:ChartGroupDescriptor Member="sector"/>
                        </telerik:GroupingSettings.GroupDescriptors>
                    </telerik:GroupingSettings>
                </telerik:SeriesMapping.GroupingSettings>
                <telerik:SeriesMapping.SeriesDefinition>
                    <telerik:StackedBarSeriesDefinition />
                </telerik:SeriesMapping.SeriesDefinition>
                <telerik:SeriesMapping.ItemMappings>
                    <telerik:ItemMapping DataPointMember="XCategory"  FieldName="qtr"/>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="data"/>
                </telerik:SeriesMapping.ItemMappings>
            </telerik:SeriesMapping>
        </telerik:RadChart.SeriesMappings>
        <telerik:RadChart.DefaultView>
            <telerik:ChartDefaultView>
                <telerik:ChartDefaultView.ChartTitle>
                    <telerik:ChartTitle />
                </telerik:ChartDefaultView.ChartTitle>
            </telerik:ChartDefaultView>
        </telerik:RadChart.DefaultView>
    </telerik:RadChart>

    You can see the result in the attached image.

    I hope this helps.

    Greetings,
    Polina
    the Telerik team
Back to Top