Different types of charts
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.example.views;
|
||||
|
||||
import com.example.components.ApexChart;
|
||||
import com.example.components.BarChart;
|
||||
import com.example.components.LineChart;
|
||||
import com.example.components.PieChart;
|
||||
import com.vaadin.flow.component.notification.Notification;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.router.Route;
|
||||
@@ -11,18 +13,38 @@ import java.util.List;
|
||||
public class DashboardView extends VerticalLayout {
|
||||
|
||||
public DashboardView() {
|
||||
ApexChart chart = new ApexChart(ApexChart.ChartType.LINE);
|
||||
chart.setWidthFull();
|
||||
chart.setHeight("400px");
|
||||
chart.setData("Umsatz 2026",
|
||||
LineChart lineChart = new LineChart();
|
||||
lineChart.setWidthFull();
|
||||
lineChart.setHeight("400px");
|
||||
lineChart.setData("Umsatz 2026",
|
||||
List.of(30.0, 40.0, 35.0, 50.0, 49.0, 60.0),
|
||||
List.of("Jan", "Feb", "Mär", "Apr", "Mai", "Jun"));
|
||||
|
||||
chart.addPointClickListener(e -> {
|
||||
lineChart.addPointClickListener(e -> {
|
||||
Notification.show("Serie %d, Punkt %d"
|
||||
.formatted(e.getSeriesIndex(), e.getDataPointIndex()));
|
||||
});
|
||||
|
||||
add(chart);
|
||||
BarChart barChart = new BarChart();
|
||||
barChart.setWidthFull();
|
||||
barChart.setHeight("400px");
|
||||
barChart.setData("Umsatz 2026",
|
||||
List.of(30.0, 40.0, 35.0, 50.0, 49.0, 60.0),
|
||||
List.of("Jan", "Feb", "Mär", "Apr", "Mai", "Jun"));
|
||||
barChart.addPointClickListener(e -> {
|
||||
Notification.show("Serie %d, Punkt %d"
|
||||
.formatted(e.getSeriesIndex(), e.getDataPointIndex()));
|
||||
});
|
||||
|
||||
PieChart pieChart = new PieChart();
|
||||
pieChart.setWidthFull();
|
||||
pieChart.setHeight("400px");
|
||||
pieChart.setData(
|
||||
List.of(30.0, 40.0, 35.0, 50.0),
|
||||
List.of("Nord", "Süd", "Ost", "West"));
|
||||
pieChart.addPointClickListener(e -> {
|
||||
Notification.show("Slice %d".formatted(e.getDataPointIndex()));
|
||||
});
|
||||
|
||||
add(lineChart, barChart, pieChart);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user