Beispiel:
Image Modified
Inhalt:
Optimale Datenstruktur (Datenbank):
Y-Achse | Kategorie | X-Achse |
---|
Beverages | 2017 | 550 |
Beverages | 2018 | 550 |
Optimale Objektstruktur (Java):
Code Block |
---|
language | java |
---|
theme | Eclipse |
---|
firstline | 1 |
---|
linenumbers | true |
---|
|
public class BarChartObject {
private String Y_Achseyvalue;
private String kategoriecategory;
private StringInteger X_Achsexvalue;
public String getY_AchsegetYvalue() {
return this.Y_Achseyvalue;
}
public void setY_AchsesetYvalue(final String y_Achseyvalue) {
this.Y_Achseyvalue = y_Achseyvalue;
}
public String getKategoriegetCategory() {
return this.kategoriecategory;
}
public void setKategoriesetCategory(final String kategoriecategory) {
this.kategoriecategory = kategoriecategory;
}
public StringInteger getX_AchsegetXvalue() {
return this.X_Achsexvalue;
}
public void setX_AchsesetXvalue(final StringInteger x_Achsexvalue) {
this.X_Achsexvalue = x_Achsexvalue;
}
} |
...
Beispiel füllen der Daten:
Code Block |
---|
language | java |
---|
theme | Eclipse |
---|
firstline | 1 |
---|
linenumbers | true |
---|
|
//Erstellen Model und hinzufügen der Kategorien
final XdevBarChartModelChartModel model = new XdevBarChartModel();model.addCategory("2017", ColumnType.NUMBER ChartModel.New()
.addColumn(Column.New(Type.STRING, "year", "Jahr"))
.addColumn(Column.New(Type.NUMBER, "iphone", "iPhone"))
.addColumn(Column.New(Type.NUMBER, "android", "Android"));
//Füllen der Items
model.addRow("2014", 1500, 1200);
model.addRow("2015", 805, 700);
model.addRow("2016", 920, 600);
model.addCategoryaddRow("20182017", ColumnType.NUMBER);, 1250, 1500);
//Setzen des Models
barChart.setModel(model); |
API und Methoden:
Properties |
|
---|
Orientation | The orientation of the chart. When set to'vertical' , rotates the axes of the chart so that (for instance) a column chart becomes a bar chart, and an area chart grows rightward instead of up: Code Block |
---|
| this.barChart.setOrientation(Orientation.VERTICAL); |
|
StackMode | The options for isStacked are: false — elements will not stack. This is the default option.true — stacks elements for all series at each domain value.'percent' — stacks elements for all series at each domain value and rescales them such that they add up to 100%, with each element's value calculated as a percentage of 100%.'relative' — stacks elements for all series at each domain value and rescales them such that they add up to 1, with each element's value calculated as a fraction of 1.'absolute' — functions the same as isStacked: true .
Code Block |
---|
| this.barChart.setStackMode(StackMode.TRUE); |
|
Konfiguration von Texten und Legenden siehe API Allgemein