0

Can anyone explain with a simple example on how to add the data dynamically to the chart which is already drawn. I tried with the details in the github link to add the data, but couldn't do so. A very short example or link is also fine. Thanks

1 Answer 1

1

You can download the project here https://github.com/PhilJay/MPAndroidChart/archive/master.zip Open the project, and in MPChartExample, you have the file DynamicalAddingActivity.java.

  1. You need to create the chart:
  2. Add dataSet (your line(s)) with the values (please view the example in addDataSet() method in MPChartExample project).
  3. After you can do a CountTimerDown that add a new Entry, for the dataset.
/** each 5 seconds **/
new CountDownTimer(5000, 1000) {

     public void onTick(long millisUntilFinished) {
     }

     public void onFinish() {
        double randomValue = 19.0 + (Math.random() * (21.0 - 19.0)); 
        int indexOfMyLine = 0;

        Entry newEntry = new Entry((float) randomValue, indexOfMyLine); 
     }

}.start();

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.