List of usage examples for javafx.scene.chart StackedBarChart StackedBarChart
public StackedBarChart(@NamedArg("xAxis") Axis<X> xAxis, @NamedArg("yAxis") Axis<Y> yAxis)
From source file:Main.java
@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(/* ww w. j a v a 2 s . c o m*/ 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(); }
From source file:gui.accessories.GraphPopup.java
private StackedBarChart createStackedBarChart() { final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); List<Nacao> nations = new ArrayList<Nacao>(WorldFacadeCounselor.getInstance().getNacoes().values()); ComparatorFactory.getComparatorNationVictoryPointsSorter(nations); xAxis.setCategories(FXCollections.<String>observableList(getNames(nations))); //format axis yAxis.setTickUnit(200);/*from w w w . j av a2 s . c o m*/ yAxis.setLabel(labels.getString("PONTOS.VITORIA")); //xAxis.setLabel(labels.getString("NACAO")); xAxis.setTickMarkVisible(false); //Series 1 XYChart.Series<Number, String> series = new XYChart.Series(); //series1.setName("XYChart.Series 1"); for (Nacao nation : WorldFacadeCounselor.getInstance().getNacoes().values()) { final XYChart.Data data = new XYChart.Data(nation.getPontosVitoria(), nation.getNome()); series.getData().add(data); } // final StackedBarChart<Number, String> stackedBarChart = new StackedBarChart<Number, String>(yAxis, xAxis); // stackedBarChart.setTitle(labels.getString("PONTOS.VITORIA")); stackedBarChart.getData().addAll(series); stackedBarChart.setLegendVisible(false); // stackedBarChart.setCategoryGap(0.2); return stackedBarChart; }