title: JFreeChart - XYBarChart Show Separate Bars for Each Series
body: <p>I'm creating a XYBarChart using JFreeChart and adding multiple series to it. Currently for a given x-value and different Y-values from the series, all of them are getting stacked on top of each other. </p>
  
  <p>Would be possible to show each series as a different bar for a given x-value?</p>
  
  <p><strong>Edit</strong>: I'm posting the relevant section of my code that is used to create the chart for your reference. </p>
  
  <p><strong>Note that</strong> I cannot use <em>CategoryDataset</em> because this does not provide zooming capabilities on the Domain Axis. This is an essential requirement for my implementation.</p>
  
  <pre><code>XYSeriesCollection intervalXYDataSet  = new XYSeriesCollection();
  int countPlotPoints = populateBandData(intervalXYDataSet, optionList); //optionList is a HashMap&lt;Integer,ArrayList&lt;Integer&gt;&gt; where key = seriesKey, and ArrayList&lt;Integer&gt; builds up the value for each series
  
  if (countPlotPoints == 0) {
      print("No options selected.\n");
      JOptionPane.showMessageDialog(this, "No Plot Points Were Selected!", "Warning", JOptionPane.WARNING_MESSAGE);
      return;
  }
  
  /**
   * Chart Creation Section
   */
  JFreeChart chart = ChartFactory.createXYBarChart(tabTitle, "Frequency Bands", false, "rxlev", intervalXYDataSet, PlotOrientation.VERTICAL, true, true, false);
  XYPlot plot = (XYPlot) chart.getPlot();
  plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
  plot.getDomainAxis().setAutoRange(true);
  
  //        
  final XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
  renderer.setDrawBarOutline(false);
  renderer.setShadowVisible(false);
  renderer.setMargin(0.2);
  renderer.setDefaultShadowsVisible(false);
  
  ChartPanel chartpanel = new ChartPanel(chart);
  chartpanel.setDefaultDirectoryForSaveAs(new File(lastAnalyzedPath));
  
  JFrame frame = new JFrame();
  frame.setTitle(plotTitle);
  frame.add(new JScrollPane(chartpanel));
  frame.pack();
  frame.setVisible(true);
  
  frame.addWindowListener(new java.awt.event.WindowAdapter() {
      @Override
      public  void windowClosing(java.awt.event.WindowEvent evt) {
          try {
              System.out.println(":: Clearning Memory ::");
              System.out.println("\tFree Memory (Before cleanup): "+Runtime.getRuntime().freeMemory());
              Component component = getComponent(0);
              if(component instanceof ChartPanel){
                  JFreeChart chart = ((ChartPanel) component).getChart();
                  XYPlot plot = (XYPlot) chart.getPlot();
                  plot        = null;
                  chart       = null;
                  component   = null;
              }
          } finally {
              System.runFinalization();
              System.gc();
              System.out.println("\tFree Memory (Post cleanup): "+Runtime.getRuntime().freeMemory());
          }
      }
  });
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/0kEk8.png" rel="nofollow noreferrer">Here's a screenshot</a> of how it's currently appearing
  <img src="https://i.stack.imgur.com/0kEk8.png" alt=""></p>