如何显示Charts.js标签

时间:2017-04-28 08:00:25

标签: chart.js

如何在charts.js中显示上述标签?enter image description here

1 个答案:

答案 0 :(得分:0)

您可以在Charts.js文档中找到它,但这是一个有效的极坐标图表。只需要在html的主体中创建你的画布并正确引用它。更改labels:是您要更改请求的顶部的位置。

var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
    type: 'polarArea',
    responsive: false,
    data: {
        labels: ["Red", "Green", "Yellow", "Grey", "Blue"],
        datasets: [{
            backgroundColor: [
                "red",
                "green",
                "yellow",
                "grey",
                "blue"
           ],
           data: [12, 19, 3, 17, 28]
        }]
    }
});