This question is locked. New answers and comments are not allowed.
Hello Community,
I am trying to plot Line and Bar chart.
Line serires gets plotted. bt, for Bar series it doesn't shows Bars.
Please, help.
My code snippet is :
I am trying to plot Line and Bar chart.
Line serires gets plotted. bt, for Bar series it doesn't shows Bars.
Please, help.
My code snippet is :
| List<List<ChartData>> chartData = new List<List<ChartData>>(); |
| ValChart.DefaultView.ChartTitle.Content = "Income Statement"; |
| ValChart.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Visible; |
| ValChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMM yyyy"; |
| ValChart.DefaultView.ChartArea.AxisX.LabelStep = 2; |
| ValChart.DefaultView.ChartArea.AxisY.AutoRange = true; |
| SeriesMapping Mapping = new SeriesMapping(); |
| BarSeriesDefinition bar = new BarSeriesDefinition(); |
| bar.ShowItemLabels = true; |
| bar.ShowItemToolTips = true; |
| Mapping.SeriesDefinition = bar; |
| Mapping.ItemMappings.Add(new ItemMapping("XValue", DataPointMember.XValue)); |
| Mapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue)); |
| Mapping.LegendLabel = lstChart[0][0].description; |
| Mapping.CollectionIndex = 0; |
| ValChart.SeriesMappings.Add(Mapping); |
| SeriesMapping ValMapping = new SeriesMapping(); |
| LineSeriesDefinition lineDefinition = new LineSeriesDefinition(); |
| lineDefinition.ShowPointMarks = true; |
| lineDefinition.ShowItemLabels = false; |
| lineDefinition.ShowItemToolTips = true; |
| ValMapping.SeriesDefinition = lineDefinition; |
| ValMapping.ItemMappings.Add(new ItemMapping("XValue", DataPointMember.XValue)); |
| ValMapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue)); |
| ValMapping.LegendLabel = lstChart[1][0].description; |
| ValMapping.CollectionIndex = 1; |
| ValChart.SeriesMappings.Add(ValMapping); |
| for (int rowcnt = 0; rowcnt < lstChart.Count; rowcnt++) |
| { |
| if (lstChart[rowcnt].ToList().Count > 1) |
| { |
| List<ChartData> lstData = new List<ChartData>(); |
| for (int i = 0; i < lstChart[rowcnt].Count; i++) |
| { |
| lstData.Add(new ChartData((DateTime)lstChart[rowcnt][i].ValDate, (double)lstChart[rowcnt][i].RatioVal)); |
| } |
| chartData.Add(lstData); |
| ValChart.ItemsSource = chartData; |
| } |
| } |