Initial commit
This commit is contained in:
Binary file not shown.
@@ -15,11 +15,33 @@ import java.util.Map;
|
|||||||
@JsModule("./components/apex-chart.ts")
|
@JsModule("./components/apex-chart.ts")
|
||||||
public class ApexChart extends Component implements HasSize {
|
public class ApexChart extends Component implements HasSize {
|
||||||
|
|
||||||
|
public enum ChartType {
|
||||||
|
BAR ("bar"),
|
||||||
|
LINE ("line")
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String type;
|
||||||
|
|
||||||
|
ChartType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final JsonMapper MAPPER = JsonMapper.builder().build();
|
private static final JsonMapper MAPPER = JsonMapper.builder().build();
|
||||||
|
|
||||||
|
private final ChartType chartType;
|
||||||
|
|
||||||
|
public ApexChart(ChartType chartType) {
|
||||||
|
this.chartType = chartType;
|
||||||
|
}
|
||||||
|
|
||||||
public void setData(String seriesName, List<Double> values, List<String> categories) {
|
public void setData(String seriesName, List<Double> values, List<String> categories) {
|
||||||
Map<String, Object> options = Map.of(
|
Map<String, Object> options = Map.of(
|
||||||
"chart", Map.of("type", "bar", "height", "100%"),
|
"chart", Map.of("type", chartType.getType(), "height", "100%"),
|
||||||
"series", List.of(Map.of("name", seriesName, "data", values)),
|
"series", List.of(Map.of("name", seriesName, "data", values)),
|
||||||
"xaxis", Map.of("categories", categories)
|
"xaxis", Map.of("categories", categories)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
public class DashboardView extends VerticalLayout {
|
public class DashboardView extends VerticalLayout {
|
||||||
|
|
||||||
public DashboardView() {
|
public DashboardView() {
|
||||||
ApexChart chart = new ApexChart();
|
ApexChart chart = new ApexChart(ApexChart.ChartType.LINE);
|
||||||
chart.setWidthFull();
|
chart.setWidthFull();
|
||||||
chart.setHeight("400px");
|
chart.setHeight("400px");
|
||||||
chart.setData("Umsatz 2026",
|
chart.setData("Umsatz 2026",
|
||||||
|
|||||||
Reference in New Issue
Block a user