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


PHP ezcGraphRenderer::drawDataHighlightText方法代码示例

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


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

示例1: renderData


//.........这里部分代码省略.........
  * @param ezcGraphBoundings $boundings Remaining boundings
  * @return void
  */
 protected function renderData(ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphBoundings $innerBoundings)
 {
     // Use inner boundings for drawning chart data
     $boundings = $innerBoundings;
     $yAxisNullPosition = $this->elements['yAxis']->getCoordinate(false);
     // Initialize counters
     $nr = array();
     $count = array();
     foreach ($this->data as $data) {
         if (!isset($nr[$data->displayType->default])) {
             $nr[$data->displayType->default] = 0;
             $count[$data->displayType->default] = 0;
         }
         $nr[$data->displayType->default]++;
         $count[$data->displayType->default]++;
     }
     $checkedRegularSteps = false;
     // Display data
     foreach ($this->data as $datasetName => $data) {
         --$nr[$data->displayType->default];
         // Check which axis should be used
         $xAxis = $data->xAxis->default ? $data->xAxis->default : $this->elements['xAxis'];
         $yAxis = $data->yAxis->default ? $data->yAxis->default : $this->elements['yAxis'];
         // Determine fill color for dataset
         if ($this->options->fillLines !== false) {
             $fillColor = clone $data->color->default;
             $fillColor->alpha = (int) round((255 - $fillColor->alpha) * ($this->options->fillLines / 255));
         } else {
             $fillColor = null;
         }
         // Ensure regular steps on axis when used with bar charts and
         // precalculate some values use to render bar charts
         //
         // Called only once and only when bars should be rendered
         if ($checkedRegularSteps === false && $data->displayType->default === ezcGraph::BAR) {
             $steps = $xAxis->getSteps();
             $stepWidth = null;
             foreach ($steps as $step) {
                 if ($stepWidth === null) {
                     $stepWidth = $step->width;
                 } elseif ($step->width !== $stepWidth) {
                     throw new ezcGraphUnregularStepsException();
                 }
             }
             $step = reset($steps);
             if (count($step->childs)) {
                 // Keep this for BC reasons
                 $barCount = ($xAxis->getMajorStepCount() + 1) * ($xAxis->getMinorStepCount() - 1);
                 $stepWidth = 1 / $barCount;
             }
             $checkedRegularSteps = true;
             $width = $xAxis->axisLabelRenderer->modifyChartDataPosition($yAxis->axisLabelRenderer->modifyChartDataPosition(new ezcGraphCoordinate(($boundings->x1 - $boundings->x0) * $stepWidth, 0)))->x;
         }
         // Draw lines for dataset
         $lastPoint = false;
         foreach ($data as $key => $value) {
             // Calculate point in chart
             $point = $xAxis->axisLabelRenderer->modifyChartDataPosition($yAxis->axisLabelRenderer->modifyChartDataPosition(new ezcGraphCoordinate($xAxis->getCoordinate($key), $yAxis->getCoordinate($value))));
             // Render depending on display type of dataset
             switch (true) {
                 case $data->displayType->default === ezcGraph::LINE:
                     $renderer->drawDataLine($boundings, new ezcGraphContext($datasetName, $key, $data->url[$key]), $data->color->default, $lastPoint === false ? $point : $lastPoint, $point, $nr[$data->displayType->default], $count[$data->displayType->default], $data->symbol[$key], $data->color[$key], $fillColor, $yAxisNullPosition, $data->lineThickness->default ? $data->lineThickness->default : $this->options->lineThickness);
                     break;
                 case $data->displayType->default === ezcGraph::BAR && $this->options->stackBars:
                     // Check if a bar has already been stacked
                     if (!isset($stackedValue[(int) ($point->x * 10000)][(int) $value > 0])) {
                         $start = new ezcGraphCoordinate($point->x, $yAxisNullPosition);
                         $stackedValue[(int) ($point->x * 10000)][(int) $value > 0] = $value;
                     } else {
                         $start = $xAxis->axisLabelRenderer->modifyChartDataPosition($yAxis->axisLabelRenderer->modifyChartDataPosition(new ezcGraphCoordinate($xAxis->getCoordinate($key), $yAxis->getCoordinate($stackedValue[(int) ($point->x * 10000)][(int) $value > 0]))));
                         $point = $xAxis->axisLabelRenderer->modifyChartDataPosition($yAxis->axisLabelRenderer->modifyChartDataPosition(new ezcGraphCoordinate($xAxis->getCoordinate($key), $yAxis->getCoordinate($stackedValue[(int) ($point->x * 10000)][(int) $value > 0] += $value))));
                     }
                     // Force one symbol for each stacked bar
                     if (!isset($stackedSymbol[(int) ($point->x * 10000)])) {
                         $stackedSymbol[(int) ($point->x * 10000)] = $data->symbol[$key];
                     }
                     // Store stacked value for next iteration
                     $side = $point->y == 0 ? 1 : $point->y / abs($point->y);
                     $stacked[(int) ($point->x * 10000)][$side] = $point;
                     $renderer->drawStackedBar($boundings, new ezcGraphContext($datasetName, $key, $data->url[$key]), $data->color->default, $start, $point, $width, $stackedSymbol[(int) ($point->x * 10000)], $yAxisNullPosition);
                     break;
                 case $data->displayType->default === ezcGraph::BAR:
                     $renderer->drawBar($boundings, new ezcGraphContext($datasetName, $key, $data->url[$key]), $data->color[$key], $point, $width, $nr[$data->displayType->default], $count[$data->displayType->default], $data->symbol[$key], $yAxisNullPosition);
                     break;
                 default:
                     throw new ezcGraphInvalidDisplayTypeException($data->displayType->default);
                     break;
             }
             // Render highlight string if requested
             if ($data->highlight[$key]) {
                 $renderer->drawDataHighlightText($boundings, new ezcGraphContext($datasetName, $key, $data->url[$key]), $point, $yAxisNullPosition, $nr[$data->displayType->default], $count[$data->displayType->default], $this->options->highlightFont, $data->highlightValue[$key] ? $data->highlightValue[$key] : $value, $this->options->highlightSize + $this->options->highlightFont->padding * 2, $this->options->highlightLines ? $data->color[$key] : null, $this->options->highlightXOffset ? $this->options->highlightXOffset : 0, $this->options->highlightYOffset ? $this->options->highlightYOffset : 0);
             }
             // Store last point, used to connect lines in line chart.
             $lastPoint = $point;
         }
     }
 }
