1. Using Tools
https://www.hcharts.cn/
http://echarts.baidu.com/
2, sub-table query
ID creation time Content processor 1 2017-02-01 11:11 1 2 2017 -03-01 11:11 11 3 2017-04-01 11:11 2 4 2017-05 -01 11:11 1 5 2017-02-02 11:11 1 1. The idea processor list = Select processes the From-TB for processor in processor list: v = select * from TB where processor = Processor Group by creation Time (2017-02) 2. Idea # Number of orders processed per month SELECT * from TB GROUP by creation time (%Y-%M) Select creation Time (%Y-%M), (select count (ID) from TB as T2 where processor =1 and t2.ctime = t1.ctime), (select COUNT (ID) From TB as T2 where processor =2 and t2.ctime = t1.cTime), from-TB as T1 group by Creation (%Y-%M) month id=1 id= 2 2017-02 2) 2017-03 0 2017-04 0 2017-05 1
def trouble_json_report (Request): reponse = [] from django.db import connection,connections userlist = UserInfo.objects.all () for row in userlist: cursor = connection.cursor () Cursor.execute ( "" "Select Unix_timestamp (Date_format (CTime, "%%y-%%m-01")) *1000, COUNT (ID) from repository_trouble WHERE processer_id=%s GROUP by Date_format (CTime, "%%y-%%m") "" ", [Row.nid]) result = Cursor.fetchall () temp = { ' name ': Row.username, ' data ': Result } reponse.append (temp) import JSON return HttpResponse ( Json.dumps (reponse))
{% extends ' backdemo.html '%} {% block title%} article{% endblock%}{% block css%} <style> </style>{% endblock%}{% block modal% }{% endblock%}{% block content%} <ol class= "breadcrumb" > <li><a href= "#" > Security Management </a></ li> <li class= "active" > Data analysis </li> </ol>
Data analysis drawing, querying data using native SQL