If I have a column of status’, how could I get a count of each status? If the table is altered via filter, I need the new counts for each status value. This will help me update charts based solely on the displayed table.
If there is a better way to update charts based solely on the items currently displayed in the table, that would help, too.
Currently, I would recommend you to add a CollectionChangeListener to your data source and generate a DataProvider containing a proper data. For example:
This isn’t working in some ways, because MapDataItem is deprecated. For instance, I can’t get the key or value from the DataItem without errors being thrown.
I tried using the code above and it worked, but I couldn’t get the rest of my pie chart functionality to work with it. Plus, because some of the recommended code will be irrelevant soon, I’m not sure if this was the best choice.
I’ve attached some files that show my current process (which works great for now), but gets the data from the database instead of the table. It also uses deprecated code. This will show you how I’m also using the chart listeners to update the table from chart interactions. When a slice is removed from the whole, the table loses the pulled out items.
The recommended code created the chart, fine, but I couldn’t create PieChartValues from the MapDatItems, and using DataItems instead of PieChartValues didn’t work either.
You’re rigth com.haulmont.charts.gui.amcharts.model.data.MapDataItem is deprecated, but in my sample I use com.haulmont.charts.gui.data.MapDataItem which is not.
Take a look at com.haulmont.charts.gui.data.EntityDataItem that probably will fit your needs. But it’s hard to guess without a sample project.