title: How to plot multiple series with javafx line chart which is in array list
body: <p>There is no error but there is an issue with the plot am not getting the correct line chart plot, I want parameters in the x-axis and values in the y-axis but I have 3 engines as series but the series is not adding but the last series is only adding up. kindly help me with this issue.</p>
  
  <p>What I am trying to do is: Suppose I have n engines and m parameters of the engines, if I have 4 engines and 30 parameters then the total value will be n x m which is 4x30=120 so I want to plot engines in one axis and parameters in another. For now am having engines as series but unable to plot it with respect to parameters. There should be multiples engines series and constant parameters with values plotted</p>
  
  <p><strong><a href="https://i.stack.imgur.com/BOceH.png" rel="nofollow noreferrer">Click this url to see the plot. Am getting something like this, as am not able to add multiple series.</a></strong></p>
  
  <p>1: performance.java</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  import javafx.scene.chart.LineChart;
  import javafx.scene.chart.XYChart;
  
  public class performance {
  
  protected LineChart&lt;String,Number&gt; lineChart;
  protected ArrayList parameters;
  protected ArrayList&lt;List&gt; param;
  protected ArrayList engines;
  public XYChart.Series series = new XYChart.Series();
  
  
  
  public performance(LineChart&lt;String,Number&gt; lineChart, ArrayList parameters, ArrayList&lt;List&gt; paramValues, ArrayList engines) {
      this.lineChart = lineChart;
      this.parameters = parameters;
      this.param = paramValues;
      this.engines = engines;
  
  }
  
  public XYChart.Series generateChart() {
  
      for(int i=0;i&lt;engines.size();i++)
      {
  
          series.setName(engines.get(i).toString());
  
          for(int j=0;j&lt;parameters.size();j++)
          {
  
      series.getData().add(new XYChart.Data(parameters.get(j).toString(),param.get(i).get(j)));
  
      System.out.println(engines.get(i) + "with parameter: " + parameters.get(j) + "having value: "+ param.get(i).get(j));
  
          }
      }
      System.out.println(lineChart);
  
  
  
      return series;
  }
  
  }
  </code></pre>
  
  <p>2: mainClass</p>
  
  <pre><code>import java.util.ArrayList;
  import javafx.application.Application;
  import static javafx.application.Application.launch;
  import javafx.scene.Scene;
  import javafx.scene.chart.CategoryAxis;
  import javafx.scene.chart.LineChart;
  import javafx.scene.chart.NumberAxis;
  import javafx.stage.Stage;
  
  public class NewFXMain extends Application {
  
  @Override 
  public void start(Stage stage) {
  
      stage.setTitle("Performance Analysis");
  
      final CategoryAxis xAxis = new CategoryAxis();
      final NumberAxis yAxis = new NumberAxis();
  
      xAxis.setLabel("Values");
      yAxis.setLabel("Engines");
  
      LineChart&lt;String, Number&gt; lineChart = new LineChart&lt;String,Number&gt;(xAxis,yAxis);
  
      Scene scene  = new Scene(lineChart,800,600); 
  
      lineChart.setTitle("Performance Analysis");
  
      ArrayList engines = new ArrayList();
       engines.add("engine1");
       engines.add("engine2");
       engines.add("engine3");
       ArrayList parameters = new ArrayList();
       parameters.add("parameter1");
       parameters.add("parameter2");
       parameters.add("parameter3");
       parameters.add("parameter4");
       parameters.add("parameter5");
       ArrayList paramvalue1 = new ArrayList();
       paramvalue1.add(12);
       paramvalue1.add(13);
       paramvalue1.add(15);
       paramvalue1.add(11);
       paramvalue1.add(10);
  
  
      ArrayList paramvalue2 = new ArrayList();
       paramvalue2.add(12);
       paramvalue2.add(20);
       paramvalue2.add(18);
       paramvalue2.add(17);
       paramvalue2.add(22);
       ArrayList paramValue3 = new ArrayList();
       paramValue3.add(14);
       paramValue3.add(12);
       paramValue3.add(11);
       paramValue3.add(22);
       paramValue3.add(12);
       ArrayList finalValue = new ArrayList();
       finalValue.add(paramvalue1);
       finalValue.add(paramvalue2);
       finalValue.add(paramValue3);
  
       for(int i=0;i&lt;engines.size();i++)
         {
          performance performvalues = new performance(lineChart, parameters, finalValue, engines);
  
          lineChart.getData().add(performvalues.generateChart());
         }
  
      stage.setScene(scene);
      stage.show();
  }    
  
  public static void main(String[] args) {
      launch(args);
  }
  }
  </code></pre>