Search in sources :

Example 31 with NumberAxis

use of javafx.scene.chart.NumberAxis 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 32 with NumberAxis

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

NumberAxis (javafx.scene.chart.NumberAxis)32 XYChart (javafx.scene.chart.XYChart)25 CategoryAxis (javafx.scene.chart.CategoryAxis)15 StackedBarChart (javafx.scene.chart.StackedBarChart)7 BarChart (javafx.scene.chart.BarChart)6 LineChart (javafx.scene.chart.LineChart)6 ArrayList (java.util.ArrayList)5 TreeSet (java.util.TreeSet)4 Node (javafx.scene.Node)4 Path (javafx.scene.shape.Path)3 CandleData (bisq.desktop.main.market.trades.charts.CandleData)2 PedFile (com.github.lindenb.jvarkit.tools.vcfviewgui.PedFile)2 CandleData (io.bitsquare.gui.main.market.trades.charts.CandleData)2 Insets (javafx.geometry.Insets)2 Scene (javafx.scene.Scene)2 StackPane (javafx.scene.layout.StackPane)2 StringConverter (javafx.util.StringConverter)2 CandleStickChart (bisq.desktop.main.market.trades.charts.price.CandleStickChart)1 VolumeChart (bisq.desktop.main.market.trades.charts.volume.VolumeChart)1 GraphDataBean (com.canoo.dp.impl.platform.projector.graph.GraphDataBean)1