package vue.simulation; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.chart.Axis; import javafx.scene.chart.BarChart; import javafx.scene.chart.CategoryAxis; import javafx.scene.chart.NumberAxis; import javafx.scene.chart.XYChart; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class SimHistogramme extends Pane{ private Pane p; // public SimHistogramme() { // super(); // } public static void setHist(int[] tabdegat ,int[] tabmort, float degat_moyen ,float mort_moyen,Pane p) { Axis xAxis = new CategoryAxis(); xAxis.setLabel("nbr mort"); NumberAxis yAxis = new NumberAxis(); yAxis.setLabel("pourcentage"); Axis xAxis2 = new CategoryAxis(); xAxis2.setLabel("nbr degat"); javafx.scene.chart.NumberAxis yAxis2 = new NumberAxis(); yAxis2.setLabel("pourcentage"); // Create a BarChart BarChart barChart = new BarChart(xAxis, yAxis); BarChart barChart2 = new BarChart(xAxis2, yAxis2); // Series 1 - Data of 2014 XYChart.Series dataSeries1 = new XYChart.Series(); //dataSeries1.setName("mort moyen : "+mort_moyen); for(int i=0;i(""+i , tabmort[i]/100)); } } //barChart.getData().add(dataSeries1); // Series 1 - Data of 2014 XYChart.Series dataSeries2 = new XYChart.Series(); //dataSeries2.setName("degat moyen : "+degat_moyen); for(int i=0;i(""+i , tabdegat[i]/100)); } } barChart.getData().add(dataSeries1); barChart2.getData().add(dataSeries2); VBox vbox = new VBox(); vbox.getChildren().add(barChart); vbox.getChildren().add(barChart2); barChart.maxWidthProperty().bind(p.widthProperty()); barChart2.maxWidthProperty().bind(p.widthProperty()); barChart2.prefHeight(150); barChart.prefHeight(150); barChart.lookupAll(".default-color0.chart-bar") .forEach(n -> n.setStyle("-fx-bar-fill: red;")); barChart2.lookupAll(".default-color0.chart-bar") .forEach(n -> n.setStyle("-fx-bar-fill: green;")); barChart.setMaxHeight(220); barChart2.setMaxHeight(220); barChart.prefHeight(200); barChart.setLegendVisible(false); barChart2.setLegendVisible(false); barChart.setTitle("nbr mort moyen : "+mort_moyen); barChart2.setTitle("nbr degat moyen : "+degat_moyen); barChart2.prefHeight(200); VBox.setVgrow(barChart, Priority.ALWAYS); VBox.setVgrow(barChart2, Priority.ALWAYS); //vbox.setSpacing(10); p.getChildren().add(vbox); } //BarChart barChart = new BarChart(xAxis, yAxis); }