weixin_33727510 2015-12-31 21:57 采纳率: 0%
浏览 146

Chart.js饼图

I got this error : "Uncaught TypeError: Cannot assign to read only property 'color' of [..."

I got the ajax data set but when I want to draw Pie it gives mentioned error, interesting part is that when I remove the color it also gives same error with 'color' keyword again. I can draw pie with static values, when use ajax get this problem.

enter image description here

  • 写回答

1条回答 默认 最新

  • weixin_33712987 2015-12-31 23:44
    关注

    According to their sample page

    Keys for data elements are not supposed to be wrapped in in single quotes.

    You should return JSON data like this:

    var data = [
        {
            value: 8.9,
            color:"#F7464A",
            label: "Jurasic Park"
        },
        {
            value: 8.1,
            color: "#46BFBD",
            label: "Saving Private Ryan"
        },
        ...
    ];
    
    评论

报告相同问题?