[Chartjs]-Drawing bar chart with Chart.js

1👍

Your barData data object should be defined before you use it, at the top, like this:

var barData = {
labels : ["January","February","March","April","May","June"],
datasets : [
    {
        fillColor : "#48A497",
        strokeColor : "#48A4D1",
        data : [456,479,324,569,702,600]
    },
    {
        fillColor : "rgba(73,188,170,0.4)",
        strokeColor : "rgba(72,174,209,0.4)",
        data : [364,504,605,400,345,320]
    }

]
};

var income = document.getElementById("income").getContext("2d");
new Chart(income).Bar(barData);

http://jsbin.com/yoguzuwoha/1/edit?html,js,output

0👍

You can’t load your your chart before barData, no need to change any thing only load your chart after barData..

var barData = {
labels : ["January","February","March","April","May","June"],
datasets : [
{
    fillColor : "#48A497",
    strokeColor : "#48A4D1",
    data : [456,479,324,569,702,600]
},
{
    fillColor : "rgba(73,188,170,0.4)",
    strokeColor : "rgba(72,174,209,0.4)",
    data : [364,504,605,400,345,320]
}

]
};

var income = document.getElementById("income").getContext("2d");
new Chart(income).Bar(barData);

Leave a comment