Esempio:

prendiamo questa immagine png true-color che ho appena creato.


Poi facciamo uno script come questo:
codice:
<?php
$values = array (48, 72, 88, 22);

$img = @imagecreatefrompng ("{$_SERVER['DOCUMENT_ROOT']}/test/bars.png");

if ($img)
{
    for ($i = 0; $i < 4; $i++)
    {
        switch ($i)
        {
            case 0:  $clr = imagecolorallocate ($img, 255, 0, 0);  break;
            case 1:  $clr = imagecolorallocate ($img, 0, 255, 0);  break;
            case 2:  $clr = imagecolorallocate ($img, 0, 0, 255);  break;
            case 3:  $clr = imagecolorallocate ($img, 255, 128, 0);  break;
        }

        $x1 = $i * 19 + 3;
        $y1 = 96 - $values[$i] * 94 / 100 + 1;
        $x2 = $x1 + 12;
        $y2 = 96;

        imagefilledrectangle ($img, $x1, $y1, $x2, $y2, $clr);
    }

    header ("Content-type: image/png");
    imagepng ($img);
    imagedestroy ($img);
    exit (0);
}
?>
Nota che i valori li ho messi fissi, ma si possono prendere, chiaramente da un database o da qualunque altra parte!.

Risultato una volta richiamato lo script dal browser: