Calculation chart


#1

Hello experts,

I am reading out a sencor for light. The value of this I want to use in a chart.
The chart width and height is 700 x 1200.
The value of the Y-axis is from 0 to 1400
The value of the X-axis is from 0 to 24 hours
I am using the line() method to draw this.
the screen of my laptop has a resolution of 1366 x 768.

Now i need to draw out the value of the sensor to my chart. But i can’t get it working!! i am trying this already for three days!

Please help me!

I have tried to use a ratio of pixels and the chart.
and i now the line method starts in the upper left corner. How do I do this?


#2

Here, study this example so that you can learn how to position the sketch’s coordinate system so it matches the graph’s.

void setup(){
  size(800,800);
}

void draw(){
  background(0);
  translate(20,height-20);
  scale(1,-1);
  stroke(255);
  line(0,0,width-40,0);
  line(0,0,0,height-40);
  stroke(255,0,0);
  line(0,0,50,500);
  line(50,500,100,70);
  line(100,70,150,400);
}

#3

For more on understanding the origins and orientation of drawing, you may also find these useful:


#4

Thank you all! Especially for the suggestions. Finally I found a way to use a percentage-calculation. With this method it fits to every resolution.

Kind regards,

Dirk