示例#1
0
 function drawSpider()
 {
     $AA = $this->AA;
     $Htmp = round($this->radius * 2 * $AA);
     $Wtmp = $Htmp;
     $x0 = round($Wtmp / 2);
     $y0 = round($Htmp / 2);
     $mul = 0.95;
     if (isset($this->vlx)) {
         $mul -= 0.25;
     }
     $this->radius = round($this->radius * $mul);
     $this->mul = $this->radius / $this->mass;
     $img_tmp = imagecreatetruecolor($Wtmp, $Htmp);
     imageantialias($img_tmp, 1);
     $trasp = imagecolorallocatealpha($img_tmp, 0, 0, 0, 127);
     imagefill($img_tmp, 0, 0, $trasp);
     $black = imagecolorallocate($img_tmp, 0, 0, 0);
     for ($cntval = $i = 0; $i < count($this->type); $i++) {
         if ($this->type[$i] == 's') {
             if ($cntval < count($this->value[$i])) {
                 $cntval = count($this->value[$i]);
             }
         }
     }
     $angleval = round(360 / $cntval);
     for ($i = 0, $angle = deg2rad(-90); $i < $cntval; $i++) {
         $x1 = round($x0 + $this->radius * cos($angle) * $AA);
         $y1 = round($y0 + $this->radius * sin($angle) * $AA);
         graidle::imagelinethick($img_tmp, $x0, $y0, $x1, $y1, $this->axis_color, $AA);
         if (isset($this->vlx)) {
             if ($angle >= deg2rad(-90) && $angle < deg2rad(0)) {
                 imagefttext($img_tmp, $this->font_small * $AA, 0, $x1 + 4, $y1 - 4, $this->font_color, $this->font, $this->vlx[$i]);
             } else {
                 if ($angle >= deg2rad(0) && $angle < deg2rad(90)) {
                     imagefttext($img_tmp, $this->font_small * $AA, 0, $x1 + 4, $y1 + $this->font_small * $AA, $this->font_color, $this->font, $this->vlx[$i]);
                 } else {
                     if ($angle >= deg2rad(90) && $angle < deg2rad(180)) {
                         imagefttext($img_tmp, $this->font_small * $AA, 0, $x1 + 4 - strlen($this->vlx[$i]) * ($this->font_small * $AA), $y1 + $this->font_small * $AA, $this->font_color, $this->font, $this->vlx[$i]);
                     } else {
                         if ($angle >= deg2rad(180) && $angle < deg2rad(270)) {
                             imagefttext($img_tmp, $this->font_small * $AA, 0, $x1 + 4 - strlen($this->vlx[$i]) * ($this->font_small * $AA), $y1, $this->font_color, $this->font, $this->vlx[$i]);
                         }
                     }
                 }
             }
         }
         for ($v = $s = 0; $s <= $this->radius + 1; $s += $this->dvx * $this->mul, $v += $this->dvx) {
             imagearc($img_tmp, $x0, $y0, ($this->radius - $s) * 2 * $AA, ($this->radius - $s) * 2 * $AA, 0, 360, $this->axis_color);
             imagefttext($img_tmp, $this->font_small * $AA, 0, $x0 + 4, $y0 + 4 + $this->font_small * $AA - $s * $AA, $this->font_color, $this->font, $v);
         }
         $angle += deg2rad($angleval);
     }
     for ($s = 0; $s < count($this->value); $s++) {
         for ($point = array(), $i = 0, $d = 1, $angle = deg2rad(-90); $i < $cntval; $i++, $d++) {
             if ($d == $cntval) {
                 $val1 = $this->value[$s][$i];
                 $val2 = $this->value[$s][0];
             } else {
                 $val1 = $this->value[$s][$i];
                 $val2 = $this->value[$s][$d];
             }
             $x2 = round($x0 + $this->mul * $val1 * cos($angle) * $AA);
             $y2 = round($y0 + $this->mul * $val1 * sin($angle) * $AA);
             array_push($point, $x2, $y2);
             $angle += deg2rad($angleval);
         }
         $c = $this->color[$s];
         list($name, $red, $green, $blue) = explode(',', $c);
         if (isset($this->filled) && $this->filled == 1) {
             $rgbA = imagecolorallocatealpha($this->im, $red, $green, $blue, 80);
             imagefilledpolygon($img_tmp, $point, $cntval, $rgbA);
             imagepolygon($img_tmp, $point, $cntval, $black);
         } else {
             $rgb = imagecolorallocate($this->im, $red, $green, $blue);
             imagepolygon($img_tmp, $point, $cntval, $rgb);
         }
     }
     $OrizAlign = ($this->w + $this->s - $this->d) / 2 - $Wtmp / $AA / 2;
     imagecopyresampled($this->im, $img_tmp, $OrizAlign, 5 + $this->a, 0, 0, $Wtmp / $AA, $Htmp / $AA, $Wtmp, $Htmp);
     if (isset($rgb)) {
         imagecolordeallocate($img_tmp, $rgb);
     }
     if (isset($rgbA)) {
         imagecolordeallocate($img_tmp, $rgbA);
     }
     imageantialias($img_tmp, 0);
     imagedestroy($img_tmp);
 }
 function gradAxis($sy = NULL, $sx = NULL)
 {
     $c = imagecolorallocatealpha($this->im, 255, 255, 255, 127);
     $bg = imagecolorallocatealpha($this->im, 0, 0, 0, 120);
     $style = array($c, $this->axis_color);
     imagesetstyle($this->im, $style);
     if ($this->mnvs <= 0) {
         $zero = $this->s + abs($this->mnvs * $this->mul);
     } else {
         $zero = $this->s;
     }
     for ($x = $zero - $this->dvx * $this->mul, $n = -$this->dvx; $x > $this->s; $n -= $this->dvx, $x -= $this->dvx * $this->mul) {
         $x1 = $x - round(count($n) * $this->font_small / 2);
         $y1 = $this->h - $this->b + $this->font_small + 4;
         $y2 = $this->h - $this->b;
         imageline($this->im, $x, $y2, $x, $y2 - 2, $this->axis_color);
         if ($sx) {
             imageline($this->im, $x, $y2, $x, $this->a, IMG_COLOR_STYLED);
         }
         imagefttext($this->im, $this->font_small, 0, $x1, $y1, $this->font_color, $this->font, $n);
     }
     if ($this->mnvs > 0) {
         $n = $this->mnvs;
     } else {
         $n = 0;
     }
     for ($x = $zero; $x <= $this->w - $this->d + 1; $n += $this->dvx, $x += $this->dvx * $this->mul) {
         $x1 = $x - round(graidle::stringLen($n) * $this->font_small / 2);
         $y1 = $this->h - $this->b + $this->font_small * 2;
         $y2 = $this->h - $this->b;
         imageline($this->im, $x, $y2, $x, $y2 - 2, $this->axis_color);
         if ($sx) {
             imageline($this->im, $x, $y2, $x, $this->a, IMG_COLOR_STYLED);
         }
         imagefttext($this->im, $this->font_small, 0, $x1, $y1, $this->font_color, $this->font, $n);
     }
     if ($sy) {
         for ($i = $this->a; $i < $this->h - $this->b - 1; $i += $this->ld * 2) {
             imagefilledrectangle($this->im, 0, $i + 1, $this->w - $this->d, $i + $this->ld + 1, $bg);
         }
     }
 }
