Populate data to RadChart 3D Stacked Bar

2 posts, 0 answers
  1. Heiko
    Heiko avatar
    20 posts
    Member since:
    Jan 2009

    Posted 28 Mar 2011 Link to this post

    Hi,

    I am working with RadChart 3D Stacked Bar.

    Is it possible to send me an example, how I can populate data , including YValues, XCategories and Legend with more than one SeriesMapping.


    Thank you & kind regards,

    Heiko

  2. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 31 Mar 2011 Link to this post

    Hello Heiko,
    I believe you will find the following online resources helpful, considering the task you have before you:
    1. http://demos.telerik.com/silverlight/#Chart/Gallery3D/StackedBar
    2. http://www.telerik.com/help/silverlight/radchart-features-categorical-charts.html

    Apart from these links, below I have included the code of a simple example, demonstrating the approach that you can use:
    <UserControl.DataContext>
        <data:ViewModel></data:ViewModel>
    </UserControl.DataContext>
     
    <Grid x:Name="LayoutRoot" Background="White">
     
        <telerik:RadChart x:Name="radChart" telerik:StyleManager.Theme="Windows7" ItemsSource="{Binding Data}">
            <telerik:RadChart.DefaultView>
                <telerik:ChartDefaultView>
                    <telerik:ChartDefaultView.ChartLegend>
                        <telerik:ChartLegend Name="legend" ReverseLegendItemsOrder="True" />
                    </telerik:ChartDefaultView.ChartLegend>
                    <telerik:ChartDefaultView.ChartArea>
                        <telerik:ChartArea LegendName="legend">
                            <telerik:ChartArea.Extensions>
                                <telerik:CameraExtension />
                            </telerik:ChartArea.Extensions>
                        </telerik:ChartArea>
                    </telerik:ChartDefaultView.ChartArea>
                </telerik:ChartDefaultView>
            </telerik:RadChart.DefaultView>
            <telerik:RadChart.SeriesMappings>
                <telerik:SeriesMapping LegendLabel="Stacked Bar 1" CollectionIndex="0">
                    <telerik:SeriesMapping.SeriesDefinition>
                        <telerik:StackedBar3DSeriesDefinition StackGroupName="Stack1" />
                    </telerik:SeriesMapping.SeriesDefinition>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="Value1" />
                    <telerik:ItemMapping DataPointMember="XCategory" FieldName="Category" />
                </telerik:SeriesMapping>
                <telerik:SeriesMapping LegendLabel="Stacked Bar 2" CollectionIndex="1">
                    <telerik:SeriesMapping.SeriesDefinition>
                        <telerik:StackedBar3DSeriesDefinition StackGroupName="Stack1" />
                    </telerik:SeriesMapping.SeriesDefinition>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="Value2" />
                    <telerik:ItemMapping DataPointMember="XCategory" FieldName="Category" />
                </telerik:SeriesMapping>
            </telerik:RadChart.SeriesMappings>
        </telerik:RadChart>
    </Grid>

    public class ViewModel
    {
        public ObservableCollection<ObservableCollection<DemoData>> Data
        {
            get
            {
                ObservableCollection<ObservableCollection<DemoData>> seriesData;
                seriesData = new ObservableCollection<ObservableCollection<DemoData>>()
                {
                    new ObservableCollection<DemoData>(){
                        new DemoData() {Category="Category 0", Value1 = 23.4600},
                        new DemoData() { Category="Category 1", Value1 = 23.3200},
                        new DemoData() { Category="Category 2", Value1 = 23.1300},
                        new DemoData() { Category="Category 3", Value1 = 23.6300},
                        new DemoData() { Category="Category 4", Value1 = 23.6200}},
                    new ObservableCollection<DemoData>(){
                        new DemoData() {Category="Category 1", Value2 = 10.2},
                        new DemoData() { Category="Category 2", Value2 = 12.6},
                        new DemoData() { Category="Category 3", Value2 = 30.1},
                        new DemoData() { Category="Category 4", Value2 = 5.3},
                        new DemoData() { Category="Category 5", Value2 = 1.5}}
                };
                return seriesData;
            }
        }
    }
     
    public class DemoData
    {
        public string Category
        {
            get;
            set;
        }
        public double Value1
        {
            get;
            set;
        }
        public double Value2
        {
            get;
            set;
        }
    }


    All the best,
    Tsvetie
    the Telerik team
Back to Top