Examples for my Android GraphView library

Related tags

Demo GraphView-Demos
Overview

Chart and Graph Library for Android

GraphView - open source graph plotting library for Android

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

Create Line Graphs, Bar Graphs, Point Graphs or implement your own custom types.

Try the Demo app at Play Store

[https://play.google.com/store/apps/details?id=com.jjoe64.graphview_demos]

Visit the project homepage

[http://www.android-graphview.org/]

Comments
  • Real Time graph issue

    Real Time graph issue

    Hey joe, i am trying to create real time graph . The data on graph will come from bluetooth , it's a massive amount of data and very fast rate lets say 1sec =60 samples of data

    problem is when i used appendata to add the data and fixed max data points to 400 ,it crashes after some time . i debug it , it causes memory leakage

    final String[] arr = str.replace("[", "").replace("]", "").split(",");

    for (int i = 0; i < arr.length; i++) { mSeries.appendData(new DataPoint(graph2LastXValue, Double.parseDouble(arr[i])),true,380); //DataPoint v = new DataPoint(graph2LastXValue,Double.parseDouble(arr[i])); // myArr[i]=v; // mSeries2.appendData(myArr[i], true, 380); graph2LastXValue++;

    }

    opened by abh22ishek 15
  • Can't get provided code to run

    Can't get provided code to run

    Hi!

    These errors popped up when I tried to run the app from the get go, without modifying any code from the GraphView-Demos-master project I downloaded from here: [https://github.com/jjoe64/GraphView-Demos]

    image

    Any clue as to what's going on? Thanks a lot before hand!

    opened by jamin-hu 2
  • lose all data if screen orientation is changed in RealtimeGraph

    lose all data if screen orientation is changed in RealtimeGraph

    I used the example code of RealtimeGraph at https://github.com/jjoe64/GraphView-Demos/blob/master/graphviewdemos/src/main/java/com/jjoe64/graphviewdemos/RealtimeGraph.java

    Whenever the screen orientation is changed, the graph is restarted again and all the previous data is not displayed.

    How do i stop restarting the graph every time the screen orientation is changed?

    opened by xxxazxxx 2
  • scrollToEnd in realtime sample doesn't work (Android 4.2.2 Nexus 7)

    scrollToEnd in realtime sample doesn't work (Android 4.2.2 Nexus 7)

    tried samples on Nexus7, compiled with Android 4.2.2 and it seems that Realtime Graph sample doesn't correctly do scrollToEnd=true within GrahViewSeries.appendData method.

    From video you can se that Y labels actually updates but linechart stays same. I created video but only images are allowed :) - I can send it to you by email.

    opened by zhivko 2
  • Program type already present: android.support.v4.app.FragmentTransitionCompat21$1

    Program type already present: android.support.v4.app.FragmentTransitionCompat21$1

    Hello there,

    After opening a new empty android studio project and typing compile 'com.jjoe64:graphview:4.2.1' into the app's build.gradle file, I get this error. It is also appearing on android studio of a colleague of mine:

    Program type already present: android.support.v4.app.FragmentTransitionCompat21$1

    Any idea what's going on?

    Thanks a lot before hand, excited to get started with GraphView! :)

    opened by jamin-hu 1
  • Cannot resolve constructor

    Cannot resolve constructor

    This isn't so much an issue but a question about using GraphView inside a fragment activity. I am getting an error Cannot resolve constructor LineGraphView

    GraphView graphView; graphView = new LineGraphView(this, message); graphView.addSeries(exampleSeries); // data

    I posted on stackoverflow and then realized I should ask here http://stackoverflow.com/questions/21326875/android-cannot-resolve-constructor-lineviewgraph

    opened by FriedCircuits 1
  • Unable to break graph line when multiple series in single line graph.

    Unable to break graph line when multiple series in single line graph.

    Hello Team,

    Please give any way to break line graph when we are updating multiple series with respect of time. if we are unable to find value in any series than i want to show break then when value not available.

    opened by sachinchoudhary085 0
  • Problem with resetData() method in BaseSeries class

    Problem with resetData() method in BaseSeries class

    Hi everyone!

    While using this library(thanks for it!) I stuck when I need to reset data on my GraphView.

    I store my data as LineGraphSeries object, independent from activity lifecycle, so when activity created, or resumed I need to refresh data in another LineGraphSeries object which is associated with GraphView.

    I check source code of BaseSeries class and found method resetData(E[] data), but it take as input only array of data and it is very hard to get those array, because in BaseSeries class there is only one method to getting data: getValues() and it returns Iterator<E>.

    So to get array I need go through this iterator and write values to ArrayList first(because Iterator can't tell us how much elements it has), and finally I can create array and write to it values from ArrayList.

    I think it's very long and not effective, so I suggest with minimum changes:

    • add getter method to BaseSeries class, which will return [] E - array of data values

    And to increase usability in this reseting data case:

    • add overload constructors to BaseSeries, LineGraphSeries, BarGraphSeries, PointsGraphSeries which will take as argument ArrayList <E>
    • add overload version of resetData() method, which will take as argument ArrayList
    • add getter method to BaseSeries class, which will return ArrayList<E>

    So what do think about my suggestion?

    opened by VitaliyBelyaev 0
  • Library dynamic loading error

    Library dynamic loading error

    With ADT (version 21.0.0.v201210310015-519525) The library is correctly used for autocompletion, but is not used at run time, resulting in a java.lang.NoClassDefFoundError !

    Correction: Move jar from lib ditectory to libs one (with a "S")

    See answer : http://stackoverflow.com/a/9916751

    accepted 
    opened by JackDesBwa 0
  • Static label only in y-axis

    Static label only in y-axis

    When I put static labels only in the y-axis, happens this: image

    Well, I just want the date, and what seems to happen is that it puts the two values on the same axis (x-axis). Here's my code: ` class MainActivity : AppCompatActivity() {

    private var mNumLabels: Int = 4
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val graph = findViewById<GraphView>(R.id.graph)
        initGraph(graph)
    }
    
    fun initGraph(graph: GraphView) {
        // generate Dates
        val calendar = Calendar.getInstance()
        val d1 = calendar.time
        calendar.add(Calendar.DATE, 1)
        val d2 = calendar.time
        calendar.add(Calendar.DATE, 1)
        val d3 = calendar.time
    
        // you can directly pass Date objects to DataPoint-Constructor
        // this will convert the Date to double via Date#getTime()
        val series = LineGraphSeries(arrayOf<DataPoint>(DataPoint(d1, 2.0), DataPoint(d2, 5.0), DataPoint(d3, 3.0)))
        graph.addSeries(series)
    
    
        series.isDrawDataPoints = true
        series.isDrawBackground = true
        // set date label formatter
        graph.gridLabelRenderer.labelFormatter = DateAsXAxisLabelFormatter(graph.context)
        graph.gridLabelRenderer.numHorizontalLabels = mNumLabels
    
    
        // second series
        val series2 = LineGraphSeries(
            arrayOf(
                DataPoint(d1, 3.0),
                DataPoint(d2, 3.0),
                DataPoint(d3, 6.0)
            )
        )
        series2.title = "speed"
        series2.isDrawBackground = true
        series2.color = Color.argb(255, 255, 60, 60)
        series2.backgroundColor = Color.argb(100, 204, 119, 119)
        series2.isDrawDataPoints = true
        graph.addSeries(series2)
    
        // second series
        val series3 = LineGraphSeries(
            arrayOf(
                DataPoint(d1, 3.0),
                DataPoint(d3, 2.0)
            )
        )
    
        series2.title = "HEY"
        series2.isDrawBackground = true
        series2.color = Color.argb(255, 255, 60, 60)
        series2.backgroundColor = Color.argb(100, 204, 119, 119)
        series2.isDrawDataPoints = true
        graph.addSeries(series3)
    
        // legend
        graph.legendRenderer.isVisible = true
        graph.legendRenderer.align = LegendRenderer.LegendAlign.BOTTOM
    
        // set manual x bounds to have nice steps
        graph.viewport.setMinX(d1.time.toDouble())
        graph.viewport.setMaxX(d3.time.toDouble())
        graph.viewport.isXAxisBoundsManual = false
    
        graph.gridLabelRenderer.setHumanRounding(false)
    
        val staticLabelsFormatter = StaticLabelsFormatter(graph)
        staticLabelsFormatter.setVerticalLabels(arrayOf("low", "hey", "high", "wei", "wai"))
        graph.gridLabelRenderer.labelFormatter = staticLabelsFormatter
    }
    

    }

    `

    When I take this: val staticLabelsFormatter = StaticLabelsFormatter(graph) staticLabelsFormatter.setVerticalLabels(arrayOf("low", "hey", "high", "wei", "wai")) graph.gridLabelRenderer.labelFormatter = staticLabelsFormatter Everything works fine... but then I can't use static labels. Can you help me?

    opened by joseRelvasF3m 0
  • Error in advanced bar graph.

    Error in advanced bar graph.

    In BarGraphFragment call by error FullscreenExample.ADVANCED_LINE_GRAPH instead of FullscreenExample.ADVANCED_BAR_GRAPH

        new AdvancedBarGraph().initGraph(graph);
        rootView.findViewById(R.id.cardAdvancedBarGraph).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                openFullscreen(FullscreenExample.ADVANCED_BAR_GRAPH);
            }
        });
        rootView.findViewById(R.id.imgFullscreen2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                openFullscreen(FullscreenExample.ADVANCED_LINE_GRAPH);
            }
        });
        rootView.findViewById(R.id.imgSource2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                openSource(FullscreenExample.ADVANCED_LINE_GRAPH);
    
    opened by oscarsan1 0
  • Date Redundance

    Date Redundance

    Hi, their support date redundance based on picture I attach and below following code that i follow

    ` DateFormat fmt1 = new SimpleDateFormat("MMMM dd, yyyy", Locale.US); Date d1 = null,d2 = null,d3 = null,d4 = null,d5 = null,d6 = null,d7 = null, d8 = null,d9 = null,d10 = null,d11 = null, d12 = null;

        try {
            d1 = fmt1.parse("January 1,  2018");
            d2 = fmt1.parse("February 1,  2018");
            d3 = fmt1.parse("March 1,  2018");
            d4 = fmt1.parse("April 1,  2018");
            d5 = fmt1.parse("May 1,  2018");
            d6 = fmt1.parse("June 1,  2018");
            d7 = fmt1.parse("July 1,  2018");
            d8 = fmt1.parse("August 1,  2018");
            d9 = fmt1.parse("September 1,  2018");
            d10 = fmt1.parse("October 1,  2018");
            d11 = fmt1.parse("November 1,  2018");
            d12 = fmt1.parse("December 1,  2018");
        } catch (ParseException e) {
            e.printStackTrace();
        }
    
        graphView = (GraphView)v.findViewById(R.id.graph);
    
        series = new LineGraphSeries<>(new DataPoint[] {
                new DataPoint(d1, 0),
                new DataPoint(d2, 123.00),
                new DataPoint(d3, 200.00),
                new DataPoint(d4, 145.00),
                new DataPoint(d5, 150.00),
                new DataPoint(d6, 180.00),
                new DataPoint(d7, 0.00),
                new DataPoint(d8, 0.00),
                new DataPoint(d9, 0.00),
                new DataPoint(d10, 0.00),
                new DataPoint(d11, 30.00),
                new DataPoint(d12, 0.00)
        });
        series.setColor(ContextCompat.getColor(getActivity(), R.color.bgwhite));
    
        //series.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.bgwhite));
        graphView.addSeries(series);
    
        // set date label formatter
        DateFormat fmt = new SimpleDateFormat("MMM", Locale.US);
        graphView.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(getActivity(), fmt));
        graphView.getGridLabelRenderer().setNumHorizontalLabels(12); // only 4 because of the space
        graphView.getGridLabelRenderer().setTextSize(20f);
        graphView.getGridLabelRenderer().setLabelHorizontalHeight(10);
    
        // set manual x bounds to have nice steps
        graphView.getViewport().setMinX(d1.getTime());
        graphView.getViewport().setMaxX(d12.getTime());
    
        graphView.getViewport().setXAxisBoundsManual(true);
        //graphView.getViewport().calcCompleteRange();
    
        // as we use dates as labels, the human rounding to nice readable numbers
    

    // is not necessary graphView.getGridLabelRenderer().setHumanRounding(false); // show line graph y whatsapp image 2018-06-27 at 11 44 10 am `

    opened by hafiz013 0
  • Inconsistent behavior with date series

    Inconsistent behavior with date series

    Hi everyone I'm very pleased with the library, great works!

    Problem is, I don't understand why it behaves inconsistently, meaning that one time it shows like this (without date X labels and incorrect Y axis rounding)

    image image

    in place of the correct display image

    image

    I'm following the example Dates.java https://github.com/jjoe64/GraphView-Demos/blob/master/app/src/main/java/com/jjoe64/graphview_demos/examples/Dates.java

    if (story.getId().equals(storyId)) {
        GraphView graph = (GraphView) findViewById(R.id.graph);
        DataPoint[] dataPoints = new DataPoint[story.getMetrics().size()];
        int i = 0;
        for (Story.Metric metric : story.getMetrics()) {
            dataPoints[i] = new DataPoint(metric.getDate(), (int)metric.getConversations());
            i++;
        }
        LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(dataPoints);
        series.setAnimated(true);
        graph.addSeries(series);
        graph.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(graph.getContext(), new SimpleDateFormat(LABEL_DATE_FORMAT)));
        graph.getGridLabelRenderer().setNumHorizontalLabels(dataPoints.length);
        // as we use dates as labels, the human rounding to nice readable numbers
        // is not nessecary
        graph.getGridLabelRenderer().setHumanRounding(false);
    
        // set manual x bounds to have nice steps
        graph.getViewport().setMinX(story.getMetrics().get(0).getDate().getTime());
        graph.getViewport().setMaxX(story.getMetrics().get(story.getMetrics().size() - 1).getDate().getTime());
        graph.getViewport().setXAxisBoundsManual(true);
    
    }
    

    I'm really puzzled..

    thanks nicola

    opened by nicolabeghin 1
