2014-10-30 3 views
0

을 기반으로 차트의 크기를 조정하는 방법 ChartA의 y 축의 크기가 (예 : chartB.yAxis = chartA.yAxis*0.5)으로 변경 될 때마다 ChartB의 y 축 높이를 수정하고 싶습니다.JavaFX 2.2

이 방법이 있습니까?

+0

높이 (픽셀 수)를 의미하거나 실제로 경계를 의미합니까? 값의 범위가 그려진다)? –

+0

@ James_D 픽셀 수입니다. – SDS

+0

chartB.prefHeightProperty(). bind (chartA.heightProperty(). 곱하기 (0.333)); \t \t chartB.minHeightProperty(). bind (chartA.heightProperty(). 곱하기 (0.333)); \t \t chartB.maxHeightProperty(). bind (chartA.heightProperty(). 곱하기 (0.333)); 위의 코드는 작동하지만 올바른 방법인지 확실하지 않습니다. – SDS

답변

0

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)로 시작하고 높이가 변경 될 때마다 표 수단 1/2의 인자에 의해 높이 속성 차트에 해당 바인딩 , chartA.heightProperty()은 차트 A의 새 높이를 제공합니다.이 값에 차트 B의 픽셀 단위로 새 높이 값을 가져 오려면이 값에 1/2 또는 0.5를 곱합니다. 차트 B의 바인드 API는이 새 높이 값을 사용하고 기본 높이 높이 및 최대 높이를 입력하십시오.

참고 : 차트 B의 높이를 정확하게 제어하는 ​​유일한 방법은 모두 prefHeightProperty, minHeightProperty 및 maxHeightProperty의 세 가지 속성 즉,

+0

답변을 편집하여 코드 작동 방식과 OP 문제를 해결하는 방법에 대한 설명을 추가하십시오. 많은 SO 포스터는 초보자이며 게시 한 코드를 이해하지 못합니다. –

관련 문제