title: How can I remove old data in MPAndroidChart?
body: <p>Hi this is my code but not work (newest version of <a href="https://github.com/PhilJay/MPAndroidChart" rel="nofollow noreferrer">library</a>)</p>
  
  <pre><code>LineData dataChart = mainChart.getData();
  
      if (dataChart != null) {
  
          LineDataSet set = (LineDataSet) dataChart.getDataSetByIndex(0);
          if (set == null) {
              set = (LineDataSet) createSet(ColorTemplate.rgb(colorChart), ColorTemplate.rgb(colorFill));
              dataChart.addDataSet(set);
          }
  
  
  
          dataChart.addEntry(new Entry(set.getEntryCount(), sensorEvent.values[2]), 0);
          dataChart.notifyDataChanged();
  
          if(set.getEntryCount() == 20) {
              set.removeFirst();
          }
  
          // let the chart know it's data has changed
          mainChart.notifyDataSetChanged();
          // limit the number of visible entries
          mainChart.setVisibleXRangeMaximum(20);
          mainChart.moveViewToX(dataChart.getEntryCount());
  
      }
  </code></pre>
  
  <p>`output of this cod:
  <a href="https://i.stack.imgur.com/c783H.jpg" rel="nofollow noreferrer">not correct</a></p>
  
  <p>but when I chang my code:</p>
  
  <pre><code>LineData dataChart = mainChart.getData();
  
      if (dataChart != null) {
  
          LineDataSet set = (LineDataSet) dataChart.getDataSetByIndex(0);
          if (set == null) {
              set = (LineDataSet) createSet(ColorTemplate.rgb(colorChart), ColorTemplate.rgb(colorFill));
              dataChart.addDataSet(set);
          }
  
  
  
          dataChart.addEntry(new Entry(set.getEntryCount(), sensorEvent.values[2]), 0);
          dataChart.notifyDataChanged();
  
          // let the chart know it's data has changed
          mainChart.notifyDataSetChanged();
          // limit the number of visible entries
          mainChart.setVisibleXRangeMaximum(300);
          mainChart.moveViewToX(dataChart.getEntryCount());
  
      }
  </code></pre>
  
  <p>and the output is correct,so what should I do to remove old data from the chart?
  <a href="https://i.stack.imgur.com/hFiJC.jpg" rel="nofollow noreferrer">correct but I want delet old data</a></p>