#chartout{$idx} { position: relative; height: ", $height + 2, "px; width: ", $width + 2, "px; background-color: {$border}; } #chartin{$idx} { position: absolute; top: 1px; left: 1px; height: {$height}px; width: {$width}px; background-color: {$bg}; } .bar{$idx} { position: absolute; bottom: 0px; background-color: {$bars}; width: 1px; overflow: hidden; } .grid{$idx} { position: absolute; left: 0px; height: 1px; width: {$width}px; background-color: {$grid}; overflow: hidden; } "; // Now output the basic parts of the chart: echo "
"; // Now create a grid pattern, divide the space into 5ths foreach(range(1,3) as $line) { $lh = round($line * ($height / 5)); echo "
\n"; } // Now run through all elements of the array, making the actual bars foreach ($data as $pos => $val) { $barheight = round($val * $scale); echo "
\n"; } // Finish off: echo "\n
\n"; } // Let's generate 200 random points of data in two different arrays $chartdata = array(); $chartdata2 = array(); for ($i = 0; $i < 200; $i++) { $chartdata[$i] = rand(1,1000); $chartdata2[$i] = rand(1,1000); } // Now generate a chart based upon this, 100 pixels tall: create_chart($chartdata, 100); // Generate another one that is only 50 pixels tall, with different colors create_chart($chartdata2, 50, '#0C0', 'black', 'black', '#666'); ?>