we must provide series highcharts, in views.py, data is:
series_1 = [ {'type': 'column', 'data': [4056], 'name': '二手家具'}, {'type': 'column', 'data': [3016], 'name': '家居百货'}, {'type': 'column', 'data': [3765], 'name': '虚拟物品'}, {'type': 'column', 'data': [4056], 'name': '服饰箱包'}, {'type': 'column', 'data': [3756], 'name': '闲置礼品'}, {'type': 'column', 'data': [4056], 'name': '图书/音乐/运动'}, {'type': 'column', 'data': [3765], 'name': '农用品'}, {'type': 'column', 'data': [4052], 'name': '母婴/儿童用品'}, {'type': 'column', 'data': [4056], 'name': '二手手机'}, {'type': 'column', 'data': [4055], 'name': '美容护肤/化妆品'}, {'type': 'column', 'data': [4055], 'name': '二手笔记本'}, {'type': 'column', 'data': [4055], 'name': '电子数码'}, {'type': 'column', 'data': [3765], 'name': '设备/办公用品'}, {'type': 'column', 'data': [4055], 'name': '台式电脑/网络'}, {'type': 'column', 'data': [4055], 'name': '老年用品'}, {'type': 'column', 'data': [4054], 'name': '家用电器'}]
the view fuction :
def chart2(request): context = { 'series':series_1 } return render(request, 'chart2.html', context)
the code of highcharts in chart2.html is:
<script> $(function () { $('#container').highcharts({ title: { text: 'tongji', x: -20 //center }, yaxis: { title: { text: 'number' }, plotlines: [{ value: 0, width: 1, color: '#808080' }] }, series:{{series|safe}} }); }); </script>>
when run it, can see messy code this:
if use unicode string u'二手家具',the highcharts has error this:
i don't know how deal problem,please me,thank you!
Comments
Post a Comment