Assign value to StackedBar100 SeriesMapping show "No data"

3 posts, 0 answers
  1. Lior
    Lior avatar
    28 posts
    Member since:
    Aug 2012

    Posted 25 Jan 2013 Link to this post

    Hello all
    We've a chart not the datasource is changing, seriser is changing, therefore we don't assign the ItemsSource in Xaml for the chart,only has the declaration in xaml.

    In codebehind we create a SeriesMappingCollection and everthing in it and assign the itemsource to very SeriesMapping, at the code bottom assign the collection back to SeriesMappings But straged that Page shows "No data  serier to me"  when load.

    Any ideas and suggestions?
    <chart:RadChart  x:Name="radChart"    Grid.Row="1"  Style="{StaticResource RadChartStyle}"  />

    Create Chart method
    private void GenerateChartData(RadChart chart, List<IEnumerable<ChartObject>> CollectionData1)
              SeriesMappingCollection seriesMappingCollection = new SeriesMappingCollection();
              string[] names = new string[] { "Apple" };
              List<ChartObject> items = new List<ChartObject>(){
                          new ChartObject("AA1",200),
                          new ChartObject("AA2", 300),
                          new ChartObject("AA3", 400),
                   new ChartObject("Estimate11", 600)};
              for (int i = 0; i < 1; i++)
                  SeriesMapping seriesMapping = new SeriesMapping();
                  seriesMapping.LegendLabel = names[i];
                  StackedBar100SeriesDefinition stackedBar100 = new StackedBar100SeriesDefinition();
                  stackedBar100.ShowItemLabels = true;
                  stackedBar100.ShowItemToolTips = true;
                  stackedBar100.StackGroupName = "Sourcing";
                  stackedBar100.ItemToolTipFormat = "#STPERCENT{#0.#%}";
                  stackedBar100.InteractivitySettings = new InteractivitySettings();
                  stackedBar100.InteractivitySettings.SelectionMode = Telerik.Windows.Controls.Charting.ChartSelectionMode.Multiple;
                  stackedBar100.InteractivitySettings.SelectionScope = InteractivityScope.Item;
                  stackedBar100.InteractivitySettings.HoverScope = InteractivityScope.Item;
                  stackedBar100.SeriesName = names[i];
                  seriesMapping.SeriesDefinition = stackedBar100;
                  seriesMapping.ItemMappings.Add(new ItemMapping("Type", DataPointMember.XCategory));
                  seriesMapping.ItemMappings.Add(new ItemMapping("Count", DataPointMember.YValue));
                  seriesMapping.ItemMappings.Add(new ItemMapping("CustomLabel", DataPointMember.Label));
                  seriesMapping.ItemsSource = items;
               chart.SeriesMappings = seriesMappingCollection;

    Result see attached
  2. Petar Kirov
    Petar Kirov avatar
    425 posts

    Posted 29 Jan 2013 Link to this post

    Hi Lior,

    I created a project using the code you provided and it everything seems to work as expected. The only thing that I added was a ChartObject class with the needed properties, so that the ItemMappings can work properly.

    I have attached the project below for reference. I hope this helps.
    Petar Kirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Lior
    Lior avatar
    28 posts
    Member since:
    Aug 2012

    Posted 01 Feb 2013 Link to this post

    Thanks , you're a lovely guy.
Back to Top