title: create bar chart using jfreechart by accessing data from 2 files and display data of file 1 and file 2 with different color
body: <p>This is my code for displaying particular vale, eg. average of one file. Now i want to create bar chart for values from both the files, and indicate both with different colors. plz help:</p>
  
  <p>public JFreeChart createBarChartFromCSV() {</p>
  
  <pre><code>    CSVFileReader csvReader = new CSVFileReader();
      List&lt;String[]&gt; csvData = null; 
      int indexOfAverage = 0;
  
      csvData = csvReader.getDataFromCSV(CSVFileReader.CSVFILENAME);
  
      for(String[] columnArray : csvData)
          for(int i = 0; i&lt; columnArray.length; i++)
              if(columnArray[i].equalsIgnoreCase("average")){
                  indexOfAverage = i;
                  break;
              }
  
      if(indexOfAverage == 0){
          System.err.println("Error retrieving data from CSV File !!");
          System.exit(0);
      }
      JFreeChart barChart = generateBarChart(csvData, indexOfAverage);
  
      return barChart;
  }
  
  
  private JFreeChart generateBarChart(List&lt;String[]&gt; csvData, int columnIndex){
  
      DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
  
      final String YAXIS_NAME = csvData.get(0)[columnIndex]; //value returned is "average"
      final String XAXIS_NAME = csvData.get(0)[0]; //value returned is "sampler_label"
  
      for(int i = 1; i &lt; csvData.size() - 1; i++){
  
          long averageValue = Long.parseLong(csvData.get(i)[columnIndex]);
          String columnKey = csvData.get(i)[0];
  
          dataSet.setValue(averageValue, YAXIS_NAME, columnKey); // plot the graph
      }
  
      JFreeChart chart = ChartFactory.createBarChart("Comparison between the average of 2 values", XAXIS_NAME, YAXIS_NAME, dataSet, PlotOrientation.VERTICAL, false, true, false);
      return chart;
  }
  </code></pre>