Fancy Oaf
Fancy Oaf

Reputation: 41

How can I center the dots on a scatter chart in JavaFX 2.0?

When using the JavaFX 2.0 scatter chart the plotted dots are graphed with the top left corner of the dot touching the point rather than the center of the dot on the point. So rather than it looking like it is plotting at the point (1, 1) it looks more like it's at (1.1, 0.9). Does anyone know how to fix this?

Upvotes: 1

Views: 848

Answers (1)

Sergey Grinev
Sergey Grinev

Reputation: 34508

There is a bug in a way ScatterChart draws shifting plotted dots.

Until fix as a workaround you can override dots style class. To perform that add new file "style.css" to the same package with your main class and next content:

.chart-symbol { /* solid circle */
    -fx-background-color: #f9d900;
    -fx-background-radius: 5px;
    -fx-translate-x: -4px;
    -fx-translate-y: -4px;
}

In the code where your main scene is created add next line:

scene.getStylesheets().add("style.css");

Upvotes: 1

Related Questions