Hi,
I am using StackColumn chart having two series in it. When I plot only one series, all data points show up. But when I use two series, the same series does not show all the data points.
To illustrate, I have attached the two pictures - one with only 1 series showing all 4 data points, and other picture with 2 series but now the 4th data point from the same series is missing. Please find the code also below.
myInfraChart.ChartType = ChartType.StackColumnChart; /// Series 1. When alone this series gives all data points. But together, 4th data point with value 10 is missing from the chartNumericSeries num1Series = new NumericSeries();num1Series.Points.Add(new NumericDataPoint(Convert.ToDouble(1), "B", false));num1Series.Points.Add(new NumericDataPoint(Convert.ToDouble(2), "B", false));num1Series.Points.Add(new NumericDataPoint(Convert.ToDouble(3), "B", false));num1Series.Points.Add(new NumericDataPoint(Convert.ToDouble(4), "B", false));myInfraChart.Series.Add(num1Series);
/// Series 2NumericSeries num2Series = new NumericSeries();num2Series.Points.Add(new NumericDataPoint(Convert.ToDouble(1), "A", false));num2Series.Points.Add(new NumericDataPoint(Convert.ToDouble(2), "A", false));num2Series.Points.Add(new NumericDataPoint(Convert.ToDouble(3), "A", false));myInfraChart.Series.Add(num2Series);
/// Set RangemyInfraChart.Axis.Y.RangeType = AxisRangeType.Custom;myInfraChart.Axis.Y.RangeMin = 0;myInfraChart.Axis.Y.RangeMax = 15;myInfraChart.Axis.Y.TickmarkStyle = AxisTickStyle.DataInterval;myInfraChart.Axis.Y.TickmarkInterval = 1;myInfraChart.Axis.Y.Visible = true;
Please let me know what I am missing.
Thanks.
Sorry, the legend doesn't allow you to add items in manually. However, if any of your series points doesn't have a label, it won't appear in the legend. If you want to hide the extra points, simply make sure their label is empty. Hopefully, this will help you. There is, of course, the option of manually drawing the entire legend using FillSceneGraph event, or creating your own control outside of the chart (a grid or a listview) to act as a legend.
Hi Max Rivlin,
Yes, I missed that. Thanks a lot for the answer. Incidentally I also figured out this a few minutes back and was about to post here!
On a slightly related note, is it possible to disable auto-generation of legends and add a legend collection specifying my own text and color.
The issue I am facing currently is that I have 2 series in my StackColumn chart. Now I will not get all points in the first series and also points will not come in a fixed order in the two series. So I will have to add empty data points in the first series. But since points dont come in a fixed order, the legend generated by default shows incorrect results - shows extra legend items.
If my explaination is not clear, please let me know and I will post sample code illustrating the problem.
Thanks a lot.
Stacked charts require the series to have an equal number of points. If you add a zero to the second series, you'll see all four points.