Code Monkey home page Code Monkey logo

graphview-demos's Introduction

graphview-demos's People

Contributors

b4nnertail avatar jjoe64 avatar pontomedon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphview-demos's Issues

gradle build fails

This was done on a clean checkout of the repository

./gradlew tasks

FAILURE: Build failed with an exception.

* Where:
Build file '/home/ron/src/GraphView-Demos/graphviewdemos/build.gradle' line: 16

* What went wrong:
A problem occurred evaluating project ':graphviewdemos'.
> Ambiguous method overloading for method java.io.File#<init>.
  Cannot resolve which method to invoke for [null, class java.lang.String] due to overlapping prototypes between:
    [class java.lang.String, class java.lang.String]
    [class java.io.File, class java.lang.String]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.235 secs

How to add the labels into the Xaxis

I want to add the Months name on the Xaxis of the Chart how to do it , I can see any thing to achieve this , Following is the method which makes the index on the xAxis

GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] {
          new GraphViewData(1, 2.0d)
          , new GraphViewData(2, 1.5d)
          , new GraphViewData(3, 2.5d)
          , new GraphViewData(4, 1.0d)
});

So how can I set the months name on the XAxis

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

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.

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?

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! :)

Multicolored Line Graphs

I have a personal implementation of a multicolored graph (the line and filled graph), and it would be nice to add here, but i've then switched to code similar to official android guide on graphs (navigable one),
do you want me to pull some code about it or you already have some ideas?

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
`

Update java classes of the library

Hi,

I need to create a custom graph according to my need.
Actually, i am updating the graph based on sound by recording audio. I got the result in byte array.
But i am unable to assign byte array to graph. :( As, graph object doesn't have any method to show the byte array. It just have method to addSeries. i.e. Object of DataPoints which have 2 double values.

I need to pass a byte array and need to update the graph accordingly.

For that i need to customize the java classes of the library but it's not allowing me as it is in jar.

Please help, or if you have some other solution w.r.t. this then please do reply..

Thank you in advance.

I need to create the graph like this,

img_1574

getting error in GraphViewSeries

i m using eclipse have made prj in eclipse and have added jar file as lib but still i m getting error GraphViewSeries in this class when trying to use this code

GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] {
new GraphViewData(1, 2.0d)
, new GraphViewData(2, 1.5d)
, new GraphViewData(3, 2.5d)
, new GraphViewData(4, 1.0d)
});

remake of the demos app

  • start with impressive graphs
  • example group for each chart type
  • realtime example with lots of data
  • simple examples with all features in 4.2
  • use cardviews
  • fullscreen button -> change to horizontal orientation

Pie, radar charts?

Good morning
I am just interesting about future of GraphView
Is any chance to see the additional development of
pie chart
polar chart
radar chart?

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!

scaling

if you scale out you will see x lables that doesn't have data , even in you demo if you try to scale out you will se the bug .

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++;

}

Viewport Maximum Stuck at 1

If you set graph.getViewport().setXAxisBoundsManual(true); for both the X and Y axes but then only supply a minimum for both (0 for each), the X axis will increase automatically with data while the Y axis is initiated at 1 on the graph and will not move. How do you get around this? In an older version of the code I'm running, this bug didn't happen.

Note: the data I have is coming in VIA bluetooth and being appended to a series in real time, so I cannot set a maximum value to begin with.

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);

setscalable conflicts with viewpager

I have an activity that holds 2 fragments with a viewpager to scroll between them. In the first fragment i have an mapfragment and a graphview which is scalable. In the second one, i have some basic stuff like textviews and such. Now, if i want to browse in my graphview, i scroll a little bit and then the viewpager takes over and takes me to the other fragment. Is there a way on how i can fix this?

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?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.