javafx.scene.chart.StackedBarChart Java Examples

The following examples show how to use javafx.scene.chart.StackedBarChart. 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: BarCharts - MainApp.java    From Java-for-Data-Science with MIT License 5 votes vote down vote up
public void stackedGraphExample(Stage stage) {
    stage.setTitle("Stacked Bar Chart");
    final StackedBarChart<String, Number> stackedBarChart
            = new StackedBarChart<>(xAxis, yAxis);
    stackedBarChart.setTitle("Country Population");
    xAxis.setLabel("Country");
    xAxis.setCategories(FXCollections.<String>observableArrayList(
            Arrays.asList(belgium, germany, france,
                    netherlands, sweden, unitedKingdom)));
    yAxis.setLabel("Population");

    series1.setName("1950");
    addDataItem(series1, belgium, 8639369);
    addDataItem(series1, france, 42518000);
    addDataItem(series1, germany, 68374572);
    addDataItem(series1, netherlands, 10113527);
    addDataItem(series1, sweden, 7014005);
    addDataItem(series1, unitedKingdom, 50127000);

    series2.setName("1960");
    addDataItem(series2, belgium, 9118700);
    addDataItem(series2, france, 46584000);
    addDataItem(series2, germany, 72480869);
    addDataItem(series2, netherlands, 11486000);
    addDataItem(series2, sweden, 7480395);
    addDataItem(series2, unitedKingdom, 52372000);

    series3.setName("1970");
    addDataItem(series3, belgium, 9637800);
    addDataItem(series3, france, 51918000);
    addDataItem(series3, germany, 77783164);
    addDataItem(series3, netherlands, 13032335);
    addDataItem(series3, sweden, 8042803);
    addDataItem(series3, unitedKingdom, 55632000);

    Scene scene = new Scene(stackedBarChart, 800, 600);
    stackedBarChart.getData().addAll(series1, series2, series3);
    stage.setScene(scene);
    stage.show();
}
 
Example #2
Source File: ChartGenerator.java    From testgrid with Apache License 2.0 5 votes vote down vote up
/**
 * Generates the history chart with the summary of test executions.
 *
 * @param dataSet input data-set for the chart
 * @param historyChartFileName file name of the history graph
 */
public void generateResultHistoryChart(Map<String, BuildExecutionSummary> dataSet, String historyChartFileName) {

    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    final StackedBarChart<String, Number> stackedBarChart = new StackedBarChart<>(xAxis, yAxis);
    // This represents the series of values e.g: Failed, skipped, Passed
    final XYChart.Series<String, Number>[] seriesSet = new XYChart.Series[]{new XYChart.Series<>(),
            new XYChart.Series<>(), new XYChart.Series<>()};

    xAxis.setCategories(FXCollections.<String>observableArrayList(dataSet.keySet()));
    // Disabling animation
    xAxis.setAnimated(false);
    yAxis.setAnimated(false);
    stackedBarChart.setAnimated(false);
    // Set Axis Names
    xAxis.setLabel("Build date");
    yAxis.setLabel("Number of infrastructure combinations");

    // Setting series names
    seriesSet[0].setName("Test failures");
    seriesSet[1].setName("Deployment errors");
    seriesSet[2].setName("Test passed");
    // Setting space between the bars
    stackedBarChart.setCategoryGap(50);
    //Setting the title of the bar chart.
    stackedBarChart.setTitle("Test Run History");

    dataSet.forEach((key, summary) -> {
        seriesSet[0].getData().add(new XYChart.Data<>(key, summary.getFailedTestPlans()));
        seriesSet[1].getData().add(new XYChart.Data<>(key, summary.getSkippedTestPlans()));
        seriesSet[2].getData().add(new XYChart.Data<>(key, summary.getPassedTestPlans()));
    });

    // Adding the series to the chart
    for (XYChart.Series series : seriesSet) {
        stackedBarChart.getData().add(series);
    }
    genChart(stackedBarChart, 800, 800, historyChartFileName, "styles/summary.css");
}
 
Example #3
Source File: StackedBarChartBuilderService.java    From AsciidocFX with Apache License 2.0 5 votes vote down vote up
@Override
protected XYChart<String, Number> createXYChart() {
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    final XYChart<String, Number> chart = new StackedBarChart<String, Number>(xAxis, yAxis);
    chart.getStyleClass().add("chart-extension");
    return chart;
}