Have an account? Sign in
Login  Register  Facebook
This Page is Under Construction! - If You Want To Help Please Send your CV - Advanced Web Core (BETA)
[Edit] Simple HTML bar chart

Simple HTML/PHP bar chart

Save 10,692 chart
$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.'">
                 &nbsp;
            </td>
        </tr>
    </table>';
}