Java tutorial
import java.util.Arrays; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.chart.CategoryAxis; import javafx.scene.chart.NumberAxis; import javafx.scene.chart.StackedBarChart; import javafx.scene.chart.XYChart; import javafx.stage.Stage; public class Main extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { Group root = new Group(); final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Month"); xAxis.setCategories( FXCollections.<String>observableArrayList(Arrays.asList("January", "February", "March"))); yAxis.setLabel("Value"); final StackedBarChart<String, Number> stackedBarChart = new StackedBarChart<String, Number>(xAxis, yAxis); stackedBarChart.setTitle("StackedBarChart"); XYChart.Series<String, Number> series1 = new XYChart.Series(); series1.setName("XYChart.Series 1"); series1.getData().add(new XYChart.Data("January", 100)); series1.getData().add(new XYChart.Data("February", 200)); series1.getData().add(new XYChart.Data("March", 50)); XYChart.Series<String, Number> series2 = new XYChart.Series(); series2.setName("XYChart.Series 2"); series2.getData().add(new XYChart.Data("January", 150)); series2.getData().add(new XYChart.Data("February", 100)); series2.getData().add(new XYChart.Data("March", 60)); stackedBarChart.getData().addAll(series1, series2); root.getChildren().addAll(stackedBarChart); primaryStage.setScene(new Scene(root, 500, 400)); primaryStage.show(); } }