asArray();
$result = '';
$table = array();
foreach ($pieChartData as $perfdata) {
if ($perfdata->isVisualizable()) {
$pieChart = $perfdata->asInlinePie($color);
if ($compact) {
$result .= $pieChart->render();
} else {
$table[] = '
| ' . $pieChart->render()
. htmlspecialchars($perfdata->getLabel())
. ' | '
. htmlspecialchars($this->formatPerfdataValue($perfdata)) .
' |
';
}
} else {
$table[] = (string)$perfdata;
}
}
if ($compact) {
return $result;
} else {
$pieCharts = empty($table) ? '' : '' . implode("\n", $table) . '
';
return $pieCharts;
}
}
protected function formatPerfdataValue(Perfdata $perfdata)
{
if ($perfdata->isBytes()) {
return Format::bytes($perfdata->getValue());
} elseif ($perfdata->isSeconds()) {
return Format::seconds($perfdata->getValue());
} elseif ($perfdata->isPercentage()) {
return $perfdata->getValue() . '%';
}
return $perfdata->getValue();
}
}