java - 如何获取栏顶部的数字
问题描述
我用 javafx 和条形图编写了一个代码,我使用了一个 CCS 样式类,一切正常,我的问题是我是否可以在 CCs 文件中的条形顶部显示数字,或者我应该编写代码,如果可以,如何我能做到。有人能帮我吗。这是我在舞台上的代码
public void start(Stage _stage) {
try {
_stage.setTitle(" Chart bar");
final CategoryAxis xAxis = new CategoryAxis();
xAxis.setLabel("field");
final NumberAxis yAxis = new NumberAxis();
yAxis.setLabel("Output Value");
final BarChart<String, Number> bc = new BarChart<String, Number>(xAxis, yAxis);
bc.setAnimated(false);
bc.setAlternativeColumnFillVisible(false);
bc.setAlternativeRowFillVisible(false);
bc.setCache(false);
bc.setTitle(" values");
bc.setBarGap(1);
bc.setCategoryGap(1);
XYChart.Series serie = new XYChart.Series();
serie.setName("field value");
for (int i = 2; i < data.length-2; ++i) {
data[i] = 0;
serie.getData().add(i-2, new XYChart.Data(fieldName[i-2], data[i]));
}
bc.getData().addAll(serie);
_stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent we) {
Platform.setImplicitExit(false);
Platform.exit();
quitRequest = true;
}
});
Scene scene = new Scene(bc, 800, 400);
_stage.setScene(scene);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
_stage.show();
解决方案
推荐阅读
- react-native - nom galio-framework 缺少 ./fonts/galio.ttf
- php - PHP“重命名”找不到文件,但命令行“less”可以
- delphi - 为什么变量记录报告的大小应该更大?
- c++ - 通过引用调用`constexpr`成员函数-clang vs gcc
- linux - 有没有办法重命名硬盘中的多个文件?
- connection - 我在 Virtual Box 下的 windows 10 虚拟机失去了互联网连接
- apache-spark - Databricks 连接失败,方案没有文件系统:abfss
- jenkins - 詹金斯在奴隶中建立了一份工作,他们有符合我工作要求的最佳要求
- reactjs - 当 Reactjs 有功能组件作为父组件和子组件作为类时
- javascript - 解构赋值 vs array.map