Я делаю круговую диаграмму, в которой вы видите посещаемость студентов из лекции. Лично я думал, что было бы здорово, что число присутствующих студентов всегда будет зеленым в круговой диаграмме. и причины отсутствия совсем другого оттенка красного. Есть ли способ сделать это?
Вот мой css:
.chart {
-fx-background-color: #484848;
}
.chart-legend {
-fx-background-color: transparent;
-fx-text-fill: #fff;
-fx-border-color: #333;
}
.chart-legend-item {
-fx-text-fill: #fff;
}
.default-color0.chart-pie { -fx-pie-color: green; }
.default-color1.chart-pie { -fx-pie-color: #ff0000; }
.default-color2.chart-pie { -fx-pie-color: #ce0000; }
.default-color3.chart-pie { -fx-pie-color: #a80000; }
.default-color4.chart-pie { -fx-pie-color: #870000; }
.default-color5.chart-pie { -fx-pie-color: #560000; }
.default-color6.chart-pie { -fx-pie-color: #380000; }
.default-color7.chart-pie { -fx-pie-color: #1c0000; }
.chart-pie-label-line {
-fx-stroke: #fff;
-fx-fill: #fff;
}
.chart-pie-label {
-fx-fill: #fff;
}
А вот мой Java:
private void setUpPieChart() {
this.pieChart.setLabelLineLength(8f);
this.updatePieChart();
}
private void updatePieChart() {
Lecture lecture = this.lectureTable.getSelectionModel().getSelectedItem();
if (lecture == null)
this.pieChart.getData().clear();
else
// Get all attendances of the lecture object which was obtained from the currently selected row,
// create a temporary dictionary by grouping all attendances by attendance type and their respective count,
// sort the dictionary by attendance name and generate a list of pie chart slices for each dictionary item
this.pieChart.setData(lecture.getAttendances().stream().collect(Collectors.groupingBy(Attendance::getType,
Collectors.counting())).entrySet().stream().sorted(Comparator.comparing(item -> item.getKey()
.toString())).map(item -> new PieChart.Data(String.format("%s: %.0f%%", item.getKey(),
item.getValue() * 100f / lecture.getAttendaceSize()), item.getValue()))
.collect(toCollection(FXCollections::observableArrayList)));
}
Заранее спасибо :)