我正在尝试从结果集中加载数据,但是当显示图表时,某些条形会丢失。
以下是我的代码:
ResultSet rs = ps.executeQuery();
XYChart.Series<String, Double> series = new XYChart.Series<>();
while (rs.next()) {
String name = rs.getString(1);
Double no = rs.getDouble(2);
series.getData().add(new XYChart.Data<>(name, no));
barchart1.getData().add(series);
}
您必须为每个行数据创建一个新系列,
ResultSet rs = ps.executeQuery();
while (rs.next()) {
String name = rs.getString(1);
Double no = rs.getDouble(2);
XYChart.Series<String, Double> series = new XYChart.Series<>();
series.getData().add(new XYChart.Data<>(name, no));
barchart1.getData().add(new XYChart.Data<>);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句