Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure to android studio graph view #665

Open
havvaj opened this issue Apr 18, 2020 · 0 comments
Open

Azure to android studio graph view #665

havvaj opened this issue Apr 18, 2020 · 0 comments

Comments

@havvaj
Copy link

havvaj commented Apr 18, 2020

Hi, I want to save my values from Azure sql database into an array list for graph view to plot it real time.this is the code I have , please help me out. I am newbie to programming
package com.example.myappgvtest;

import androidx.appcompat.app.AppCompatActivity;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.Viewport;
import com.jjoe64.graphview.series.DataPoint;
import com.jjoe64.graphview.series.LineGraphSeries;

import android.os.Bundle;

import java.util.Random;

public class MainActivity extends AppCompatActivity {
private static final Random RANDOM = new Random();
private int lastX =0;
private LineGraphSeries series;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    GraphView graph = (GraphView) findViewById(R.id.graph); //instance
   // List<DataPoint> myPointList = ....
   // LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(Arrays.asList(myPointList));
    series = new LineGraphSeries<DataPoint>(); //data
    graph.addSeries(series);
    Viewport viewport = graph.getViewport();
    viewport.setYAxisBoundsManual(true);
    viewport.setMinY(0);
    viewport.setMaxY(10);
    viewport.setScrollable(true);
}
 @Override
protected void onResume() {
    super.onResume();
    new Thread (new Runnable() {
        public void run(){
            for (int i=0;1<100;i++) {
                runOnUiThread(new Runnable() {
                    public void run() {
                        addEntry();
                    }
                });
                try {
                    Thread.sleep(600);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        } }).start();

}
private void addEntry() {
series.appendData(new DataPoint(lastX++ , RANDOM.nextDouble()*10d),true,10);

}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant