如何将javafx条形图刻度设置为条形的中间?
我在刻度线和生成的条形图之间发现了一些间隙。
public static class ContinentBarChart extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("Numebr of reqests based on continent");
final CategoryAxis xAxis = new CategoryAxis();
//xAxis.setStyle("-fx-font-size: " + 20 + "px;");
xAxis.tickLabelFontProperty().set(Font.font(null,FontWeight.BOLD, 15));
xAxis.setTickLabelRotation(90);
final NumberAxis yAxis = new NumberAxis();
final BarChart<String, Number> chart = new BarChart<String, Number>(xAxis, yAxis);
//bc.autosize();
// bc.setBarGap(-50);
chart.setTitle("Number of reqests based on continent");
xAxis.setLabel("Country");
yAxis.setLabel("Number of requests");
HashMap<String, HashMap<String, Integer>> continentCountryMap = GenericUtil
.extractContinentCountryMapFromLogs();
for (String continent : continentCountryMap.keySet()) {
HashMap<String, Integer> exisitingCountry = continentCountryMap.get(continent);
exisitingCountry = (HashMap<String, Integer>) GenericUtil.sortByValue(exisitingCountry);
XYChart.Series series = new XYChart.Series();
series.setName(continent);
Set<String> countryList = exisitingCountry.keySet();
int i = 0;
for (String countryName : countryList) {
if (i < 10) {
series.getData().add(new XYChart.Data(countryName, exisitingCountry.get(countryName)));
i++;
} else {
break;
}
}
chart.getData().add(series);
}
Scene scene = new Scene(chart);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
如何使图表正常?我添加了解释我的要求的图像。
最佳答案
关于java - 如何将javafx条形图刻度线设置为条形图的中间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49303779/