StackedBar wont show items

2 posts, 0 answers
  1. Letoir
    Letoir avatar
    6 posts
    Member since:
    Nov 2011

    Posted 02 Dec 2011 Link to this post

    I Have an asset with with a name, that contains  a value for each day (in  7 days)
    List <ChartData>list = xData.GetData(DateTime.FromOADate(40839), DateTime.FromOADate(40846),  assetName);
    so here i am saving for each asset the day, the name and the value it has on that day

    no i want to make a stackedbar, where the value for each asset is given on day 12/1/2011, so i want all assets like
    xbox, telephone, tv, .. give a value in a stackedbar for 12/1/2011 in the stackedbar chart.

    How can i do this, 

    this is what i tried

    List<ChartTot> data = new List<ChartTot>();
    XMLData xData = new XMLData();
    XMLData xData2 = new XMLData();
    data.Add(new ChartTot(xData.GetData(DateTime.FromOADate(40839), DateTime.FromOADate(40846), "Stereo")));
    data.Add(new ChartTot(xData2.GetData(DateTime.FromOADate(40839), DateTime.FromOADate(40846), "Gas")));
    radChart1.ItemsSource = data;
    public class ChartTot
           private List<ChartData> cd = new List<ChartData>();
           public ChartTot(List<ChartData> list)
      = list;
    public class ChartData
          public String Naam { get; set; }
          public double Waarde { get; set; }
          public DateTime DezeW { get; set; }
          public ChartData()

    (xData.GetData(DateTime.FromOADate(40839), DateTime.FromOADate(40846), "Stereo")
    this gives me a list from ChartData class, and i put it in a List of ChartTot.

    the itemsSource contains a list (ChartTot) that contains a list of ChartData

    But i get no chart ???
  2. Petar Marchev
    Petar Marchev avatar
    996 posts

    Posted 07 Dec 2011 Link to this post

    Hi Letoir,

    Below I have pasted some code that you can use to get you started with stacked bar series.

    <telerik:RadChart x:Name="radChartProducts" >
         <telerik:ItemMapping DataPointMember="XCategory" FieldName="ProductName" />
         <telerik:ItemMapping DataPointMember="YValue" FieldName="SoldUnits" />
      <telerik:StackedBarSeriesDefinition />
         <telerik:ItemMapping DataPointMember="XCategory" FieldName="ProductName" />
         <telerik:ItemMapping DataPointMember="YValue" FieldName="ReturnedUnits" />
      <telerik:StackedBarSeriesDefinition />

    public partial class MainWindow : Window
      public MainWindow()
        var products = new List<ProductInfo>()
          new ProductInfo(){ProductName="keyboard", SoldUnits=200, ReturnedUnits=40},
          new ProductInfo(){ProductName="xbox", SoldUnits=150, ReturnedUnits=30},
          new ProductInfo(){ProductName="mouse", SoldUnits=120, ReturnedUnits=10},
          new ProductInfo(){ProductName="monitor", SoldUnits=220, ReturnedUnits=10},
          new ProductInfo(){ProductName="motherboard", SoldUnits=150, ReturnedUnits=20},           
        this.radChartProducts.ItemsSource = products;
    public class ProductInfo
      public string ProductName { get; set; }
      public int SoldUnits { get; set; }
      public int ReturnedUnits { get; set; }

    For more information and examples you can download our examples from here or if you have installed our controls you can find the example projects in your local program files directory
    C:\Program Files (x86) \ Telerik \ RadControls for Wpf Q3 2011 \ Demos

    Look specifically for the Stacked Bar examples. Looking from these examples you can see how classes are structured and how you need to pass data to the chart in order to use the stacked bar series.

    You might also find this help topic on Grouping and Aggregation helpful.

    Please read this topic on Categorical Charts too and have in mind that the data for one category will appear stacked when using stacked bar series. 

    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top