gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 00:27:29 25 4
gpt4 key购买 nike

我想知道如何在圆环图和图例上显示标签,我使用 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

关于javascript - 如何在 Chart.js 中的圆环图上显示标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29345407/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com