JavaFX + 如何获取图表绘图部分的长度和高度?
JavaFX + How to get the length and height of the chart plot section?
谁能告诉我如何找到 JavaFX 图表中可见绘图部分的长度和高度(比如 LineChart
)。
换句话说,我想找到轴 lowerBound 和 upperBound 之间的长度(以像素为单位)。
请参考以下截图。
谢谢。
假设你的坐标轴是 ValueAxis
的实例,你可以这样做:
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 ;
谁能告诉我如何找到 JavaFX 图表中可见绘图部分的长度和高度(比如 LineChart
)。
换句话说,我想找到轴 lowerBound 和 upperBound 之间的长度(以像素为单位)。
请参考以下截图。
谢谢。
假设你的坐标轴是 ValueAxis
的实例,你可以这样做:
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 ;