. .

JpGraph: Beispiel: RadarPlot: Hits nach Stunde

 

<?PHP
    function gProzent($alle, $anteil, $stellen = 2) {
        if ($anteil > 0)
            return (round(($anteil / ($alle / 100 )), $stellen));
        else
            return 0;
    }

    for ($z = 12; $z > 0; $z--) {
        if ($z < 10)
            $z = "0{$z}";
        $legende[] = "{$z}\n".((int) $z + 12);
    }

    $handle = fopen("access_log", "r");
    while (!feof($handle)) {
        $zeile = fgets($handle, 4096);

        $gValidHit = explode("\"", $zeile);
        if (strstr($gValidHit[1], "?")) {
            $p = explode(" ", $zeile);
            $aHits[(int) substr($p[3], 13, 2)]++;
    }    }
    fclose ($handle);

    for ($z = 0; $z <= 11; $z++)
        $aHitsPM[$z] = $aHits[(11 - $z)];
    for ($z = 0; $z <= 11; $z++)
        $aHitsAM[$z] = $aHits[(23 - $z)];

    $ds = array_sum($aHits);

    foreach ($aHitsPM as $i => $v)
        $aHitsPM[$i] = gProzent($ds, $v);
    foreach ($aHitsAM as $i => $v)
        $aHitsAM[$i] = gProzent($ds, $v);

    $graph = new RadarGraph(600, 300, "auto");
    $graph->title->Set("(echte) Hits nach Stunde");
    $graph->title->SetFont(FF_VERDANA,FS_BOLD, 9);
    $graph->title->SetMargin(8);
    $graph->title->SetColor("black");
    $graph->SetColor("#EBEBEB");
    $graph->SetPlotSize(0.65);
    $graph->SetCenter(0.40, 0.55);
    $graph->SetScale("log");
    
    $graph->SetTitles($legende);

    $graph->axis->title->SetFont(FF_VERDANA, FS_BOLD, 7);
    $graph->axis->HideFirstTickLabel();
    $graph->yscale->ticks->SetMarkColor("darkgray", "white");
    $graph->axis->SetColor("blue");

    $rplot1 = new RadarPlot($aHitsPM);
    $rplot1->SetLineWeight(2);
    $rplot1->SetColor("forestgreen");
    $rplot1->SetLegend("vormittags (%)");
    $rplot1->SetFillColor("forestgreen@0.8");

    $rplot2 = new RadarPlot($aHitsAM);
    $rplot2->SetLineWeight(2);
    $rplot2->SetColor("red");
    $rplot2->SetLegend("nachmittags (%)");
    $rplot2->SetFillColor("red@0.8");

    $graph->Add($rplot1);
    $graph->Add($rplot2);

    $graph->legend->Pos(0.80, 0.80, "center", "bottom");
    $graph->legend->SetColor("darkblue");
    $graph->legend->SetFont(FF_VERDANA, FS_BOLD, 7);
    $graph->legend->SetFillColor("white");
    $graph->legend->SetShadow(FALSE);

    $graph->Stroke("include/tmp/jpgraph/JpGraph_HitsStunde.png");
?>

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>