LineChart
Inhalt:
- Optimale Datenstruktur
- Beispiel: Füllen der Daten
Optimale Datenstruktur (Datenbank):
Kategorie | Y-Achse | X-Achse |
---|---|---|
Kunden | 2013 | 4500 |
Kunden | 2014 | 9500 |
Kunden | 2015 | 10850 |
... | ||
Verkäufe | 2013 | 1200 |
Verkäufe | 2014 | 8500 |
... |
Optimale Objektstruktur (Java):
public class LineChartObject { private String category; private String y_axis; private Integer x_axis; public String getCategory() { return this.category; } public void setCategory(final String category) { this.category = category; } public String getY_axis() { return this.y_axis; } public void setY_axis(final String y_axis) { this.y_axis = y_axis; } public Integer getX_axis() { return this.x_axis; } public void setX_axis(final Integer x_axis) { this.x_axis = x_axis; } }
Beispiel füllen der Daten:
//Erstellen Model und hinzufügen der Kategorien final ChartModel model = ChartModel.New() .addColumn(Column.New(Type.STRING, "year", "Jahr")) .addColumn(Column.New(Type.NUMBER, "sales", "Verkäufe")) .addColumn(Column.New(Type.NUMBER, "customer", "Kunden")); //Füllen der Items model.addRow("2013", "6500", 6500); model.addRow("2014", "4321", 4321); model.addRow("2015", "9460", 9460); model.addRow("2016", "7450", 7450); model.addRow("2013", "1500", 1500); model.addRow("2014", "2850", 2850); model.addRow("2015", "685", 685); model.addRow("2016", "4850", 4850); //Setzen des Models lineChart.setModel(model);
API und Methoden:
Properties | |
---|---|
PointShape | The shape of individual data elements: 'circle', 'triangle', 'square', 'diamond', 'star', or 'polygon'. lineChart.setPointShape(PointShape.New(PointShape.Type.CIRCLE)); For detailed informations see: https://developers.google.com/chart/interactive/docs/points |
PointSize | Diameter of displayed points in pixels. Use zero to hide all points. You can override values for individual series using the lineChart.setPointSize(5); |
PointVisible | Determines whether points will be displayed. Set to lineChart.setPointsVisible(true); |
LineDashStyle | The on-and-off pattern for dashed lines. For instance, lineChart.setLineDashStyle(Arrays.asList(4,4,4)); |
LineWidth | Data line width in pixels. Use zero to hide all lines and show only the points. You can override values for individual series using the lineChart.setLineWidth(5); |
CurveType | Controls the curve of the lines when the line width is not zero. Can be one of the following: lineChart.setCurveType(CurveType.FUNCTION); |
SelectionMode | When lineChart.setSelectionMode(SelectionMode.MULTIPLE); |
Orientation | The orientation of the chart. When set to lineChart.setOrientation(Orientation.HORIZONTAL); |
DataOpacity | The transparency of data points, with 1.0 being completely opaque and 0.0 fully transparent. lineChart.setCurveType(CurveType.FUNCTION); |
XDEV Software Corp. - One Embarcadero Center, San Francisco, CA 94111, US
Copyright © 2015. XDEV Software Corp. All rights reserved.