Search in sources :

Example 6 with Series

use of javafx.scene.chart.XYChart.Series in project Gargoyle by callakrsos.

the class ScmCommitComposite method scmHistoryWalk.

private void scmHistoryWalk() throws SVNException {
    List<GagoyleDate> periodDaysByWeek = DateUtil.getPeriodDaysByWeek(supplier.getWeekSize());
    Collection<SVNLogEntry> allLogs = supplier.getAllLogs();
    //		supplier.createStream(allLogs);
    TreeMap<String, Long> dayOfMonths = allLogs.stream().collect(Collectors.groupingBy(v -> FxSVNHistoryDataSupplier.YYYYMMDD_EEE_PATTERN.format(v.getDate()), () -> new TreeMap<>(), Collectors.counting()));
    Map<String, Long> dayOfWeeks = new LinkedHashMap<>();
    //초기값 세팅. [중요한건 정렬순서를 유지해아하므로. 초기값을 넣어준것.]
    for (GagoyleDate d : DateUtil.getPeriodDaysByWeek()) {
        String eee = FxSVNHistoryDataSupplier.EEE_PATTERN.format(d.toDate());
        dayOfWeeks.put(eee, new Long(0));
    }
    //실제값 add
    dayOfWeeks.putAll(allLogs.stream().collect(Collectors.groupingBy(v -> FxSVNHistoryDataSupplier.EEE_PATTERN.format(v.getDate()), Collectors.counting())));
    {
        BarChart<String, Long> barChartDayOfMonth = getBarChartDayOfMonth();
        ObservableList<Data<String, Long>> convert = convert(FxSVNHistoryDataSupplier.YYYYMMDD_EEE_PATTERN, periodDaysByWeek, dayOfMonths, true);
        Series<String, Long> series = new Series<>(SERIES_LABEL, convert);
        barChartDayOfMonth.getData().add(series);
    }
    {
        LineChart<String, Long> lineChartDayOfWeek = getLineChartDayOfWeek();
        ObservableList<Data<String, Long>> convert = convert(FxSVNHistoryDataSupplier.EEE_PATTERN, DateUtil.getPeriodDaysByWeek(), dayOfWeeks, false);
        Series<String, Long> series = new Series<>(SERIES_LABEL, convert);
        lineChartDayOfWeek.getData().add(series);
    }
}
Also used : MouseButton(javafx.scene.input.MouseButton) ListView(javafx.scene.control.ListView) GagoyleDate(com.kyj.fx.voeditor.visual.framework.model.GagoyleDate) MouseEvent(javafx.scene.input.MouseEvent) LoggerFactory(org.slf4j.LoggerFactory) Series(javafx.scene.chart.XYChart.Series) SimpleDateFormat(java.text.SimpleDateFormat) XYChart(javafx.scene.chart.XYChart) LinkedHashMap(java.util.LinkedHashMap) LineChart(javafx.scene.chart.LineChart) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) FxCollectors(com.kyj.fx.voeditor.visual.util.FxCollectors) Color(javafx.scene.paint.Color) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) SVNException(org.tmatesoft.svn.core.SVNException) Data(javafx.scene.chart.XYChart.Data) Collection(java.util.Collection) Node(javafx.scene.Node) Set(java.util.Set) MasterSlaveChartComposite(com.kyj.fx.voeditor.visual.component.MasterSlaveChartComposite) BarChart(javafx.scene.chart.BarChart) Collectors(java.util.stream.Collectors) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) TreeMap(java.util.TreeMap) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ValueUtil(kyj.Fx.dao.wizard.core.util.ValueUtil) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) GagoyleDate(com.kyj.fx.voeditor.visual.framework.model.GagoyleDate) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap) Series(javafx.scene.chart.XYChart.Series) ObservableList(javafx.collections.ObservableList) BarChart(javafx.scene.chart.BarChart) LineChart(javafx.scene.chart.LineChart)

Example 7 with Series

use of javafx.scene.chart.XYChart.Series in project Gargoyle by callakrsos.

the class ScheduleTimeLineComposite method initialize.

