From 3b316a28ef12310103534726c7652c23b76fe4d8 Mon Sep 17 00:00:00 2001 From: f43nd1r Date: Wed, 27 Nov 2019 04:43:39 +0100 Subject: [PATCH] fix charts api usage --- .../java/com/faendir/acra/ui/base/statistics/PieChart.java | 6 ++++-- .../java/com/faendir/acra/ui/base/statistics/TimeChart.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/acrarium/src/main/java/com/faendir/acra/ui/base/statistics/PieChart.java b/acrarium/src/main/java/com/faendir/acra/ui/base/statistics/PieChart.java index 2436e50..067b161 100644 --- a/acrarium/src/main/java/com/faendir/acra/ui/base/statistics/PieChart.java +++ b/acrarium/src/main/java/com/faendir/acra/ui/base/statistics/PieChart.java @@ -18,6 +18,7 @@ package com.faendir.acra.ui.base.statistics; import com.faendir.acra.util.LocalSettings; import com.github.appreciated.apexcharts.ApexCharts; +import com.github.appreciated.apexcharts.ApexChartsBuilder; import com.github.appreciated.apexcharts.config.builder.ChartBuilder; import com.github.appreciated.apexcharts.config.chart.Type; import org.springframework.data.util.Pair; @@ -44,11 +45,12 @@ class PieChart extends Chart { if(list.size() > MAX_PARTS) { } - ApexCharts chart = new ApexCharts() + ApexCharts chart = new ApexChartsBuilder() .withChart(ChartBuilder.get().withType(Type.pie).withBackground("transparent").build()) //.withTheme(ThemeBuilder.get().withMode(isDarkTheme() ? Mode.dark : Mode.light).build()) .withLabels(list.stream().map(Pair::getFirst).toArray(String[]::new)) - .withSeries(list.stream().map(p -> p.getSecond().doubleValue()).toArray(Double[]::new)); + .withSeries(list.stream().map(p -> p.getSecond().doubleValue()).toArray(Double[]::new)) + .build(); /*List> values = new ArrayList<>(map.entrySet()); values.sort((e1, e2) -> Long.compare(e2.getValue(), e1.getValue())); DefaultPieDataset dataset = new DefaultPieDataset(); diff --git a/acrarium/src/main/java/com/faendir/acra/ui/base/statistics/TimeChart.java b/acrarium/src/main/java/com/faendir/acra/ui/base/statistics/TimeChart.java index b91e70f..f360375 100644 --- a/acrarium/src/main/java/com/faendir/acra/ui/base/statistics/TimeChart.java +++ b/acrarium/src/main/java/com/faendir/acra/ui/base/statistics/TimeChart.java @@ -18,6 +18,7 @@ package com.faendir.acra.ui.base.statistics; import com.faendir.acra.i18n.Messages; import com.faendir.acra.util.LocalSettings; import com.github.appreciated.apexcharts.ApexCharts; +import com.github.appreciated.apexcharts.ApexChartsBuilder; import com.github.appreciated.apexcharts.config.builder.ChartBuilder; import com.github.appreciated.apexcharts.config.builder.XAxisBuilder; import com.github.appreciated.apexcharts.config.chart.Type; @@ -44,7 +45,7 @@ class TimeChart extends Chart { @Override public ApexCharts createChart(@NonNull Map map) { List> list = map.entrySet().stream().map(e -> Pair.of(e.getKey(), e.getValue())).sorted(Comparator.comparing(Pair::getFirst)).collect(Collectors.toList()); - ApexCharts chart = new ApexCharts() + ApexCharts chart = new ApexChartsBuilder() .withChart(ChartBuilder.get().withType(Type.bar).withBackground("transparent").build()) .withXaxis(XAxisBuilder.get().withType(XAxisType.datetime).build()) .withSeries(new Series<>(list.stream().map(p -> new Object[]{p.getFirst(), p.getSecond()}).toArray(Object[][]::new))) @@ -53,7 +54,8 @@ class TimeChart extends Chart { .withPalette("palette1") .withMonochrome(MonochromeBuilder.get().withColor("0x197de1").withEnabled(true).withShadeIntensity(0.1).withShadeTo(ShadeTo.light).build()) .build())*/ - .withLabels(getTranslation(Messages.REPORTS)); + .withLabels(getTranslation(Messages.REPORTS)) + .build(); /*TimeSeries series = new TimeSeries("Date"); series.add(new Day(new Date()), 0); map.forEach((date, count) -> series.addOrUpdate(new Day(date), count));