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

Related tags

Charts android chart
Overview

HelloCharts for Android

Charting library for Android compatible with API 8+(Android 2.2). Works best when hardware acceleration is available, so API 14+(Android 4.0) is recommended. Apache License 2.0.

Android Arsenal Coverity Scan Build Status Maven Central Release

Features

  • Line chart(cubic lines, filled lines, scattered points)
  • Column chart(grouped, stacked, negative values)
  • Pie chart
  • Bubble chart
  • Combo chart(columns/lines)
  • Preview charts(for column chart and line chart)
  • Zoom(pinch to zoom, double tap zoom), scroll and fling
  • Custom and auto-generated axes(top, bottom, left, right, inside)
  • Animations

Screens and Demos

  • Code of a demo application is in hellocharts-samples directory, requires appcompat v21.
  • The demo app is also ready for download on Google Play.
  • Short video is available on YouTube.

Download and Import

Android Studio/Gradle

  • Maven Central/jCenter, add dependency to your build.gradle:
   dependencies{
		compile 'com.github.lecho:hellocharts-library:1.5.8@aar'
   }
  • JitPack.io, add jitpack.io repositiory and dependency to your build.gradle:
   repositories {
       maven {
           url "https://jitpack.io"
       }
   }
   
   dependencies {
       compile 'com.github.lecho:hellocharts-android:v1.5.8'
   }

Eclipse/ADT

  • Download the latest release jar file.
  • Copy hellocharts-library-<version>.jar into the libs folder of your application project.

Usage

Every chart view can be defined in layout xml file:

   <lecho.lib.hellocharts.view.LineChartView
       android:id="@+id/chart"
       android:layout_width="match_parent"
       android:layout_height="match_parent" />

or created in code and added to layout later:

   LineChartView chart = new LineChartView(context);
   layout.addView(chart);

Use methods from *Chart classes to define chart behaviour, example methods:

   Chart.setInteractive(boolean isInteractive);
   Chart.setZoomType(ZoomType zoomType);
   Chart.setContainerScrollEnabled(boolean isEnabled, ContainerScrollType type);

Use methods from data models to define how chart looks like, example methods:

   ChartData.setAxisXBottom(Axis axisX);
   ColumnChartData.setStacked(boolean isStacked);
   Line.setStrokeWidth(int strokeWidthDp);

Every chart has its own method to set chart data and its own data model, example for line chart:

   List<PointValue> values = new ArrayList<PointValue>();
   values.add(new PointValue(0, 2));
   values.add(new PointValue(1, 4));
   values.add(new PointValue(2, 3));
   values.add(new PointValue(3, 4));

   //In most cased you can call data model methods in builder-pattern-like manner.
   Line line = new Line(values).setColor(Color.BLUE).setCubic(true);
   List<Line> lines = new ArrayList<Line>();
   lines.add(line);

   LineChartData data = new LineChartData();
   data.setLines(lines);

   LineChartView chart = new LineChartView(context);
   chart.setLineChartData(data);

After the chart data has been set you can still modify its attributes but right after that you should call set*ChartData() method again to let chart recalculate and redraw data. There is also an option to use copy constructor for deep copy of chart data. You can safely modify copy in other threads and pass it to set*ChartData() method later.

Contributing

Yes:) If you found a bug, have an idea how to improve library or have a question, please create new issue or comment existing one. If you would like to contribute code fork the repository and send a pull request.

License

HelloCharts	
Copyright 2014 Leszek Wach

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

 HelloCharts library uses code from InteractiveChart sample available 
 on Android Developers page:
 
   http://developer.android.com/training/gestures/scale.html
