Closed
Description
Expected Behavior
In plain old chart.js, I can do something like this in the options:
tooltips: {
callbacks: {
label: function (tooltipItem, data) {
// get the concerned dataset
var tooltipLabel = data.labels[tooltipItem.index]
var dataset = data.datasets[tooltipItem.datasetIndex]
// calculate the total of this data set
var total = dataset.data.reduce(function (previousValue, currentValue, currentIndex, array) {
return previousValue + currentValue
})
// get the current items value
var currentValue = dataset.data[tooltipItem.index]
// calculate the precentage based on the total and current item, also this does a rough rounding to give a whole number
var precentage = Math.floor(((currentValue / total) * 100) + 0.5)
return tooltipLabel.replace(/-/g, ' ') + ': ' + precentage + '%'
}
}
}
Actual Behavior
But in vue-chartjs, it is being ignored, and/or I don't seem to be accessing the data. Is there a way I should refer to this? (I have tried the same data object name as for the chart to no avail, and also tried this._chart.data
with no success)