Inhalt:
...
Code Block |
---|
language | java |
---|
theme | Eclipse |
---|
firstline | 1 |
---|
linenumbers | true |
---|
|
//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
areaChart.setModel(model); |
API und Methoden:
Füllen und Definieren der Kategorien
Code Block |
---|
language | java |
---|
theme | Eclipse |
---|
firstline | 1 |
---|
title | model.addCategory(String value); |
---|
linenumbers | true |
---|
|
final ChartModel model = ChartModel.New()
.addColumn(Column.New(Type.STRING, "year", "Jahr"))
//Parameter 1 ("2013"): definiert die Beschriftung und wird als Mapping Parameter und Gruppierung verwendet wird |
Füllen der Daten
Code Block |
---|
language | java |
---|
theme | Eclipse |
---|
firstline | 1 |
---|
title | model.addItem(String value, String value2, Integer value3) |
---|
linenumbers | true |
---|
|
model.addRow("2013", "7450", 7450);
//Parameter 1 ("2013"): Wert, welchen in der X-Achse angezeigt werden soll
//Parameter 2 ("6358"): Zuweisung zur jeweiligen vorher festgelegten Kategorie (Kategoriemapping)
//Parameter 3 (7450): Wert für die Y-Achse. Zulässige Datentypen: Integer, Double |
Anchor |
---|
Sizing | Sizing | Positionierung und GrößeKonfiguration Linien und Punkte...
Properties |
|
---|
PointShape | The shape of individual data elements: 'circle', 'triangle', 'square', 'diamond', 'star', or 'polygon'. |
...
final ChartArea area = new ChartArea();
area.setHeigth("100"); //Höhe des Pie
area.setWidth("100"); //Breite des Pie
area.setLeft("100"); //Abstand des Pie von Links in Pixel
area.setRight("100"); //Abstand des Pie von Links in Pixel
area.setTop("100"); //Abstand des Pie von Links in Pixel
areaChart.setChartArea(area);
...
this.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 series property. If you're using a trendline, the pointSize option will affect the width of the trendline unless you override it with the trendlines.n.pointsize option. |
...
//Konfiguration der Punkte
areaChart.setPointShape("circle"); //Form der Punkte. Mögliche Werte: Options.POINTSHAPE_CIRCLE, Options.POINTSHAPE_DIAMOND, Options.POINTSHAPE_POLYGON, Options.POINTSHAPE_SQUARE, Options.POINTSHAPE_STAR, Options.POINTSHAPE_TRIANGLE
areaChart.setPointSize(10); //Größe der Punkte in Pixel
//Konfiguration der Linien
List<Integer> places = Arrays.asList(4,4); //Strichformatierung: Bsp: 4,4 --> 4xMinus 4xLeer Bsp: 4,1,5 --> 4xMinus 4xLeer 5xMinus 4xMinus 4xLeer 5xMinus usw.,
areaChart.setLineDashStyle(places);
areaChart.setLineWidth(5); //Setzen der Linienbreite
areaChart.setCurveType("function"); //Geschwungene Linien ("function") oder gerade Striche ("none")
this.lineChart.setPointSize(5); |
|
LineDashStyle | The on-and-off pattern for dashed lines. For instance, [4, 4] will repeat 4-length dashes followed by 4-length gaps, and [5, 1, 3] will repeat a 5-length dash, a 1-length gap, a 3-length dash, a 5-length gap, a 1-length dash, and a 3-length gap. See Dashed Lines for more information. |
...
this.lineChart.setLineDashStyle(Arrays.asList( |
|
...
|
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 series property. |
...
areaChart.setLegend(...); //Siehe API Allgemein "LegendOptions"
areaChart.setTitleTextStyle(...); //Siehe API Allgemein "TextStyle"
areaChart.setFontName(""); //Wahl der Schriftart (Schriftart muss vom Browser unterstützt werden)
areaChart.setFontSize(15); //Setzen allgemeine Schriftgröße im Chart
areaChart.setTitle("Sales Overview"); //Setzen ChartTitel
...
this.lineChart.setLineWidth(5); |
|
CurveType | Controls the curve of the lines when the line width is not zero. Can be one of the following: |
...
this.lineChart.setCurveType(CurveType.FUNCTION); |
|