简体   繁体   English

如何在Chart.js中的甜甜圈图上显示标签

[英]How to display Labels on Doughnut chart in Chart.js

I want to know how I would be able to show Labels on the doughnut chart and the legend, I'm using chart.js as plugin 我想知道如何在甜甜圈图和图例上显示标签,我使用chart.js作为插件

I used scaleShowLabels: true but It doesn't work 我使用了scaleShowLabels: true但是不起作用

here is my code : 这是我的代码:

  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 演示+代码

I found all the solutions of the Chart js main problems, 我找到了Chart js主要问题的所有解决方案,

it's about an edited js file, which has all code samples, you can find more information about it here : 它是关于一个经过编辑的js文件,其中包含所有代码示例,您可以在这里找到有关它的更多信息:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM