当前位置: 首页>>代码示例>>PHP>>正文


PHP Label::drawSpecial方法代码示例

本文整理汇总了PHP中Label::drawSpecial方法的典型用法代码示例。如果您正苦于以下问题:PHP Label::drawSpecial方法的具体用法?PHP Label::drawSpecial怎么用?PHP Label::drawSpecial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Label的用法示例。


在下文中一共展示了Label::drawSpecial方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: drawComponent

 public function drawComponent(awDrawer $drawer, $x1, $y1, $x2, $y2, $aliasing)
 {
     $this->label->setFont(new Tuffy(8));
     $datayReal = $this->datay;
     $dataySkewed = array();
     for ($index = 0; $index < count($this->datay); $index++) {
         $dataySkewed[$index] = false;
     }
     $count = count($this->datay);
     $max = $this->getRealYMax(NULL);
     $min = $this->getRealYMin(NULL);
     // Find zero for bars
     if ($this->xAxisZero and $min <= 0 and $max >= 0) {
         $zero = 0;
     } else {
         if ($max < 0) {
             $zero = $max;
         } else {
             $zero = $min;
         }
     }
     // Get base position
     $zero = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint(0, $zero));
     // Distance between two values on the graph
     $distance = $this->xAxis->getDistance(0, 1);
     // Compute paddings
     $leftPadding = $this->barPadding->left * $distance;
     $rightPadding = $this->barPadding->right * $distance;
     $padding = $leftPadding + $rightPadding;
     $space = $this->barSpace * ($this->number - 1);
     $barSize = ($distance - $padding - $space) / $this->number;
     $barPosition = $leftPadding + $barSize * ($this->identifier - 1);
     for ($key = 0; $key < $count; $key++) {
         $value = $this->datay[$key];
         if ($value !== NULL) {
             /* Determine if we should use cut symbol */
             $position = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($key, $value));
             $barStart = $barPosition + ($this->identifier - 1) * $this->barSpace + $position->x;
             $barStop = $barStart + $barSize;
             $t1 = min($zero->y, $position->y);
             $t2 = max($zero->y, $position->y);
             if (round($t2 - $t1) == 0) {
                 continue;
             }
             if ($dataySkewed[$key]) {
                 $xmin = round($t1) - $this->depth + $this->move->top;
                 $xmax = round($t2) - $this->depth + $this->move->top;
                 $dividerPoint = ($xmax - $xmin) * 0.2 + $xmin;
                 $p1x = round($barStart) + $this->depth + $this->move->left;
                 $p1y = round($t1) - $this->depth + $this->move->top;
                 $p2x = round($barStop) + $this->depth + $this->move->left;
                 $p2y = round($t2) - $this->depth + $this->move->top;
                 $p1 = new awPoint($p1x, $p1y);
                 $p2 = new awPoint($p2x, $p2y);
                 $this->drawBar($drawer, $p1, $p2, $key);
                 $lineX = round($barStop) + $this->depth + $this->move->left;
                 $lineY = $dividerPoint;
                 /* Draw a two-pixel white line over the bar at the divider point. */
                 $white = imagecolorallocate($drawer->resource, 255, 255, 255);
                 imageline($drawer->resource, $lineX - $barSize + 1, $lineY, $lineX + 1, $lineY, $white);
                 imageline($drawer->resource, $lineX - $barSize + 1, $lineY + 1, $lineX + 1, $lineY + 1, $white);
             } else {
                 $p1 = new awPoint(round($barStart) + $this->depth + $this->move->left, round($t1) - $this->depth + $this->move->top);
                 $p2 = new awPoint(round($barStop) + $this->depth + $this->move->left, round($t2) - $this->depth + $this->move->top);
                 $this->drawBar($drawer, $p1, $p2, $key);
             }
         }
     }
     $maxValue = $this->maxValue;
     // Draw labels
     foreach ($datayReal as $key => $value) {
         if ($value !== NULL) {
             if ($value > $maxValue) {
                 $maxValue = $value;
             }
             $position = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($key, $this->datay[$key]));
             $position2 = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($key, $this->datay[$key] / 2));
             $point = new awPoint($barPosition + ($this->identifier - 1) * $this->barSpace + $position->x + $barSize / 2 + 1 + $this->depth, $position->y - $this->depth);
             $point2 = new awPoint($barPosition + ($this->identifier - 1) * $this->barSpace + $position2->x + $barSize / 2 + 1 + $this->depth, $position2->y - $this->depth);
             if ($maxValue == 0) {
                 $maxValue = 1;
             }
             if ($value != 0 && $this->drawPercent) {
                 /* Mode 2 is the white box number at the top of the bar */
                 $this->label->drawSpecial($drawer, $point2, $key, $value);
                 //$this->label->draw($drawer, $point, $key);
             }
         }
     }
     switch ($this->view) {
         case DASHBOARD_GRAPH_YEARLY:
             $tabImage = imagecreatefrompng('images/tab3.png');
             imagecopy($drawer->resource, $tabImage, 399, 0, 0, 0, 63, 73);
             break;
         case DASHBOARD_GRAPH_MONTHLY:
             $tabImage = imagecreatefrompng('images/tab2.png');
             imagecopy($drawer->resource, $tabImage, 399, 0, 0, 0, 63, 73);
             break;
         case DASHBOARD_GRAPH_WEEKLY:
         default:
//.........这里部分代码省略.........
开发者ID:PublicityPort,项目名称:OpenCATS,代码行数:101,代码来源:BarPlotDashboard.class.php

示例2: drawComponent

 public function drawComponent(awDrawer $drawer, $x1, $y1, $x2, $y2, $aliasing)
 {
     $datayReal = $this->datay;
     $dataySkewed = array();
     for ($index = 0; $index < count($this->datay); $index++) {
         $dataySkewed[$index] = false;
     }
     if (count($this->datay) > 5) {
         for ($index = 0; $index < count($this->datay); $index++) {
             if ($index < 3) {
                 if ($this->datay[$index] * 0.5 > $this->datay[$index + 1] && $this->datay[$index + 1] != 0) {
                     $multiplyer = $this->datay[$index] * 0.5 / $this->datay[$index + 1];
                     for ($i = $index + 1; $i < count($this->datay); $i++) {
                         $this->datay[$i] = $this->datay[$i] * $multiplyer;
                     }
                     for ($i = $index; $i >= 0; $i--) {
                         $dataySkewed[$index] = true;
                     }
                 }
             }
         }
     }
     $count = count($this->datay);
     $max = $this->getRealYMax(NULL);
     $min = $this->getRealYMin(NULL);
     // Find zero for bars
     if ($this->xAxisZero and $min <= 0 and $max >= 0) {
         $zero = 0;
     } else {
         if ($max < 0) {
             $zero = $max;
         } else {
             $zero = $min;
         }
     }
     // Get base position
     $zero = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint(0, $zero));
     // Distance between two values on the graph
     $distance = $this->xAxis->getDistance(0, 1);
     // Compute paddings
     $leftPadding = $this->barPadding->left * $distance;
     $rightPadding = $this->barPadding->right * $distance;
     $padding = $leftPadding + $rightPadding;
     $space = $this->barSpace * ($this->number - 1);
     $barSize = ($distance - $padding - $space) / $this->number;
     $barPosition = $leftPadding + $barSize * ($this->identifier - 1);
     for ($key = 0; $key < $count; $key++) {
         $value = $this->datay[$key];
         if ($value !== NULL) {
             /* Determine if we should use cut symbol */
             $position = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($key, $value));
             $barStart = $barPosition + ($this->identifier - 1) * $this->barSpace + $position->x;
             $barStop = $barStart + $barSize;
             $t1 = min($zero->y, $position->y);
             $t2 = max($zero->y, $position->y);
             if (round($t2 - $t1) == 0) {
                 continue;
             }
             if ($dataySkewed[$key]) {
                 $xmin = round($t1) - $this->depth + $this->move->top;
                 $xmax = round($t2) - $this->depth + $this->move->top;
                 $dividerPoint = ($xmax - $xmin) * 0.2 + $xmin;
                 $p1x = round($barStart) + $this->depth + $this->move->left;
                 $p1y = round($t1) - $this->depth + $this->move->top;
                 $p2x = round($barStop) + $this->depth + $this->move->left;
                 $p2y = round($t2) - $this->depth + $this->move->top;
                 $p1 = new awPoint($p1x, $p1y);
                 $p2 = new awPoint($p2x, $p2y);
                 $this->drawBar($drawer, $p1, $p2, $key);
                 $lineX = round($barStop) + $this->depth + $this->move->left;
                 $lineY = $dividerPoint;
                 /* Draw a two-pixel white line over the bar at the divider point. */
                 $white = imagecolorallocate($drawer->resource, 255, 255, 255);
                 imageline($drawer->resource, $lineX - $barSize + 1, $lineY, $lineX + 1, $lineY, $white);
                 imageline($drawer->resource, $lineX - $barSize + 1, $lineY + 1, $lineX + 1, $lineY + 1, $white);
             } else {
                 $p1 = new awPoint(round($barStart) + $this->depth + $this->move->left, round($t1) - $this->depth + $this->move->top);
                 $p2 = new awPoint(round($barStop) + $this->depth + $this->move->left, round($t2) - $this->depth + $this->move->top);
                 $this->drawBar($drawer, $p1, $p2, $key);
             }
         }
     }
     $maxValue = $this->maxValue;
     // Draw labels
     foreach ($datayReal as $key => $value) {
         if ($value !== NULL) {
             if ($value > $maxValue) {
                 $maxValue = $value;
             }
             $position = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($key, $this->datay[$key]));
             $position2 = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($key, $this->datay[$key] / 2));
             $point = new awPoint($barPosition + ($this->identifier - 1) * $this->barSpace + $position->x + $barSize / 2 + 1 + $this->depth, $position->y - $this->depth);
             $point2 = new awPoint($barPosition + ($this->identifier - 1) * $this->barSpace + $position2->x + $barSize / 2 + 1 + $this->depth, $position2->y - $this->depth);
             if ($maxValue == 0) {
                 $maxValue = 1;
             }
             if ($value != 0 && $this->drawPercent) {
                 $this->label->drawSpecial($drawer, $point2, $key, '' . round($value / $maxValue * 100, 0) . '%');
                 $this->label->draw($drawer, $point, $key);
             }
//.........这里部分代码省略.........
开发者ID:PublicityPort,项目名称:OpenCATS,代码行数:101,代码来源:BarPlotPipeline.class.php


注:本文中的Label::drawSpecial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。