Android Graph Library for creating zoomable and scrollable line and bar graphs.

Last update: Jun 13, 2022

Chart and Graph Library for Android

Project maintainer wanted! For time reasons I can not continue to maintain GraphView. Contact me if you are interested and serious about this project. [email protected]

What is GraphView

GraphView is a library for Android to programmatically create flexible and nice-looking diagrams. It is easy to understand, to integrate and to customize.

Supported graph types:

  • Line Graphs
  • Bar Graphs
  • Point Graphs
  • or implement your own custom types.

Top Features

  • Line Chart, Bar Chart, Points
  • Combination of different graph types
  • Scrolling vertical and horizontal . You can scroll with a finger touch move gesture.
  • Scaling / Zooming vertical and horizontal . With two-fingers touch scale gesture (Multi-touch), the viewport can be changed.
  • Realtime Graph (Live change of data)
  • Second scale axis
  • Draw multiple series of data . Let the diagram show more that one series in a graph. You can set a color and a description for every series.
  • Show legend . A legend can be displayed inline the chart. You can set the width and the vertical align (top, middle, bottom).
  • Custom labels . The labels for the x- and y-axis are generated automatically. But you can set your own labels, Strings are possible.
  • Handle incomplete data . It's possible to give the data in different frequency.
  • Viewport . You can limit the viewport so that only a part of the data will be displayed.
  • Manual Y axis limits
  • And much more... Check out the project page and/or the demo app

How to use

  1. Add gradle dependency:
implementation 'com.jjoe64:graphview:4.2.2'
  1. Add view to layout:
<com.jjoe64.graphview.GraphView
        android:layout_width="match_parent"
        android:layout_height="200dip"
        android:id="@+id/graph" />
  1. Add some data:
GraphView graph = (GraphView) findViewById(R.id.graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[] {
          new DataPoint(0, 1),
          new DataPoint(1, 5),
          new DataPoint(2, 3),
          new DataPoint(3, 2),
          new DataPoint(4, 6)
});
graph.addSeries(series);

Download Demo project at Google Play Store


Showcase GraphView Demo App

More examples and documentation

Get started at project wiki homepage

To show you how to integrate the library into an existing project see the GraphView-Demos project! See GraphView-Demos for examples. https://github.com/jjoe64/GraphView-Demos
View GraphView wiki page https://github.com/jjoe64/GraphView/wiki

GitHub

