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

Assign value to StackedBar100 SeriesMapping show "No data"

2 Answers 34 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Lior
Top achievements
Rank 1
Lior asked on 25 Jan 2013, 06:51 AM
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?
Xaml
<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;
              seriesMappingCollection.Add(seriesMapping);
          }
 
           chart.SeriesMappings = seriesMappingCollection;
      }

Result see attached

2 Answers, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 29 Jan 2013, 03:26 PM
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.
 
Regards,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Lior
Top achievements
Rank 1
answered on 01 Feb 2013, 06:18 AM
Thanks , you're a lovely guy.
Tags
Chart
Asked by
Lior
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Lior
Top achievements
Rank 1
Share this question
or