title: JavaFX 2.x : How to Remove XY Line Chart once plotted?
body: <p>I have a simple serie plotted on a XY Line Chart as below</p>
  
  <pre><code>public class SimpleXYLineChart extends Application {
  
  @Override
  public void start(Stage stage) {        
     stage.setTitle("Line plot");       
  
     final CategoryAxis xAxis = new CategoryAxis();
     final NumberAxis yAxis = new NumberAxis(1, 22, 0.5);
  
     yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis){
          @Override
      public String toString(Number object){
          return String.format("%7.2f", object);
      }
  });
      final LineChart&lt;String, Number&gt;lineChart = new LineChart&lt;String, Number&gt;(xAxis, yAxis);
  
      lineChart.setCreateSymbols(false);
      lineChart.setAlternativeRowFillVisible(false);
      lineChart.setLegendVisible(false);
      lineChart.setTitle("LineChart");
  
      XYChart.Series series1 = new XYChart.Series();
  
      series1.getData().add(new XYChart.Data("Jan", 1));
      series1.getData().add(new XYChart.Data("Feb", 1.5));
      series1.getData().add(new XYChart.Data("Mar", 2));
      series1.getData().add(new XYChart.Data("Apr", 2.5));
      series1.getData().add(new XYChart.Data("May", 3));
      series1.getData().add(new XYChart.Data("Jun", 4));
      series1.getData().add(new XYChart.Data("Jul", 6));
      series1.getData().add(new XYChart.Data("Aug", 9));
      series1.getData().add(new XYChart.Data("Sep", 12));
      series1.getData().add(new XYChart.Data("Oct", 15));
      series1.getData().add(new XYChart.Data("Nov", 20));
      series1.getData().add(new XYChart.Data("Dec", 22));
  
      lineChart.getData().addAll(series1);        
  
      Scene scene = new Scene(new Group(), 800, 600);
      final VBox vbox = new VBox();
      final HBox hbox = new HBox();
  
      final Button remove = new Button("Remove Series");
      remove.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
          @Override public void handle(ActionEvent e) {
      if (!lineChart.getData().isEmpty()){ 
          System.out.println("Remove Series");
          lineChart.getData().remove((lineChart.getData().size()-1),0);
          }
      }
      });                
  
      hbox.setSpacing(10);
      hbox.getChildren().addAll(remove);
  
      vbox.getChildren().addAll(lineChart, hbox);
      hbox.setPadding(new Insets(10, 10, 10, 50));
  
      ((Group)scene.getRoot()).getChildren().add(vbox);
      stage.setScene(scene);
      stage.show();
  }
  
  public static void main(String[] args) {
      launch(args);
  }   
  </code></pre>
  
  <p>}</p>
  
  <p>I would like to remove the line plotted (by clicking on a button or by flagging a checkBox) and have the empty scene as below</p>
  
  <p><img src="https://i.stack.imgur.com/eYDyT.png" alt="enter image description here"></p>
  
  <p>I do not know how to remove the Line once plotted, haven't found any .remove() or .delete() methods.</p>
  
  <p>How to accomplish this?</p>
  
  <p>Thanks</p>