https://github.com/appsthatmatter/GraphView
Comments
  • 1. GraphView on Android Studio

    Hi, I can not load the library on android study also having followed the steps and still get this error: cannot resolve method. Please help me. Import only this "import com.jjoe64.graphview.GraphView;"

    Reviewed by davix10 at 2015-02-05 15:18
  • 2. GraphView No Horizontal Labels

    Hello- I am new to GitHub, but I am trying to use GraphView 4.0 for an app and for some reason the horizontal labels do not display. Below is the code I am using:

    GraphView graph = (GraphView) chrtView.findViewById(R.id.graph); LineGraphSeries series = new LineGraphSeries(new DataPoint[] { new DataPoint(0, 1), new DataPoint(1, 5), new DataPoint(2, 3), new DataPoint(3, 2), new DataPoint(4, 6) }); graph.addSeries(series);

    And the following XML which is imbedded in a linear layout.

        <com.jjoe64.graphview.GraphView
        android:layout_width="match_parent"
        android:layout_height="200dip"
        android:id="@+id/graph" />
    

    I am not including the .jar file in my library folder but instead include the following statement with my dependencies in my build.gradle:

    compile 'com.jjoe64:graphview:4.0.0'

    This is basically the exact code that included in the documentation. Doe anyone have any suggestions what I might be doing incorrectly?

    thanks.

    Reviewed by hydrophylic at 2015-02-28 07:26
  • 3. Sample select callback and multi-line X axis labels.

    Hi Jonas, Thanks for making this nice and intuitive way to quickly draw graphs on Android. I am developing an app which is using GraphView and added some features which were useful for me. My updates are:

    1. Provided a callback mechanism to notify user when a sample point is selected.
    2. X axis labels can now be multi-line (I needed 2 lines). This pull request covers both the above changes. Do review and take in if possible.

    Thanks, Narendra

    Reviewed by nma83 at 2012-04-05 18:34
  • 4. added support for missing values and added buffered drawing (great performance improvement)

    Added support for missing values (if Y value is NaN it is not drawn, datapoint between two NaN values are drawn as a dot)

    Added buffered drawing (great performance improvement!)

    ToDo: move the creation of the bitmap/canvas away from the OnDraw event (should only be done at initialisation or orientation change) ToDo: manage scaling when only NaN datapoints are in the series. (skip scaling completely perhaps, or scale to a default range)

    Reviewed by mberntsen at 2013-12-10 13:26
  • 5. ConcurrentModificationException

    I am using appendData() to create a realtime graph. I call this method during a Bluetooth notification callback which is not running on the main UI thread. This creates a ConcurrentModificationException because the LineGraphSeries is being accessed by my thread to add a new DataPoint, and also an iterator in the onDraw routine of the GraphView. I've been able to work around the problem by pushing my call to appendData() onto the UI thread, but a better solution would be to protect the LineGraphSeries storing the DataPoints inside GraphView using synchronization. This would allow any thread to add data to the graph without pushing the work onto the UI thread. Something like this might work:

    List list = Collections.synchronizedList(new ArrayList(...));

    Reviewed by RobSenix at 2016-12-16 18:34
  • 6. Logarithm Scale

    At the moment graphview doesnt support logarithic scale. However this can be accomplished, by doing the following:

    First let's add some points:(Note all values, must be greater then 0, because of log)

      //Creates an ArrayList
      ArrayList<DataPoint> testList = new ArrayList<>();
    
      //Populates the arrayList whit some values
      float value1 = (float) (Math.log10(1));
      float value2 = (float) (Math.log10(1000));
      float value3 = (float) (Math.log10(30));
      testList.add(new DataPoint(0, value1));
      testList.add(new DataPoint(1,value2));
      testList.add(new DataPoint(2, value3));
      testList.add(new DataPoint(3,value3));
      testList.add(new DataPoint(4, value2));
    
      //Converts ArrayList<DataPoints> to DataPoints[] array
      DataPoint[] test = new DataPoint[testList.size()];
      test = testList.toArray(test);
    
      //Adds the dataPoint array to the graph
      LineGraphSeries<DataPoint> seriesLine = new LineGraphSeries<>(test);
      graphQuality.addSeries(seriesLine);
    

    Second we gonna add our max value, take in notice this use log so, when we set the max value to 1600 doesn't mean the max value will be exactly 1600 but an aproximation to that value.(Complain float numbers not me).

        //Defines graph structure
        graphQuality.getViewport().setYAxisBoundsManual(true);
        graphQuality.getViewport().setMaxY(Math.floor(Math.log10(1600)));
        graphQuality.getViewport().setMinY(0);
    

    Finaly we format the Y value so that now replace the log values by the wanted values:

    graphExample.getLegendRenderer().setVisible(true);
    graphExample.getGridLabelRenderer().setLabelFormatter(new DefaultLabelFormatter() {
    @Override
         public String formatLabel(double value, boolean isValueX) {
             if (isValueX) {
                 return super.formatLabel(value, isValueX);
             } else {
                 String yValue=super.formatLabel(value, isValueX).replaceAll(",",".");
                 Float yLogValue = (float)Math.floor((Math.pow(10, Float.valueOf(yValue))));
                 return (value<=0)? "-∞":String.valueOf(yLogValue);
              }
          }
    });
    
    Reviewed by Yvtq8K3n at 2017-12-22 05:25
  • 7. Support for android 4.4, 4.4.2

    Hi, I used this awesome library, and it worked for my device, except for my nexus 5 (api 19). I saw in the manifest and the project properties that there is no support for api 19. Can you fix it please? The only problem I noticed is that the graph is not scalable and scrollable.

    Thanks, you do a greate job!

    Golan.

    Reviewed by Golanhershku at 2014-02-16 05:55
  • 8. GraphView must be used in hardware accelerated mode

    when i try to take a snapshot of my screen in which GraphView has been used, it throws me an error. "GraphView must be used in hardware accelerated mode" Even though i make it hardware "acceleration =true" on the required Activity and even on Application still the problem persists. I am using version Graphview 4.1.0

    Reviewed by BplAndroid at 2017-03-20 06:12
  • 9. Import with Eclipse failed: Plugin with id 'android-library' not found

    I'm new to Gradle so please excuse me, if this is just a noob asking sth. obvious:

    Since we still use Eclipse for our day-to-day Android programming, we need to somehow import your lib with the Eclipse Gradle Plugin (by the Spring guys). Uppon clicking the "Build Model" button on Gradles import wizard, the error from the title occurs.

    Can you give me some advice, how to solve this without a necessity of installing Android Studio? And please not just by "Install Android Studio"...

    Thank you in advance, Daniel

    Reviewed by bgmf at 2014-10-21 14:01
  • 10. BarGraphView

    Hello. I have some issues with BarGraphView; (vertical lines count and barwidth)

    There are quick fixes:

    //BarGraphView.java //float colwidth = (graphwidth - (2 * border)) / values.length; float colwidth = graphwidth / values.length;

    //GraphView.java // horizontal labels + lines int hors = horlabels.length; for (int i = 0; i <= horlabels.length; i++) { paint.setColor(Color.DKGRAY); float x = ((graphwidth / hors) * i) + horstart; canvas.drawLine(x, height - border, x, border, paint); paint.setTextAlign(Align.CENTER); if (i < horlabels.length) { paint.setColor(Color.WHITE); canvas.drawText(horlabels[i], x + (graphwidth / hors) / 2, height - 4, paint); } }

    Reviewed by lexius at 2012-05-06 11:49
  • 11. Unexpected freeze with real time updates

    My app requires drawing graph from real time data. I have thread with all the communication that is providing the data. In main thread I am reading this data and simply use mSeries1.appendData(new DataPoint(counter,data[0]),true,100); where counter is int that is incremented after each update.

    Unfortunately at some point it freeze. I've tried putting it in synchronized block or changing the line of code to mSeries1.appendData(new DataPoint(counter,counter),true,100); and still this same result.

    This is how the memory looks like during app running and when it freezes: memory

    Is that some library error or there is something wrong in my code?

    Reviewed by s-peryt at 2015-05-18 22:15
  • 12. App Crash

    Hello everyone,

    I am using this library for plotting real-time coming data. I clean the graph each 2000 samples reiceved in order to not stress the visualization capability. I also activate Log.v in some parts of my code. At some point in a randomly way I got this error from my Log:

    V/Plot 1: OK V/Plot 3: OK V/Plot 2: OK V/Plot 1: OK V/Plot 3: OK V/Plot 2: OK D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.myapplication.exo_app, PID: 2918 java.lang.NullPointerException: Attempt to invoke interface method 'double com.jjoe64.graphview.series.DataPointInterface.getX()' on a null object reference at com.jjoe64.graphview.series.BaseSeries.getLowestValueX(BaseSeries.java:125) at com.jjoe64.graphview.Viewport.calcCompleteRange(Viewport.java:741) at com.jjoe64.graphview.GraphView.onDataChanged(GraphView.java:283) at com.jjoe64.graphview.Viewport.scrollToEnd(Viewport.java:1180) at com.jjoe64.graphview.series.BaseSeries.appendData(BaseSeries.java:484) at com.jjoe64.graphview.series.LineGraphSeries.appendData(LineGraphSeries.java:677) at com.jjoe64.graphview.series.BaseSeries.appendData(BaseSeries.java:502) at com.example.myapplication.exo_app.MainActivity$Thread2$1.run(MainActivity.java:418) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7560) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) I/Process: Sending signal. PID: 2918 SIG: 9

    Based in my code in MainActivity.java:

    if (data[7]%plot_freq==0) { series.appendData(new DataPoint(x, pitch_1),true,500); Log.v("Plot 1","OK"); } if (data_2[7]%plot_freq==0) { series_2.appendData(new DataPoint(x, pitch_2),true,500); Log.v("Plot 2","OK"); } if (data_3[7]%plot_freq==0) { series_3.appendData(new DataPoint(x, pitch_3),true,500); Log.v("Plot 3","OK"); }

    It means that I got error before appending 3rd series. Has anyone has an idea?

    Thanks,

    Reviewed by valerio-arcobelli at 2022-03-30 13:00
  • 13. GraphView not getting any Data, Lines etc.

    Hey guys, i am really new in this and I have to make an app for a project in my school.. the thing is I am trying to put some Data in the GraphView but it´s not showing anything in the app.. I see the GraphView with default values only and my values don´t get shown in there.. i am using the bottom navigation tab and GraphView is in the home_fragment..so i made a public class (own file) under .ui.home and wrote this code : ` public class GraphActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_dashboard);
    
        GraphView graph = (GraphView) findViewById(R.id.graph);
    
        LineGraphSeries<DataPoint> series = new LineGraphSeries<>(new DataPoint[]{
                new DataPoint(0, 1),
                new DataPoint(1, 5),
                new DataPoint(2, 3),
                new DataPoint(3, 2),
                new DataPoint(4, 6)});
        graph.addSeries(series);
    
    }
    

    } ` i´m not getting any errors just the data is not being shown... thanks in advance

    Reviewed by mglbvc8 at 2022-03-29 17:57
  • 14. GridLabelRenderer humanRound causes data to be hidden

    In GridLabelRenderer.adjustHorizontal the call to humanRound is hardwired to false for the second argument. This means that the increments between labels will always round down. That leads to data being truncated from the graph.

    An easy way to see this is a one-line modification of the all-XML example given here. Replace the last line of

        <com.jjoe64.graphview.helper.GraphViewXML
            android:layout_width="match_parent"
            android:layout_height="100dip"
            app:seriesData="0=5;2=5;3=0;4=2" />
    

    with

            app:seriesData="100=5;150=5;200=0;250=2" />
    

    and you will see that the data, which runs from 100 to 250, is truncated at 180, hiding two of the four points. GraphTruncated

    There are several ways to address this I suppose, including

    • Just hardwire the value to true. This may waste a little screen space, but should not hide data.
    • Make the value user-configurable.
    • Adjust both the step size and number of labels for a possibly better compromise.
    Reviewed by VeloSteve at 2022-01-18 00:00
  • 15. Move text

    Copy-pasting an issue from a project that uses GraphView, Issue 355

    Describe the bug The text Wifi channels is too close to the numbers .

    Expected behavior There should be a little more space above the text (circled in the screenshot)

    Screenshots Screenshot_20210812-154353252_1.jpg

    Provide Device/Android OS information Asus zenfone 6, android 11 stock

    Reviewed by aha999 at 2021-10-09 18:37
  • 16. appendData performance issue simple fix

    Problem

    The line 456

    mData.remove(0);
    

    of BaseSeries.appendData function makes an internal copy of the whole array on each call. This is because mData is initialized as an ArrayList.

    Solution

    A simple solution would be changing the mData from ArrayList to LinkedList. A better solution would encorporate some sort of a fixed-size list to hide this routine into a simple instruction mData.add(dataPoint).

    Reviewed by dizcza at 2021-09-20 10:56
