Stacked Bar chart issue

4 posts, 0 answers
  1. Alex
    Alex avatar
    36 posts
    Member since:
    Sep 2010

    Posted 13 Feb 2012 Link to this post

    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>
  2. Nikolay
    Admin
    Nikolay avatar
    386 posts

    Posted 16 Feb 2012 Link to this post

    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 >>
  3. DevCraft banner
  4. Alex
    Alex avatar
    36 posts
    Member since:
    Sep 2010

    Posted 21 Feb 2012 Link to this post

    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

  5. Nikolay
    Admin
    Nikolay avatar
    386 posts

    Posted 24 Feb 2012 Link to this post

    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 >>
Back to Top