Exemplo n.º 1
0
function drawGraph($x, $y, $w = GWIDTH, $h = GHEIGHT)
{
    $im = @imagecreate($w, $h) or die("Cannot Initialize new GD image stream");
    $backgroundColor = imagecolorallocate($im, 255, 255, 255);
    $legend = array("Bad" => imagecolorallocate($im, 255, 0, 0), "Good" => imagecolorallocate($im, 51, 255, 255), "SSL" => imagecolorallocate($im, 250, 230, 0), "Fast" => imagecolorallocate($im, 0, 255, 0));
    drawAxis($im, $w, $h, $x, $y, $legend);
    imagepng($im, FILE);
    imagedestroy($im);
}
Exemplo n.º 2
0
function graph($name, $w, $h, $bgc, $fgc, $title, $xtitle, $ytitle, $numX, $xTitles, $xValues, $bc)
{
    $top = 15;
    $right = 5;
    $left = 35;
    $bottom = 25;
    $image = ImageCreate($w, $h);
    $cols = colours($image);
    ImageFill($image, 0, 0, $cols[$bgc]);
    drawAxis($image, $w, $h, $cols[$fgc], $top, $right, $left, $bottom);
    drawLines($image, $w, $h, $cols[$fgc], $top, $right, $left, $bottom);
    drawTitles($image, $w, $h, $cols[$fgc], $title, $xtitle, $ytitle);
    drawXLables($image, $w, $h, $right, $left, $cols[$fgc], $numX, $xTitles);
    $max = calcMaxDataItem($xValues, $numX);
    drawYLables($image, $w, $h, $cols[$fgc], $top, $right, $left, $bottom, $max);
    drawData($image, $w, $h, $cols[$bc], $top, $right, $left, $bottom, $numX, $xValues, $max);
    ImageJPEG($image, $name);
    ImageDestroy($image);
}
Exemplo n.º 3
0
 function drawPath($myDoc, $name, $n, $weights)
 {
     global $doc, $SCALE, $dx, $dy;
     $path = $doc->createElement("path");
     $myD = "";
     if (isset($name) && $name != "") {
         $tree = $myDoc->getWeightedSubTree($name, $weights);
     } else {
         $tree = $myDoc->getWeightedTree($weights);
     }
     /*N
           $totalWeight = 0;
           for ($i=0; $i < count($tree); $i++) {
     	$totalWeight = $totalWeight + $weights[$tree[$i]->name];
           }*/
     drawAxis(count($tree));
     $angle = 0;
     for ($i = 0; $i < count($tree); $i++) {
         /*N $delta = $weights[$tree[$i]->name]*2*pi()/$totalWeight;
         	$angle_text = $angle + $delta/2;
         	$angle = $angle + $delta;
         	drawSingleAxis($angle);*/
         $myD .= $i == 0 ? "M" : "L";
         //N: should be commented
         $angle = ($i + 1) * 2 * pi() / count($tree);
         $x = $tree[$i]->score * $SCALE * cos($angle);
         $x = $x + $dx;
         $y = $tree[$i]->score * $SCALE * sin($angle);
         $y = $y + $dy;
         $myD .= " {$x} {$y} ";
         //2.1 = 2 + 0.1 of padding before actual text display
         //N: drawText(2.1*$SCALE*cos($angle_text), 2.1*$SCALE*sin($angle_text), $tree[$i]);
         drawText(2.1 * $SCALE * cos($angle), 2.1 * $SCALE * sin($angle), $tree[$i]);
     }
     $myD .= "z";
     $path->setAttribute("d", $myD);
     $path->setAttribute("fill", getColor($n));
     $path->setAttribute("fill-opacity", "0.2");
     $path->setAttribute("stroke-width", "3");
     $path->setAttribute("stroke", getColor($n));
     return $path;
 }