javascript - Script error : "Uncaught SyntaxError: Unexpected identifier"
问题描述
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 ?
解决方案
选项前缺少逗号:
}
options: {
推荐阅读
- angular - 如何将变量从一个组件设置到另一个组件?
- node.js - 如何处理:错误:打开 COM6:在 Node js 中找不到文件
- sql - SQL Server 2005 中的临时表创建问题
- drools - 有没有办法在drools中使用基于规则LHS的休眠插入事实
- doxygen - 如何直接在单例实例上生成函数调用的调用者图?
- postgresql - 在 Postgres 中创建对自引用关系的约束
- jquery - 如何使用此嵌套 HTML 定位类的最近 div?
- javascript - 要求一个文件一次并使用函数参数传输它还是每次都在文件中要求它更好?
- python - 使用具有多个数据帧的 mplcursors
- vue.js - 如何知道异步组件何时完成渲染