People mostly perceive information visually: videos, photos, and charts draw attention and explain things better than plain numbers or words. This is why many applications use bright and clear charts to present information. In this article, we explore how to add charts to your app without spending lots of time (and therefore money) on their development.

Why and where should you use charts?

Charts have become an extremely popular element of modern UI design in mobile applications. There are lots of ways you can use them in your application, and there are even more ways you can make your charts sleek and beautiful.

Charts have benefits that make this way of presenting information one of the best:

  • Visual — According to multiple studies, people perceive visual information much better than any other kind of information. For example, a study by researchers at the University of Minnesota showed that people process visuals 60,000 times faster than text. This means that adding a chart to your mobile app will make information clearer and therefore improve the user experience.
  • Optimize space — A chart can also be a compact way to present information. Instead of using tables, just implement charts and free screen space.

You can use charts to display lots of information. For example, Apple uses charts in the Apple Watch to show fitness information.

apple watch charts
Apple Watch unique design represents fitness information clearly on a small screen

You can also use charts in a banking app or an app for managing personal finances to show spending and income:

mobile app finance chart
Using charts in personal finance management apps is a good practice: they help to show the difference between the income and spendings and also present statistics about monthly spendings on different categories like groceries, beauty products, insurance, etc

Charts can be used in apps for mobile analytics and marketing:

analytics charts
Charts in analytics are absolutely mandatory, and you need to make sure they are clear and show all necessary information

And there are countless cases where you can use charts in your mobile app. These types of applications often use charts:

  • Banking and personal finance
  • Fitness and nutrition
  • Analytics
  • Logistics
  • Social media
  • Battery management
  • Time management
  • Internet of Things
  • Business and management

You can find lots of creative ways to use charts in other types of mobile applications as well.

Now let’s talk about how to implement a chart in your mobile application and not spend lots of development hours on it.

A simple solution for your app

Creating a chart using graphics can take lots of time, prolonging development and increasing costs. To avoid this, you can use an open source library to create charts. There are already lots of them online, and you can choose any. In this article we’ll look at MPAndroidChart by Phil Jay. It’s new in comparison to other chart libraries, and I like it because it’s stable. Over 3,000 users on GitHub agree with me. With this library, you can create different kinds of customizable charts without much effort. You can also add animations and customize them.

Now I’ll show you how to draw charts on Android with this library. In this article we’ll focus on a simple bar chart with animation, but first let’s explore what types of charts are available in this library.

MPAndroidChart Library

All you need to know about MPAndroidChart is that it’s one of the simplest ways to add charts to your app and that it works on Android API 8 and above. If you want to use animations, you’ll need API 11 or above.

Animations are a core element of modern mobile app UIs, which is why it’s such a great thing to have them in this library. You’ll find over 25 built-in animations, but if you want something special you can also add custom ones. So what can you actually build with MPAndroidChart?

  • Simple bar chart
  • Grouped bar chart
  • Horizontal bar chart
  • Simple line chart
  • Line chart with cubic lines
  • Grouped line chart
  • Combined line and bar chart
  • Pie chart
  • Scatter chart
  • Candlestick chart
  • Radar chart

In this tutorial, we’ll build a grouped bar chart with an animation like the one shown here:

bar chart mobile app
In this tutorial we’ll learn how to implement this simple animated bar chart into your mobile app

How to integrate an animated chart step by step

Step 1

To start, first add these lines to your gradle file:

build.gradle (app)