@FXML
public void initialize() {
    Monitors.addListener(this);
    Main.addPrimaryStageCloseListener(this);
    chartTimeLine.setVerticalGridLinesVisible(false);
    ObservableList<Series<String, Number>> data = chartTimeLine.getData();
    // allJvmProcessSeries = new Series<String, Number>();
    // allJvmProcessSeries.setName("All JVM Process");
    // data.add(allJvmProcessSeries);
    passBatchProcessSeries = new Series<String, Number>();
    passBatchProcessSeries.setName("Java Process");
    data.add(passBatchProcessSeries);
    // monitorService.setOnRunning(ev ->{
    // System.err.println("running~~~~~~~~~~~~~~~~~~~");
    // });
    // monitorService.setOnScheduled(ev ->{
    // System.err.println("service schedule.....");
    // });
    monitorService = new Service<Void>() {

        @Override
        protected Task<Void> createTask() {
            return new Task<Void>() {

                @Override
                protected Void call() throws Exception {
                    Thread.sleep(1000);
                    String mmss = format.format(new Date());
                    updateMessage(mmss);
                    return null;
                }
            };
        }
    };
    monitorService.messageProperty().addListener((oba, oldval, newval) -> {
        if (newval == null || newval.isEmpty())
            return;
        ObservableList<Data<String, Number>> seriesData = passBatchProcessSeries.getData();
        Data<String, Number> e = new Data<String, Number>(newval, Monitors.getActivedJavaProcessCount());
        e.setNode(new Rectangle(1, 1));
        seriesData.add(e);
        if (seriesData.size() > CHART_SHOWING_ITEM_COUNT) {
            seriesData.remove(0);
        }
    });
    monitorService.setOnSucceeded(ev -> {
        if (running.get()) {
            monitorService.restart();
            onTickTock();
        }
    });
    monitorService.start();
}
Also used : Task(javafx.concurrent.Task) Rectangle(javafx.scene.shape.Rectangle) Data(javafx.scene.chart.XYChart.Data) Date(java.util.Date) Series(javafx.scene.chart.XYChart.Series) FXML(javafx.fxml.FXML)

Example 8 with Series

use of javafx.scene.chart.XYChart.Series in project drbookings by DrBookings.

the class ProfitChartController method flushBin.

@Override
protected void flushBin() {
    if (bin.isEmpty()) {
        return;
    }
    final Optional<LocalDate> xValue = bin.stream().map(d -> d.getDate()).max((d1, d2) -> d1.compareTo(d2));
    final Map<String, Number> yValue = new TreeMap<>();
    final double costsToCover = getCostsToCover();
    final double refColdRentLongTerm = getRefColdRentLongTerm();
    for (final DateBean d : bin) {
        for (final Entry<String, Number> e : d.getEarningsPerOrigin().entrySet()) {
            double n = yValue.getOrDefault(e.getKey(), Double.valueOf(0)).doubleValue();
            final double earnings = e.getValue().doubleValue();
            final double sizeThis = 1;
            final double sizeAll = allBookingEntries.get();
            System.err.println(sizeThis);
            System.err.println(sizeAll);
            final double percent = sizeThis / sizeAll;
            if (logger.isDebugEnabled()) {
                logger.debug("percent: " + percent);
                logger.debug("earnings: " + earnings);
                logger.debug("costsToCover: " + (costsToCover * percent));
                logger.debug("refColdRent: " + (refColdRentLongTerm * percent));
            }
            final double performance = (earnings - (costsToCover * percent) - (refColdRentLongTerm * percent));
            n += performance / bin.size();
            yValue.put(e.getKey(), n);
            System.err.println("yValue: " + yValue);
        }
    }
    for (final Entry<String, Number> e : yValue.entrySet()) {
        // System.err.println("Entry " + e);
        Series<String, Number> s = mapSeries.get(e.getKey());
        if (s == null) {
            s = new Series<>();
            s.setName(e.getKey());
            mapSeries.put(e.getKey(), s);
            chart.getData().add(s);
        }
        final XYChart.Data<String, Number> data = new XYChart.Data<>(xValue.get().toString(), e.getValue());
        categories.add(xValue.get().toString());
        s.getData().add(data);
    // System.err.println("Adding " + data);
    }
    bin.clear();
}
Also used : BookingSelectionManager(com.github.drbookings.ui.selection.BookingSelectionManager) Initializable(javafx.fxml.Initializable) Logger(org.slf4j.Logger) StackedBarChart(javafx.scene.chart.StackedBarChart) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) Series(javafx.scene.chart.XYChart.Series) Callable(java.util.concurrent.Callable) DoubleProperty(javafx.beans.property.DoubleProperty) CategoryAxis(javafx.scene.chart.CategoryAxis) XYChart(javafx.scene.chart.XYChart) DateBean(com.github.drbookings.ui.beans.DateBean) Bindings(javafx.beans.binding.Bindings) SettingsManager(com.github.drbookings.model.settings.SettingsManager) FXML(javafx.fxml.FXML) ResourceBundle(java.util.ResourceBundle) TreeMap(java.util.TreeMap) LocalDate(java.time.LocalDate) Map(java.util.Map) Entry(java.util.Map.Entry) Optional(java.util.Optional) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) NumberAxis(javafx.scene.chart.NumberAxis) TreeMap(java.util.TreeMap) LocalDate(java.time.LocalDate) DateBean(com.github.drbookings.ui.beans.DateBean) XYChart(javafx.scene.chart.XYChart)

Example 9 with Series

use of javafx.scene.chart.XYChart.Series in project drbookings by DrBookings.

the class EarningsPerDayChartViewController method flushBin.

