JavaFX2.2如何根据其他图表调整图表大小



每当调整图表A的y轴大小时,我都想修改图表B的y轴高度(例如:chartB.yAxis = chartA.yAxis*0.5)。

有办法做到这一点吗?

chartB.prefHeightProperty().bind(chartA.heightProperty().multiply(0.5)); chartB.minHeightProperty().bind(chartA.heightProperty().multiply(0.5)); chartB.maxHeightProperty().bind(chartA.heightProperty().multiply(0.5));

说明:从图表B的高度属性(prefHeightProperty、minHeightProperty和maxHeightProperty)开始,将其与图表A的高度属性绑定1/2倍,这意味着每当图表A的身高发生变化时,chartA.heightProperty()都会提供图表A的新高度。该值乘以1/2或0.5,得到图表B的新高度值(以像素为单位)。图表B上的绑定API将使用这个新的高度值,并在图表B上设置pref高度、最小高度和最大高度。

注意:精确控制图表B高度的唯一方法是绑定所有3个属性,即prefHeightProperty、minHeightProperty和maxHeightProperty

最新更新