gpt4 book ai didi

javafx - 在 JavaFx 中的条下定位 xAxis 值

转载 作者:行者123 更新时间:2023-12-03 17:47:53 25 4
gpt4 key购买 nike

正如您在照片中看到的那样,我正在创建一个条形图。问题是 XAxis 上的酒吧名称都有些怎么不配了吧。
在 fxml 中刻度标签旋转设置为 -45。我怎样才能将它们准确地移动到横杆下方?
bar

public class MostComputerizedController {
@FXML
private BarChart<String, Number> barChart;
@FXML
private CategoryAxis orgNameAxis;
@FXML
private NumberAxis yAxis;
@FXML
private Label itsfField;

private ObservableList<String> orgNames = FXCollections
.observableArrayList();
private DataConstructor dc = new DataConstructor();
private int numberOfOrganizations;
private List<Double> sumOfOrgsITSF = new ArrayList<Double>();

/**
* sets the name of x axis, with the name of organizations
*/
@FXML
private void initialize() {
dc.findSortedAssignedOrg();
dc.orgFuncFuncType();
orgNames.addAll(dc.getOrgFuncFunctype().keySet());
orgNameAxis.setCategories(orgNames);

orgNameAxis.setLabel("Name of Organizations");
orgNameAxis.tickLabelFontProperty().set(Font.font(9));
yAxis.setLabel("Saturation");
numberOfOrganizations = dc.getSortedAssignedOrg().size();

}

/**
* sets organization and their saturation
*/
public void setOrgData() {
XYChart.Series<String, Number> seriesGreen = new XYChart.Series<>();
XYChart.Series<String, Number> seriesYellow = new XYChart.Series<>();
seriesGreen.setName("IT Saturation Satisfying");
seriesYellow.setName("IT Saturation not Satisfying");
for (Entry<String, List<Double>> entry : dc.getOrgFuncFunctype()
.entrySet()) {
sumOfOrgsITSF.add(entry.getValue().get(0));
if (entry.getValue().get(0) > 50) {
seriesGreen.getData().add(
new XYChart.Data<String, Number>(entry.getKey(), entry
.getValue().get(0)));
} else if ((entry.getValue().get(0) <= 50)) {
seriesYellow.getData().add(
new XYChart.Data<String, Number>(entry.getKey(), entry
.getValue().get(0)));
}

}

double value = sumOfOrgsITSF.stream().mapToDouble(Double::doubleValue)
.sum()
/ numberOfOrganizations;
itsfField.setText(String.format("%.0f", value) + "%");
barChart.setBarGap(1);
barChart.setCategoryGap(10);
barChart.getData().addAll(seriesGreen, seriesYellow);
}

最佳答案

将所有数据放在一个系列中。

series1.getData().add(new Data<Number, String>(Integer1),(Title1)));
series1.getData().add(new Data<Number, String>(Integer2),(Title2)));
series1.getData().add(new Data<Number, String>(Integer3),(Title3)));
结果:
enter image description here

关于javafx - 在 JavaFx 中的条下定位 xAxis 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29502414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com