你把逗号弄乱了一点。试试下面的方法。如果不起作用,请提供更多关于错误的信息(可能是在JavaScript执行过程中)
AmCharts.makeChart("chartdiv",
{
"type": "serial",
"categoryField": "category",
"dataDateFormat": "YYYY-MM-DD",
"startDuration": 1,
"theme": "dark",
"categoryAxis": {
"gridPosition": "start",
"parseDates": true
},
"chartCursor": {
"enabled": true
},
"chartScrollbar": {
"enabled": true
},
"trendLines": [],
"graphs": [
{
"fillAlphas": 1,
"id": "AmGraph-1",
"title": "graph 1",
"type": "column",
"valueField": "column-1"
}
],
"guides": [],
"valueAxes": [
{
"id": "ValueAxis-1",
"title": "score range"
}
],
"allLabels": [],
"balloon": {},
"titles": [
{
"id": "Title-1",
"size": 15,
"text": "Merit Score Chart"
}
],
"dataProvider": [
{% for score_date, score_graph_data in chart_data %}
{
"category": '{{score_date|safe}}',
"column-1": '{{score_graph_data}}'
}
{{ "," if not loop.last }}
{% endfor %}
]
}
);