Do not show tooltips for piechart areas that indicate empty or free areas
refs #6117
This commit is contained in:
parent
6555d347a7
commit
aae49ce0c0
|
@ -68,6 +68,7 @@ class InlinePie extends AbstractWidget
|
|||
style="{style}"
|
||||
labels="{labels}"
|
||||
formatted="{formatted}"
|
||||
hideEmptyLabel={hideEmptyLabel}
|
||||
values="{data}"
|
||||
tooltipFormat="{tooltipFormat}"
|
||||
sparkSliceColors="[{colors}]"
|
||||
|
@ -146,7 +147,14 @@ EOD;
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $labels;
|
||||
private $labels = array();
|
||||
|
||||
/**
|
||||
* If the tooltip for the "empty" area should be hidden
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $hideEmptyLabel = false;
|
||||
|
||||
/**
|
||||
* The format string used to display tooltips
|
||||
|
@ -162,6 +170,16 @@ EOD;
|
|||
*/
|
||||
private $format = self::NUMBER_FORMAT_BYTES;
|
||||
|
||||
/**
|
||||
* Set if the tooltip for the empty area should be hidden
|
||||
*
|
||||
* @param bool $hide Whether to hide the empty area
|
||||
*/
|
||||
public function setHideEmptyLabel($hide = true)
|
||||
{
|
||||
$this->hideEmptyLabel = $hide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the data to be displayed.
|
||||
*
|
||||
|
@ -355,6 +373,7 @@ EOD;
|
|||
$template = preg_replace('{{colors}}', implode(',', $this->colors), $template);
|
||||
$template = preg_replace('{{borderWidth}}', htmlspecialchars($this->borderWidth), $template);
|
||||
$template = preg_replace('{{borderColor}}', htmlspecialchars($this->borderColor), $template);
|
||||
$template = preg_replace('{{hideEmptyLabel}}', $this->hideEmptyLabel ? 'true' : 'false', $template);
|
||||
|
||||
// values
|
||||
$formatted = array();
|
||||
|
|
|
@ -18,12 +18,12 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
|||
if (!$perfdata->isPercentage() && $perfdata->getMaximumValue() === null) {
|
||||
continue;
|
||||
}
|
||||
$pieChart = $this->createInlinePie($perfdata);
|
||||
$pieChart = $this->createInlinePie($perfdata, $label);
|
||||
if ($compact) {
|
||||
$pieChart->setTitle(
|
||||
htmlspecialchars($label) /* . ': ' . htmlspecialchars($this->formatPerfdataValue($perfdata) */
|
||||
);
|
||||
if (!$float) {
|
||||
if (! $float) {
|
||||
$result .= $pieChart->render();
|
||||
} else {
|
||||
$result .= '<div style="float: right;">' . $pieChart->render() . '</div>';
|
||||
|
@ -85,20 +85,23 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
|||
return $perfdata->getValue();
|
||||
}
|
||||
|
||||
protected function createInlinePie(Perfdata $perfdata)
|
||||
protected function createInlinePie(Perfdata $perfdata, $label = '')
|
||||
{
|
||||
$pieChart = new InlinePie($this->calculatePieChartData($perfdata));
|
||||
$pieChart->setLabels(array($label, $label, $label, ''));
|
||||
$pieChart->setHideEmptyLabel();
|
||||
|
||||
//$pieChart->setHeight(32)->setWidth(32);
|
||||
if ($perfdata->isBytes()) {
|
||||
$pieChart->setLabels(array(t('Used'), t('Used'), t('Used'), t('Free')));
|
||||
$pieChart->setTooltipFormat('{{label}}: {{formatted}} ({{percent}}%)');
|
||||
$pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_BYTES);
|
||||
} else if ($perfdata->isSeconds()) {
|
||||
$pieChart->setLabels(array(t('Runtime'), t('Runtime'), t('Runtime'), t('Tolerance')));
|
||||
$pieChart->setTooltipFormat('{{label}}: {{formatted}} ({{percent}}%)');
|
||||
$pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_TIME);
|
||||
} else {
|
||||
$pieChart->setLabels(array(t('Packet Loss'), t('Packet Loss'), t('Packet Loss'), t('Packet Return')));
|
||||
$pieChart->setTooltipFormat('{{label}}: {{formatted}}%');
|
||||
$pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_RATIO);
|
||||
$pieChart->setHideEmptyLabel();
|
||||
}
|
||||
return $pieChart;
|
||||
}
|
||||
|
|
|
@ -77,12 +77,16 @@
|
|||
var formatted = $spark.attr('formatted').split('|');
|
||||
var tooltipChartTitle = $spark.attr('sparkTooltipChartTitle') || '';
|
||||
var format = $spark.attr('tooltipformat');
|
||||
var hideEmpty = $spark.attr('hideEmptyLabel') === 'true';
|
||||
$spark.sparkline(
|
||||
'html',
|
||||
{
|
||||
enableTagOptions: true,
|
||||
tooltipFormatter: function (sparkline, options, fields) {
|
||||
var out = format;
|
||||
if (hideEmpty && fields.offset === 3) {
|
||||
return '';
|
||||
}
|
||||
var replace = {
|
||||
title: tooltipChartTitle,
|
||||
label: labels[fields.offset] ? labels[fields.offset] : fields.offset,
|
||||
|
|
Loading…
Reference in New Issue