Reputation: 101
I've been working on a site that requires a graph to show some data, and the way the data is shown is like this:
I was wondering if anyone knew a correct formula for this graph, along with having the distinct values etc. At the moment I am doing this:
$hitspercent = @round(($hits / $totalinfo) * 100);
$uniquespercent = @round(($uniques / $totalinfo) * 100);
I am trying to make it so the values are rather distinct, so the largest value is at the top of the graph, and smallest is at the bottom, not necessarily half way.
Upvotes: 4
Views: 259
Reputation: 91
nice graph!
actually, i'm doubting what to answer seeing that you have 2 values on each bar, the blue ones ($uniques ?) being quite low.
For one value per bar i'd just use the minimum value of the array as bottom (and maybe add an offset just for design purposes, so that the lowest bar wouldn't have 0 pixels height), something like :
$offset = 5;
$bottom = min($hits / $totalinfo) - $offset;
maybe this tutorial on bar graphs in php is of help, i have it on my bookmarks for an app i'm planning : http://www.qualitycodes.com/tutorial.php?articleid=20&title=How-to-create-bar-graph-in-PHP-with-dynamic-scaling
Upvotes: 1