我想在条形图中显示每个值的类别,但似乎所有类别都显示在彼此的顶部,如下图所示
enter image description here
String query = "";
String destination = "";
try{
if(classe.isSelected()){
PreparedStatement tableToGraph = con.prepareStatement(
"SELECT libelle_classe,avg(numseance) FROM Absence JOIN Etudiant on Etudiant.id_etudiant=Absence.id_etudiantA Join Classe on Etudiant.id_classeE=Classe.id_classe Group by libelle_classe"
);
ResultSet resultSet = tableToGraph.executeQuery();
ArrayList<Double> numseance = new ArrayList<Double>();
ArrayList<String> libelle_classe = new ArrayList<String>();
while (resultSet.next()) {
libelle_classe.add(resultSet.getString(1));
numseance.add(resultSet.getDouble(2));
}
resultSet.close();
for (int i = 0; i < numseance.size(); i++) {
System.out.println(libelle_classe.get(i));
}
XYChart.Series<String, Double> dataSeries = new XYChart.Series();
/*CategoryAxis xAxis = new CategoryAxis();
xAxis.setLabel("Libelle Classe");
CategoryAxis yAxis = new CategoryAxis();
yAxis.setLabel("Avg des absences");*/
dataSeries.setName("Taux d'Absenteisme pour chaque classe");
for (int i = 0; i < numseance.size(); i++) {
dataSeries.getData().add(new XYChart.Data(libelle_classe.get(i), numseance.get(i)));
}
income_data.getData().add(dataSeries);
1条答案
按热度按时间efzxgjgh1#
您是否尝试过从
CategoryAxis
类调用setCategories
方法?