本文整理匯總了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;
}
}
}