我已经创建了一个带有多系列的条形图,如图所示。
列表ent
有2个列表。
我需要以某种方式将xAxis值写在对角线的顶部(旋转45度)。然后为xAxis设置另一个值。
public class FunctionalRedundantController {
@FXML
private BarChart<String, Number> barchart;
@FXML
private CategoryAxis funcNameAxis;
@FXML
private NumberAxis yAxis;
private ObservableList<String> funcNames = FXCollections
.observableArrayList();
private DataConstructor dc = new DataConstructor();
@FXML
private void initialize() {
funcNameAxis.setLabel("Name of Functions");
funcNameAxis.tickLabelFontProperty().set(Font.font(10));
yAxis.setLabel("Redundant");
}
public void setfunctionalredundant() {
XYChart.Series<String, Number> series = new XYChart.Series<>();
XYChart.Series<String, Number> series2 = new XYChart.Series<>();
int green = 0;
int yellow = 0;
List<String> compGreen = new ArrayList<String>();
List<String> compyellow = new ArrayList<String>();
for (List<String> ent : dc.getFuncTypeOrg().values()) {
if (ent.size() > 10) {
for (int k = 0; k < ent.size(); k++) {
if (ent.get(k).equals("hasType")) {
if (ent.get(k+1).equals("Green")) {
series.getData().add(
new XYChart.Data<String, Number>(ent.get(k-2), 1));
}
else if(ent.get(k+1).equals("yellow")){
series2.getData().add(
new XYChart.Data<String, Number>(ent.get(k-2), 1));
}
}
}
}
}
barchart.getYAxis().setVisible(false);
barchart.getYAxis().setOpacity(0);
barchart.getData().addAll(series, series2);
barchart.setBarGap(1);
barchart.setCategoryGap(20);
}
}