cyborgv7
cyborgv7

Reputation: 63

ChartJS - Uncaught SyntaxError: Unexpected number

I have been writing a fucntion to pull data from a mysql database and display them in a chart. When i pull any other data it works fine but when i pull data from this set i get the "Uncaught SyntaxError: Unexpected number"

I have given an example of the data taken from the database below which is giving the error.

Any help would be much appreciated

<body><div class="chartjs-wrapper">
<canvas id="line-chart" height="100px"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
<script>
new Chart(document.getElementById("line-chart"), {
  type: 'line',
  data: {
    labels: [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40], 
    datasets: [{ 
        data: [08.212,07.514,07.334,07.214,06.986,07.367,07.225,07.619,07.090,07.148,07.090,07.684,07.890,07.132,07.234,07.065,07.033,07.110,08.262,07.150,07.122,06.878,07.864,07.295,07.235,09.855,09.176,09.498,08.163,07.395,07.369,07.230,07.065,07.365,07.024,07.276,07.275,07.405,07.120],
        label: "Lap Data",
        spanGaps: false,
        borderColor: "#3e95cd",
        fill: false
      }
    ]
  },
  options: {
    title: {
        
      display: true,
      spanGaps: [5,5],
      spanGaps: true,  
    }
  }
});
</script>
</div></body>

Upvotes: 1

Views: 1539

Answers (1)

Jabster28
Jabster28

Reputation: 177

JavaScript numbers can't have preceding zeroes and a decimal point - try removing all of the zeroes from the array.

Upvotes: 1

Related Questions