A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.

⚡ A powerful & easy to use chart library for Android ⚡ Charts is the iOS version of this library Table of Contents Quick Start Gradle Maven Documentat

Jun 25, 2022
Open-source native Android graph/chart framework includes line chart,stick chart,candlestick chart,pie chart,spider-web chart etc.
Open-source native Android graph/chart framework includes line chart,stick chart,candlestick chart,pie chart,spider-web chart etc.

Welcome to Android-Charts Welcome to Android-Charts project page on github.com. We just moved from Google Code. Android-Charts is an open-source andro

May 19, 2022
Android Tableau library supports variety of graphs which developers simply integrate visualization reports on Android application.
Android Tableau library supports variety of graphs which developers simply integrate visualization reports on Android application.

Android Tableau Library Android Tableau library supports variety of graphs which developers simply integrate visualization reports on Android applicat

May 28, 2022
Charts/graphs library for Android compatible with API 8+, several chart types with support for scaling, scrolling and animations
Charts/graphs library for Android compatible with API 8+, several chart types with support for scaling, scrolling and animations

HelloCharts for Android Charting library for Android compatible with API 8+(Android 2.2). Works best when hardware acceleration is available, so API 1

Jun 16, 2022
An android compose library with different Graphs and Charts
An android compose library with different Graphs and Charts

