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

时间:2015-03-30 11:45:51

标签: javascript charts 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

1 个答案:

答案 0 :(得分:1)

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

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

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

相关问题