Owner
Jonas Gehring
Mobile App Developer
Jonas Gehring
! Usage examples for Android Maven Plugin

Android Maven Plugin - Sample Projects WARNING This project is deprecated. All sample projects for the Android Maven Plugin as of version 4.0.0-rc.1 a

Jayway 190 Nov 28, 2022
RxJava architecture library for Android

Reference Architecture for Android using RxJava This is an ambitious reference project of what can be done with RxJava to create an app based on strea

Reark 2.1k Dec 17, 2022
Sample Project for Android Support Library 23.2

SnapShot: Contains features Vector Drawable Animated Vector Drawable AppCompat DayNight theme Bottom Sheets Using BottomSheetDialog in day-night mode.

Huqiu Liao 779 Nov 24, 2022
RoboDemo is a ShowCase library for Android to demonstrate to users how a given Activity works.

RoboDemo RoboDemo is a ShowCase library for Android to demonstrate to users how a given Activity works. A sample is available in the download area of

Stéphane Nicolas 220 Nov 25, 2022
RxJava architecture library for Android

Reference Architecture for Android using RxJava This is an ambitious reference project of what can be done with RxJava to create an app based on strea

Reark 2.1k Dec 17, 2022
an easy to use android library to let devs know how much internet-data their app is consuming

EasyAnalytics! an easy to use android library to let developers know how much internet-data their app is consuming. We can identify this as we want ba

