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;
}
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);
}
}
}
Aggregations