Jim
Jim

Reputation: 2064

JavaFX ScatterChart Data dont appear in the correct location

Using JavaFX within Swing, I create a JFXPAnel and a ScatterChart to the Scene.

However looking at the graph the data isn't quite right. It appears as if the icons top left corners are being drawn at the data point and not the center of the shapes.

Here is the sample data I am using. You'll notice that all of the Y values are whole integers. But when the graph is shown the icons are below the lines for that value. Is this a JavaFX bug, or could I be doing something wrong?

    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));

Upvotes: 0

Views: 134

Answers (1)

Sergey Grinev
Sergey Grinev

Reputation: 34508

You've encountered an issue http://javafx-jira.kenai.com/browse/RT-18389 which was fixed in 2.2 release.

Development preview version of 2.2 can be downloaded from here: http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html

If you need to have scatterchart work with 2.1 you can use next workaround: How can I center the dots on a scatter chart in JavaFX 2.0?

Upvotes: 1

Related Questions