plot An android compose library with different Graphs and Charts (currently supports only Line graph, more types will be added soon) Download reposito

Jun 22, 2022
Simple Line, Circle, Bar chart for Android
Simple Line, Circle, Bar chart for Android

SimpleChart Simple Line, Circle, Bar chart for Android LineChart <com.aghajari.simplechart.LineChart android:id="@+id/line_chart" android:layo

Mar 18, 2022
An Android chart and graph library
An Android chart and graph library

EazeGraph EazeGraph is an Android library for creating beautiful and fancy charts. Its main goal was to create a lighweight library which is easy to u

Jun 19, 2022
AnyChart Android Chart is an amazing data visualization library for easily creating interactive charts in Android apps. It runs on API 19+ (Android 4.4) and features dozens of built-in chart types.
AnyChart Android Chart is an amazing data visualization library for easily creating interactive charts in Android apps. It runs on API 19+ (Android 4.4) and features dozens of built-in chart types.

AnyChart for Android AnyChart Android Charts is an amazing data visualization library for easily creating interactive charts in Android apps. It runs

Jun 23, 2022
BubbleTabBar is bottom navigation bar with customizable bubble like tabs
BubbleTabBar is bottom navigation bar with customizable bubble like tabs

BubbleTabBar BubbleTabBar is bottom navigation bar with customizable bubble like tabs Download AIX : Download Aix License Licensed under the Apache Li

