在Swing中使用JavaFX,我为场景创建了一个JFXPAnel和一个ScatterChart。
然而,查看图表数据并不完全正确。看起来好像图标左上角是在数据点绘制的,而不是形状的中心。
以下是我正在使用的示例数据。您会注意到所有Y值都是整数。但是当显示图表时,图标位于该值的行下方。这是一个JavaFX错误,还是我做错了什么?
XYChart.Series series1 = new XYChart.Series();
series1.setName("Effects");
series1.getData().add(new XYChart.Data(4.2, 2));
series1.getData().add(new XYChart.Data(2.8, 2));
series1.getData().add(new XYChart.Data(6.2, 2));
series1.getData().add(new XYChart.Data(1, 1));
series1.getData().add(new XYChart.Data(1.2, 1));
series1.getData().add(new XYChart.Data(4.4, 1));
series1.getData().add(new XYChart.Data(8.5, 1));
series1.getData().add(new XYChart.Data(6.9, 1));
series1.getData().add(new XYChart.Data(9.9, 1));
series1.getData().add(new XYChart.Data(0.9, 1));
series1.getData().add(new XYChart.Data(3.2, 3));
series1.getData().add(new XYChart.Data(4.8, 3));
series1.getData().add(new XYChart.Data(7.3, 3));
series1.getData().add(new XYChart.Data(1.8, 3));
series1.getData().add(new XYChart.Data(7.3, 3));
series1.getData().add(new XYChart.Data(2.7, 3));
XYChart.Series series2 = new XYChart.Series();
series2.setName("Cause");
series2.getData().add(new XYChart.Data(2.4, -1));
series2.getData().add(new XYChart.Data(3.2, -1));
series2.getData().add(new XYChart.Data(1.8, -1));
series2.getData().add(new XYChart.Data(3.2, -1));
series2.getData().add(new XYChart.Data(7.4, -1));
series2.getData().add(new XYChart.Data(3.5, -2));
series2.getData().add(new XYChart.Data(9.3, -2));
series2.getData().add(new XYChart.Data(8.1, -2));
XYChart.Series series3 = new XYChart.Series();
series3.setName("Events");
series3.getData().add(new XYChart.Data(5.2, 0));
series3.getData().add(new XYChart.Data(2.9, 0));
series3.getData().add(new XYChart.Data(3.3, 0));
答案 0 :(得分:1)
您遇到了问题http://javafx-jira.kenai.com/browse/RT-18389,已在2.2版本中修复。
2.2的开发预览版可以从这里下载:http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html
如果您需要使用散点图2.1,可以使用下一个解决方法:How can I center the dots on a scatter chart in JavaFX 2.0?