diff --git a/src/main/bundles/dev.bundle b/src/main/bundles/dev.bundle index 404bfd6..f8124c7 100644 Binary files a/src/main/bundles/dev.bundle and b/src/main/bundles/dev.bundle differ diff --git a/src/main/java/com/example/components/ApexChart.java b/src/main/java/com/example/components/ApexChart.java index 6290423..942b113 100644 --- a/src/main/java/com/example/components/ApexChart.java +++ b/src/main/java/com/example/components/ApexChart.java @@ -15,11 +15,33 @@ import java.util.Map; @JsModule("./components/apex-chart.ts") 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 final ChartType chartType; + + public ApexChart(ChartType chartType) { + this.chartType = chartType; + } + public void setData(String seriesName, List values, List categories) { Map 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)), "xaxis", Map.of("categories", categories) ); diff --git a/src/main/java/com/example/views/DashboardView.java b/src/main/java/com/example/views/DashboardView.java index baa5351..3c88026 100644 --- a/src/main/java/com/example/views/DashboardView.java +++ b/src/main/java/com/example/views/DashboardView.java @@ -11,7 +11,7 @@ import java.util.List; public class DashboardView extends VerticalLayout { public DashboardView() { - ApexChart chart = new ApexChart(); + ApexChart chart = new ApexChart(ApexChart.ChartType.LINE); chart.setWidthFull(); chart.setHeight("400px"); chart.setData("Umsatz 2026",