Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

  

Optimale Datenstruktur (Datenbank)

KategoryWert
Bverages393
Condiments507
Confections386

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);
  • No labels