1、常用的前端生成图表的工具HighCharts和echarts
2、具体内容可参考官方文档,有一些具体实例,JS和HTML的代码都存在,还可以编辑代码
3、具体的设置还可以参考官方文档
4、使用样例:
def get_data(request):
data ={}
from django.db import connection,connections
cursor = connection.cursor()
users = models.User.objects.all()
jsondata = []
for i in range(1,4):
user_obj = models.User.objects.filter(id = i).first()
cursor.execute("""select strftime("%%s",strftime("%%Y-%%m-01",respository_trouble.ctime)) * 1000 as a,count(respository_trouble.id) as num,respository_user.username from respository_trouble,respository_user WHERE respository_user.id = respository_trouble.user_id and user_id = %s group by user_id,strftime("%%Y-%%m",respository_trouble.ctime)""",[i])
rows = cursor.fetchall()
print(rows)
temp = {'name':user_obj.username ,'data':rows}
jsondata.append(temp)
import json
return HttpResponse(json.dumps(jsondata))
评论(0)