Merge pull request #5855 from chimp1984/fix-dao-charts

Fix missing update of time line in dao charts
This commit is contained in:
Christoph Atteneder 2021-11-23 09:55:17 +01:00 committed by GitHub
commit 7280b66553
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 15 deletions

View File

@ -110,7 +110,6 @@ public abstract class ChartView<T extends ChartViewModel<? extends ChartDataMode
private EventHandler<MouseEvent> dividerMouseDraggedEventHandler;
private final StringProperty fromProperty = new SimpleStringProperty();
private final StringProperty toProperty = new SimpleStringProperty();
private boolean dataApplied;
///////////////////////////////////////////////////////////////////////////////////////////
@ -569,6 +568,8 @@ public abstract class ChartView<T extends ChartViewModel<? extends ChartDataMode
long ts2 = System.currentTimeMillis();
updateChartAfterDataChange();
log.debug("updateChartAfterDataChange took {}", System.currentTimeMillis() - ts2);
onDataApplied();
});
}
@ -776,21 +777,13 @@ public abstract class ChartView<T extends ChartViewModel<? extends ChartDataMode
}
protected void mapToUserThread(Runnable command) {
UserThread.execute(() -> {
command.run();
onDataApplied();
});
UserThread.execute(command);
}
// For the async handling we need to wait until we get the data applied and then still delay a bit otherwise
// the UI does not get rendered at first start
protected void onDataApplied() {
if (!dataApplied) {
dataApplied = true;
UserThread.execute(() -> {
applyTimeLineNavigationLabels();
updateTimeLinePositions();
});
// Once we have data applied we need to call initBoundsForTimelineNavigation again
if (model.upperBound.longValue() == 0) {
initBoundsForTimelineNavigation();
}
}
}

View File

@ -247,8 +247,9 @@ public abstract class ChartViewModel<T extends ChartDataModel> extends Activatab
private Tuple2<Double, Double> getMinMax(List<XYChart.Data<Number, Number>> chartData) {
long min = Long.MAX_VALUE, max = 0;
for (XYChart.Data<Number, ?> data : chartData) {
min = Math.min(data.getXValue().longValue(), min);
max = Math.max(data.getXValue().longValue(), max);
long value = data.getXValue().longValue();
min = Math.min(value, min);
max = Math.max(value, max);
}
return new Tuple2<>((double) min, (double) max);
}