Chartjs-Chart JS not working with Dynamic Data

0👍

The following works fine for me. Are you using the latest version of chart.js?

var array = [298,287,284,282,280];
var labelArray = ["April","May","June","July","August"];

var data = {
labels : labelArray,
pointDotStrokeWidth : 5,
datasets : [
    {
        label: "My First dataset",
        fillColor : "rgba(151,187,205,0.5)",
        strokeColor : "rgba(151,187,205,1)",
        pointColor : "rgba(151,187,205,1)",
        pointStrokeColor : "#fff",
        data : array


    },
    {
        label: "My First dataset",
        fillColor: "rgba(220,220,220,0.0)",
        strokeColor: "rgba(20, 138, 44, 1)",
        highlightFill: "rgba(220,220,220,0.75)",
        highlightStroke: "rgba(220,220,220,1)",
        pointColor : "rgba(151,187,205,0)",
        pointStrokeColor : "rgba(151,187,205,0)",
        data: [287, 287, 287, 287, 287]
    }
]
}

var ctx = $("#weekChart").get(0).getContext("2d");
new Chart(ctx).Line(data);  

Leave a comment