use of com.github.drbookings.model.NightlyRateView in project drbookings by DrBookings.
the class NightlyRateChartViewController method doChart.
protected void doChart(final List<? extends BookingEntry> allElements) {
if (logger.isDebugEnabled()) {
logger.debug("Drawing chart");
}
chartSeries.clear();
seriesMap.clear();
final NightlyRateView view = new NightlyRateView(allElements);
view.setBinSize(getBinSize());
view.setBinType(toggle.getSelectionModel().getSelectedItem());
for (final Map.Entry<BookingOrigin, Map<LocalDate, Collection<Number>>> e : view.getData().entrySet()) {
XYChart.Series<String, Number> series = seriesMap.get(e.getKey());
if (series == null) {
series = new XYChart.Series<>(e.getKey().getName(), FXCollections.observableArrayList());
if (logger.isDebugEnabled()) {
logger.debug("Adding new series " + series);
}
seriesMap.put(e.getKey(), series);
chartSeries.add(series);
}
for (final Map.Entry<LocalDate, Collection<Number>> e2 : e.getValue().entrySet()) {
series.getData().add(new XYChart.Data<>(e2.getKey().toString(), e2.getValue().stream().mapToDouble(Number::doubleValue).average().getAsDouble()));
}
// checkNoData(series);
}
}
Aggregations