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

How to bind multi series in the Stacked Bar Chart

1 Answer 117 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 01 Oct 2010, 08:08 AM
Hi,

I need display 5 series in the Stacked Bar Chart.

I used the following code to generate the ItemDataSource. But I got some runtime errors. Anyone can help me on that?
private List<IEnumerable<RFIAgingChartModel>> GetChartItemSource()
{
          List<IEnumerable<RFIAgingChartModel>> lstChartData = new List<IEnumerable<RFIAgingChartModel>>();
          // series 1 --  < 14 days
          IEnumerable<RFIAgingChartModel> lstSeries1 = context.RFIAgingChartModels; 
          context.Load(context.GetHeadContractSeriesDataQuery(596, "Head_LT14d"));
          // series 2 --  > 14 < 28 days
          IEnumerable<RFIAgingChartModel> lstSeries2 = context.RFIAgingChartModels;
          context.Load(context.GetHeadContractSeriesDataQuery(596, "Head_14-28d"));
          // series 3 -- > 1 month 
          IEnumerable<RFIAgingChartModel> lstSeries3 = context.RFIAgingChartModels;
          context.Load(context.GetHeadContractSeriesDataQuery(596, "Head_1-2m"));
          // series 4 -- > 2 months
          IEnumerable<RFIAgingChartModel> lstSeries4 = context.RFIAgingChartModels;
          context.Load(context.GetHeadContractSeriesDataQuery(596, "Head_2-3m"));
          // series 5 -- > 3 months
          IEnumerable<RFIAgingChartModel> lstSeries5 = context.RFIAgingChartModels;
          context.Load(context.GetHeadContractSeriesDataQuery(596, "Head_GT3m"));
          lstChartData.Add(lstSeries1);
          lstChartData.Add(lstSeries2);
          lstChartData.Add(lstSeries3);
          lstChartData.Add(lstSeries4);
          lstChartData.Add(lstSeries5);
          return lstChartData;
}
private void RenderChart()
{
          SeriesMapping sm1 = new SeriesMapping();
          StackedBarSeriesDefinition d1 = new StackedBarSeriesDefinition();
          d1.StackGroupName = "Stack1";
          sm1.SeriesDefinition = d1;
          sm1.LegendLabel = "Stacked Bar 1";
          sm1.CollectionIndex = 0;
          sm1.ItemMappings.Add(new ItemMapping("Week", DataPointMember.XValue));
          sm1.ItemMappings.Add(new ItemMapping("Volume", DataPointMember.YValue));
          SeriesMapping sm2 = new SeriesMapping();
          StackedBarSeriesDefinition d2 = new StackedBarSeriesDefinition();
          d1.StackGroupName = "Stack1";
          sm2.SeriesDefinition = d2;
          sm2.LegendLabel = "Stacked Bar 2";
          sm1.CollectionIndex = 1;
          sm2.ItemMappings.Add(new ItemMapping("Week", DataPointMember.XValue));
          sm2.ItemMappings.Add(new ItemMapping("Volume", DataPointMember.YValue));
          SeriesMapping sm3 = new SeriesMapping();
          StackedBarSeriesDefinition d3 = new StackedBarSeriesDefinition();
          // d1.StackGroupName = "Stack1";
          sm3.SeriesDefinition = d3;
          sm3.LegendLabel = "Stacked Bar 3";
          // sm1.CollectionIndex = 0;
          sm3.ItemMappings.Add(new ItemMapping("Week", DataPointMember.XValue));
          sm3.ItemMappings.Add(new ItemMapping("Volume", DataPointMember.YValue));
          SeriesMapping sm4 = new SeriesMapping();
          StackedBarSeriesDefinition d4 = new StackedBarSeriesDefinition();
          // d1.StackGroupName = "Stack1";
          sm4.SeriesDefinition = d4;
          sm4.LegendLabel = "Stacked Bar 5";
          // sm1.CollectionIndex = 0;
          sm4.ItemMappings.Add(new ItemMapping("Week", DataPointMember.XValue));
          sm4.ItemMappings.Add(new ItemMapping("Volume", DataPointMember.YValue));
          SeriesMapping sm5 = new SeriesMapping();
          StackedBarSeriesDefinition d5 = new StackedBarSeriesDefinition();
          // d1.StackGroupName = "Stack1";
          sm5.SeriesDefinition = d5;
          sm5.LegendLabel = "Stacked Bar 5";
          // sm1.CollectionIndex = 0;
          sm5.ItemMappings.Add(new ItemMapping("Week", DataPointMember.XValue));
          sm5.ItemMappings.Add(new ItemMapping("Volume", DataPointMember.YValue));
          RadChart1.SeriesMappings.Add(sm1);
          RadChart1.SeriesMappings.Add(sm2);
          RadChart1.SeriesMappings.Add(sm3);
          RadChart1.SeriesMappings.Add(sm4);
          RadChart1.SeriesMappings.Add(sm5);
          RadChart1.ItemsSource = GetChartItemSource();
            
}

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 06 Oct 2010, 08:42 AM
Hello Justin,

Based on the supplied information, it is hard to determine what is causing the exceptions which you mentioned. I suspect there is an issue with the databinding of the control. In order to properly trace the issue, you can open a formal support ticket, and send us a small working project, demonstrating your setup, and showing the unwanted behavior/exception. We will debug it locally, and get back to you with more information on the matter.

Regards,
Yavor
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Justin
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or