repositories {
    maven { url "" }
dependencies {
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'

Step 2

Create a layout for your MPAndroidChart:


<RelativeLayout xmlns:android=""
        android:layout_height="match_parent" />

As you can see in the above layout, I’ve used the com.github.mikephil.charting.charts.BarChart xml tag to create an Android bar chart.

Step 3

Now have a look at the activity code:

package com.truiton.mpchartexample;
import android.os.Bundle;
import com.github.mikephil.charting.charts.BarChart;
import com.github.mikephil.charting.utils.ColorTemplate;
import java.util.ArrayList;
public class MainActivity extends ActionBarActivity {
    protected void onCreate(Bundle savedInstanceState) {
        BarChart chart = (BarChart) findViewById(;
        BarData data = new BarData(getXAxisValues(), getDataSet());
        chart.setDescription("My Chart");
        chart.animateXY(2000, 2000);
    private ArrayList getDataSet() {
        ArrayList dataSets = null;
        ArrayList valueSet1 = new ArrayList();
        BarEntry v1e1 = new BarEntry(110.000f, 0); // Jan
        BarEntry v1e2 = new BarEntry(40.000f, 1); // Feb
        BarEntry v1e3 = new BarEntry(60.000f, 2); // Mar
        BarEntry v1e4 = new BarEntry(30.000f, 3); // Apr
        BarEntry v1e5 = new BarEntry(90.000f, 4); // May
        BarEntry v1e6 = new BarEntry(100.000f, 5); // Jun
        ArrayList valueSet2 = new ArrayList();
        BarEntry v2e1 = new BarEntry(150.000f, 0); // Jan
        BarEntry v2e2 = new BarEntry(90.000f, 1); // Feb
        BarEntry v2e3 = new BarEntry(120.000f, 2); // Mar
        BarEntry v2e4 = new BarEntry(60.000f, 3); // Apr
        BarEntry v2e5 = new BarEntry(20.000f, 4); // May
        BarEntry v2e6 = new BarEntry(80.000f, 5); // Jun
        BarDataSet barDataSet1 = new BarDataSet(valueSet1, "Brand 1");
        barDataSet1.setColor(Color.rgb(0, 155, 0));
        BarDataSet barDataSet2 = new BarDataSet(valueSet2, "Brand 2");
        dataSets = new ArrayList();
        return dataSets;
    private ArrayList getXAxisValues() {
        ArrayList xAxis = new ArrayList();
        return xAxis;

This will result in a great-looking bar chart like this:

chart example
This is what you should get if you followed my instructions accurately

Let me explain how the MPAndroidChart library works. As shown in the class above, first a BarChart is initialized. Then data is generated according to the bar chart with the help of the BarEntry class. This is a subclass of the Entry class, which is the base class for all chart data types in the MPAndroidChart library.
Further, this BarEntry is added into BarDataSet. Then all of these values along with X-axis values are set in the bar chart using the chart.setData(data) method. Now to make the bar chart reflect this latest data, we need to call chart.invalidate()method. This will result in the great-looking bar chart shown above.

As I’ve mentioned, the MPAndroidChart library is customizable. Let’s have a look at some of its key features.

MPAndroidChart animations

To animate a chart from the MPAndroidChart library, these methods are used:

  • chart.animateX(2000) – For X-axis animation
  • chart.animateY(2000) – For Y-axis animation
  • chart.animateXY(2000, 2000) – For XY-axis animation

The above code will add a standard animation. But if you wish to change the animation style or want to make a custom animation, refer to this page. Note that animations will work only on API 11 and above.

MPAndroidChart colors

While making charts on Android using the MPAndroidChart library, you can also change the color of bars in the chart using these methods:

  • setColor – Used to set a single color for a full data set
  • setColors – Used to set entries in different colors within a data set

These methods are used while creating the DataSet object shown above.


MPAndroidChart is a great library that can help developers create beautiful, customized, and animated charts in just a few steps. In this article I showed you how to build a bar chart, but you can create all kinds of charts for your application — just change the class names. Mostly you won’t have to change anything: the MPAndroidChart library is created in such a way that in all charts you input the information in the same way.

If you have any questions on integrating or using charts in your mobile app, don’t hesitate to contact Mobindustry for a free consultation. We’ll be glad to help.

Ecommerce development services

Are you planning to expand your business online? We will translate your ideas into intelligent and powerful ecommerce solutions.

Get a Free Consultation!
Request Callback

Request Callback