title: scenebuilder javafx linechart
body: <p>So here's the deal, i'm trying to code a GUI that shows live data on a linechart.
  So far so good, i can get the linechart working but not into the GUI.</p>
  
  <p>Using scenebuilder, i made a view with a linechart object, in order to link it to my generated chart. But for some reason this does not seem to work with this code in my mainApp.</p>
  
  <pre><code>public void showSes() {
      try {
          // Load the fxml file and set into the center of the main layout
          FXMLLoader loader = new FXMLLoader();
          loader.setLocation(MainApp.class.getResource("view/Session.fxml"));
  
          AnchorPane Session = (AnchorPane) loader.load();
          rootLayout.setCenter(Session);
  
          SessionController controller = loader.getController();
          controller.setMainApp(this);
          controller.initGraph();
  
      } catch (IOException e) {
          // Exception gets thrown if the fxml file could not be loaded
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>This simply shows the view with an empty linechart.
  I know the chart should know however, because i can use it to create a scene, and show that into the GUI, but the view i made in scenebuilder also has some other fields i want to show...</p>
  
  <p>Does anybody have an idea?</p>
  
  <p>FXML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.text.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.chart.*?&gt;
  &lt;?import java.lang.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  
  &lt;AnchorPane prefHeight="900.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gui.view.SessionController"&gt;
     &lt;children&gt;
        &lt;Pane prefHeight="900.0" prefWidth="1280.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"&gt;
           &lt;children&gt;
              &lt;LineChart fx:id="linechart" layoutX="29.0" layoutY="194.0" prefHeight="416.0" prefWidth="1222.0" title="Temperature of session"&gt;
                &lt;xAxis&gt;
                  &lt;CategoryAxis label="Time (s)" fx:id="xAxis" /&gt;
                &lt;/xAxis&gt;
                &lt;yAxis&gt;
                  &lt;NumberAxis fx:id="yAxis" label="Temperature (Â°C)" side="LEFT" upperBound="160.0" /&gt;
                &lt;/yAxis&gt;
              &lt;/LineChart&gt;
              &lt;GridPane layoutX="254.0" layoutY="87.0" prefHeight="150.0" prefWidth="771.0"&gt;
                &lt;columnConstraints&gt;
                  &lt;ColumnConstraints hgrow="SOMETIMES" maxWidth="274.0" minWidth="10.0" prefWidth="274.0" /&gt;
                    &lt;ColumnConstraints hgrow="SOMETIMES" maxWidth="273.0" minWidth="10.0" prefWidth="273.0" /&gt;
                  &lt;ColumnConstraints hgrow="SOMETIMES" maxWidth="273.0" minWidth="10.0" prefWidth="273.0" /&gt;
                &lt;/columnConstraints&gt;
                &lt;rowConstraints&gt;
                  &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /&gt;
                &lt;/rowConstraints&gt;
                 &lt;children&gt;
                    &lt;Label prefHeight="53.0" prefWidth="153.0" text="Temperature fluid:" GridPane.halignment="CENTER" GridPane.valignment="TOP"&gt;
                       &lt;font&gt;
                          &lt;Font size="16.0" /&gt;
                       &lt;/font&gt;
                    &lt;/Label&gt;
                    &lt;Label prefHeight="52.0" prefWidth="181.0" text="Temperature vapor:" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.valignment="TOP"&gt;
                       &lt;font&gt;
                          &lt;Font size="16.0" /&gt;
                       &lt;/font&gt;
                    &lt;/Label&gt;
                    &lt;TextField fx:id="fluidT" editable="false" /&gt;
                    &lt;TextField fx:id="gasT" editable="false" GridPane.columnIndex="2" /&gt;
                 &lt;/children&gt;
              &lt;/GridPane&gt;
              &lt;Label layoutX="474.0" layoutY="14.0" text="TempTracker"&gt;
                 &lt;font&gt;
                    &lt;Font size="50.0" /&gt;
                 &lt;/font&gt;
              &lt;/Label&gt;
              &lt;TextArea editable="false" layoutX="190.0" layoutY="638.0" prefHeight="160.0" prefWidth="900.0" promptText="&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;------Warning log------- " wrapText="true" /&gt;
              &lt;Button layoutX="540.0" layoutY="808.0" mnemonicParsing="false" onAction="#handleStop" prefHeight="65.0" prefWidth="200.0" text="STOP"&gt;
                 &lt;font&gt;
                    &lt;Font size="22.0" /&gt;
                 &lt;/font&gt;
              &lt;/Button&gt;
           &lt;/children&gt;&lt;/Pane&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>CONTROLLER</p>
  
  <pre><code>    private static final int MAX_DATA_POINTS = 50;
      private String xSeriesData = "";
      private XYChart.Series series1;
      private XYChart.Series series2;
      private ExecutorService executor;
      private BlockingQueue&lt;Number&gt; dataQ1 = new ArrayBlockingQueue&lt;Number&gt;(1024);
      private BlockingQueue&lt;Number&gt; dataQ2 = new ArrayBlockingQueue&lt;Number&gt;(1024);
  
      @FXML
      private CategoryAxis xAxis = new CategoryAxis();
      @FXML
      final NumberAxis yAxis = new NumberAxis();
      @FXML
      final LineChart&lt;String, Number&gt; linechart = new LineChart&lt;String, Number&gt;(xAxis, yAxis);
  
  
  public void initGraph(){
      xAxis.setAutoRanging(false);
  
      xAxis.setTickLabelsVisible(false);
      xAxis.setTickMarkVisible(false);
  
      NumberAxis yAxis = new NumberAxis();
      yAxis.setAutoRanging(true);
  
      //Graph
      final LineChart&lt;String, Number&gt; lc = new LineChart&lt;String, Number&gt;(xAxis, yAxis){
              @Override 
              protected void dataItemAdded(Series&lt;String, Number&gt; series, int itemIndex, Data&lt;String, Number&gt; item){}
              };
      lc.setAnimated(false);
      lc.setId("liveLineChart");
      lc.setTitle("Animated Line Chart");
  
      //Graph Series
      series1 = new XYChart.Series&lt;Number, Number&gt;();
      series2 = new XYChart.Series&lt;Number, Number&gt;();
      linechart.getData().addAll(series1, series2);
  
      series1.setName("T1");
      series2.setName("T2");
  
      fluidT.setText("0000");
      gasT.setText("0000");
  
      prepareTimeline();
  
      Runnable con = new Consumer(this);
      Thread c = new Thread(con);
      c.start();
  
  }
  </code></pre>