java - JavaFX BarChart - 主轴系列
问题描述
为什么条形图偏离其中心刻度线?为什么我不能控制栏的大小?
public class DoubleSeriesBarChart extends Application {
private BarChart<String, Number> chart;
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("BarChart Experiments");
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
this.chart = new BarChart<>(xAxis,yAxis);
this.chart.setAnimated(false);
this.chart.setBarGap(0);
this.chart.setCategoryGap(0);
XYChart.Series series1 = new XYChart.Series();
series1.setName("300");
series1.getData().add(new XYChart.Data("A1", 25601.34));
series1.getData().add(new XYChart.Data("A2", 20148.82));
XYChart.Series series2 = new XYChart.Series();
series2.setName("302.50");
series2.getData().add(new XYChart.Data("B1", 57401.85));
series2.getData().add(new XYChart.Data("B2", 41941.19));
XYChart.Series series3 = new XYChart.Series();
series3.setName("305");
series3.getData().add(new XYChart.Data("C1", 45000.65));
series3.getData().add(new XYChart.Data("C2", 44835.76));
this.chart.getData().addAll(series1, series2, series3);
VBox vbox = new VBox(this.chart);
Scene scene = new Scene(vbox, 400, 600);
primaryStage.setScene(scene);
primaryStage.setWidth(400);
primaryStage.setHeight(600);
primaryStage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
解决方案
推荐阅读
- python - 实现一个用于表示线串的类并实现一个方法 length(),它返回(任意数字)或线段的长度之和
- jmeter - 如何阻止 jmeter 在 .csv 结果文件中写入任何内容
- watson-assistant - 是否可以在 Watson Assistant 的搜索技能中返回段落.passage_text
- html - 打印屏幕的样式 div 行消失
- spring-data-rest - 如何使用 Bowman 库访问 Spring Data Rest 响应_links?
- google-apps-script - GScript 将同一文档中的多个工作表转换为单个 PDF,并将每个 PDF 发送到每个工作表上单元格 B2 中包含的电子邮件地址
- coq - Simplifying expression with lists equality
- c++ - 使用动态数组进行初始化为其索引分配的默认值是什么?
- vue.js - Kendo-Vue 隐藏列中的按钮?
- python - 使用 pip 安装 pygame 时出现错误消息