Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @FXML
- private BarChart<String, Integer> barChart;
- @FXML
- private CategoryAxis xAxis;
- private ObservableList<String> dateA = FXCollections.observableArrayList();
- @FXML
- private void initialize() {
- // Get an array with the English month names.
- String[] months = DateFormatSymbols.getInstance(Locale.ENGLISH).getMonths();
- // Convert it to a list and add it to our ObservableList of months.
- dateA.addAll(Arrays.asList(months));
- // Assign the month names as categories for the horizontal axis.
- xAxis.setCategories(dateA);
- }
- /**
- *
- * @param entry
- */
- public void setEntryData(List<Entry> entry) {
- int[] monthCounter = new int[12];
- for (Entry p : entry) {
- int month = p.getDateA();
- monthCounter[month]++;
- }
- XYChart.Series<String, Integer> series = new XYChart.Series<>();
- // Create a XYChart.Data object for each month. Add it to the series.
- for (int i = 0; i < monthCounter.length; i++) {
- series.getData().add(new XYChart.Data<>(dateA.get(i), monthCounter[i]));
- }
- barChart.getData().add(series);
- }
Add Comment
Please, Sign In to add comment