title: Javafx: How to hide XYChart Node when binding == null
body: <p>I am binding a linechart to several TextFields, which contain double values  as strings, or are empty. It works fine if the Field contains a number, but unfortunatey, I get an exception when it is empty. </p>
  
  <p>I could find a way to handle "emptyness" and set it to 0.0, but actually I need to hide the node completey in this case (If "X" or "Y" Field is empty)</p>
  
  <p>Any ideas how to solve it?</p>
  
  <p>Basic Example with only one set of Textfields:</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.beans.binding.Bindings;
  import javafx.scene.Scene;
  import javafx.scene.chart.LineChart;
  import javafx.scene.chart.NumberAxis;
  import javafx.scene.chart.XYChart;
  import javafx.scene.chart.XYChart.Data;
  import javafx.scene.control.TextField;
  import javafx.scene.layout.AnchorPane;
  import javafx.stage.Stage;
  
  public class LineChartSample extends Application {
  
      @Override
      public void start(Stage stage) {
           stage.setTitle("Demo");
           final NumberAxis xAxis = new NumberAxis();
           final NumberAxis yAxis = new NumberAxis();
           xAxis.setLabel("X");
           yAxis.setLabel("Y");
           final LineChart&lt;Number, Number&gt; lineChart = new LineChart&lt;Number, Number&gt;(xAxis, yAxis);
           AnchorPane ap = new AnchorPane();
  
           lineChart.setTitle("Demo");
           XYChart.Series series = new XYChart.Series();
           AnchorPane.setTopAnchor(lineChart, 5d);
           AnchorPane.setLeftAnchor(lineChart, 5d);
           AnchorPane.setRightAnchor(lineChart, 5d);
  
           TextField t1 = new TextField("33.3");
           TextField t2 = new TextField("33.3");
  
           Data d = new XYChart.Data();
           d.XValueProperty().bind(Bindings.when(t1.textProperty().isEmpty())
                   .then(0.0) //   &lt;--  here is the problem
                   .otherwise(Bindings.createDoubleBinding(() -&gt; {
                            return Double.parseDouble(t1.getText());
                   }, t1.textProperty())));
  
            d.YValueProperty().bind(Bindings.when(t2.textProperty().isEmpty())
                   .then(0.0) //   &lt;--  here is the problem
                   .otherwise(Bindings.createDoubleBinding(() -&gt; {
                          return Double.parseDouble(t2.getText());
                    }, t2.textProperty())));
  
  
           series.getData().add(d);
  
           AnchorPane.setBottomAnchor(t1, 50d);
           AnchorPane.setLeftAnchor(t1, 5d);
  
           AnchorPane.setBottomAnchor(t2, 50d);
           AnchorPane.setRightAnchor(t2, 5d);
  
           ap.getChildren().addAll(lineChart, t1, t2);
           Scene scene = new Scene(ap, 800, 600);
           lineChart.getData().add(series);
           stage.setScene(scene);
           stage.show();
       }
  
       public static void main(String[] args) {
           launch(args);
       }
  }
  </code></pre>