Пример #1
0
function plot_histogram($image_filename, $param)
{
    extract($param);
    $histo = get_histogram($image_filename);
    if (empty($histo)) {
        return;
    }
    for ($i = 0; $i < 256; $i++) {
        $data[$i] = array('', $histo[$i]);
    }
    $p = new PHPlot_truecolor($plot_image_width, $plot_image_height);
    $p->SetFileFormat('jpg');
    $p->SetBgImage($image_filename, 'scale');
    $p->SetDataType('text-data');
    $p->SetDrawXAxis(False);
    $p->SetDrawYAxis(False);
    $p->SetDataValues($data);
    $p->SetXDataLabelPos('none');
    $p->SetXTickLabelPos('none');
    $p->SetYTickLabelPos('none');
    $p->SetXTickPos('none');
    $p->SetYTickPos('none');
    $p->SetDrawYGrid(False);
    $p->SetDataColors($histogram_color, NULL, $histogram_alpha);
    $p->SetPlotType('thinbarline');
    if ($draw_border) {
        $p->SetGridColor($border_color);
        $p->SetPlotBorderType('full');
    } else {
        $p->SetPlotBorderType('none');
    }
    # Compute the position of the histogram plot within the image.
    $hx0 = (int) ($hx * $plot_image_width);
    $hy0 = (int) ($hy * $plot_image_height);
    $hx1 = (int) ($h_width * $plot_image_width) + $hx0;
    $hy1 = (int) ($h_height * $plot_image_height) + $hy0;
    $p->SetPlotAreaPixels($hx0, $hy0, $hx1, $hy1);
    $p->DrawGraph();
}
Пример #2
0
        $responses = $post["responses"];
        foreach ($responses as $response) {
            $userId = $response["user"];
            $userName = $users[$userId];
            if (!isset($nbContrib[$userName])) {
                $nbContrib[$userName] = 1;
            } else {
                $nbContrib[$userName]++;
            }
        }
    }
    $posX = 10;
    $maxHeight = max($nbContrib) * 10;
    foreach ($nbContrib as $userName => $nb) {
        $height = $nb * 10;
        $posY = $maxHeight - $height;
        $posYText = $maxHeight + 20;
        $svg .= "\t<rect width='30' height='{$height}' x='{$posX}' y='{$posY}' />\n";
        $svg .= "\t<text x='{$posX}' y='{$posYText}' font-size='60%'>{$userName}</text>\n\n";
        $posX = $posX + 100;
    }
    $svg .= "</g>\n</svg>\n";
    return $svg;
}
//Test
require_once "constantes.php";
require_once "functions.php";
require_once "forum.sax.php";
lancer_phraseur(FORUM_FILE);
echo get_histogram($forum, $users);