Optimale Datenstruktur (Datenbank)
Kategory | Wert |
---|---|
Bverages | 393 |
Condiments | 507 |
Confections | 386 |
Optimale Objektstruktur (Java)
public class PieChartObject { private String category; private Integer value; public String getCategory() { return this.category; } public void setCategory(final String category) { this.category = category; } public Integer getValue() { return this.value; } public void setValue(final Integer value) { this.value = value; } }
Beispiel: Füllen der Daten
final XdevPieChartModel model = new XdevPieChartModel(); model.addItem("Beverages", 393, null); model.addItem("Condimants", 507, null); model.addItem("Confections", 386, null); chart.setModel(model);
oder per Schleife aus Query-Methode:
final XdevPieChartModel model = new XdevPieChartModel(); new ProductDAO().getProductsByCategoryForChart().forEach(p -> { model.addItem(p.getCategory().getCategoryname(), (int) p.getAmount(), null); }); chart.setModel(model);