“我使用的是Flask,Jinja2,higHighcharts”
示例(Python / Flask):
@app.route("/column/") def column(): data=[{"data": [49.9,54.4],"name": "Tokyo"},{"data": [42,30.4],"name": "AC"}] return render_template('column.html',data=data)
我的模板
$(document).ready(function() { chart1 = new Highcharts.Chart({ chart: { renderTo: 'container',type: 'bar' },title: { text: 'Fruit Consumption' },xAxis: { categories: ['Apples','Bananas','Oranges'] },yAxis: { title: { text: 'Fruit eaten' } },series:{{ data }} }); });
我查看highcharts(column.html)
series:[{&\#39;data': [4,5,9],&\#39;name&\#39;: &\#39;Jane&\#39;},{&\#39;data&\#39;: [8,3,4],&\#39;name&\#39;: &\#39;John&\#39;}]});
我想纠正Jinja2的措辞,最终是期望的结果.
series: [{ name: 'Jane',data: [1,4]},{ name: 'John',data: [5,7,3] }]