开发者ID:broschb,项目名称:cyclebrain,代码行数:101,代码来源:line.php

示例2: renderData

 /**
  * Render the assigned data
  *
  * Will renderer all charts data in the remaining boundings after drawing 
  * all other chart elements. The data will be rendered depending on the 
  * settings in the dataset.
  * 
  * @param ezcGraphRenderer $renderer Renderer
  * @param ezcGraphBoundings $boundings Remaining boundings
  * @return void
  */
 protected function renderData(ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphBoundings $innerBoundings)
 {
     // Use inner boundings for drawning chart data
     $boundings = $innerBoundings;
     $yAxisNullPosition = $this->elements['xAxis']->getCoordinate(false);
     // Initialize counters
     $nr = array();
     $count = array();
     foreach ($this->data as $data) {
         if (!isset($nr[$data->displayType->default])) {
             $nr[$data->displayType->default] = 0;
             $count[$data->displayType->default] = 0;
         }
         $nr[$data->displayType->default]++;
         $count[$data->displayType->default]++;
     }
     $checkedRegularSteps = false;
     // Display data
     foreach ($this->data as $datasetName => $data) {
         --$nr[$data->displayType->default];
         // Check which axis should be used
         $xAxis = $data->xAxis->default ? $data->xAxis->default : $this->elements['xAxis'];
         $yAxis = $data->yAxis->default ? $data->yAxis->default : $this->elements['yAxis'];
         // Determine fill color for dataset
         if ($this->options->fillLines !== false) {
             $fillColor = clone $data->color->default;
             $fillColor->alpha = (int) round((255 - $fillColor->alpha) * ($this->options->fillLines / 255));
         } else {
             $fillColor = null;
         }
         // Ensure regular steps on axis when used with bar charts and
         // precalculate some values use to render bar charts
         //
         // Called only once and only when bars should be rendered
         if ($checkedRegularSteps === false && $data->displayType->default === ezcGraph::BAR) {
             $height = $this->calculateStepWidth($yAxis, $xAxis, $boundings->height)->y;
         }
         // Draw lines for dataset
         $lastPoint = false;
         foreach ($data as $key => $value) {
             // Calculate point in chart
             $point = $xAxis->axisLabelRenderer->modifyChartDataPosition($yAxis->axisLabelRenderer->modifyChartDataPosition(new ezcGraphCoordinate($xAxis->getCoordinate($value), $yAxis->getCoordinate($key))));
             // Render depending on display type of dataset
             switch (true) {
                 case $data->displayType->default === ezcGraph::BAR:
                     $renderer->drawHorizontalBar($boundings, new ezcGraphContext($datasetName, $key, $data->url[$key]), $data->color[$key], $point, $height, $nr[$data->displayType->default], $count[$data->displayType->default], $data->symbol[$key], $yAxisNullPosition);
                     // Render highlight string if requested
                     if ($data->highlight[$key]) {
                         $renderer->drawDataHighlightText($boundings, new ezcGraphContext($datasetName, $key, $data->url[$key]), $point, $yAxisNullPosition, $nr[$data->displayType->default], $count[$data->displayType->default], $this->options->highlightFont, $data->highlightValue[$key] ? $data->highlightValue[$key] : $value, $this->options->highlightSize + $this->options->highlightFont->padding * 2, $this->options->highlightLines ? $data->color[$key] : null, $this->options->highlightXOffset ? $this->options->highlightXOffset : 0, $this->options->highlightYOffset ? $this->options->highlightYOffset : 0, $height, $data->displayType->default);
                     }
                     break;
                 default:
                     throw new ezcGraphInvalidDisplayTypeException($data->displayType->default);
                     break;
             }
             // Store last point, used to connect lines in line chart.
             $lastPoint = $point;
         }
     }
 }
开发者ID:gbleydon,项目名称:mahara-survey,代码行数:71,代码来源:horizontal_bar.php


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