Added YLabel splitter and Extra info on tooltip

Actually, custom label are not allowed, it directly uses the provided by
the query result as the target/alias

This feature allows to:

- Split YLabel to store its partials and reuse them on link and extra tooltip field
- Override YLabel with splitted and custom values
- Added Extra Tooltip to show metadata to the user on each serie
This commit is contained in:
sbengo
2020-12-02 16:41:18 +01:00
parent a7a82ff3f5
commit fa80d4a3dc
13 changed files with 309 additions and 18 deletions
+11
View File
@@ -112,6 +112,7 @@ export class StatusmapTooltip {
let timestamp = bucket.to;
let yLabel = bucket.yLabel;
let pLabels = bucket.pLabels;
let value = bucket.value;
let values = bucket.values;
// TODO create option for this formatting.
@@ -188,6 +189,11 @@ export class StatusmapTooltip {
// Grafana 7.0 compatible
scopedVars[`__url_time_range`] = {value: this.panelCtrl.retrieveTimeVar()};
//New vars based on partialLabels:
for (let i in pLabels) {
scopedVars[`__y_label_${i}`] = {value: pLabels[i]};
}
for (let item of items) {
if (_.isEmpty(item.urlTemplate)) {
item.link = "#";
@@ -217,6 +223,11 @@ export class StatusmapTooltip {
}
}
if (this.panel.tooltip.showCustomContent) {
let customContent: string = this.panelCtrl.templateSrv.replace(this.panel.tooltip.customContent, scopedVars)
tooltipHtml += `<div>${customContent}</div>`
}
tooltipHtml += _.join(_.map(items, v => `
<div>
<a href="${v.link}" target="_blank">