var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: [
"Men",
"Women",
"Unknown"
],
datasets: [{
label: 'Sweden',
data: [60, 40, 20],
backgroundColor: [
'rgba(158, 216, 202, 0.75)',
'rgba(255, 150, 162, 0.75)',
'rgba(160, 160, 160, 0.75)'
]
}, {
label: 'Netherlands',
data: [40, 70, 10],
backgroundColor: [
'rgba(158, 216, 202, 0.5)',
'rgba(255, 150, 162, 0.5)',
'rgba(160, 160, 160, 0.5)'
]
}, {
data: [33, 33, 34],
backgroundColor: [
'rgba(158, 216, 202, 0.25)',
'rgba(255, 150, 162, 0.25)',
'rgba(160, 160, 160, 0.25)'
]
}]
},
options: {
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
return 'This value ' + tooltipItem.yLabel;
},
title: function(tooltipItem, data) {
return 'The tooltip title ' + tooltipItem[0].xLabel;
}
}
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.2/Chart.min.js"></script>
<canvas id="myChart" width="400" height="200"></canvas>
Musisz użyć 'callbacks.label'. Zobacz przykład: http://stackoverflow.com/questions/37158477/where-put-multitooltiptemplate-in-chat-js-v2-x. – potatopeelings