Always display tooltips in all charts
Make information about data types available to colorblind, when hovering over the displayed data set fixes #8364
This commit is contained in:
parent
28dfbe7e55
commit
2992bf3445
|
@ -65,7 +65,13 @@ class BarGraph extends Styleable implements Drawable
|
||||||
) {
|
) {
|
||||||
$this->order = $order;
|
$this->order = $order;
|
||||||
$this->dataSet = $dataSet;
|
$this->dataSet = $dataSet;
|
||||||
|
|
||||||
$this->tooltips = $tooltips;
|
$this->tooltips = $tooltips;
|
||||||
|
foreach ($this->tooltips as $value) {
|
||||||
|
$ts[] = $value;
|
||||||
|
}
|
||||||
|
$this->tooltips = $ts;
|
||||||
|
|
||||||
$this->graphs = $graphs;
|
$this->graphs = $graphs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,13 @@ class LineGraph extends Styleable implements Drawable
|
||||||
*/
|
*/
|
||||||
private $isDiscrete = false;
|
private $isDiscrete = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tooltips
|
||||||
|
*
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
private $tooltips;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default stroke width
|
* The default stroke width
|
||||||
* @var int
|
* @var int
|
||||||
|
@ -56,10 +63,22 @@ class LineGraph extends Styleable implements Drawable
|
||||||
*
|
*
|
||||||
* @param array $dataset An array of [x, y] arrays to display
|
* @param array $dataset An array of [x, y] arrays to display
|
||||||
*/
|
*/
|
||||||
public function __construct(array $dataset)
|
public function __construct(
|
||||||
{
|
array $dataset,
|
||||||
|
array &$graphs,
|
||||||
|
$order,
|
||||||
|
array $tooltips = null
|
||||||
|
) {
|
||||||
usort($dataset, array($this, 'sortByX'));
|
usort($dataset, array($this, 'sortByX'));
|
||||||
$this->dataset = $dataset;
|
$this->dataset = $dataset;
|
||||||
|
$this->graphs = $graphs;
|
||||||
|
|
||||||
|
$this->tooltips = $tooltips;
|
||||||
|
foreach ($this->tooltips as $value) {
|
||||||
|
$ts[] = $value;
|
||||||
|
}
|
||||||
|
$this->tooltips = $ts;
|
||||||
|
$this->order = $order;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,14 +161,41 @@ class LineGraph extends Styleable implements Drawable
|
||||||
$path->setAdditionalStyle('clip-path: url(#clip);');
|
$path->setAdditionalStyle('clip-path: url(#clip);');
|
||||||
$path->setId($this->id);
|
$path->setId($this->id);
|
||||||
$group = $path->toSvg($ctx);
|
$group = $path->toSvg($ctx);
|
||||||
|
|
||||||
|
foreach ($this->dataset as $x => $point) {
|
||||||
|
|
||||||
if ($this->showDataPoints === true) {
|
if ($this->showDataPoints === true) {
|
||||||
foreach ($this->dataset as $point) {
|
|
||||||
$dot = new Circle($point[0], $point[1], $this->dotWith);
|
$dot = new Circle($point[0], $point[1], $this->dotWith);
|
||||||
$dot->setFill($this->strokeColor);
|
$dot->setFill($this->strokeColor);
|
||||||
|
|
||||||
$group->appendChild($dot->toSvg($ctx));
|
$group->appendChild($dot->toSvg($ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw invisible circle for tooltip hovering
|
||||||
|
$invisible = new Circle($point[0], $point[1], 20);
|
||||||
|
$invisible->setFill($this->strokeColor);
|
||||||
|
$invisible->setAdditionalStyle('opacity: 0.0;');
|
||||||
|
$invisible->setAttribute('class', 'chart-data');
|
||||||
|
if (isset($this->tooltips[$x])) {
|
||||||
|
$data = array(
|
||||||
|
'label' => isset($this->graphs[$this->order]['label']) ?
|
||||||
|
strtolower($this->graphs[$this->order]['label']) : '',
|
||||||
|
'color' => isset($this->graphs[$this->order]['color']) ?
|
||||||
|
strtolower($this->graphs[$this->order]['color']) : '#fff'
|
||||||
|
);
|
||||||
|
$format = isset($this->graphs[$this->order]['tooltip'])
|
||||||
|
? $this->graphs[$this->order]['tooltip'] : null;
|
||||||
|
$invisible->setAttribute(
|
||||||
|
'title',
|
||||||
|
$this->tooltips[$x]->renderNoHtml($this->order, $data, $format)
|
||||||
|
);
|
||||||
|
$invisible->setAttribute(
|
||||||
|
'data-title-rich',
|
||||||
|
$this->tooltips[$x]->render($this->order, $data, $format)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
$group->appendChild($invisible->toSvg($ctx));
|
||||||
|
}
|
||||||
|
|
||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ class Tooltip
|
||||||
*/
|
*/
|
||||||
public function __construct (
|
public function __construct (
|
||||||
$data = array(),
|
$data = array(),
|
||||||
$format = '<b>{title}</b></b><br/> {value} of {sum} {label}'
|
$format = '<b>{title}</b>: {value} {label}'
|
||||||
) {
|
) {
|
||||||
$this->data = array_merge($this->data, $data);
|
$this->data = array_merge($this->data, $data);
|
||||||
$this->defaultFormat = $format;
|
$this->defaultFormat = $format;
|
||||||
|
|
|
@ -402,7 +402,12 @@ class GridChart extends Chart
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::TYPE_LINE:
|
case self::TYPE_LINE:
|
||||||
$graphObj = new LineGraph($axis->transform($graph['data']));
|
$graphObj = new LineGraph(
|
||||||
|
$axis->transform($graph['data']),
|
||||||
|
$graphs,
|
||||||
|
$dataset,
|
||||||
|
$this->tooltips
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -44,7 +44,6 @@ EOD;
|
||||||
</noscript>
|
</noscript>
|
||||||
EOD;
|
EOD;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Url
|
* @var Url
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -446,7 +446,8 @@ class Monitoring_AlertsummaryController extends Controller
|
||||||
'label' => $this->translate('Notifications'),
|
'label' => $this->translate('Notifications'),
|
||||||
'color' => '#07C0D9',
|
'color' => '#07C0D9',
|
||||||
'data' => $notifications,
|
'data' => $notifications,
|
||||||
'showPoints' => true
|
'showPoints' => true,
|
||||||
|
'tooltip' => '<b>{title}:</b> {value} {label}'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -455,7 +456,8 @@ class Monitoring_AlertsummaryController extends Controller
|
||||||
'label' => $this->translate('Avg (min)'),
|
'label' => $this->translate('Avg (min)'),
|
||||||
'color' => '#ffaa44',
|
'color' => '#ffaa44',
|
||||||
'data' => $dAvg,
|
'data' => $dAvg,
|
||||||
'showPoints' => true
|
'showPoints' => true,
|
||||||
|
'tooltip' => t('<b>{title}:</b> {value}m min. reaction time')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -464,7 +466,8 @@ class Monitoring_AlertsummaryController extends Controller
|
||||||
'label' => $this->translate('Max (min)'),
|
'label' => $this->translate('Max (min)'),
|
||||||
'color' => '#ff5566',
|
'color' => '#ff5566',
|
||||||
'data' => $dMax,
|
'data' => $dMax,
|
||||||
'showPoints' => true
|
'showPoints' => true,
|
||||||
|
'tooltip' => t('<b>{title}:</b> {value}m max. reaction time')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -493,7 +496,8 @@ class Monitoring_AlertsummaryController extends Controller
|
||||||
'label' => $this->translate('Notifications'),
|
'label' => $this->translate('Notifications'),
|
||||||
'color' => '#07C0D9',
|
'color' => '#07C0D9',
|
||||||
'data' => $this->notificationData,
|
'data' => $this->notificationData,
|
||||||
'showPoints' => true
|
'showPoints' => true,
|
||||||
|
'tooltip' => '<b>{title}:</b> {value} {label}'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -502,7 +506,8 @@ class Monitoring_AlertsummaryController extends Controller
|
||||||
'label' => $this->translate('Defects'),
|
'label' => $this->translate('Defects'),
|
||||||
'color' => '#ff5566',
|
'color' => '#ff5566',
|
||||||
'data' => $this->problemData,
|
'data' => $this->problemData,
|
||||||
'showPoints' => true
|
'showPoints' => true,
|
||||||
|
'tooltip' => '<b>{title}:</b> {value} {label}'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
var $el = $(this);
|
var $el = $(this);
|
||||||
$el.attr('title', $el.data('title-rich') || $el.attr('title'));
|
$el.attr('title', $el.data('title-rich') || $el.attr('title'));
|
||||||
});
|
});
|
||||||
$('svg rect.chart-data[title]', el).tipsy({ gravity: 'se', html: true });
|
$('svg .chart-data', el).tipsy({ gravity: 'se', html: true });
|
||||||
$('.historycolorgrid a[title]', el).tipsy({ gravity: 's', offset: 2 });
|
$('.historycolorgrid a[title]', el).tipsy({ gravity: 's', offset: 2 });
|
||||||
$('img.icon[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, offset: 2 });
|
$('img.icon[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, offset: 2 });
|
||||||
$('[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, delayIn: 500 });
|
$('[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, delayIn: 500 });
|
||||||
|
|
Loading…
Reference in New Issue