3 bars for each x axis point instead of 1 bar

3 posts, 1 answers
  1. IT Support
    IT Support avatar
    11 posts
    Member since:
    Nov 2005

    Posted 21 Mar 2011 Link to this post

    Hi,

    I'm trying to make a graph with 3 bars that each bar is connected to a specific legend.

    For some reason, I get 3 bars for each x axis item.

    I'm probably doing something wrong.

    Avi

    <
    telerik:RadChart
                             Margin="0,0,-108,-34"
                             ItemsSource="{Binding Data}">
     
               <telerik:RadChart.DefaultView>
     
                   <telerik:ChartDefaultView>
     
                       <telerik:ChartDefaultView.ChartLegend>
                           <telerik:ChartLegend x:Name="chartLegend"
                                                 
                                                UseAutoGeneratedItems="True" />
                       </telerik:ChartDefaultView.ChartLegend>
     
                       <telerik:ChartDefaultView.ChartArea>
     
                           <telerik:ChartArea
                                              LabelFormatBehavior="None"
                                              LegendName="chartLegend"
                                              Visibility="Visible">
                               <telerik:ChartArea.DataSeries>
                                   <telerik:DataSeries>
                                       <telerik:DataSeries.Definition>
                                           <telerik:BarSeriesDefinition LegendDisplayMode="DataPointLabel"
                                                                        ShowItemLabels="True"
                                                                        Visibility="Visible"/>
                                       </telerik:DataSeries.Definition>
                                   </telerik:DataSeries>
     
                               </telerik:ChartArea.DataSeries>
     
                               <telerik:ChartArea.AxisX>
                                   <telerik:AxisX Title="x name" />
                               </telerik:ChartArea.AxisX>
                               <telerik:ChartArea.AxisY>
                                   <telerik:AxisY Title="y name"
                                                  AutoRange="False"
                                                  MaxValue="30000"
                                                  MinorTickPointMultiplier="5"
                                                  Step="1000" />
                               </telerik:ChartArea.AxisY>
                           </telerik:ChartArea>
     
                       </telerik:ChartDefaultView.ChartArea>
     
                   </telerik:ChartDefaultView>
     
               </telerik:RadChart.DefaultView>
               <telerik:RadChart.SeriesMappings>
                   <telerik:SeriesMapping LegendLabel="label_1">
                       <telerik:ItemMapping DataPointMember="YValue" FieldName="Amount" />
                       <telerik:ItemMapping DataPointMember="XCategory" FieldName="TypeAmount" />
                   </telerik:SeriesMapping>
     
                   <telerik:SeriesMapping LegendLabel="label_2">
                       <telerik:ItemMapping DataPointMember="YValue" FieldName="Amount" />
                       <telerik:ItemMapping DataPointMember="XCategory" FieldName="TypeAmount" />
                   </telerik:SeriesMapping>
     
                   <telerik:SeriesMapping LegendLabel="label_3">
                       <telerik:ItemMapping DataPointMember="YValue" FieldName="Amount" />
                       <telerik:ItemMapping DataPointMember="XCategory" FieldName="TypeAmount" />
                   </telerik:SeriesMapping>
     
               </telerik:RadChart.SeriesMappings>
     
           </telerik:RadChart>
  2. IT Support
    IT Support avatar
    11 posts
    Member since:
    Nov 2005

    Posted 23 Mar 2011 Link to this post

    Can anybody help me?
  3. Answer
    Missing user
    Missing user avatar

    Posted 24 Mar 2011 Link to this post

    Hi,

    In this scenario you need to use SeriesMapping.GroupingSettings in order to group the data by one or more parameters. For example:
    <telerik:RadChart x:Name="radChart">
        <telerik:RadChart.SeriesMappings>
            <telerik:SeriesMapping >
                <telerik:SeriesMapping.SeriesDefinition>
                    <telerik:BarSeriesDefinition />
                </telerik:SeriesMapping.SeriesDefinition>
                <telerik:SeriesMapping.GroupingSettings>
                    <telerik:GroupingSettings ShouldCreateSeriesForLastGroup="True">
                        <telerik:GroupingSettings.GroupDescriptors>
                            <telerik:ChartGroupDescriptor Member="TypeAmount"/>
                        </telerik:GroupingSettings.GroupDescriptors>
                    </telerik:GroupingSettings>
                </telerik:SeriesMapping.GroupingSettings>
                <telerik:SeriesMapping.ItemMappings>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="Amount" />
                    <telerik:ItemMapping DataPointMember="XCategory" FieldName="TypeAmount" />
                </telerik:SeriesMapping.ItemMappings>
            </telerik:SeriesMapping>
        </telerik:RadChart.SeriesMappings>
    </telerik:RadChart>

    I hope this helps.

    Kind regards,
    Polina
    the Telerik team
Back to Top