Java Code Examples for javafx.scene.chart.BarChart#setData()

The following examples show how to use javafx.scene.chart.BarChart#setData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Renderer.java    From strangefx with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void renderMeasuredProbabilities(int[] results) {
    CategoryAxis xAxis = new CategoryAxis();
    NumberAxis yAxis = new NumberAxis();
    BarChart<String, Integer> barChart = new BarChart(xAxis, yAxis);
    barChart.setData(getChartData(results));
    barChart.setTitle("Measured probability distribution");
    StackPane root = new StackPane();
    root.getChildren().add(barChart);
    if (myStage != null) {
        Scene oldscene = myStage.getScene();
        VBox box = (VBox)(oldscene.getRoot());
        oldscene.setRoot(new StackPane());
        box.getChildren().add(root);
        Scene newScene = new Scene(box);
        newScene.getStylesheets().add(Main.class.getResource("/styles.css").toExternalForm());
        myStage.setScene(newScene);
    } else {
        Stage stage = new Stage();
        stage.setScene(new Scene(root, 640, 480));
        stage.show();
    }

}
 
Example 2
Source File: Main.java    From quantumjava with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void showResults(int[] results) {
    CategoryAxis xAxis = new CategoryAxis();
    NumberAxis yAxis = new NumberAxis();
    BarChart<String, Integer> barChart = new BarChart(xAxis, yAxis);
    barChart.setData(getChartData(results));
    barChart.setTitle("Classic probability distribution");
    StackPane root = new StackPane();
    root.getChildren().add(barChart);
    Stage stage = new Stage();
    stage.setTitle("Two coins, classic case");
    stage.setScene(new Scene(root, 640, 480));
    stage.show();
}
 
Example 3
Source File: MainWindow.java    From quantumjava with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    int results[] = TwoCoins.calculate(count);
    CategoryAxis xAxis = new CategoryAxis();
    NumberAxis yAxis = new NumberAxis();
    BarChart<String, Integer> barChart = new BarChart(xAxis, yAxis);
    barChart.setData(getChartData(results));
    StackPane root = new StackPane();
    root.getChildren().add(barChart);
    stage.setScene(new Scene(root, 640, 480));
    stage.show();
}