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

How to group stacked bars

3 Answers 183 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Sebastien
Top achievements
Rank 2
Sebastien asked on 03 Aug 2010, 06:58 PM
Hello,

I use the silverlight chart control to display charts with several stacked bars and simple bars, for example 6 stacked bars grouped in 2 bars (3 series on 1 bar, the others 3 on the second bar) using the property XCategory to group the series. I want to print this chart using the reporting but I haven't found the equivalent of the property 'XCategory', all the stacked series appears on the same bar. What can I do to group the series like in the silverlight chart control ?

3 Answers, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 06 Aug 2010, 10:27 AM
Hello Rodolphe Latta,

Please use the StackGroupName property on the StackedBarSeriesDefinition class.

Sincerely yours,
Vladimir Milev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dave
Top achievements
Rank 1
answered on 10 Aug 2010, 12:12 AM
HI Vladimir ,

USing the StackGroupName did not work for me. The group name is data driven.

This is the xaml:

   
<telerik:RadChart x:Name="RevenueChart" telerik:StyleManager.Theme="Vista" ><br>
        <telerik:RadChart.SeriesMappings><br>
            <telerik:SeriesMapping LegendLabel="Renewals Not Signed" ><br>
                <telerik:SeriesMapping.SeriesDefinition><br>
                    <telerik:StackedBarSeriesDefinition StackGroupName="{Binding BranchName}" ><br>
                    </telerik:StackedBarSeriesDefinition><br>
                </telerik:SeriesMapping.SeriesDefinition><br>
                <telerik:SeriesMapping.ItemMappings><br>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="RenewalsNotSigned" ></telerik:ItemMapping><br>
                    <telerik:ItemMapping DataPointMember="XCategory"  FieldName="IssueName"></telerik:ItemMapping><br>
                </telerik:SeriesMapping.ItemMappings><br>
            </telerik:SeriesMapping><br>
<br>
            <telerik:SeriesMapping LegendLabel="Renewals Signed" ><br>
                <telerik:SeriesMapping.SeriesDefinition><br>
                    <telerik:StackedBarSeriesDefinition  StackGroupName="{Binding BranchName}" ><br>
                    </telerik:StackedBarSeriesDefinition><br>
                </telerik:SeriesMapping.SeriesDefinition><br>
                <telerik:SeriesMapping.ItemMappings><br>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="RenewalsSigned"></telerik:ItemMapping><br>
                    <telerik:ItemMapping DataPointMember="XCategory" FieldName="IssueName"></telerik:ItemMapping><br>
                </telerik:SeriesMapping.ItemMappings><br>
            </telerik:SeriesMapping><br>
<br>
            <telerik:SeriesMapping LegendLabel="Ongoing" ><br>
                <telerik:SeriesMapping.SeriesDefinition><br>
                    <telerik:StackedBarSeriesDefinition  StackGroupName="{Binding BranchName}" ></telerik:StackedBarSeriesDefinition><br>
                </telerik:SeriesMapping.SeriesDefinition><br>
                <telerik:SeriesMapping.ItemMappings><br>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="OngoingRev"></telerik:ItemMapping><br>
                    <telerik:ItemMapping DataPointMember="XCategory" FieldName="IssueName"></telerik:ItemMapping><br>
                </telerik:SeriesMapping.ItemMappings><br>
            </telerik:SeriesMapping><br>
<br>
            <telerik:SeriesMapping LegendLabel="New" ><br>
                <telerik:SeriesMapping.SeriesDefinition><br>
                    <telerik:StackedBarSeriesDefinition  StackGroupName="{Binding BranchName}" ></telerik:StackedBarSeriesDefinition><br>
                </telerik:SeriesMapping.SeriesDefinition><br>
                <telerik:SeriesMapping.ItemMappings><br>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="NewRev"></telerik:ItemMapping><br>
                    <telerik:ItemMapping DataPointMember="XCategory" FieldName="IssueName"></telerik:ItemMapping><br>
                </telerik:SeriesMapping.ItemMappings><br>
            </telerik:SeriesMapping><br>
        </telerik:RadChart.SeriesMappings><br>
    </telerik:RadChart>

   
