I'm using Chart.js for a Doughnut chart. On hover in a Doughnut section I'm trying to display 'People 40%' however it displays the data in the 'datasets' object showing 'People 40%: 40'. If you hover the navy part of the Doughnut you will see the data display. I've tried javascript split and splice on the data array but couldn't get it to remove the : 40 . My question is how do I display: 'People 40%' instead of 'People 40%: 40', and so on for each label?
https://codepen.io/zepzia/pen/WdrWww
<div class="wrapper">
<canvas id="commitments-area" width="200" height="200"></canvas>
</div>
.wrapper {
height: 200px;
width: 200px;
margin: 0 auto;
}
var oilCanvas = document.getElementById("commitments-area");
Chart.defaults.global.defaultFontSize = 12;
Chart.defaults.global.legend.display = false;
Chart.defaults.global.tooltips;
var oilData = {
labels: [
"People (40%)",
"Aliens (32%)",
"Dogs (13%)",
"Whales (15%)"
],
datasets: [
{
data: [40, 32, 13, 15],
backgroundColor: [
"#13284a",
"#4b9cd3",
"#3b7ca7",
"#99cdec",
"#84d1ff"
]
}]
};
var chartOptions = {
legend: {
position: 'bottom'
},
animation: {
animateRotate: true,
animateScale: true
},
};
var pieChart = new Chart(oilCanvas, {
type: 'doughnut',
data: oilData,
options: chartOptions
});