title: Android: Drawing horizontal bar charts with `MPAndroidChart`
body: <p>I am trying to draw a Horizontal bar chart in android using <a href="https://github.com/PhilJay/MPAndroidChart" rel="nofollow noreferrer">MPAndroidChart</a>. Please check the below code.</p>
  
  <p><strong>activity_mail.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/activity_main"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.example.graphs.graphs2.MainActivity"&gt;
  
  
  
      &lt;com.github.mikephil.charting.charts.HorizontalBarChart
          android:id="@+id/chart"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>import android.graphics.Color;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  
  import com.github.mikephil.charting.charts.HorizontalBarChart;
  import com.github.mikephil.charting.data.BarData;
  import com.github.mikephil.charting.data.BarDataSet;
  import com.github.mikephil.charting.data.BarEntry;
  import com.github.mikephil.charting.utils.ColorTemplate;
  
  import java.util.ArrayList;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          HorizontalBarChart chart = (HorizontalBarChart) findViewById(R.id.chart);
  
          BarData data = new BarData(getDataSet());
          chart.setData(data);
          chart.animateXY(2000, 2000);
          chart.invalidate();
      }
  
      private BarDataSet getDataSet() {
  
          ArrayList&lt;BarEntry&gt; entries = new ArrayList();
                  entries.add(new BarEntry(4f, 0));
                  entries.add(new BarEntry(8f, 1));
                  entries.add(new BarEntry(6f, 2));
                  entries.add(new BarEntry(12f, 3));
                  entries.add(new BarEntry(18f, 4));
                  entries.add(new BarEntry(9f, 5));
  
          BarDataSet dataset = new BarDataSet(entries,"hi");
          return dataset;
      }
  
      private ArrayList&lt;String&gt; getXAxisValues() {
          ArrayList&lt;String&gt; labels = new ArrayList();
                  labels.add("January");
                  labels.add("February");
                  labels.add("March");
                  labels.add("April");
                  labels.add("May");
                  labels.add("June");
          return labels;
      }
  
  
  }
  </code></pre>
  
  <p>This gave me the following chart.
  <a href="https://i.stack.imgur.com/nyQEe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nyQEe.png" alt="enter image description here"></a></p>
  
  <p>However, the bar chart I want is like below...
  <a href="https://i.stack.imgur.com/5xj9i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5xj9i.png" alt="enter image description here"></a></p>
  
  <p>So I need to do few things...</p>
  
  <ol>
  <li>Colour the bars</li>
  <li>Remove guide lines</li>
  <li>Show the description of each bar at the left side of it</li>
  <li>Display the "%" mark with numbers at the end of bars (ex: for the first bar, display <code>4%</code> instead of <code>4</code>)</li>
  </ol>
  
  <p>I visited this post as well, the authher of the library seems to have done some of what I requested, so probably possible with this library. How can I do them?</p>