JavaFx PieChart:控件大小 [英] JavaFx PieChart: control size

查看:413
本文介绍了JavaFx PieChart:控件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我是JavaFX的新手。)

(I'm new to JavaFX.)

我正在调整在JavaFX中开发的应用程序,该应用程序使用大量彼此相邻的饼图,所有这些都是相同的孩子 HBox

I'm adjusting an application developed in JavaFX that uses lots of pie charts depicted next to each other, all as children of the same HBox.

图表的类别数量不一样,并且由于某种原因,其中一些图表变得比其他图书更大。

The charts don't have the same number of categories, and for some reason some of them become bigger than others.

有没有办法控制它们的半径?我希望所有这些都具有相同的半径以实现一致性。

Is there any way to control their radii? I would prefer all of them to have the same radius for some uniformity.

推荐答案

虽然没有公共API可以直接控制PieChart的半径,但您可以使用区域

Though there is no public API to directly control the radius of the PieChart, but you can control it using the different public methods of Region.

饼图半径取决于封闭区域的高度和宽度。标签不存在时的半径由PieChart中的以下代码段控制。

The pie-radius depends on the Height and Width of the enclosing region. The radius when labels are absent is controlled by the following piece of code inside PieChart.

// Code from PieChart.java
if(!shouldShowLabels) {
     pieRadius = Math.min(contentWidth,contentHeight) / 2;
}

所以你可以使用各种 width height 方法可用于控制饼图的大小。您可以使用min和max属性分别指定最小和最大区域空间。

So you can use a combination of various width and height methods available to control the size of the pie chart. You can use min and max properties to specify min and max region space respectively.

这篇关于JavaFx PieChart:控件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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