我尝试使用django-nvd3实现pieChart
。但是,{% load_chart charttype chartdata chartcontainer extra %}
的输出html计算结果为False
。结果(很可能)图表无法出现。下面是视图.py,django模板和html输出。在
def results(request, nlm_id, time):
journal = Journal.objects.get(nlm_id = nlm_id)
stats = return_week(nlm_id, time, PLATFORMS)
chartdata = {'x': PLATFORMS, 'y': stats}
charttype = "pieChart"
chartcontainer = 'piechart_container'
data = {
'charttype': charttype,
'chartdata': chartdata,
'chartcontainer': chartcontainer,
'extra': {
'x_is_date': False,
'x_axis_format': '',
'tag_script_js': True,
'jquery_on_ready': True,
}
}
return render(request, 'journals/results.html', {'journal': journal,
'stats': stats, 'time': time, 'data': data})
<html>
<head>
...
<script>False</script>
</head>
<body>
<div id=""><svg style="width:600px;height:400px;"></svg></div>
</body>
</html>
我也遇到了类似的问题,当我改变}
{% load_chart charttype chartdata chartcontainer extra %}
时,我解决了这个问题 到{% load_chart data.charttype data.chartdata data.chartcontainer data.extra %}
类似地{% include_container chartcontainer 400 600 %}
到{一种解决方案是直接传递变量},如下所示:
charttype
、chartdata
、chartcontainer
、和{您可以在检查是否存在chartdata的if语句中包装负荷图表,例如:
相关问题 更多 >
编程相关推荐