Search in sources :

Example 1 with NightlyRateView

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);
    }
}
Also used : LocalDate(java.time.LocalDate) XYChart(javafx.scene.chart.XYChart) NightlyRateView(com.github.drbookings.model.NightlyRateView) BookingOrigin(com.github.drbookings.model.data.BookingOrigin)

Aggregations

NightlyRateView (com.github.drbookings.model.NightlyRateView)1 BookingOrigin (com.github.drbookings.model.data.BookingOrigin)1 LocalDate (java.time.LocalDate)1 XYChart (javafx.scene.chart.XYChart)1