$image_height = 50; //The height of the image in pixels.
$max_value = 100; //The maximum value of the graph.
$real_value = 50; //The value you want to plot.
//Take the ratio of the real value to the maximum (etc 50/100 = 0.5), and multiply it by the image height.
$plot_height = ($real_value/$max_value) * $image_height;
//Plot from 0,0 to $imgWidth,$image_value.
imagefilledrectangle($image, 0, 0, $imgWidth, $plot_height, $colorRed);
You might also find that with 0,0 being the top left your graph is upside down.
onion2k wrote:The size of the vertical axis needed to be scaled against the size of the image. The most straightforward way to achieve that is with a percentage...
$image_height = 50; //The height of the image in pixels.
$max_value = 100; //The maximum value of the graph.
$real_value = 50; //The value you want to plot.
//Take the ratio of the real value to the maximum (etc 50/100 = 0.5), and multiply it by the image height.
$plot_height = ($real_value/$max_value) * $image_height;
//Plot from 0,0 to $imgWidth,$image_value.
imagefilledrectangle($image, 0, 0, $imgWidth, $plot_height, $colorRed);
You might also find that with 0,0 being the top left your graph is upside down.
Hi,
Thanks for the reply....
Is there any way to plot without percentage....
$imgHeight=15
$imgWidth=50
$avg=75
$max=333
How to divide the width based on the max value into ten parts and then plot........
How can we add the imageString to it