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


PHP ezcGraphRenderer::drawPieSegment方法代码示例

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


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

示例1: 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)
 {
     // Only draw the first (and only) dataset
     $dataset = $this->data->rewind();
     $datasetName = $this->data->key();
     $this->driver->options->font = $this->options->font;
     // Calculate sum of all values to be able to calculate percentage
     $sum = 0;
     foreach ($dataset as $name => $value) {
         if ($value < 0) {
             throw new ezcGraphInvalidDataException("Values >= 0 required, '{$name}' => '{$value}'.");
         }
         $sum += $value;
     }
     if ($this->options->sum !== false) {
         $sum = max($sum, $this->options->sum);
     }
     if ($sum <= 0) {
         throw new ezcGraphInvalidDataException("Pie charts require a value sum > 0, your value: '{$sum}'.");
     }
     $angle = 0;
     foreach ($dataset as $label => $value) {
         // Skip rendering values which equals 0
         if ($value <= 0) {
             continue;
         }
         switch ($dataset->displayType->default) {
             case ezcGraph::PIE:
                 $displayLabel = $this->options->labelCallback !== null ? call_user_func($this->options->labelCallback, $label, $value, $value / $sum) : sprintf($this->options->label, $label, $value, $value / $sum * 100);
                 $renderer->drawPieSegment($boundings, new ezcGraphContext($datasetName, $label, $dataset->url[$label]), $dataset->color[$label], $angle, $angle += $value / $sum * 360, $displayLabel, $dataset->highlight[$label]);
                 break;
             default:
                 throw new ezcGraphInvalidDisplayTypeException($dataset->displayType->default);
                 break;
         }
     }
 }
开发者ID:jose-martins,项目名称:glpi,代码行数:48,代码来源:pie.php


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