Search in sources :

Example 16 with CategoryAxis

use of javafx.scene.chart.CategoryAxis in project jvarkit by lindenb.

the class SamFlagsChartFactory method build.

@Override
public StackedBarChart<String, Number> build() {
    final CategoryAxis xAxis = new CategoryAxis();
    xAxis.setLabel("Flags");
    final NumberAxis yAxis = new NumberAxis();
    yAxis.setLabel("Count");
    final XYChart.Series<String, Number> serie = new XYChart.Series<String, Number>();
    serie.setName("Flags");
    for (final Integer L : new TreeSet<Integer>(this.flags2count.keySet())) {
        serie.getData().add(new XYChart.Data<String, Number>(String.valueOf(L), this.flags2count.count(L)));
    }
    final StackedBarChart<String, Number> sbc = new StackedBarChart<String, Number>(xAxis, yAxis);
    sbc.setTitle("SAM Flags");
    sbc.getData().add(serie);
    sbc.setCategoryGap(0.2);
    sbc.setLegendVisible(false);
    return sbc;
}
Also used : NumberAxis(javafx.scene.chart.NumberAxis) CategoryAxis(javafx.scene.chart.CategoryAxis) TreeSet(java.util.TreeSet) StackedBarChart(javafx.scene.chart.StackedBarChart) XYChart(javafx.scene.chart.XYChart)

Example 17 with CategoryAxis

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

Aggregations

CategoryAxis (javafx.scene.chart.CategoryAxis)17 NumberAxis (javafx.scene.chart.NumberAxis)15 XYChart (javafx.scene.chart.XYChart)11 StackedBarChart (javafx.scene.chart.StackedBarChart)7 BarChart (javafx.scene.chart.BarChart)6 ArrayList (java.util.ArrayList)5 TreeSet (java.util.TreeSet)3 PedFile (com.github.lindenb.jvarkit.tools.vcfviewgui.PedFile)2 Series (javafx.scene.chart.XYChart.Series)2 GraphDataBean (com.canoo.dp.impl.platform.projector.graph.GraphDataBean)1 GraphMetadata (com.canoo.dp.impl.platform.projector.graph.GraphMetadata)1 GraphType (com.canoo.dp.impl.platform.projector.graph.GraphType)1 MetadataUtilities (com.canoo.dp.impl.platform.projector.metadata.MetadataUtilities)1 Binding (com.canoo.platform.core.functional.Binding)1 Subscription (com.canoo.platform.core.functional.Subscription)1 FXBinder (com.canoo.platform.remoting.client.javafx.FXBinder)1 BaseGoogleTrendChart (com.kyj.fx.voeditor.visual.component.chart.service.BaseGoogleTrendChart)1 JavaTextArea (com.kyj.fx.voeditor.visual.component.text.JavaTextArea)1 Location (eu.hansolo.tilesfx.tools.Location)1 TimeData (eu.hansolo.tilesfx.tools.TimeData)1