Chart.js 如何在圆环图上显示标签

How to display Labels on Doughnut chart in Chart.js

我想知道如何在圆环图和图例上显示标签,我使用 chart.js 作为插件

我用了scaleShowLabels: true但是没用

这是我的代码:

  var data = [{
    value: 30,
    color: "#F7464A",
    label: "Yasser"
}, {
    value: 50,
    color: "#E2EAE9",
    label: "Zeyd"
}, {
    value: 100,
    color: "#D4CCC5",
    label: "Mouad"
}, {
    value: 40,
    color: "#949FB1",
    label: "Hanine"
}, {
    value: 120,
    color: "#4D5360",
    label: "Kheira"
}

]

var options = {
    animation: false,
    scaleShowLabels: true
};

//Get the context of the canvas element we want to select
var c = $('#myChart');
var ct = c.get(0).getContext('2d');
var ctx = document.getElementById("myChart").getContext("2d");
/*************************************************************************/
myNewChart = new Chart(ct).Doughnut(data, options);

DEMO + CODE

我找到了Chart js主要问题的所有解决方案,

它是关于一个已编辑的 js 文件,其中包含所有代码示例,您可以在此处找到有关它的更多信息:

https://github.com/FVANCOP/ChartNew.js