Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
440
Migrate stacked bar chart from xamChart to xamDataChart
posted

I plan to migrate from xamChart to xamDataChart since xamChart is no longer supported.

It looks like it will be difficult to migrate my stacked bar chart.  The reason is that I have a dynamic set of categories I want to stack.  In xamChart I dynamically created a new data serie for each category given in the data set.  Now it seems like I have to add one column for each category in the data source dynamically.

Can you give me some hints on how to achieve this?

Will xamDataChart accept AnonymousTypes or two dimensional arrays as data source?

Parents
  • 34510
    Suggested Answer
    Offline posted

    Hi underlid,

    Please take a look at the example here: http://help.infragistics.com/NetAdvantage/WPF/2013.1/CLR4.0/?page=xamDataChart_Category_Stacked_Bar_Series.html

    The XamDataChart works best when given a flat list of objects so AnonymousTypes should work however two dimensional arrays will not.  Dynamically adding new categories is definitely possible as this just involves adding a new data point for the new category and letting the change notifications fire to update the chart.  One thing to keep in mind with a stacked series though is that each data point needs to have the value for each stack already defined.  For example, if you open the above link you will see a StackedBarSeries.  The data source for this series has 6 data points and each data point has properties for each of the stacks. 

    public class EnergyProduction
    {
        public string Country { get; set; }
        public double Nuclear { get; set; }
        public double Coal { get; set; }
        public double Oil { get; set; }
        public double Gas { get; set; }
        public double Hydro { get; set; }
    }

     

    The Country property is the category and this is what appears on the Y Axis.  The other properties in this object represent each stack block for this data point.  The main thing here is that each data point needs the same amount of properties because the chart is going to create a StackFragmentSeries for each value property.  So while dynamically adding categories is possible, it is not possible to dynamically add stacks to an individual category.

    Let me know if this doesn't make sense and I can try explaining it differently.

Reply Children
No Data