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