The Shape is the following:

 
public List<RevenueRecords> GetRevenue()
        {
            List<RevenueRecords> rec = new List<RevenueRecords>();
 
            rec.Add(new RevenueRecords() { BranchName = "Branch1", IssueName = "Issue 1", NewRev = 10, OngoingRev = 40, RenewalsNotSigned = -10, RenewalsSigned = 12 });
            rec.Add(new RevenueRecords() { BranchName = "Branch1", IssueName = "Issue 2", NewRev = 10, OngoingRev = 40, RenewalsNotSigned = -10, RenewalsSigned = 13 });
            rec.Add(new RevenueRecords() { BranchName = "Branch1", IssueName = "Issue 3", NewRev = 10, OngoingRev = 40, RenewalsNotSigned = -10, RenewalsSigned = 14 });
            rec.Add(new RevenueRecords() { BranchName = "Branch1", IssueName = "Issue 4", NewRev = 10, OngoingRev = 40, RenewalsNotSigned = -10, RenewalsSigned = 15 });
<br>
            rec.Add(new RevenueRecords() { BranchName = "Branch2", IssueName = "Issue 1", NewRev = 10, OngoingRev = 40, RenewalsNotSigned = -10, RenewalsSigned = 16 });
            rec.Add(new RevenueRecords() { BranchName = "Branch2", IssueName = "Issue 2", NewRev = 10, OngoingRev = 40, RenewalsNotSigned = -10, RenewalsSigned = 17 });
            rec.Add(new RevenueRecords() { BranchName = "Branch2", IssueName = "Issue 3", NewRev = 10, OngoingRev = 40, RenewalsNotSigned = -10, RenewalsSigned = 18 });
            rec.Add(new RevenueRecords() { BranchName = "Branch2", IssueName = "Issue 4", NewRev = 10, OngoingRev = 40, RenewalsNotSigned = -10, RenewalsSigned = 19 });
 
             
            return rec;
        }
 
        public class RevenueRecords
        {
            public string BranchName { get; set; }
            public string IssueName { get; set; }
            public double RenewalsNotSigned { get; set; }
            public double RenewalsSigned { get; set; }
            public double OngoingRev { get; set; }
            public double NewRev { get; set; }
        }

   
THis is the itemsource setting
  RevenueChart.ItemsSource = GetRevenue();

What am I missing? Attached is the resulting chart.
Thanks!
0
Ves
Telerik team
answered on 12 Aug 2010, 10:33 AM
Hi Dave Lowery,

You can take advantage of the StackGroupFieldName property of the GroupingSettings:

<telerik:SeriesMapping LegendLabel="Renewals Not Signed" >
    <telerik:SeriesMapping.GroupingSettings>
        <telerik:GroupingSettings StackGroupFieldName="BranchName">
            <telerik:GroupingSettings.GroupDescriptors>
                <telerik:ChartGroupDescriptor Member="BranchName"></telerik:ChartGroupDescriptor>
            </telerik:GroupingSettings.GroupDescriptors>
        </telerik:GroupingSettings>
    </telerik:SeriesMapping.GroupingSettings>
    <telerik:SeriesMapping.SeriesDefinition>
        <telerik:StackedBarSeriesDefinition  />
    </telerik:SeriesMapping.SeriesDefinition>
    <telerik:SeriesMapping.ItemMappings>
        <telerik:ItemMapping DataPointMember="YValue" FieldName="RenewalsNotSigned" ></telerik:ItemMapping>
        <telerik:ItemMapping DataPointMember="XCategory"  FieldName="IssueName"></telerik:ItemMapping>
    </telerik:SeriesMapping.ItemMappings>
</telerik:SeriesMapping>

I have attached a small example, based on your code.

All the best,
Ves
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Sebastien
Top achievements
Rank 2
Answers by
Vladimir Milev
Telerik team
Dave
Top achievements
Rank 1
Ves
Telerik team
Share this question
or