score:1

Accepted answer

take a look at the fiddle - pie chart with chart.js i made the following changes:-

var piechartcanvas = $("#mychart").get(0).getcontext("2d");
var piechart = new chart(piechartcanvas);
piechart.pie(data, options);

score:0

from the example you gave it looks like the syntax has changed too.

it should be

var mypiechart = new chart(ctx).pie(data);

not

var mypiechart = new chart(ctx, {
    type: "pie",
    data: data,
    options: options
});

got that from the example found in the docs -> https://github.com/nnnick/chart.js/blob/master/samples/pie.html

score:0

they also changed the data format in 2.0. if you checkout the sample here. you'll see the data is like this now:

data: {
        datasets: [{
            data: [
               ...
            ],
            backgroundcolor: [
               ...
            ]
        }/* notice you can have more than one dataset, with pie they interlace when you have more than one */],
        labels: [
            ...
        ]
    }

hope that helps.... also i needed to pull the v2.0-dev branch and build it myself to get past one bug that i found in the "released" version, so you may have better luck with that!


Related Query

More Query from same tag