style improvements
This commit is contained in:
parent
3b316a28ef
commit
ade719ccc4
7 changed files with 35 additions and 85 deletions
|
@ -16,6 +16,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;
|
||||
|
@ -41,42 +42,20 @@ class PieChart extends Chart<String> {
|
|||
|
||||
@Override
|
||||
public ApexCharts createChart(@NonNull Map<String, Long> map) {
|
||||
List<Pair<String, Long>> list = map.entrySet().stream().map(e -> Pair.of(e.getKey(), e.getValue())).sorted(Comparator.comparing(Pair::getSecond)).collect(Collectors.toList());
|
||||
List<Pair<String, Long>> list = map.entrySet().stream()
|
||||
.map(e -> Pair.of(e.getKey(), e.getValue()))
|
||||
.sorted(Comparator.<Pair<String, Long>, Long>comparing(Pair::getSecond).reversed())
|
||||
.collect(Collectors.toList());
|
||||
if(list.size() > MAX_PARTS) {
|
||||
|
||||
List<Pair<String, Long>> replace = list.subList(MAX_PARTS, list.size());
|
||||
Pair<String, Long> other = Pair.of(getTranslation(Messages.OTHER), replace.stream().mapToLong(Pair::getSecond).sum());
|
||||
replace.clear();
|
||||
list.add(other);
|
||||
}
|
||||
ApexCharts chart = new ApexChartsBuilder()
|
||||
return ApexChartsBuilder.get()
|
||||
.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))
|
||||
.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();
|
||||
values.subList(0, Math.min(MAX_PARTS, values.size())).forEach(e -> dataset.insertValue(0, e.getKey(), e.getValue()));
|
||||
dataset.sortByValues(SortOrder.DESCENDING);
|
||||
if (values.size() > MAX_PARTS) {
|
||||
dataset.insertValue(dataset.getItemCount(), "Other", values.subList(MAX_PARTS, values.size()).stream().mapToLong(Map.Entry::getValue).sum());
|
||||
}
|
||||
JFreeChart chart = ChartFactory.createPieChart("", dataset, false, false, false);
|
||||
chart.setBackgroundPaint(null);
|
||||
PiePlot plot = (PiePlot) chart.getPlot();
|
||||
plot.setStartAngle(0);
|
||||
plot.setShadowPaint(null);
|
||||
plot.setBackgroundAlpha(0);
|
||||
plot.setOutlineVisible(false);
|
||||
plot.setLabelBackgroundPaint(null);
|
||||
plot.setLabelOutlinePaint(null);
|
||||
plot.setLabelShadowPaint(null);
|
||||
Paint foregroundColor = getForegroundColor();
|
||||
plot.setLabelPaint(foregroundColor);
|
||||
plot.setLabelFont(Statistics.LABEL_FONT);
|
||||
plot.setLabelLinkPaint(foregroundColor);
|
||||
plot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE);
|
||||
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})", NumberFormat.getNumberInstance(), new DecimalFormat("0.0%")));
|
||||
//noinspection unchecked
|
||||
((List<String>) dataset.getKeys()).forEach(key -> plot.setExplodePercent(key, 0.01));*/
|
||||
return chart;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,12 @@ 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.DataLabelsBuilder;
|
||||
import com.github.appreciated.apexcharts.config.builder.XAxisBuilder;
|
||||
import com.github.appreciated.apexcharts.config.chart.Type;
|
||||
import com.github.appreciated.apexcharts.config.chart.builder.SelectionBuilder;
|
||||
import com.github.appreciated.apexcharts.config.chart.builder.ToolbarBuilder;
|
||||
import com.github.appreciated.apexcharts.config.chart.builder.ZoomBuilder;
|
||||
import com.github.appreciated.apexcharts.config.xaxis.XAxisType;
|
||||
import com.github.appreciated.apexcharts.helper.Series;
|
||||
import org.springframework.data.util.Pair;
|
||||
|
@ -45,56 +49,18 @@ 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 ApexChartsBuilder()
|
||||
.withChart(ChartBuilder.get().withType(Type.bar).withBackground("transparent").build())
|
||||
return ApexChartsBuilder.get()
|
||||
.withChart(ChartBuilder.get()
|
||||
.withType(Type.bar)
|
||||
.withBackground("transparent")
|
||||
.withToolbar(ToolbarBuilder.get().withShow(false).build())
|
||||
.withSelection(SelectionBuilder.get().withEnabled(false).build())
|
||||
.withZoom(ZoomBuilder.get().withEnabled(false).build())
|
||||
.build())
|
||||
.withXaxis(XAxisBuilder.get().withType(XAxisType.datetime).build())
|
||||
.withSeries(new Series<>(list.stream().map(p -> new Object[]{p.getFirst(), p.getSecond()}).toArray(Object[][]::new)))
|
||||
/*.withTheme(ThemeBuilder.get()
|
||||
.withMode(isDarkTheme() ? Mode.dark : Mode.light)
|
||||
.withPalette("palette1")
|
||||
.withMonochrome(MonochromeBuilder.get().withColor("0x197de1").withEnabled(true).withShadeIntensity(0.1).withShadeTo(ShadeTo.light).build())
|
||||
.build())*/
|
||||
.withSeries(new Series<>(getTranslation(Messages.REPORTS), list.stream().map(p -> new Object[]{p.getFirst(), p.getSecond()}).toArray(Object[][]::new)))
|
||||
.withDataLabels(DataLabelsBuilder.get().withEnabled(false).build())
|
||||
.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));
|
||||
JFreeChart chart = ChartFactory.createXYBarChart("",
|
||||
"Date",
|
||||
true,
|
||||
"Reports",
|
||||
new TimeSeriesCollection(series),
|
||||
PlotOrientation.VERTICAL,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
chart.setBackgroundPaint(null);
|
||||
XYPlot plot = chart.getXYPlot();
|
||||
plot.getRangeAxis().setStandardTickUnits(new NumberTickUnitSource(true));
|
||||
plot.setBackgroundAlpha(0);
|
||||
plot.setDomainGridlinesVisible(false);
|
||||
plot.setOutlineVisible(false);
|
||||
Paint foregroundColor = getForegroundColor();
|
||||
plot.setRangeGridlinePaint(foregroundColor);
|
||||
ValueAxis domainAxis = plot.getDomainAxis();
|
||||
domainAxis.setLabelPaint(foregroundColor);
|
||||
domainAxis.setLabelFont(Statistics.LABEL_FONT);
|
||||
domainAxis.setTickLabelFont(Statistics.LABEL_FONT);
|
||||
domainAxis.setTickLabelPaint(foregroundColor);
|
||||
domainAxis.setAxisLinePaint(foregroundColor);
|
||||
domainAxis.setTickMarkPaint(foregroundColor);
|
||||
ValueAxis rangeAxis = plot.getRangeAxis();
|
||||
rangeAxis.setLabelPaint(foregroundColor);
|
||||
rangeAxis.setLabelFont(Statistics.LABEL_FONT);
|
||||
rangeAxis.setTickLabelFont(Statistics.LABEL_FONT);
|
||||
rangeAxis.setTickLabelPaint(foregroundColor);
|
||||
rangeAxis.setAxisLinePaint(foregroundColor);
|
||||
rangeAxis.setTickMarkPaint(foregroundColor);
|
||||
XYBarRenderer barRenderer = (XYBarRenderer) plot.getRenderer();
|
||||
barRenderer.setBarPainter(new StandardXYBarPainter());
|
||||
barRenderer.setSeriesPaint(0, Statistics.BLUE);
|
||||
barRenderer.setBarAlignmentFactor(0.5);
|
||||
barRenderer.setMargin(0.2);*/
|
||||
return chart;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.vaadin.flow.component.HasText;
|
|||
import com.vaadin.flow.component.HasValue;
|
||||
import com.vaadin.flow.component.Text;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.button.ButtonVariant;
|
||||
import com.vaadin.flow.component.checkbox.Checkbox;
|
||||
import com.vaadin.flow.component.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.html.Div;
|
||||
|
@ -96,7 +97,9 @@ public class Translatable<T extends Component> extends Composite<T> implements L
|
|||
|
||||
@NonNull
|
||||
public static Translatable<Button> createButton(@NonNull ComponentEventListener<ClickEvent<Button>> clickListener, @NonNull String captionId, @NonNull Object... params) {
|
||||
return create(new Button("", clickListener), captionId, params);
|
||||
Button button = new Button("", clickListener);
|
||||
button.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
return create(button, captionId, params);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -129,9 +129,9 @@ public class MainView extends ParentLayout {
|
|||
});
|
||||
layout.addToDrawer(tabs);
|
||||
DrawerToggle drawerToggle = new DrawerToggle();
|
||||
drawerToggle.setIcon(Translatable.createImage("favicon.ico", Messages.ACRARIUM));
|
||||
Translatable<Button> button = Translatable.createButton(e -> logout(), Messages.LOGOUT).with(b -> {
|
||||
b.setIcon(VaadinIcon.POWER_OFF.create());
|
||||
b.removeThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
b.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
});
|
||||
button.setPaddingRight(10, Unit.PIXEL);
|
||||
|
|
|
@ -37,7 +37,7 @@ import com.vaadin.flow.component.AttachEvent;
|
|||
import com.vaadin.flow.component.ComponentEventListener;
|
||||
import com.vaadin.flow.component.checkbox.Checkbox;
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
import com.vaadin.flow.component.html.Div;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.component.textfield.NumberField;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
|
@ -72,7 +72,7 @@ public class Overview extends VerticalLayout implements ComponentEventListener<A
|
|||
grid.addColumn(VApp::getReportCount, QReport.report.count(), Messages.REPORTS);
|
||||
grid.addOnClickNavigation(BugTab.class, VApp::getId);
|
||||
if (SecurityUtils.hasRole(User.Role.ADMIN)) {
|
||||
grid.appendFooterRow().getCell(appColumn).setComponent(new Div(Translatable.createButton(e -> {
|
||||
grid.appendFooterRow().getCell(appColumn).setComponent(new HorizontalLayout(Translatable.createButton(e -> {
|
||||
Translatable<TextField> name = Translatable.createTextField("", Messages.NAME);
|
||||
new Popup().setTitle(Messages.NEW_APP).addComponent(name).addCreateButton(popup -> {
|
||||
popup.clear().addComponent(new ConfigurationLabel(dataService.createNewApp(name.getContent().getValue()))).addCloseButton().show();
|
||||
|
|
|
@ -165,4 +165,5 @@ proguardMappings=Proguard map
|
|||
score=Punktzahl
|
||||
home=Startseite
|
||||
locale=Sprache
|
||||
settings=Einstellungen
|
||||
settings=Einstellungen
|
||||
other=Weitere
|
|
@ -167,4 +167,5 @@ proguardMappings=Proguard mappings
|
|||
score=Score
|
||||
home=Home
|
||||
locale=Language
|
||||
settings=Settings
|
||||
settings=Settings
|
||||
other=Other
|
Loading…
Reference in a new issue