Need guidance on creating line charts

edited June 2017 in How To...

I want to create visual animated line charts in the form of a video. Any help in which direction i should go.I have been through tutorials and examples and confused about the correct direction. I want to make videos similar to this

Tagged:

Answers

  • //
    ArrayList<Ball> balls;
    final int ballWidth = 1; 
    
    //
    // ---------------------------------------------------------------
    //
    void setup()
    {
      // init
      size(800, 600);
      // frameRate(3);
      // Create an empty ArrayList
      balls = new  ArrayList();
      for (int i=0; i < 122; i++) {
        balls.add(new Ball(mouseX, 300, ballWidth, 
        color ( 255, 0, 0)));
      }
    } // func 
    //
    //
    void draw() 
    { 
      background(255);
      //
      fill(111);
      text ("move the mouse to see an heart curve like in hospital that moves over time. ", 20, 30);
      fill(0);
      noStroke();
      rect(200, 200, 200, 200);
      //
      Ball ball;
      balls.add(new Ball(mouseX, map(mouseY, 0, height, 200, 400), ballWidth, 
      color ( 255, 0, 0)));
      for (int i=0; i < balls.size(); i++) {
        ball = balls.get(i);
        ball.display(200+i);
      }
      if (balls.size()>0)
        balls.remove(0);
    } // func 
    //
    
    // =====================================================================
    // Simple ball class
    
    class Ball {
      float x;
      float y;
      color myColor; 
      float w;
    
      Ball(float tempX, float tempY, float tempW, color tempmyColor1) {
        x = tempX;
        y = tempY;
        w = tempW;
        myColor=tempmyColor1;
      }
    
      void display(float i) {
        // Display the ball
        fill(myColor);
        stroke(myColor); 
        ellipse(i, y, w, w);
        point(i, y);
      }
    }  
    
    // =========================================
    
  • Interesting -- we had a recent discussion about almost exactly the same adaptation problem of the save type of video, only for Go:

Sign In or Register to comment.