How to draw real-time chart?

Hello, guys.

I need your help.

I try to implement a kind of real-time chart with input file.

  1. Read input file. It consists of two filed, time and data.
  2. Start to draw the data. But it should be changed every second.
    For example, input file is
    “1.0 23
    1.0 24
    3.0 -11

    100.0 100”.
    The program draw the data every second. So, in this case, data should be drawn 100 times.

I can draw this chart at once, but I do not have any idea how to draw each data in every single time.

Please give me good advice.

I wish you have a good day.

Do you want to draw an histogram (history of previous value until now) ?
Or only the more recent value ?

For case 1:

  1. Read input file from start.
  2. draw the data.
  3. wait a bit, goto 1.

For case 2:
0. Read input file from start, until last line.

  1. try to read one line from current file pointer, wait until ok.
  2. draw the data that was on the line.
  3. goto 1.

You know that OpenGL is only about step 2. in both cases ? The rest come from fairly generic programming. What language do you use ?

Thank you for your advice.

Yes, right, It is a histogram and I must use opengl.

I use C++ to program. I tried many ways. One of them was Sleep() function, but I could see the result but not real-time drawing chart.

Technically, I know what you told me.

  1. Read input file from start, until last line.
  2. try to read one line from current file pointer, wait until ok.
  3. draw the data that was on the line.
  4. goto 1.

You mean, my program should read whole data file. Then, read one line and draw it. Indeed, keep going the procedure, right?

These procedure should be happend at display() or seperated? I mean, I should use glutTimerFunc or glutIdleFunc?

Thank you.

I got it. I’m doing test and it was successful. I was confused while I was thinking about algorithm.

Thank you, again.