PhilippeGeek PhilippeGeek - 5 months ago 33
Java Question

Remove an axis from JavaFX Chart

I've created a

XYChart
with numerical values different (for example temperatue with pressure) so I want to draw my own axeS just beside my chart. To do the following I've to unshow the YAxis, how should I do that ?

Answer

By using a trick: The Chart needs the Y Axis to remain in place so it knows where to render your content. You can, however, hide it. Hide the tick labels and set the axis' opacity to 0 using this code:

    chart.getYAxis().setTickLabelsVisible(false);
    chart.getYAxis().setOpacity(0);

The axis will still be there, but not shown.

Comments