title: MPChart in Android Built Pie chart by custom values
body: <p>This is the method of library setData. I have four values <code>q1,q2,q3,q4</code> total of all 4 so my total is supposed 10000 <code>q1=1000,q2=500,q3=500,q4=8000</code>. so how do i passed all these values in this and generate my own graph see this data is coming from my API so for every user data if different and chart built according to that data values.</p>
  
  <pre><code>   private void setData(int count, float range){
  
      float mult = range;
  
      ArrayList&lt;Entry&gt; yVals1 = new ArrayList&lt;Entry&gt;();
  
      // IMPORTANT: In a PieChart, no values (Entry) should have the same
      // xIndex (even if from different DataSets), since no values can be
      // drawn above each other.
      for (int i = 0; i &lt; count + 1; i++) {
        //yVals1.add(new Entry((float) (Math.random() * mult) + mult / 5, i));
          yVals1.add(new Entry((float)(dislikeval), i));
      }
  
      ArrayList&lt;String&gt; xVals = new ArrayList&lt;String&gt;();
  
      for (int i = 0; i &lt; count + 1; i++)
          xVals.add(mParties[i % mParties.length]);
  
      PieDataSet dataSet = new PieDataSet(yVals1, "Election Results");
      dataSet.setSliceSpace(2f);
      dataSet.setSelectionShift(5f);
  
      // add a lot of colors
      ArrayList&lt;Integer&gt; colors = new ArrayList&lt;Integer&gt;();
      for (int c : ColorTemplate.VORDIPLOM_COLORS)
          colors.add(c);
  
      for (int c : ColorTemplate.JOYFUL_COLORS)
          colors.add(c);
  
      for (int c : ColorTemplate.COLORFUL_COLORS)
          colors.add(c);
  
      for (int c : ColorTemplate.LIBERTY_COLORS)
          colors.add(c);
  
      for (int c : ColorTemplate.PASTEL_COLORS)
          colors.add(c);
  
      colors.add(ColorTemplate.getHoloBlue());
  
      dataSet.setColors(colors);
      //dataSet.setSelectionShift(0f);
  
      PieData data = new PieData(xVals, dataSet);
      data.setValueFormatter(new PercentFormatter());
      data.setValueTextSize(11f);
      data.setValueTextColor(Color.WHITE);
      data.setValueTypeface(tf);
      mChart.setData(data);
  
      // undo all highlights
      mChart.highlightValues(null);
  
      mChart.invalidate();
  }
  </code></pre>