Display the metric's suffix in tooltip.

When we mouseovered on a point on a metric, the value was shown but the
suffix wasn't.
It was due to a curly bracket issue, the "tooltip" option wasn't given
as an "option" sub-object, but as a third argument of the Chart
constructor. A curly bracket was closed to early.
This is fixed and the suffix is now displayed.

Related to CachetHQ/Cachet#2848
This commit is contained in:
A
2018-01-15 13:00:56 +01:00
parent b660468a56
commit 0f6512fbf1
3 changed files with 10 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -116,7 +116,8 @@ module.exports = {
if (this.chart !== null) { if (this.chart !== null) {
this.chart.destroy() this.chart.destroy()
} }
//Used in tooltip callback where this.metric is not the same.
var metric = this.metric;
this.chart = new Chart(this.context, { this.chart = new Chart(this.context, {
type: 'line', type: 'line',
data: { data: {
@@ -164,15 +165,14 @@ module.exports = {
} }
}] }]
}, },
}, tooltips: {
tooltips: { callbacks: {
callbacks: { label: function(tooltipItem, data) {
label: function(tooltipItem, data) { return tooltipItem.yLabel + ' ' + metric.suffix;
return tooltipItem.yLabel + ' ' + result.data.metric.suffix }
} }
} }
} }})
})
} }
} }
} }