fix charts api usage

This commit is contained in:
f43nd1r 2019-11-27 04:43:39 +01:00
parent 435d0885be
commit 3b316a28ef
2 changed files with 8 additions and 4 deletions

View file

@ -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<String> {
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<Map.Entry<String, Long>> values = new ArrayList<>(map.entrySet());
values.sort((e1, e2) -> Long.compare(e2.getValue(), e1.getValue()));
DefaultPieDataset dataset = new DefaultPieDataset();

View file

@ -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<Date> {
@Override
public ApexCharts createChart(@NonNull Map<Date, Long> map) {
List<Pair<Date, Long>> 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<Date> {
.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));