コード例 #1
0
ファイル: CGraphDraw.php プロジェクト: itnihao/zatree-2.2
 public function drawHeader()
 {
     if (!isset($this->header)) {
         $str = $this->items[0]['hostname'] . NAME_DELIMITER . $this->items[0]['name'];
     } else {
         $str = CMacrosResolverHelper::resolveGraphName($this->header, $this->items);
     }
     if ($this->period) {
         $str .= $this->period2str($this->period);
     }
     // calculate largest font size that can fit graph header
     // TODO: font size must be dynamic in other parts of the graph as well, like legend, timeline, etc
     for ($fontsize = 11; $fontsize > 7; $fontsize--) {
         $dims = imageTextSize($fontsize, 0, $str);
         $x = $this->fullSizeX / 2 - $dims['width'] / 2;
         // most important information must be displayed, period can be out of the graph
         if ($x < 2) {
             $x = 2;
         }
         if ($dims['width'] <= $this->fullSizeX) {
             break;
         }
     }
     imageText($this->im, $fontsize, 0, $x, 24, $this->getColor($this->graphtheme['textcolor'], 0), $str);
 }