Simple bar chart
Doesn't require any image manipulation software on the server
<?php
// total width
$total_width = 600;
// base color
$base_color = 'silver';
// add an array per field to show
$graphs = array(
array('label'=>'whatever', 'color'=>'red', 'amount'=>'30'),
array('label'=>'more here', 'color'=>'green', 'amount'=>'36'),
array('label'=>'just an example', 'color'=>'blue', 'amount'=>'82'),
array('label'=>'even more', 'color'=>'orange', 'amount'=>'4'),
);
for($x = 0; $x < count($graphs); $x++){
echo '<table width="'.$total_width.'">
<tr>
<td colspan="2">
'.$graphs[$x]['label'].'
</td>
</tr>
<tr>
<td width="'.$graphs[$x]['amount'].'%" bgcolor="'.$graphs[$x]['color'].'">
'.$graphs[$x]['amount'].'%
</td>
<td width="'.(100-$graphs[$x]['amount']).'%" bgcolor="'.$base_color.'">
</td>
</tr>
</table>';
}
?>
|
|
Top