title: MPAndroidChart Bar Chart - how to group bars with random x-axis intervals in between groups?
body: <p>I want to make a bar chart with 3 different datasets grouped together at each data point like so:</p>
  
  <p><a href="https://i.stack.imgur.com/UcSt6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UcSt6.png" alt="enter image description here"></a></p>
  
  <p>However, I am unable to group the bars together using the library's provided <code>groupBars</code> method because no matter what x-value I set for an entry, it groups the bars according to the interval I specify in its parameters. </p>
  
  <p>For example, if I generate a dataset with entry x-values {0, 5, 13, 17...50} and call `groupBars', all of my entries are gathered 1 x-value apart like so:</p>
  
  <p><a href="https://i.stack.imgur.com/sLNsd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sLNsd.png" alt="enter image description here"></a></p>
  
  <p>What I want is the bars to each be grouped and each be visible at their specified x-value. If I simply remove the <code>groupBars</code> call, I get something similar to what I want but not quite since the bars are all overlapping, like so:</p>
  
  <p><a href="https://i.stack.imgur.com/206RP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/206RP.png" alt="enter image description here"></a></p>
  
  <p>How do I achieve a result similar to the above image but with the bar of each dataset completely visible? Here is my code for generating the dataset and grouping the bars: </p>
  
  <pre><code>        ArrayList&lt;BarEntry&gt; happinessValues = new ArrayList&lt;&gt;();
          ArrayList&lt;BarEntry&gt; stressValues = new ArrayList&lt;&gt;();
          ArrayList&lt;BarEntry&gt; painValues = new ArrayList&lt;&gt;();
  
          for (int i = 0; i &lt; 50; ++i) {
              happinessValues.add(new BarEntry(
                      i,
                      datapoint.getHappiness()));
              stressValues.add(new BarEntry(
                      i,
                      datapoint.getStress()));
              painValues.add(new BarEntry(
                      i,
                      datapoint.getPain()));
          }
  
          HappinessDataset happyDataset;
  
          BarDataSet stressDataset, painDataset;
  
              happyDataset = new HappinessDataset(happinessValues, "Happiness");
  
              stressDataset = new BarDataSet(stressValues, "Stress");
  
              painDataset = new BarDataSet(painValues, "Pain");
  
              BarData data = new BarData(happyDataset, stressDataset, painDataset);
  
              mChart.setData(data);
  
          mChart.getXAxis().setAxisMinimum(0);
          mChart.getXAxis().setAxisMaximum(50);
  
  
        float groupSpace = 0.4f;
          float barSpace = 0f; // x3 DataSet
          float barWidth = 0.2f; // x3 DataSet
          // (0.2 + 0) * 3 + 0.4 = 1.00 -&gt; interval per "group"
          mChart.groupBars(startTime, groupSpace, barSpace);
  </code></pre>