title: MPAndroidChart combined chart bar + line with space
body: <p>I am trying to create a combined chart with 2 barcharts and one linechart datasets. X axis should be same for all datasets. Between barcharts should be a 300% space set with BarData setGroupSpace(300f). And this is the problem, I am not able to make linechart have this space too, so that the point of linechart would be always between this 2 bars. But it looks like linechart has its own X axis.. Also the labels on X axis should be shifted to be centered with 2 bars.
  Any hints how to do it ?</p>
  
  <p><a href="https://i.stack.imgur.com/zRgrK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zRgrK.png" alt="enter image description here"></a></p>
  
  <pre><code>private void setupChart(){
  
      chart.setDrawOrder(new CombinedChart.DrawOrder[]{CombinedChart.DrawOrder.BAR, CombinedChart.DrawOrder.BUBBLE, CombinedChart.DrawOrder.CANDLE,
              CombinedChart.DrawOrder.LINE, CombinedChart.DrawOrder.SCATTER});
  
      chart.getAxisLeft().setDrawGridLines(false);
      chart.getXAxis().setDrawGridLines(false);
      XAxis x = chart.getXAxis();
      x.setTextSize(14f);
      x.setPosition(XAxis.XAxisPosition.BOTTOM);
  
      YAxis y = chart.getAxisLeft();
      y.setEnabled(false);
  
      chart.setDrawGridBackground(false);
      chart.setDrawBarShadow(false);
      chart.setVisibleXRangeMaximum(10f);
      chart.setVisibleXRangeMinimum(10f);
      chart.setDescription("");
  
      ArrayList&lt;String&gt; labels = new ArrayList&lt;String&gt;();
      for (int i = 0; i &lt; itemcount; i++) {
          String timeString = formatter.format(i * 1000);
          labels.add(timeString);
      }
      CombinedData data = new CombinedData(labels);
  
      data.setData(generateLineData());
      data.setData(generateBarData());
      chart.setData(data);
  
      GraphPopup popup = new GraphPopup(this, R.layout.view_graph_tooltip);
      chart.setMarkerView(popup);
  
      Legend legend = chart.getLegend();
      legend.setTextSize(14f);
      legend.setPosition(Legend.LegendPosition.BELOW_CHART_CENTER);
  
      //chart.animateY(2000);
      chart.setVisibleXRangeMaximum(10f);
      chart.setVisibleXRangeMinimum(10f);
      chart.moveViewToX(entries1.size());
  
      buttonAdd = (Button) findViewById(R.id.buttonAdd);
      buttonAdd.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              dataset0.addEntry(new BarEntry(3, dataset0.getEntryCount()));
              dataset1.addEntry(new BarEntry(12, dataset1.getEntryCount()));
             // labels.add(labels.size(), "x" + labels.size());
              chart.notifyDataSetChanged(); // let the chart know it's data changed
              chart.setVisibleXRangeMaximum(10f);
              chart.setVisibleXRangeMinimum(10f);
              chart.moveViewToX(entries1.size());
              //chart.invalidate(); // refresh
          }
      });
  }
  
  private LineData generateLineData() {
  
      ArrayList&lt;Entry&gt; entries = new ArrayList&lt;Entry&gt;();
      ArrayList&lt;String&gt; labels = new ArrayList&lt;String&gt;();
      for (int index = 0; index &lt; itemcount; index++) {
          entries.add(new Entry(rand.nextInt(22), index));
          String timeString = formatter.format(index * 3600*24*1000);
          labels.add(timeString);
      }
  
      LineData d = new LineData(labels);
      LineDataSet set = new LineDataSet(entries, "Line DataSet");
      set.setColor(Color.RED);
      set.setLineWidth(2.5f);
      set.setCircleColor(Color.RED);
      set.setCircleSize(5f);
      set.setFillColor(Color.WHITE);
      set.setDrawCubic(true);
      set.setDrawValues(true);
      set.setValueTextSize(10f);
      set.setValueTextColor(Color.RED);
      set.setAxisDependency(YAxis.AxisDependency.LEFT);
  
      d.addDataSet(set);
  
      return d;
  }
  
  private BarData generateBarData() {
  
      ArrayList&lt;String&gt; labels0 = new ArrayList&lt;String&gt;();
      for (int i = 0; i &lt; itemcount; i++) {
          BarEntry entry = new BarEntry(rand.nextInt(22) + 8, i);
          entries.add(entry);
          String timeString = formatter.format(i * 3600*24*1000);
          labels0.add(timeString);
      }
  
      dataset0.setColor(getResources().getColor(R.color.graph_bar));
      dataset0.setHighLightColor(getResources().getColor(R.color.graph_bar_selected));
      dataset0.setBarSpacePercent(0f);
  
      ArrayList&lt;String&gt; labels1 = new ArrayList&lt;String&gt;();
      for (int j = 0; j &lt; itemcount; j++) {
          BarEntry entry = new BarEntry(rand.nextInt(22) + 0, j);
          entries1.add(entry);
          String timeString = formatter.format(j * 3600*24*1000);
          labels1.add(timeString);
      }
  
      dataset1.setColor(getResources().getColor(R.color.color1));
      dataset1.setHighLightColor(getResources().getColor(R.color.color2));
      dataset1.setBarSpacePercent(0f);
  
      BarData d = new BarData(labels0);
      d.addDataSet(dataset0);
      d.addDataSet(dataset1);
      d.setGroupSpace(300f);
  
      return d;
  }
  </code></pre>