Good day,
We have a seemingly unique implementation for the XamDataChart, building charts with multiple series generically given any data and metadata.
This approach has some drawbacks, since none of the examples here can be applied directly.
I am currently struggling with implementing a stacked chart (area, column, etc.). I have tried adding StackedFragmentSeries for every group as well as using the Infragistics.GroupBy object.
The object I use for data points is as follows:
public class ChartDataPoint2DGrouped{ public string Label { get; set; } public string Colour { get; set; } public object AxisXValue { get; set; } public string AxisXValueFormatted { get; set; } public object AxisYValue { get; set; } public string AxisYValueFormatted { get; set; } public string GroupByValue { get; set; }}
I set the chart series ItemsSource property as follows where 'context' is a populated List<ChartDataPoint2DGrouped>:
chartSeries.ItemsSource = new Infragistics.GroupBy{ GroupMemberPath = "GroupByValue", KeyMemberPath = "AxisXValue", ValueMemberPath = "AxisYValue", ItemsSource = context};
No rendering of the chart occurs though - even if I set AutoGenerateSeries = true.
Am I missing something in particular?
Thanks!
Hi Key360,
There are two things that I saw that would cause issues. The first was that the collection the CategoryDateTimeXAxis was set to was not the same collection that the StackedColumnSeries was using. They need to use the same ItemsSource or it will throw off the series rendering. I updated your sample to create the GroupBy and set both the axis and the series to this GroupBy instance.
The second thing I saw was how the GroupBy was setup. The way you group the data is important. Each group that is generated is a single column. Within each group will be a bunch of automatically generated properties that will represent each stack in that column. So generally you want the GroupMemberPath to be whatever the XAxis value is. Your XAxis is a CategoryDateTimeXAxis so the GroupMemberPath should be set to the DateTime property that represents your X axis in the ChartDataPoint2DGrouped class.
You can find a modified version of your sample attached to this post. I made some comments in the code to try and explain what I did. Hopefully it makes sense.
Let me know if you have any questions on this.
Example application attached (not so hard after all)...