use of name.abuchen.portfolio.ui.views.dataseries.DataSeries in project portfolio by buchen.
the class PerformanceHeatmapWidget method fillTable.
private void fillTable() {
// fill the table lines according to the supplied period
// calculate the performance with a temporary reporting period
// calculate the color interpolated between red and green with yellow as
// the median
Interval interval = get(ReportingPeriodConfig.class).getReportingPeriod().toInterval();
DoubleFunction<Color> coloring = buildColorFunction();
addHeaderRow();
DataSeries dataSeries = get(DataSeriesConfig.class).getDataSeries();
// adapt interval to include the first and last month fully
Interval calcInterval = Interval.of(interval.getStart().getDayOfMonth() == interval.getStart().lengthOfMonth() ? interval.getStart() : interval.getStart().withDayOfMonth(1).minusDays(1), interval.getEnd().withDayOfMonth(interval.getEnd().lengthOfMonth()));
PerformanceIndex performanceIndex = getDashboardData().calculate(dataSeries, new ReportingPeriod.FromXtoY(calcInterval));
Interval actualInterval = performanceIndex.getActualInterval();
for (Integer year : actualInterval.iterYears()) {
// year
Cell cell = new Cell(table, () -> {
int numColumns = getDashboardData().getDashboard().getColumns().size();
return numColumns > 2 ? String.valueOf(year % 100) : String.valueOf(year);
});
GridDataFactory.fillDefaults().grab(true, false).applyTo(cell);
// monthly data
for (LocalDate month = LocalDate.of(year, 1, 1); month.getYear() == year; month = month.plusMonths(1)) {
if (actualInterval.contains(month)) {
cell = createCell(performanceIndex, month, coloring);
InfoToolTip.attach(cell, Messages.PerformanceHeatmapToolTip);
} else {
// $NON-NLS-1$
cell = new Cell(table, () -> "");
}
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(cell);
}
}
table.layout(true);
}
use of name.abuchen.portfolio.ui.views.dataseries.DataSeries in project portfolio by buchen.
the class ChartWidget method update.
@Override
public void update() {
title.setText(getWidget().getLabel());
try {
chart.suspendUpdate(true);
chart.getTitle().setText(title.getText());
for (ISeries s : chart.getSeriesSet().getSeries()) chart.getSeriesSet().deleteSeries(s.getId());
List<DataSeries> series = new DataSeriesSerializer().fromString(dataSeriesSet, get(ChartConfig.class).getData());
ReportingPeriod reportingPeriod = get(ReportingPeriodConfig.class).getReportingPeriod();
switch(useCase) {
case STATEMENT_OF_ASSETS:
buildAssetSeries(series, reportingPeriod);
break;
case PERFORMANCE:
buildPerformanceSeries(series, reportingPeriod);
break;
case RETURN_VOLATILITY:
throw new UnsupportedOperationException();
default:
throw new IllegalArgumentException();
}
chart.adjustRange();
} finally {
chart.suspendUpdate(false);
}
chart.redraw();
}
use of name.abuchen.portfolio.ui.views.dataseries.DataSeries in project portfolio by buchen.
the class DataSeriesConfig method doAddSeries.
private void doAddSeries(boolean showOnlyBenchmark) {
List<DataSeries> list = delegate.getDashboardData().getDataSeriesSet().getAvailableSeries().stream().filter(ds -> ds.isBenchmark() == showOnlyBenchmark).collect(Collectors.toList());
ListSelectionDialog dialog = new ListSelectionDialog(Display.getDefault().getActiveShell(), new DataSeriesLabelProvider());
dialog.setTitle(Messages.ChartSeriesPickerTitle);
dialog.setMessage(Messages.ChartSeriesPickerTitle);
dialog.setElements(list);
dialog.setMultiSelection(false);
if (dialog.open() != ListSelectionDialog.OK)
return;
Object[] result = dialog.getResult();
if (result == null || result.length == 0)
return;
dataSeries = (DataSeries) result[0];
delegate.getWidget().getConfiguration().put(Dashboard.Config.DATA_SERIES.name(), dataSeries.getUUID());
// construct label to indicate the data series (user can manually change
// the label later)
// $NON-NLS-1$
String label = WidgetFactory.valueOf(delegate.getWidget().getType()).getLabel() + ", " + dataSeries.getLabel();
delegate.getWidget().setLabel(label);
delegate.getClient().markDirty();
}
Aggregations