Chart.js bar chart only displaying first value in data array

I have created a web page in a html file. I have used the chart.js plugin to display a bar chart. However, only the first value of the array displays in the chart. Here is my index.html.


    <meta charset="utf-8" />
    <script src="/Chart.js" type="text/javascript"></script>


      <h1>Battery Levels</h1>
        <canvas id="myChart1" width="800" height="450"></canvas>
        var batlevels = {
            datasets: [{
                data: [20, 40, 10, 30, 50],
                backgroundColor: [

        // Get the context of the canvas element we want to select
        var chart1 = document.getElementById("myChart1").getContext("2d");
        new Chart(chart1, {
            type: 'bar',
            data: batlevels


Welcome, marionb.

You need to pass in the labels property of the data object.

Hope this helps.