@Override
protected void flushBin() {
    if (bin.isEmpty()) {
        return;
    }
    final LocalDate xValue = bin.stream().map(d -> d.getDate()).max((d1, d2) -> d1.compareTo(d2)).get();
    final Map<String, Number> yValue = new TreeMap<>();
    final int dayCnt = bin.stream().map(d -> d.getDate()).collect(Collectors.toSet()).size();
    for (final BookingEntry d : bin) {
        final String originName = d.getElement().getBookingOrigin().getName();
        Number n = yValue.getOrDefault(originName, 0);
        n = n.doubleValue() + d.getEarnings(SettingsManager.getInstance().isShowNetEarnings());
        yValue.put(originName, n);
    }
    for (final Entry<String, Number> e : yValue.entrySet()) {
        Series<String, Number> s = mapSeries.get(e.getKey());
        if (s == null) {
            s = new Series<>();
            s.setName(e.getKey());
            mapSeries.put(e.getKey(), s);
            chart.getData().add(s);
        }
        Number value = e.getValue();
        if (BinType.MEAN.equals(toggle.getSelectionModel().getSelectedItem())) {
            if (dayCnt < 1) {
                if (logger.isWarnEnabled()) {
                    logger.warn("Invalid data, day cnt: " + dayCnt + " for " + bin.stream().map(d -> d.getDate()).collect(Collectors.toSet()));
                }
            }
            value = value.doubleValue() / dayCnt;
        }
        final XYChart.Data<String, Number> data = new XYChart.Data<>(xValue.toString(), value);
        categories.add(xValue.toString());
        s.getData().add(data);
    }
    if (logger.isDebugEnabled()) {
        logger.debug(xValue + ": " + yValue);
    }
    bin.clear();
}
Also used : BookingSelectionManager(com.github.drbookings.ui.selection.BookingSelectionManager) Initializable(javafx.fxml.Initializable) java.util(java.util) URL(java.net.URL) Series(javafx.scene.chart.XYChart.Series) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) BinType(com.github.drbookings.model.BinType) Callable(java.util.concurrent.Callable) XYChart(javafx.scene.chart.XYChart) Bindings(javafx.beans.binding.Bindings) Slider(javafx.scene.control.Slider) ListChangeListener(javafx.collections.ListChangeListener) ComboBox(javafx.scene.control.ComboBox) Label(javafx.scene.control.Label) Logger(org.slf4j.Logger) CategoryAxis(javafx.scene.chart.CategoryAxis) Collectors(java.util.stream.Collectors) SettingsManager(com.github.drbookings.model.settings.SettingsManager) FXML(javafx.fxml.FXML) LocalDate(java.time.LocalDate) Entry(java.util.Map.Entry) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) NumberAxis(javafx.scene.chart.NumberAxis) BookingEntry(com.github.drbookings.ui.BookingEntry) ChangeListener(javafx.beans.value.ChangeListener) ExceptionUnknownType(net.sf.kerner.utils.exception.ExceptionUnknownType) LocalDate(java.time.LocalDate) BookingEntry(com.github.drbookings.ui.BookingEntry) XYChart(javafx.scene.chart.XYChart)

Example 10 with Series

use of javafx.scene.chart.XYChart.Series in project Money-Manager by krHasan.

the class GetMoneyChart method getSourceData.

public static Series<String, Number> getSourceData(String monthName) {
    XYChart.Series<String, Number> source = new XYChart.Series<>();
    String[] allSource = new ComboboxList().getSourceListForDashboard();
    for (String sourceName : allSource) {
        if (!sourceName.equals("All")) {
            if (sourceName.equals("Carried Over Amount")) {
                String sourceShortName = getAbbreviateName(sourceName);
                double amount = longToDouble(new CarriedOver().getCOAmount(monthName));
                source.getData().add(new XYChart.Data<>(sourceShortName, amount));
            } else {
                String sourceShortName = getAbbreviateName(sourceName);
                double amount = longToDouble(new Source().getAmountBySourceFromGM(monthName, sourceName));
                source.getData().add(new XYChart.Data<>(sourceShortName, amount));
            }
        }
    }
    return source;
}
Also used : Series(javafx.scene.chart.XYChart.Series) CarriedOver(operation.CarriedOver) ComboboxList(operation.ComboboxList) XYChart(javafx.scene.chart.XYChart) Source(tab.Source)

Aggregations

Series (javafx.scene.chart.XYChart.Series)10 XYChart (javafx.scene.chart.XYChart)6 CategoryAxis (javafx.scene.chart.CategoryAxis)4 Data (javafx.scene.chart.XYChart.Data)4 Label (javafx.scene.control.Label)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 Collectors (java.util.stream.Collectors)3 ObservableList (javafx.collections.ObservableList)3 FXML (javafx.fxml.FXML)3 NumberAxis (javafx.scene.chart.NumberAxis)3 SettingsManager (com.github.drbookings.model.settings.SettingsManager)2 BookingSelectionManager (com.github.drbookings.ui.selection.BookingSelectionManager)2 MasterSlaveChartComposite (com.kyj.fx.voeditor.visual.component.MasterSlaveChartComposite)2 GagoyleDate (com.kyj.fx.voeditor.visual.framework.model.GagoyleDate)2 DateUtil (com.kyj.fx.voeditor.visual.util.DateUtil)2 FxCollectors (com.kyj.fx.voeditor.visual.util.FxCollectors)2 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)2