#native_company# #native_desc#

HTML_Graphs Page 3

By Tim Perdue
on July 30, 2000

That function is quite simple. Hand it a result set, it checks for the length,
then turns that result set into a set of arrays to pass into my other general function,
GraphIt(). GraphIt() can be called directly if you already have an array, or you
need to do some custom stuff with it that cannot be done with straight SQL.
Notice that GraphIt() will determine scale for you. It iterates through the values[] array
and finds the biggest value. It also builds an appropriate array of colors for the bars
on the graph.


Function GraphIt($names,$values,$title) {



        Can choose any color you wish


for ($i 0$i $counter$i++) {





        Figure the max_value passed in, so scale can be determined



    for ($i 0$i $counter$i++) {

        if (
$values[$i] > $max_value) {




    if ($max_value 1) {




        I want my graphs all to be 800 pixels wide, so that is my divisor


    $scale = (int) (800/$max_value);


        I create a wrapper table around the graph that holds the title





        Create an associatve array to pass in. I leave most of it blank


    $vals =  array(

























        This is the actual call to the HTML_Graphs class



    echo "</TD></TR></TABLE>";



So those two functions really do the heavy lifting for you. Determing scale was always a headache until
I built the wrapper classes, and sometimes the graph would be so large it would go off the page.