Reputation: 504
I know this question has been asked several times, I tried to find a solution but I found nothing. I am trying to create a graph chart.js.
the part that contains the error is that of 'option:', because when I delete it all works well, but despite that I check well, I do not find the error
here is my error:
Uncaught SyntaxError: Unexpected identifier
here is my script:
<script>
var timeFormat = 'MM/DD/YYYY HH:mm:ss';
function newDateLabel(dateObject) {
val_date = moment(dateObject).format(timeFormat);
return new Date(val_date)
}
var config = {
// The type of chart we want to create
type: 'line',
data: {
labels: [
%for time in list_date:
newDateLabel('{{time}}'),
%end
],
datasets: [{
label: 'Demo',
fill: false,
data: [
%for val in list_valeurs:
{{val}},
%end
],
borderWidth: 1
}]
},
options: {
title: {
text: 'Chart.js Time Scale'
},
scales: {
xAxes: [{
type: 'time',
time: {
format: timeFormat,
tooltipFormat: 'll HH:mm'
},
scaleLabel: {
display: true,
labelString: 'Date'
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'value'
}
}]
},
}
};
window.onload = function() {
var ctx = document.getElementById('canvas').getContext('2d');
window.myLine = new Chart(ctx,config);
};
</script>
could you help me please ?
Upvotes: 2
Views: 5853