title: LineChart in JavaFX
body: <p>I'm trying to work on a LineChart in JavaFX , I have two classes the Main class and the Controller class , the Main class has the Stage and the Scene , and the Controller Class has the functionality of the LineChart , after initializing the LineChart in the Contoller Class and after the running the code , the LineChart is not displaying the coordinates on the chart , why is that happeing ?</p>
  <p>Here's the Main Class :</p>
  <pre><code>package sample;
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  import java.io.IOException;
  
  public class Main extends Application {
  @Override
  public void start(Stage primaryStage) throws IOException {
      Parent root = FXMLLoader.load(getClass().getResource(&quot;sample.fxml&quot;));
      primaryStage.setTitle(&quot;Line Chart&quot;);
      primaryStage.setScene(new Scene(root, 900, 500));
      primaryStage.show();
  }
  
  public static void main(String[] args) {
      launch(args);
  }
  }
  </code></pre>
  <p>Controller Class :</p>
  <pre><code>package sample;
  
  import javafx.collections.FXCollections;
  import javafx.fxml.FXML;
  import javafx.fxml.Initializable;
  import javafx.scene.Scene;
  import javafx.scene.chart.LineChart;
  import javafx.scene.chart.NumberAxis;
  import javafx.scene.chart.XYChart;
  import javafx.scene.control.ComboBox;
  import javafx.scene.control.Label;
  import javafx.scene.control.RadioButton;
  import javafx.scene.control.TextField;
  import javafx.stage.Stage;
  
  import java.net.URL;
  import java.util.ResourceBundle;
  
  public class Controller implements Initializable {
  
  @FXML
  private ComboBox functionChooser;
  
  @FXML
  private TextField tfWidth,tfMin,tfMax;
  
  @FXML
  private RadioButton showFunction,hideFunction;
  
  @FXML
  private Label labelWidth,labelMin,labelMax;
  
  @FXML
  private LineChart lnChart;
  
  @Override
  public void initialize(URL url, ResourceBundle resourceBundle) {
  
      final NumberAxis xAxis = new NumberAxis();
      final NumberAxis yAxis = new NumberAxis();
  
      String funcs[] = {&quot;y(x) = sin(X)&quot;,&quot;y(x) = cos(x) - 2 * sin(x)&quot;,&quot;y(x) = sin(x*x)&quot;};
      functionChooser.getItems().setAll(funcs);
      functionChooser.getSelectionModel().selectFirst();
  
      Stage stage = new Stage();
  
      lnChart = new LineChart&lt;Number,Number&gt;(xAxis,yAxis);
      XYChart.Series series1 = new XYChart.Series();
      series1.setName(&quot;Portfolio 1&quot;);
      series1.getData().add(new XYChart.Data(0, 23));
      series1.getData().add(new XYChart.Data(1, 14));
      series1.getData().add(new XYChart.Data(2, 15));
      series1.getData().add(new XYChart.Data(3, 24));
      series1.getData().add(new XYChart.Data(4, 34));
  
      lnChart.getData().add(series1);
  
  }
  }
  </code></pre>