Calculation Problems
-
Hi all, I've been working on a Graph class for our web stats system and i'm having a few problems. After getting some help of a few guys/gals (not sure) from here, I solved many problems and then hit another one. I have currently got a class that generates an image of a graph which has X and Y Axis labels all correctly placed. Now my problem is, how can I display my values in a staticly sized image? My working space is 150hx650w. My X and Y Labels are all placed in the right place, and I need to calculate how tall I need to make my bars to reflect their value. So my values are now : 0,0,4,0,90,172,0 (graph shows stats for the last 7 days) At first I thought 150*value/100 would give me a percentage of the height, which I could simply draw but when I tried it against the 172, my return value was 258. Has anyone got any idea's on how to solve this. Maths was my strong subject at school, but i've forgotten most of it. Thanks everyone. Gav
-
Hi all, I've been working on a Graph class for our web stats system and i'm having a few problems. After getting some help of a few guys/gals (not sure) from here, I solved many problems and then hit another one. I have currently got a class that generates an image of a graph which has X and Y Axis labels all correctly placed. Now my problem is, how can I display my values in a staticly sized image? My working space is 150hx650w. My X and Y Labels are all placed in the right place, and I need to calculate how tall I need to make my bars to reflect their value. So my values are now : 0,0,4,0,90,172,0 (graph shows stats for the last 7 days) At first I thought 150*value/100 would give me a percentage of the height, which I could simply draw but when I tried it against the 172, my return value was 258. Has anyone got any idea's on how to solve this. Maths was my strong subject at school, but i've forgotten most of it. Thanks everyone. Gav
bar = bar_max * value / value_max For example: bar = 150 * 172 / 172 = 150 bar = 150 * 90 / 172 = 78
-
bar = bar_max * value / value_max For example: bar = 150 * 172 / 172 = 150 bar = 150 * 90 / 172 = 78
THANK YOU! I knew it would be simple, but I didn't think it was THAT simple.