4

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.

4
  • what a nice graphic there! +1 Commented Jul 28, 2011 at 23:59
  • 1
    Anybody else notice his variable is called $hits? Commented Jul 29, 2011 at 0:28
  • @genesis Read the $ as an S. it struck me as funny for some reason. Commented Jul 29, 2011 at 1:04
  • @Cyclone: xDD I didn't think about it this way :p Commented Jul 29, 2011 at 1:05

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.