# QuestionAxis not updated when i add a new point

#### jloc

##### New member
Hello,

I would like to draw a graph of multiple serie with y and y2. This I can do it.

Now my problem is that I want to display data in real time but in a chart in which the size of axis doesnt change.

a small drawing worths better than long explanation.

so the graph should start like this :

and 7 hour after, finish like this :

so i add 1 point every minute, but axis keep stable...

I start to look and i can do many things but I dont have any idea on how to proceed to do that stuff :S

Jloc

#### 22-degrees

##### Well-known member
I'm not sure i follow.. If you know the height and width of the area being drawn to, what is it about simple mathematics and line drawing that you are having trouble with?

For example, you need to add one point every minute, therefore any multiple of 60 pixels will work for your x-axis "Time" units (i.e "hour 1" will be drawn 120 pixels from the bottom left corner of the chart, "hour 2" will be drawn 120 pixels to the right of "hour 1" etc etc)

The same goes for the temperature units on the y-axis. If the temperature will range from 0 to 100 then just divide the height of your chart by 100 to get the whole unit placements (or by 200 for half unit placements).

Then, to add your actual graph line, you just calculate your points using the Unit pixel size..

Example:

Suppose that the bottom left corner of your charting area is at the pixel location of (x=10,y=1000)

If during the first 4 minutes of hour 1, the temperature started at 0 and saw the following readings (34,45,49,56), here is how you would convert this to drawing points

Reading at end of minute 1

Start point:
point x of previous reading (which was nothing so) x = 10
Point y of previous reading (which was nothing so) y = 1000

Finish point:
x = Previous x plus New time increment (Time unit pixel size / 60) so if your unit pixel size was 120 then x = (10 + 2) or x = 12
y = zero-degrees pixel location minus (temperature multiplied by (y-axis height / 100)), so if the y-axis height was 800 and the temperature is 34 degrees then _
y = 1000-(34*(800/100)) = 728

Then just draw a line from point (10,1000) to point (12,728)

Reading at end of minute 2

Start point:
point x of previous reading (12)
Point y of previous reading (728)

Finish point:
x = Previous x plus New time increment (Time unit pixel size / 60) so if your unit pixel size was 120 then x = (12 + 2) or x = 14
y = zero-degrees pixel location minus (temperature multiplied by (y-axis height / 100)), so if the y-axis height was 800 and the temperature is 45 degrees then _
y = 1000-(45*(800/100)) = 640

Then just draw a line from point (12,728) to point (14,640)

Reading at end of minute 3

Start point:
point x of previous reading (14)
Point y of previous reading (640)

Finish point:
x = Previous x plus New time increment (Time unit pixel size / 60) so if your unit pixel size was 120 then x = (14 + 2) or x = 16
y = zero-degrees pixel location minus (temperature multiplied by (y-axis height / 100)), so if the y-axis height was 800 and the temperature is 49 degrees then _
y = 1000-(49*(800/100)) = 608

Then just draw a line from point (14,640) to point (16,608)

Reading at end of minute 4

Start point:
point x of previous reading (16)
Point y of previous reading (608)

Finish point:
x = Previous x plus New time increment (Time unit pixel size / 60) so if your unit pixel size was 120 then x = (16 + 2) or x = 18
y = zero-degrees pixel location minus (temperature multiplied by (y-axis height / 100)), so if the y-axis height was 800 and the temperature is 56 degrees then _
y = 1000-(56*(800/100)) = 552

Then just draw a line from point (16,608) to point (18,552)

Hope this is what you were looking for.. If not, then hopefully it helps someone else at least.

EDIT:: I just noticed this post is in the Charting section so if you wanted a Chart Control specific answer then I apologize.

Last edited:

#### jloc

##### New member
actually...

Haha.. Actualy yes, I was waiting for a Chart control style answer but I really do appreciate the effort you did to answer me . It really nice from you to spend so much energy on the forum.

I got the explanation, it's pretty smart...If I cannot do what I want with my chart control then I will use your method, and will let you know.

Go on continue to help people like you do... me I go back fighting with my script

see you