weixin_42041808
2019-04-11 22:23Django+highcharts画饼状图问题
view代码如下
listz.append({"name": str(key.name),"value":int(total)})
return render(request, "cartogram6.html", {'Z': listz})
highcharts用的是官网的模板,是这样的
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"><link rel="icon" href="https://jscdn.com.cn/highcharts/images/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* css 代码 */
</style>
<script src="https://img.highcharts.com.cn/highcharts/highcharts.js"></script>
<script src="https://img.highcharts.com.cn/highcharts/modules/exporting.js"></script>
<script src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script>
</head>
<body>
<div id="container" style="min-width:400px;height:400px"></div>
<script>
// JS 代码
Highcharts.chart('container', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: '出库到各个客户的商品数量占比'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
name: 'Brands',
colorByPoint: true,
data:{{ Z|safe }}
}]
});
</script>
</body>
</html>
但是画不出饼状图,求问各位大佬应该怎么改呀?非常感蟹大嘎~
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- 关于Django和mysql的一些问题
- django
- mysql
- 1个回答
- nginx + django + uwsgi 部署问题
- django
- nginx
- python
- mysql
- ubuntu
- 1个回答
- django框架,page not found问题
- django
- 1个回答
- Django写网站遇到IndexError: list index out of range问题求解
- django
- python
- sqlite
- 1个回答
- CentOS7.2+Django1.8+Nginx+uwsgi部署
- django
- python
- centos
- 2个回答
换一换