I am trying to create a dynamic stacked column series that binds to the data in view model.
Here is the sample of data I have
var ChartData = new ObservableCollection<CityData>();
public class CityData
public class CityInfo
I am trying to create a stacked column series with City names on X axis and columns with multiple stacked fragmented series by Building Type and Count
I have been investigating into the behavior you are looking to achieve in this case, and I would like you to take a look at the sample project I am attaching.
The sample project’s XamDataChart is using the “UpdatedViewModel,” as the “ViewModel” was used for an attempt to use your data structure for this, but this will not work. Your data structure appears hierarchical in nature, and there is no easy way for the StackedColumnSeries to work with this.
Instead, I would suggest that you format your data structure into a DataTable. Your columns in the DataTable in this case would be CityName and then as many BuildingTypes that you need. The values of the rows would then be the name of the city and the value of BuildingCount for the BuildingType. This would allow you to dynamically add as many BuildingTypes that you would need as well as many cities that you would need to plot. The sample project I am attaching does this and allows you to add new cities and building types dynamically.
I hope this helps you. Please let me know if you have any other questions or concerns on this matter.
The solution is great, but I was wondering if I can auto generated stackedfragmentseries and update the chart when the data in the backend updates.