Examples for my Android GraphView library

Related tags

App 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
Examples of Android applications

Android Demos This is a collection of basic android examples created by Novoda. CarouselFragment CompassExample ContactSelector CustomActivityTransiti

Novoda 2k Dec 16, 2022
Examples of using Torus CustomAuth Android SDK

Torus CustomAuth Android Samples Examples of using Torus CustomAuth Android SDK. Usage Clone the repository and open with Android Studio Run the app,

Minh-Phuc Tran 1 Nov 12, 2021
It is a project that contains lessons and examples about Kotlin programming language. 🇰

Kotlin Tutorials What is Kotlin? I added the platforms it supports and great resources. You can access the article from the link below: https://medium

Halil Özel 94 Dec 22, 2022
UML model and code examples of design patterns for Kotlin/Native. The model is created with Astah.

Design Pattern Examples in Kotlin/Native Model and code examples of GoF Design Patterns for Kotlin/Native. This project is available for the following

Takaaki Teshima 3 Jun 27, 2022
Show worldwide headline. API/Glide library/recycler view/volley library/kotlin/xml/ chrome custom tabs

Show worldwide headline. API/Glide library/recycler view/volley library/kotlin/xml/ chrome custom tabs. -> you can click on headline and it will open an article of that news in the app(no need to go to chrome or any browser)

SUMIT KUMAR 5 Nov 28, 2022
A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.

Expo Music Picker A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library. Supp

Bartłomiej Klocek 60 Dec 29, 2022
:movie_camera: Movie discovery app showcasing Android best practices with Google's recommended architecture: MVVM + Repository + Offline support + Android Architecture Components + Paging library & Retrofit2.

Popular Movies Stage 1 + Stage 2 Discover the most popular and top rated movies playing. Movies data fetched using themoviedb.org API. ✨ Screenshots M

Yassin AJDI 189 Nov 26, 2022
Oratio Library for Android Studio helps you simplify your Android TTS codes

Oratio Oratio is a library for Android Studio. This library is useful to a number of developers who are currently making apps using android TTS(Text-T

Jacob Lim 1 Oct 28, 2021
Unity-Android-SDK-Plugins - Android SDK/Library/Plugins (aar) for Unity Developers

Unity Android SDK Plugins Unity Android SDK Plugins is an Open Source project th

NNK 1 Aug 14, 2022
Spantastic - an Android library that provides a simple and Kotlin fluent API for creating Android Spannable

Spantastic is an Android library that provides a simple and Kotlin fluent API for creating Android Spannable. This library wrappers SpannableStringBuilder and add methods to easily decorate the text with multiple spans.

Wellington Cabral da Silva 12 Nov 27, 2022
AndroidEssentials is an android library that creates helper functions for performing common tasks in Android

AndroidEssentials is an android library that creates helper functions for performing common tasks in Android such as managing preferences, managing files, showing alerts, showing toasts, checking user country & checking network connection of users. All the methods of the class are static and should be accessed directly from the AndroidEssentials class.

Isaac Sichangi 3 Jul 7, 2022
Utility Android app for generating color palettes of images using the Palette library. Written in Kotlin.

Palette Helper is a simple utility app made to generate color palettes of images using Google's fantastic Palette library. It's mostly a for-fun pet p

Zac Sweers 154 Nov 18, 2022
Android app built with MVP architectural approach and uses Marvel Comics API that allows developers everywhere to access information about Marvel's vast library of comics. :zap:

Villains & Heroes Android app built with MVP architectural approach and uses Marvel Comics API that allows developers everywhere to access information

André Mion 53 Jul 13, 2022
Library to change Android launcher App Icon and App Name programmatically !

AppIconNameChanger Change Android App launcher Icon and App Name programmatically ! Download Demo APK from HERE Kindly use the following links to use

Prabhakar Thota 587 Dec 29, 2022
📱 Android Library to implement Rich, Beautiful, Stylish 😍 Material Navigation View for your project with Material Design Guidelines. Easy to use.

Material NavigationView for Android ?? ?? Android Library to implement Rich, Beautiful Material Navigation View for your project with Material Design

Shreyas Patil 198 Dec 17, 2022
Utility Android app for generating color palettes of images using the Palette library. Written in Kotlin.

Palette Helper is a simple utility app made to generate color palettes of images using Google's fantastic Palette library. It's mostly a for-fun pet p

Zac Sweers 154 Nov 18, 2022
📱 AppListManager (Android Library) makes managing application and activity lists easy.

AppListManager (Android Library) AppListManager is easy to use Android library, which minimizes developing time when working on application or activit

Rokas Jankunas 60 Dec 27, 2022
An library to help android developers working easly with activities and fragments (Kotlin version)

AFM An library to help android developer working easly with activities and fragments (Kotlin) Motivation Accelerate the process and abstract the logic

Massive Disaster 12 Oct 3, 2022