示例#3
0
 function setLegend($legend, $align = NULL)
 {
     if (!isset($this->legend)) {
         $this->legend = array();
     }
     $this->legend = array_merge($this->legend, $legend);
     $spch = $this->font_legend * 4;
     #spazio per i caratteri della legenda
     for ($i = 0; $i < count($this->legend); $i++) {
         if (strlen($this->legend[$i]) > $this->LegStrLen) {
             $this->legend[$i] = substr($this->legend[$i], 0, $this->LegStrLen) . "...";
         }
         $tmpsp = graidle::stringlen($this->legend[$i]) * $this->font_legend;
         if ($spch < $tmpsp) {
             $spch = $tmpsp;
         }
     }
     if (isset($this->w)) {
         $this->nrow = ceil(($spch + $this->dim_quad + $this->spacing) * count($this->legend) / ($this->w - $this->s - $this->d));
     } else {
         $this->nrow = count($this->legend);
     }
     $this->spacerow = ceil($this->nrow * ($this->dim_quad + $this->spacing));
     $this->spch = $spch;
     $this->LegendAlign = strtolower($align);
     switch ($this->LegendAlign) {
         case "left":
             $this->s += $this->spacing + $this->dim_quad + $this->spch;
             break;
         case "top":
             $this->a += $this->spacerow;
             break;
         case "bottom":
             $this->b += $this->nrow * ($this->dim_quad + $this->spacing);
             break;
             break;
         default:
             $this->LegendAlign = "right";
             $this->d += $this->spacing + $this->dim_quad + $this->spch;
             break;
     }
 }
示例#4
0
nomvar => [Array] (numerada desde 0) Nombres de columnas de cada serie
tit => [string] Titulo del grafico
ser1 => [Array] (numerada desde 0) valores de las serie
ser2 => [Array] (numerada desde 0) valores de las serie
serx => [Array] (numerada desde 0) valores de las serie
**************/
require_once "graidle.php";
if (!isset($_REQUEST['cantser']) || !isset($_REQUEST['nomvar']) || !isset($_REQUEST['nomser'])) {
    exit('error_1');
}
if (isset($_REQUEST['tit'])) {
    $tit = $_REQUEST['tit'];
} else {
    $tit = ' ';
}
$graidle = new graidle($tit);
$nomvar = $_REQUEST['nomvar'];
$z = 0;
while ($z < sizeof($nomvar)) {
    $nvar = $nomvar[$z];
    $a = 0;
    while ($a <= $_REQUEST['cantser']) {
        $nomser = "ser" . $a;
        if (is_array($_REQUEST[$nomser]) && isset($_REQUEST[$nomser])) {
            $serie = $_REQUEST[$nomser];
            if (isset(${$nvar})) {
                ${$nvar} = array_merge(${$nvar}, array($a => $serie[$z]));
            } else {
                ${$nvar} = array($a => $serie[$z]);
            }
        }