title: Android MPAndroidCharts LineChart skipping values
body: <p>I´m working with MPAndroid charts on my app to draw a chart from my sqlite database using &quot;weight&quot; values for the Y axes and &quot;date&quot; values for the X axes.</p>
  <p>The problem is that just some rows of my database have that weight value. When all the rows have the weight layout my code works like a charm, but when there is a row that doesn´t have weight value, and the next one contains that weight value, it leaves a space on the YAxes of the chart, altought the date value is set on XAxes. As a result of that, a value is missed on Y Axes for every row without the weight value, because the value that comes after the weight row is moved one point forward. For example:<a href="https://i.stack.imgur.com/gt59j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gt59j.png" alt="enter image description here" /></a></p>
  <p>I have this code for setting up the chart:</p>
  <pre><code>public void setUpCharts(){
          chart = (LineChart) rootView.findViewById(R.id.weightChart);
  
          chart.setNoDataTextDescription(&quot;Nothing&quot;);
          chart.setDrawBorders(false);
          chart.setDescription(&quot;&quot;);
          chart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
          chart.getAxisRight().setEnabled(false);
          chart.getAxisLeft().setEnabled(false);
          chart.getAxisLeft().setDrawGridLines(false);
          chart.getAxisRight().setDrawGridLines(false);
          chart.getXAxis().setDrawGridLines(false);
          chart.getXAxis().setDrawAxisLine(false);
          chart.getLegend().setEnabled(false);
  
          chart.setScaleEnabled(false);
          chart.setPinchZoom(false);
          chart.setDoubleTapToZoomEnabled(false);
  
  
          weights = new ArrayList&lt;&gt;(); //Pesos
          dates = new ArrayList&lt;String&gt;(); //Días del mes
  
          getChartData();
  
          LineDataSet dataSet = new LineDataSet(weights, &quot;Weights&quot;);
  
          dataSet.setDrawCubic(false);
          dataSet.setCircleRadius(4);
          dataSet.setLineWidth(3);
          dataSet.setDrawValues(true);
          dataSet.setColor(getContext().getResources().getColor(R.color.colorWeightChart));
          dataSet.setCircleColor(getContext().getResources().getColor(R.color.colorWeightChart));
          dataSet.setCircleColorHole(getContext().getResources().getColor(R.color.colorWeightChart));
          LineData data = new LineData(dates, dataSet);
          chart.setData(data);
  
          //LimitLine
          String weight_get = PreferenceManager.getDefaultSharedPreferences(getContext()).getString(&quot;Goal_weight&quot;, null);
          if(!weight_get.equals(null) &amp;&amp; !weight_get.equals(&quot;&quot;)){
              float weight_goal = Float.valueOf(weight_get);
              YAxis leftAxis = chart.getAxisLeft();
              LimitLine ll = new LimitLine(weight_goal);
              ll.setLineColor(getContext().getResources().getColor(R.color.weightTabFAB));
              ll.setLineWidth(1f);
              ll.enableDashedLine(10f, 10f, 0f);
              leftAxis.addLimitLine(ll);
  
              float YMax= dataSet.getYMax();
              if(weight_goal &gt; YMax){
                  float difference = weight_goal - YMax;
                  chart.getAxisRight().setAxisMaxValue(weight_goal + difference); //So the limit line will be always visible
                  chart.getAxisLeft().setAxisMaxValue(weight_goal + difference);
              }
          }
  
          chart.setVisibleXRangeMaximum(5f);
      }
  </code></pre>
  <p>And I use getChartData to set up all the chart data getting the values from my sqlite database. It´s supposed to add just the values of rows in which weight exists, and in fact the log shows that it works correctly, so I don´t know how can I fix it.</p>
  <pre><code>protected void getChartData(){
      IDs = new ArrayList&lt;Integer&gt;();
      Cursor data = dataSource.getAllItems();
      if(data!=null) {
          while(data.moveToNext()){
              int id = data.getInt(data.getColumnIndex(RecordsDataSource.ColumnRecords.ID_RECORDS));
              String weight=  data.getString(data.getColumnIndex(RecordsDataSource.ColumnRecords.WEIGHTS_RECORDS));
  
              if(weight!=null &amp;&amp; !weight.equals(&quot;&quot;)){
                  long milisDate =data.getLong(data.getColumnIndex(RecordsDataSource.ColumnRecords.DATES_RECORDS));
                  String date = Utils.milisToDate(milisDate, &quot;dd/MM&quot;);
  
                  IDs.add(id);
                  weights.add(new Entry(Float.valueOf(weight), id -1));
                  dates.add(date);
                  Log.i(&quot;ID &quot;+ String.valueOf(id),&quot;Not null, &quot;+ weight);
              }else{
                  Log.i(&quot;ID &quot;+ String.valueOf(id), &quot;Null&quot;);
              }
          }
          data.close();
      }
  }
  </code></pre>
  <p>I have been all the day trying to solve this issue, but nothing has worked.
  Could somebody help me please?
  By the way, sorry for my bad English.</p>