Sachin Rajput 13 Feb 21, 2022
Non-official Library Genesis (Libgen) Android mobile client.

Aurora If my noble work has helped you, consider becoming a . This is a non-official Library Genesis mobile client. The project is completely independ

null 318 Dec 23, 2022
Viacheslav Veselov 0 Jul 8, 2022
Create curve bottom navigation using this library

Curve Bottom Bar Download Add it to your build.gradle with: allprojects { repositories { maven { url "https://jitpack.io" } } } and: d

null 49 Sep 17, 2022
SquircleView is a library which provides you with Squircle views to use for buttons, views, etc.

SquircleView SquircleView is a library which provides you with Squircle views to use for buttons, views, etc. Screenshots Different kinds of buttons,

Juky 96 Dec 15, 2022
This is a repository for implementing Brontodroid and test it easily before we finalize things into a library/module to be consumed separately.

Bronto Playground This is a repository for implementing Brontodroid and test it easily before we finalize things into a library/module to be consumed

Ishat Gupta 1 Nov 30, 2021
Quality-Tools-for-Android 7.5 0.0 L5 Java This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android platform.

Quality Tools for Android This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android pl

Stéphane Nicolas 1.3k Dec 27, 2022
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Mike Penz 1.8k Nov 10, 2022
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Mike Penz 1.8k Nov 10, 2022
simple android grocery app using kotlin and android studio

Project Idea The idea of this project is to make a grocery android app that users can use to order the groceries they want. It doesn't contain any bac

null 0 Nov 29, 2021
Beetlebug is an open source insecure Android application with CTF challenges built for Android Penetration Testers and Bug Bounty hunters.

Beetlebug Beetlebug is a beginner-friendly Capture the Flag Android application that aims to inspire interest in Mobile Application Security. It is ge

Hafiz Abdulaziz 60 Oct 11, 2022
Do's and Don'ts for Android development, by Futurice developers

Best practices in Android development Avoid reinventing the wheel by following these guidelines. Lessons learned from Android developers in Futurice.

Futurice 20.2k Dec 31, 2022
Learning RxJava for Android by example

Learning RxJava for Android by example This is a repository with real-world useful examples of using RxJava with Android. It usually will be in a cons

Kaushik Gopal 7.6k Dec 30, 2022