diff --git a/src/main/java/es/kauron/estraba/controller/DashboardController.java b/src/main/java/es/kauron/estraba/controller/DashboardController.java index df4e21c..f4adbf7 100644 --- a/src/main/java/es/kauron/estraba/controller/DashboardController.java +++ b/src/main/java/es/kauron/estraba/controller/DashboardController.java @@ -45,6 +45,7 @@ import javafx.scene.Scene; import javafx.scene.chart.AreaChart; import javafx.scene.chart.LineChart; import javafx.scene.chart.PieChart; +import javafx.scene.chart.XYChart; import javafx.scene.control.Label; import javafx.scene.control.Tab; import javafx.scene.image.Image; @@ -120,7 +121,6 @@ public class DashboardController implements Initializable, MapComponentInitializ @FXML private void toggleChart(MouseEvent e) { - System.out.println("hi"); for (Node n : ((Node) e.getSource()).getParent().getChildrenUnmodifiable()) n.setVisible(!n.isVisible()); } @@ -139,21 +139,27 @@ public class DashboardController implements Initializable, MapComponentInitializ } @FXML - private void onMapButton(ActionEvent event){ - switch (((JFXButton)event.getSource()).getId()) { + private void onMapButton(ActionEvent event) { + XYChart.Series data = elevationChart.getData().get(0); + switch (((JFXButton) event.getSource()).getId()) { case "elevationButton": - mapChart.setData(elevationChart.getData()); + data = elevationChart.getData().get(0); break; case "speedButton": - mapChart.setData(speedChart.getData()); + data = speedChart.getData().get(0); break; case "hrButton": - mapChart.setData(hrChart.getData()); + data = hrChart.getData().get(0); break; case "cadenceButton": - mapChart.setData(cadenceChart.getData()); + data = cadenceChart.getData().get(0); break; } + + if (mapChart.getData().contains(data)) + mapChart.getData().remove(data); + else mapChart.getData().add(data); + } private String randomMotivation() { diff --git a/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml b/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml index 6f15eee..c050952 100644 --- a/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml +++ b/src/main/resources/es/kauron/estraba/fxml/Dashboard.fxml @@ -58,7 +58,7 @@ - + @@ -204,9 +204,11 @@ - + - +