如何确定折线图原点的像素位置? [英] How to determine pixel position of line chart origin?

查看:78
本文介绍了如何确定折线图原点的像素位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JavaFX LineChart由绘图区域和轴组成.由于轴渲染使用了一些显示空间,因此折线图中原点的位置不是(0,0).如何获得相对于折线图本身位置的位置?

A JavaFX LineChart consists of the plot area and axes. Since the axes rendering uses some display space, the position of the origin in a line chart is not (0, 0). How do I get this position relative to the position of the line chart itself?

我想相对于折线图的位置来计算绘图区域中点的位置.x轴和y轴的 getDisplayPosition 方法提供了相对于原点的相对位置,但是我没有找到一种明显的方法来获取原点位置.

I'd like to calculate the position of a point in the plot area relative to the position of the line chart. The getDisplayPosition method of the x- and y-axis provide this relative to the origin but I don't see an obvious way to get the origin position.

推荐答案

更好的观察方法是通过 chart.lookup 命令获取绘图区域,如下所示:

Much better way as observing is to get the plot-area by the chart.lookup command like this:

//gets the display region of the chart
Node chartPlotArea = chart.lookup(".chart-plot-background");
double chartZeroX = chartPlotArea.getLayoutX();
double chartZeroY = chartPlotArea.getLayoutY();

这篇关于如何确定折线图原点的像素位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