Chartjs-How to setting chart js customization

0👍

Add label with your data to show it in the tooltip

var doughnutData = [{
    value: 30,
    color: "#f91942",
    label: 'Red'
}, {
    value: 50,
    color: "#0b7bb5",
    label: 'Yellow'
}, {
    value: 120,
    color: "#4D5360",
    label: 'Blue'
}];

This will display tooltip with default template

<%if (label){%><%=label%>: <%}%><%= value %>

Which show like

Red: 30

You can change the template using tooltipTemplate key, like below

var options: {
  tooltipTemplate: "This value is -> <%= value %>"
};
var myDoughnut = new Chart(document.getElementById("canvas").getContext("2d")).Doughnut(data, options);

This will give you

This value is -> 50

Leave a comment