Comments
  • Out Of Memory Error Since hellocharts used

    Out Of Memory Error Since hellocharts used

    Hello,

    I'm french, so sorry for my bad english...

    I'm an Android developer and, in my app, i recently add hellocharts to replace another old chart library. It's a very beautiful lib, and i congratulate developers :-)

    But I've a problem since i imported this solution in my fragments of an activity...

    Now i often have Out Of Memory Errors that make my app crash. When i see the error log I see each time :

    " java.lang.OutOfMemoryError at android.graphics.Bitmap.nativeCreate(Native Method) ... at lecho.lib.hellocharts.renderer.LineChartRenderer.initDataMeasuremetns(LineChartRenderer.java:93)"

    and i don't know what to do in my onStop() or onDestroy() functions to make it disappear... I tried to use chart.destroyDrawingCache() function but it seems to be useless.... Could you help me please?

    Thank you very much!

    Regards.

    opened by sol4ris2048 16
  • View Axis data

    View Axis data

    thanks for the help. the viewport thing help me to show more of the graph.

    But my 1st problem was that i was not able to see the value of the graph

    //values of the axeY
    List<AxisValue> axisValuesForY = new ArrayList<AxisValue>();
    
    for (int i = 1; i < 100; i +=10){
        axisValuesForX.add(new AxisValue(i));
    }
    
    Axis axeX = new Axis(axisValuesForX);
    Axis axeY = new Axis(axisValuesForY);
    
    data.setAxisXBottom(axeX);
    data.setAxisYLeft(axeY);
    

    i've done this and nothing show's up on the axeY neither for X. Plus i've put this.

    axeX.setName("Days");
    axeY.setName("amount");
    

    and only day is displayed

    bug 
    opened by thomaslc66 15
  • help with multiple lines

    help with multiple lines

    goodmorning,

    i'm using your library but i have some problem with multiple lines.

    1. it's possible to create two different lines using differents axis without using scale and range?

    2. i use that code:

    ArrayList axisValues = new ArrayList(); for (float i = 0; i < maxTime; i += 1000) { axisValues.add(new AxisValue(i, moreWorkouts .formatMinutes((long) i))); } Axis tempoAxis = new Axis(axisValues) .setMaxLabelChars(5) .setTextColor(Color.RED) .setHasSeparationLine(false) .setFormatter( new HeightValueFormater(scale, sub, 1, null, null));

    where formatMinutes create char in format hh:mm. By this the formatter look not work and the value of axis result not scaled.

    1. it's possible to have dinamically decimal number using setFormatter for axis right, like axis without setFormatter.

    sorry for my english. thanks a lot. nicholas

    bug 
    opened by Lemen47Nic 13
  • How to use AxisValueFormatter() and SimpleLineChartValueFormatter()

    How to use AxisValueFormatter() and SimpleLineChartValueFormatter()

    The looked in to the sample app and couldn't find a self-explanatory usage of the classes AxisValueFormatter() and SimpleLineChartValueFormatter(). Would be great if you could give some explanation of these classes, their methods and how to use them.

    I'm seeking to format my chart's axis values extensively... so in dire need of this. Thanks!

    opened by hfahmy 11
  • Legend and title - ability to set chart title and legend

    Legend and title - ability to set chart title and legend

    I don't know if this already exists, or if this should be part of the charts, but I thought I'd suggest these anyway in case it makes sense:

    • The ability to set a title that appears somewhere in the LineChart area. Something like chart.setTitle
    • The ability to show a legend (eg when using multiple line) indicating what the different line colors mean. I suppose this could be derived from something like Line.setName.

    Anyway, thanks for all the work on this chart, it's very nice and easy to use. The structure of the charts has been well thought out.

    enhancement 
    opened by mendhak 11
  • One option for label 45º.

    One option for label 45º.

    I thought of creating an option for the label is printed in 45º, or the user's choice. As you can see in the picture, the data may be confusing in some cases. What do you think?

    Before screenshot_2014-12-24-09-42-32 - before

    After screenshot_2014-12-24-09-40-54 - after

    Something like this:

    AxesRenderer.java

        private void drawAxisHorizontalLabels(Canvas canvas, Axis axis, int position) {
            final Rect contentRectMargins = chart.getChartComputator().getContentRectWithMargins();
    
    
            for (int valueToDrawIndex = 0; valueToDrawIndex < axisValuesToDrawNumTab[position]; ++valueToDrawIndex) {
                int charsNumber = 0;
    
                if (axis.isAutoGenerated()) {
                    final float value = axisAutoValuesToDrawTab[position][valueToDrawIndex];
                    charsNumber = axis.getFormatter().formatValueForAutoGeneratedAxis(labelBuffer, value,
                            axisAutoValuesBufferTab[position].decimals);
                } else {
                    AxisValue axisValue = axisValuesToDrawTab[position][valueToDrawIndex];
                    charsNumber = axis.getFormatter().formatValueForManualAxis(labelBuffer, axisValue);
                }
    
                canvas.save(); // here
                canvas.rotate(degrees ,axisRawValuesTab[position][valueToDrawIndex], axisFixedCoordinateTab[position]); // here
                canvas.drawText(labelBuffer, labelBuffer.length - charsNumber, charsNumber,
                        axisRawValuesTab[position][valueToDrawIndex], axisFixedCoordinateTab[position],
                        textPaintTab[position]);
                canvas.restore(); // here
            }
    
    
            // Drawing axis name
            if (!TextUtils.isEmpty(axis.getName())) {
                textPaintTab[position].setTextAlign(Align.CENTER);
                canvas.drawText(axis.getName(), contentRectMargins.centerX(), axisNameBaselineTab[position],
                        textPaintTab[position]);
            }
        }
    
    enhancement 
    opened by douglasjunior 10
  • setAutoGenerated(true) with Date values

    setAutoGenerated(true) with Date values

    I want to show a set of dates in the X Axis that can adjust the visible range (show/hide) based on zoom level (like the integers when setAutoGenerated(true) is set). How can I do it?

    opened by jaichandra 8
  • Question about label

    Question about label

    I wanna show this effect: chart but in my codes , the effect like this: chart2 is there some thing wrong ? how can I get that . and can I make the "日期" from center to the left position .

    question 
    opened by yfsyyy 7
  • Is there a way to limit the Lines of YAxis in LineChartView ?

    Is there a way to limit the Lines of YAxis in LineChartView ?

    Hello Guys!

    My Input values are from 0 to 6 and the Lines the YAxis are displaying are 0, 0.3, 0.6, 0.9 .... 5.1, 5.4, 5.7. just like in the picture below: device-2015-09-14-012016

    Is there are way to limit it to 5 lines + offset like in the picture below? assuming that the data is 0 to 6

    12026618_419486551595044_1069217485_n

    Additonal question: Can I make the style of the line dashed?

    opened by raquezha 6
  • divide by zero in lecho.lib.hellocharts.renderer.AxesRenderer.prepareCustomAxis

    divide by zero in lecho.lib.hellocharts.renderer.AxesRenderer.prepareCustomAxis

    Hi, I get java.lang.ArithmeticException: divide by zero in lecho.lib.hellocharts.renderer.AxesRenderer.prepareCustomAxis This exception occurs when I have only one value for LineChartData. My point data looks like this: PointValue [x=1.4261441E12, y=64.0] where 'x' is timestamp. I want to show day of week on x axis, so I add also a list of AxisValue where AxisValue [label=[T,h,u], value=1.426144100352E12] Then:

    lineChartData = new LineChartData(); Axis axis = new Axis(axisLabels).setHasLines(true); axis.setMaxLabelChars(100); lineChartData.setAxisXBottom(axis); //! THIS LINE CAUSE AN EXCEPTION lineChartData.setAxisYLeft(new Axis().setHasLines(true)); lineChartData.setLines(graphLines);

    Removing lineChartData.setAxisXBottom(axis); line resolve the problem, but custom x axis label don't work in this case

    bug 
    opened by kitolog 6
  • How to use hellocharts as an external offline lib or jar?

    How to use hellocharts as an external offline lib or jar?

    I have alot of trouble with using this library as an offline external lib. Whatever I try to do in Android Studio everything fails. Is it possible to import it is a jar and add it as a library in Android Studio?

    opened by Muddz 5
  • library configuration

    library configuration

    I couldn't configured library in my project. I had done in my way what I have to do and also followed your instructions in your readme file. Please help me. Thanks

    opened by tejagalande 0
  • Unsupported Modules Detected

    Unsupported Modules Detected

    I'm getting this error when I sync after adding the dependency.

    7:07 PM Unsupported Modules Detected: Compilation is not supported for following modules: App Name. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.

    opened by qayyumabro 0
  • About the problem that the y-axis is not displayed.

    About the problem that the y-axis is not displayed.

    My x-axis is displayed normally, but the y-axis is not displayed. How can I solve this? Where is the root of the problem?? This is my email: [email protected] && [email protected] I am very grateful to you for solving this problem for me Here is my code ↓:

    ` List axisX = new ArrayList<>(); for(int index = 0; index < GPST.size(); index++) axisX.add(new AxisValue(index).setLabel(GPST.get(index)));

                        List<AxisValue> axisY = new ArrayList<>();
                        for(int index = 0; index < Dist.size(); index++) {
                            axisY.add(new AxisValue(index).setLabel(Dist.get(index)));
                        }
    
                        // This is Y axis
                        Axis axis1 = new Axis();
                        axis1.setValues(axisX);
                        axis1.setTextColor(Color.BLUE);
    
                        // This is Y axis
                        Axis axis2 = new Axis();
                        axis2.setValues(axisY);
    
                        data.setAxisXBottom(axis2);
                        data.setAxisYLeft(axis1);
                        lineChartView.setLineChartData(data);
    

    `

    opened by YongfaWang 0
  • 关于一个点问题(已解决)

    关于一个点问题(已解决)

    关于一个点不显示问题,网上找了很多方案,大致都是说要去改源码的,但我觉得比较麻烦,说下我的解决方法: 我是判断如果我的列表只有一个值的话,就动态给添加一个空数据元素(value为负数),这样相当于是两个点,而第二个点的值是负数,那就会把第二个点绘制到x轴的下面,这样就看不到了,也就是默认显示了一个点带一根线,然后动态判断把这个线设置成白色即可 a855ff66768075231cba7b5bbc543f9 微信截图_20210612163019

    ;下面是截图:

    opened by xcode126 0
  • Horizontal spacing between points

    Horizontal spacing between points

    I have a line chart filled with 432 points. The graph looks very cluttered and I was wondering if it is possible to set a horizontal distance between each point. halp As you can see above the points are very close together (and for some reason the y axis has multiple points for the same number)

    opened by Cyber-cp 0
