javafxシーンビルダーで正しく初期化された棒グラフがあります。
私のコントローラーのコードは次のとおりです。
@FXML
private BarChart<String, Integer> barChart;
@FXML
private CategoryAxis xAxis;
@FXML
private NumberAxis yAxis;
private XYChart.Series<String, Integer> series1;
/**
* Initializes the controller class. automatically called after the fxml file has been loaded.
*/
@FXML
private void initialize() {
series1 = new XYChart.Series();
series1.setName("myname");
series1.getData().add(new Data<String, Integer>("", 100));
barChart.getData().addAll(series1);
}
Task<Integer> task = new Task<Integer>() {
@Override
protected Integer call() throws Exception {
/* now I have to update my barchart. I tried to write few lines like this
but I'm not be able to update the values of the series1 in my barchart:
series = new XYChart.Series();
int newValue = 50;
series.getData().add(new XYChart.Data("", newValue));
barChart.getData().set(0, series);
*/
return null;
}
};
}
upd: バックグラウンドで実行され、正常に動作するタスク関数。唯一の問題は、シリーズの新しい値を再設定するコードだと思います