Search in sources :

Example 6 with BarChart

use of javafx.scene.chart.BarChart 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 BarChart

use of javafx.scene.chart.BarChart in project dolphin-platform by canoo.

the class GraphComponent method onUpdate.

private void onUpdate() {
    getChildren().clear();
    bindings.forEach(b -> b.unbind());
    bindings.clear();
    if (metadataSubscription != null) {
        metadataSubscription.unsubscribe();
    }
    metadataSubscription = MetadataUtilities.addListenerToMetadata(data.get(), () -> {
        onUpdate();
    });
    GraphDataBean currentBean = data.get();
    if (currentBean != null) {
        if (GraphType.PIE.equals(GraphMetadata.getGraphType(data.get()))) {
            PieChart chart = new PieChart();
            bindings.add(FXBinder.bind(chart.dataProperty().get()).to(currentBean.getValues(), valueBean -> {
                PieChart.Data data = new PieChart.Data(valueBean.getName(), valueBean.getValue());
                bindings.add(FXBinder.bind(data.nameProperty()).to(valueBean.nameProperty()));
                bindings.add(FXBinder.bind(data.pieValueProperty()).to(valueBean.valueProperty()));
                return data;
            }));
            getChildren().add(chart);
        } else {
            BarChart<String, Number> barChart = new BarChart<>(new CategoryAxis(), new NumberAxis());
            XYChart.Series<String, Number> defaulSeries = new XYChart.Series<>();
            barChart.getData().add(defaulSeries);
            bindings.add(FXBinder.bind(defaulSeries.dataProperty().get()).to(currentBean.getValues(), valueBean -> {
                XYChart.Data<String, Number> data = new XYChart.Data<>(valueBean.getName(), valueBean.getValue());
                bindings.add(FXBinder.bind(data.XValueProperty()).to(valueBean.nameProperty()));
                bindings.add(FXBinder.bind(data.YValueProperty()).to(valueBean.valueProperty()));
                return data;
            }));
            getChildren().add(barChart);
        }
    }
}
Also used : Binding(com.canoo.platform.core.functional.Binding) ObjectProperty(javafx.beans.property.ObjectProperty) Subscription(com.canoo.platform.core.functional.Subscription) GraphDataBean(com.canoo.dp.impl.platform.projector.graph.GraphDataBean) MetadataUtilities(com.canoo.dp.impl.platform.projector.metadata.MetadataUtilities) GraphType(com.canoo.dp.impl.platform.projector.graph.GraphType) CategoryAxis(javafx.scene.chart.CategoryAxis) StackPane(javafx.scene.layout.StackPane) FXBinder(com.canoo.platform.remoting.client.javafx.FXBinder) BarChart(javafx.scene.chart.BarChart) XYChart(javafx.scene.chart.XYChart) GraphMetadata(com.canoo.dp.impl.platform.projector.graph.GraphMetadata) ArrayList(java.util.ArrayList) PieChart(javafx.scene.chart.PieChart) List(java.util.List) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) NumberAxis(javafx.scene.chart.NumberAxis) NumberAxis(javafx.scene.chart.NumberAxis) PieChart(javafx.scene.chart.PieChart) GraphDataBean(com.canoo.dp.impl.platform.projector.graph.GraphDataBean) CategoryAxis(javafx.scene.chart.CategoryAxis) BarChart(javafx.scene.chart.BarChart) XYChart(javafx.scene.chart.XYChart)

Example 8 with BarChart

use of javafx.scene.chart.BarChart in project jOOQ by jOOQ.

the class BarChartSample method chart.

private BarChart<String, Number> chart(TableField<CountriesRecord, ? extends Number> field, String title, String yAxisLabel) {
    CategoryAxis xAxis = new CategoryAxis();
    NumberAxis yAxis = new NumberAxis();
    xAxis.setLabel("Country");
    yAxis.setLabel(yAxisLabel);
    BarChart<String, Number> bc = new BarChart<>(xAxis, yAxis);
    bc.setTitle(title);
    bc.setUserData(field);
    return bc;
}
Also used : NumberAxis(javafx.scene.chart.NumberAxis) CategoryAxis(javafx.scene.chart.CategoryAxis) BarChart(javafx.scene.chart.BarChart)

Aggregations

BarChart (javafx.scene.chart.BarChart)8 CategoryAxis (javafx.scene.chart.CategoryAxis)6 NumberAxis (javafx.scene.chart.NumberAxis)6 XYChart (javafx.scene.chart.XYChart)6 List (java.util.List)3 Series (javafx.scene.chart.XYChart.Series)3 PedFile (com.github.lindenb.jvarkit.tools.vcfviewgui.PedFile)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 SimpleDateFormat (java.text.SimpleDateFormat)2 Collection (java.util.Collection)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 TreeMap (java.util.TreeMap)2 Collectors (java.util.stream.Collectors)2 ObservableList (javafx.collections.ObservableList)2