图表js每个数据的标签

问题描述 投票:0回答:1

如何为图表js中的每个项目添加标签,而不是为所有数据添加一个标签

    labels: ['Most Bought Assets', 'Most Bought Consumable','# of Item in A', '# of Item in B', '# of Good(Assets)],
    datasets: [{

           label:["January,February,March,April,May"],

        data: [5,4,3,2,1],
        backgroundColor: [
            'rgba(255, 99, 132, 0.2)',
            'rgba(54, 162, 235, 0.2)',
            'rgba(255, 206, 86, 0.2)',
            'rgba(75, 192, 192, 0.2)',
            'rgba(153, 102, 255, 0.2)',
            'rgba(255, 159, 64, 0.2)'
        ],
        borderColor: [
            'rgba(255, 99, 132, 1)',
            'rgba(54, 162, 235, 1)',
            'rgba(255, 206, 86, 1)',
            'rgba(75, 192, 192, 1)',
            'rgba(153, 102, 255, 1)',
            'rgba(255, 159, 64, 1)'
        ],

    }]

而不是这样

enter image description here

laravel chart.js
1个回答
0
投票

您的标签当前是一个长字符串,我想这必须是一个字符串数组:

label: ["January", "February", "March", "April", "May"],
© www.soinside.com 2019 - 2024. All rights reserved.