title: Error "Dataset and renderer should be not null and should have the same number of series" in Android
body: <p>I am trying to display a graph with the data in the sqlitedatabase using AChartEngine library. I am having two records in database. BarChart graph displayed when there is one record. But with two records of data, it says, "Dataset and renderer should be not null and should have the same number of series". I dont understand this. </p>
  
  <p>My code is,</p>
  
  <pre><code>    Button ReportGraph = (Button) findViewById(R.id.ReportGraph);
      ReportGraph.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              GraphicalView GraphChartView = ChartFactory.getBarChartView(
                      getApplicationContext(), getWaterElectricityReading(),
                      getDemoRenderer(), Type.DEFAULT);
              // Intent intent=ChartFactory.getLineChartIntent(this,
              // getDemoDataset(), getDemoRenderer());
              // startActivity(intent);
              if (GraphChartView != null) {
                  GraphChartView.repaint();
              }
              relChartView.addView(GraphChartView);
              mainLayout.setVisibility(View.GONE);
              relChartView.setVisibility(View.VISIBLE);
  
          }
      });
  
  
  private XYMultipleSeriesDataset getWaterElectricityReading() {
      XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
  
      SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-mm-dd", Locale.US);
      SimpleDateFormat df2 = new SimpleDateFormat("MMM dd yyyy");
  
      Date StartDate;
      Date EndDate;
      String Pastdateformat = "";
      String CurrentDateFormat = "";
  
      SQLiteDatabase DB = Context
              .openOrCreateDatabase("WaterElectricityReadingDataBase.db",
                      MODE_WORLD_READABLE, null);
      Cursor c = DB
              .rawQuery(
                      "select ReadingValue,strftime('%m/%d/%Y',StartDateTime) StartDateTime,strftime('%m/%d/%Y',EndDateTime) EndDateTime from WaterElectricity order by StartDateTime desc ",
                      null);
      int rowCount = c.getCount();
  
      if (c != null) {
          if (rowCount &gt; 0) {
              if (c.moveToFirst()) {
                  do {
                      String ReadingValue = c.getString(c
                              .getColumnIndex("ReadingValue"));
                      String PastDate = c.getString(c
                              .getColumnIndex("StartDateTime"));
                      String CurrentDate = c.getString(c
                              .getColumnIndex("EndDateTime"));
                      try {
                          StartDate = df2.parse(PastDate);
                          Pastdateformat = sdf1.format(StartDate);
  
                          EndDate = df2.parse(CurrentDate);
                          CurrentDateFormat = sdf1.format(EndDate);
                      } catch (Exception e) {
  
                      }
                      XYSeries series = new XYSeries(
                              "WaterElectricityReading");
                      double ReadingVal = Double.parseDouble(ReadingValue);
                      series.add(rowCount, ReadingVal);
                      XYMultipleSeriesRenderer render = new XYMultipleSeriesRenderer();
  
  
                      dataset.addSeries(series);
                      rowCount++;
                  } while (c.moveToNext());
              }
          }
      }
      return dataset;
  }
  
  private XYMultipleSeriesRenderer getDemoRenderer() {
      XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
      renderer.setAxisTitleTextSize(12);
      renderer.setChartTitleTextSize(12);
      renderer.setLabelsTextSize(15);
      renderer.setLegendTextSize(15);
      renderer.setPointSize(5f);
      renderer.setMargins(new int[] { 20, 30, 15, 0 });
      XYSeriesRenderer r = new XYSeriesRenderer();
      r.setColor(Color.GREEN);
      r.setPointStyle(PointStyle.DIAMOND);
      r.setFillBelowLine(false);
      r.setFillPoints(true);
      renderer.addSeriesRenderer(r);
      setChartSettings(renderer);
      return renderer;
  }
  
  private void setChartSettings(XYMultipleSeriesRenderer renderer) {
      renderer.setChartTitle("Chart demo");
      renderer.setXTitle("x values");
      renderer.setYTitle("y values");
      renderer.setApplyBackgroundColor(false);
      renderer.setRange(new double[] { 0, 6, -70, 40 });
      renderer.setFitLegend(false);
      renderer.setAxesColor(Color.BLACK);
      renderer.setShowGrid(true);
      renderer.setXAxisMin(0);
      renderer.setXAxisMax(10.5);
      renderer.setYAxisMin(0);
      renderer.setZoomEnabled(false);
      renderer.setYAxisMax(1000);
  }
  </code></pre>
  
  <p>For two records, I want two bars to be displayed.
   Can anyone please point out the Mistake.</p>
  
  <p>Any Help will be appreciated!!</p>
  
  <p>Thanks.</p>