Jan 1, 2022
PopupBarChart 📊 can shows a tooltip when user click on the bar 😍 🤩
 PopupBarChart 📊 can shows a tooltip when user click on the bar 😍 🤩

PopupBarChart ?? can shows a tooltip when user click on the bar ?? ??

May 16, 2022
Android Library to rapidly develop attractive and insightful charts in android applications.
Android Library to rapidly develop attractive and insightful charts in android applications.

williamchart Williamchart is an Android Library to rapidly implement attractive and insightful charts in android applications. Note: WilliamChart v3 h

Jun 17, 2022
Android Library to rapidly develop attractive and insightful charts in android applications.
Android Library to rapidly develop attractive and insightful charts in android applications.

williamchart Williamchart is an Android Library to rapidly implement attractive and insightful charts in android applications. Note: WilliamChart v3 h

Dec 22, 2021
Android library for drawing Pie charts and Donut charts with the ability to customize almost anything in it.
Android library for drawing Pie charts and Donut charts with the ability to customize almost anything in it.

A Pie/Donut*/Ring chart for Android, customizable to the most extent possible. For tutorial and examples refer to the website. build.gradle[.kts] impl

Jun 19, 2022
An open source library used to draw charts in Android with Jetpack Compose with a simple and easy to use
An open source library used to draw charts in Android with Jetpack Compose with a simple and easy to use

android-compose-charts This is an open source library used to draw charts in Android with Jetpack Compose with a simple and easy to use. Just couples

Jun 15, 2022
Charting library for Android applications. Automatically exported from code.google.com/p/achartengine

achartengine Charting library for Android applications. Automatically exported from code.google.com/p/achartengine AChartEngine is a charting library

Jun 16, 2022
An easy-to-use Android charts library with animation.
An easy-to-use Android charts library with animation.

AndroidCharts A simple Android charts library. Known Uses in Pomotodo Including in Your Project Eclipse Import /AndroidCharts folder. Move /java folde

Jun 17, 2022
Android Charting Library
Android Charting Library

What is desCharts? yet another android charting library Why the name desCharts? a tribute to René Descartes, father of analytical geometry Where is th

Jan 12, 2022
A Powerful Android Charting Library by https://www.numetriclabz.com/
A Powerful Android Charting Library by https://www.numetriclabz.com/

numAndroidCharts A Powerful Android Charting Library by Numetric Technologies Features Core features: [Line Chart](#Line Chart) [Bar Chart](#Bar Chart

May 7, 2022