public function __construct($aData) { $this->iData = $aData; $this->legend = new LegendStyle(); // Setup the scale $this->scale = new Graph\WindrosePlotScale($this->iData); // default label for free type i agle and a degree sign $this->iLabelFormatString = '%.1f' . Graph\SymChar::Get('degree'); $delta = 2 * M_PI / 16; for ($i = 0, $a = 0; $i < 16; ++$i, $a += $delta) { $this->iStandardDirections[$this->iAllDirectionLabels[$i]] = $a; } }
public function StrokeAngleLabels($pos, $type) { if (!$this->show_angle_label) { return; } $x0 = round($this->img->left_margin + $this->img->plotwidth / 2) + 1; $d = max($this->img->plotwidth, $this->img->plotheight) * 1.42; $a = $this->angle_step; $t = new Text(); $t->SetColor($this->angle_fontcolor); $t->SetFont($this->angle_fontfam, $this->angle_fontstyle, $this->angle_fontsize); $xright = $this->img->width - $this->img->right_margin; $ytop = $this->img->top_margin; $xleft = $this->img->left_margin; $ybottom = $this->img->height - $this->img->bottom_margin; $ha = 'left'; $va = 'center'; $w = $this->img->plotwidth / 2; $h = $this->img->plotheight / 2; $xt = $x0; $yt = $pos; $margin = 5; $tl = $this->angle_tick_len; // Outer len $tl2 = $this->angle_tick_len2; // Interior len $this->img->SetColor($this->angle_tick_color); $rot90 = $this->img->a == 90; if ($type == POLAR_360) { // Corner angles of the four corners $ca1 = atan($h / $w) / M_PI * 180; $ca2 = 180 - $ca1; $ca3 = $ca1 + 180; $ca4 = 360 - $ca1; $end = 360; while ($a < $end) { $ca = cos($a / 180 * M_PI); $sa = sin($a / 180 * M_PI); $x = $d * $ca; $y = $d * $sa; $xt = 1000; $yt = 1000; if ($a <= $ca1 || $a >= $ca4) { $yt = $pos - $w * $y / $x; $xt = $xright + $margin; if ($rot90) { $ha = 'center'; $va = 'top'; } else { $ha = 'left'; $va = 'center'; } $x1 = $xright - $tl2; $x2 = $xright + $tl; $y1 = $y2 = $yt; } elseif ($a > $ca1 && $a < $ca2) { $xt = $x0 + $h * $x / $y; $yt = $ytop - $margin; if ($rot90) { $ha = 'left'; $va = 'center'; } else { $ha = 'center'; $va = 'bottom'; } $y1 = $ytop + $tl2; $y2 = $ytop - $tl; $x1 = $x2 = $xt; } elseif ($a >= $ca2 && $a <= $ca3) { $yt = $pos + $w * $y / $x; $xt = $xleft - $margin; if ($rot90) { $ha = 'center'; $va = 'bottom'; } else { $ha = 'right'; $va = 'center'; } $x1 = $xleft + $tl2; $x2 = $xleft - $tl; $y1 = $y2 = $yt; } else { $xt = $x0 - $h * $x / $y; $yt = $ybottom + $margin; if ($rot90) { $ha = 'right'; $va = 'center'; } else { $ha = 'center'; $va = 'top'; } $y1 = $ybottom - $tl2; $y2 = $ybottom + $tl; $x1 = $x2 = $xt; } if ($a != 0 && $a != 180) { $t->Align($ha, $va); if ($this->scale->clockwise) { $t->Set(360 - $a); } else { $t->Set($a); } if ($this->show_angle_mark && $t->font_family > 4) { $a .= SymChar::Get('degree'); } $t->Stroke($this->img, $xt, $yt); if ($this->show_angle_tick) { $this->img->Line($x1, $y1, $x2, $y2); } } $a += $this->angle_step; } } else { // POLAR_HALF $ca1 = atan($h / $w * 2) / M_PI * 180; $ca2 = 180 - $ca1; $end = 180; while ($a < $end) { $ca = cos($a / 180 * M_PI); $sa = sin($a / 180 * M_PI); $x = $d * $ca; $y = $d * $sa; if ($a <= $ca1) { $yt = $pos - $w * $y / $x; $xt = $xright + $margin; if ($rot90) { $ha = 'center'; $va = 'top'; } else { $ha = 'left'; $va = 'center'; } $x1 = $xright - $tl2; $x2 = $xright + $tl; $y1 = $y2 = $yt; } elseif ($a > $ca1 && $a < $ca2) { $xt = $x0 + 2 * $h * $x / $y; $yt = $ytop - $margin; if ($rot90) { $ha = 'left'; $va = 'center'; } else { $ha = 'center'; $va = 'bottom'; } $y1 = $ytop + $tl2; $y2 = $ytop - $tl; $x1 = $x2 = $xt; } elseif ($a >= $ca2) { $yt = $pos + $w * $y / $x; $xt = $xleft - $margin; if ($rot90) { $ha = 'center'; $va = 'bottom'; } else { $ha = 'right'; $va = 'center'; } $x1 = $xleft + $tl2; $x2 = $xleft - $tl; $y1 = $y2 = $yt; } $t->Align($ha, $va); if ($this->show_angle_mark && $t->font_family > 4) { $a .= SymChar::Get('degree'); } $t->Set($a); $t->Stroke($this->img, $xt, $yt); if ($this->show_angle_tick) { $this->img->Line($x1, $y1, $x2, $y2); } $a += $this->angle_step; } } }