Jump to content

GD Image / pixel question


rilana

Recommended Posts

Hi guyes I am trying to figure out how to adapt a graph to a different currency. The code i used for this was born thanks to this forum a cupple of years ago http://www.phpfreaks.com/forums/index.php/topic,208349.30.html thanks again, without you I would have had no clue at all.

 

Anyway, this is my new problem now. I am having a graph with CHF values from 340 to 740 and a graph with EUR values from 220 to 500. Evan do the graph is basicaly the same, it looks different becuase of the exchange rate, EUR is smaller then CHF so the graph looks squized in the y-axes... Now I tryed several things to make the graph grow, but I think the problem is that it will allways draw a pixel for a value (1 = 1px). So is there anyway I can say 1 is 1.5px?

 

Thank you for your help, I am not evan shoure if I am thinking on the right end.

Thank you, Rilana

Link to comment
https://forums.phpfreaks.com/topic/193218-gd-image-pixel-question/
Share on other sites

I do the same kind of graphs with earthquakes!

 

Start by determining how many pixels you have to play with on your vertical/horizontal lines axes and then divide this up into divisions that make the graph look its best. For example you may only have 400px in height but representing a maximum value of 800 on the graph which would equate to a value of 2 for each pixel vertically (or 20 per 10px)

A value of 200 would be 100px up, etc. (I think I have that right!)

 

Then you need to equate how many pixels with how many CHFs and multiple or divide accordingly to get the position where the x should go on the graph. Same thing along the baseline.

 

It took me a while to get my head around it but I worked it out eventually.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.