Releases(v1.5.8)
Owner
Leszek Wach
Leszek Wach
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

limc.cn 813 Dec 20, 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 for Android AnyChart Android Charts is an amazing data visualization library for easily creating interactive charts in Android apps. It runs

AnyChart 2k Jan 4, 2023
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

Philipp Jahoda 36k Dec 31, 2022
A powerful 🚀 Android range bar chart library as well as scaling, panning and animations.

RangeBarChart ⚡ Range bar chart library for Android using MPAndroidChart ⚡ There were no charts in MPAndroidChart to show ranges. We were forced to sh

Ted Park 8 Nov 24, 2022
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

Madrapps 106 Dec 30, 2022
Straiberry Charts - An awesome Chart library for android

Straiberry Charts An awesome Chart library for android Straiberry · Report Bug · Request Feature Getting Started Adding dependecies Add it in your roo

StrAIberry 30 Dec 30, 2022
Jetpack-linear-chart - A simple way to draw linear chart using Jetpack Compose

jetpack-linear-chart A simple way to draw linear chart using Jetpack Compose We

Bruno Gabriel dos Santos 8 Jan 4, 2023
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

Mahdi Hosseinzadeh 20 Nov 18, 2022
Arc Chart View (Draw Creative Statistic Arc Charts)

ArcChartViewDemo You can use this library to draw Arc charts and show your statistics or anything you want or maybe get some ratings from user. you ca

