Sai Dandem
Sai Dandem

Reputation: 9959

JavaFX + How to get the length and height of the chart plot section?

Can anyone let me know how I can find the length and height of the visible plot section in JavaFX charts (say LineChart).

In other words, I want to find the length(in px) between axis lowerBound and upperBound.

Please refer to the below screenshot.

Thanks.

Refer to Screenshot

Upvotes: 0

Views: 686

Answers (1)

James_D
James_D

Reputation: 209358

Assuming your axes are instances of ValueAxis, you can do:

double xMin = xAxis.getDisplayPosition(xAxis.getLowerBound());
double xMax = xAxis.getDisplayPosition(xAxis.getUpperBound());
double width = xMax - xMin ;

double yMin = yAxis.getDisplayPosition(yAxis.getUpperBound());
double yMax = yAxis.getDisplayPosition(yAxis.getLowerBound());
double height = yMax - yMin ;

Upvotes: 4

Related Questions