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

Stacked Bar chart issue

3 Answers 89 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 13 Feb 2012, 06:34 PM
I have a list with 4 objects with the folloving parameters/values:

Name=BC ; Name2=111 ; Value=200
Name=Al ; Name2=222; Value=99
Name=Ba ; Name2=222; Value=99
Name=BV ; Name2=333 ; Value=250

Look at the screen shot attached - 2 bars in the moddle are not stacked ie one bar is over the other bar. What am I doing wrong?

Thanks
<telerik:SeriesMapping>
                                <telerik:StackedBarSeriesDefinition.LabelSettings>
                                    <telerik:BarLabelSettings LabelDisplayMode="Outside" Distance="15" ShowConnectors="True"/>
                                </telerik:StackedBarSeriesDefinition.LabelSettings>
                                <telerik:StackedBarSeriesDefinition.InteractivitySettings>
                                    <telerik:InteractivitySettings SelectionMode="Multiple" SelectionScope="Item"/>
                                </telerik:StackedBarSeriesDefinition.InteractivitySettings>
                            </telerik:StackedBarSeriesDefinition>
                        </telerik:SeriesMapping.SeriesDefinition>
                        <telerik:SeriesMapping.ItemMappings>
                            <telerik:ItemMapping FieldName="Value" DataPointMember="YValue" />
                            <telerik:ItemMapping FieldName="Name" DataPointMember="LegendLabel" />
                            <telerik:ItemMapping FieldName="Name2" DataPointMember="XCategory" />
                        </telerik:SeriesMapping.ItemMappings>
                    </telerik:SeriesMapping>

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 16 Feb 2012, 11:07 AM
Hello Alex,

The most appropriate approach in this scenario would be to create a nested collection  :
public ExampleViewModel()
        {
            List<List<DataObject>> data = new List<List<DataObject>>();
  
            data.Add(new List<DataObject>() { new DataObject("BC", "111", 200) });
            data.Add(new List<DataObject>() { new DataObject("Al", "222", 99) });
            data.Add(new List<DataObject>() { new DataObject("Ba", "222", 99) });
            data.Add(new List<DataObject>() { new DataObject("BV", "333", 250) });
  
            this._data = data;
        }
 
and then create 4 separate series mappings, one for each series, using CollectionIndex, in the following manner :
<telerik:SeriesMapping CollectionIndex="0" LegendLabel="BC">
                <telerik:SeriesMapping.SeriesDefinition>
                    <telerik:StackedBarSeriesDefinition>
                        <telerik:StackedBarSeriesDefinition.InteractivitySettings>
                            <telerik:InteractivitySettings SelectionScope="Item" SelectionMode="Multiple" />
                        </telerik:StackedBarSeriesDefinition.InteractivitySettings>
                    </telerik:StackedBarSeriesDefinition>
                </telerik:SeriesMapping.SeriesDefinition>
                <telerik:SeriesMapping.ItemMappings>
                    <telerik:ItemMapping FieldName="Value" DataPointMember="YValue" />
                     <telerik:ItemMapping FieldName="Name2" DataPointMember="XCategory" />
                    </telerik:SeriesMapping.ItemMappings>
            </telerik:SeriesMapping>

Hope this helps.

Greetings,
Nikolay
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Alex
Top achievements
Rank 1
answered on 21 Feb 2012, 05:09 PM

Please have a look at the very quick drawing that I have attached. That is what I am trying to achieve - any of the two examples shown in the picture. I don’t think your current example is trying to simulate that scenario?

Thanks

0
Nikolay
Telerik team
answered on 24 Feb 2012, 08:19 AM
Hi Alex,

I'm attaching the sample test application we've created to simulate your scenario locally ( with the data provided in the original post ) and an image of the result we get which seems to be the same as the requirement. Please, have a look at the app and let us know if it works for you as well.

Greetings,
Nikolay
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Chart
Asked by
Alex
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Alex
Top achievements
Rank 1
Share this question
or