Iman khoshabi 106 Nov 22, 2022
Library for charts in android with animations

Charts Gradle Setup Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories: allprojects {

Ayush Saini 4 Dec 30, 2022
A basic chart written by kotlin. Support animation loading, touch event monitoring and JSON data.

A basic chart written by kotlin. Support animation loading, touch event monitoring and JSON data.

null 2 Dec 21, 2022
Android Graph Library for creating zoomable and scrollable line and bar graphs.

Chart and Graph Library for Android Project maintainer wanted! For time reasons I can not continue to maintain GraphView. Contact me if you are intere

Jonas Gehring 2.7k Jan 5, 2023
Android Graph Library for creating zoomable and scrollable line and bar graphs.

Chart and Graph Library for Android Project maintainer wanted! For time reasons I can not continue to maintain GraphView. Contact me if you are intere

Jonas Gehring 2.7k Jan 2, 2023
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

Sung Hyun 54 Jan 1, 2023
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

Paul Cech 1.6k Dec 23, 2022
An Elementary Chart library for Jetpack Compose

Charty : Elementary Chart library for Compose Chart Library built using Jetpack Compose and is highly customizable. Updates coming soon! Made with ❤️

Himanshu Singh 491 Jan 9, 2023
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

Diogo Bernardino 4.9k Dec 30, 2022
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

Diogo Bernardino 4.8k Dec 22, 2021
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

Mahmoud Ibrahim 17 Dec 31, 2022