diff --git a/dashboard/templates/dashboard/index.html b/dashboard/templates/dashboard/index.html
index cb9e559..a77e0f9 100644
--- a/dashboard/templates/dashboard/index.html
+++ b/dashboard/templates/dashboard/index.html
@@ -165,25 +165,27 @@
-
-
时间/更新篇数
-
SERVER UP
-
-
Loading...
-
+{#
#}
+{#
时间/更新篇数#}
+{#
SERVER UP#}
+{#
#}
+{#
Loading...#}
+{#
#}
-
新媒体数量
-
USERS ONLINE
+
新媒体数量/时间
+
+
+{#
USERS ONLINE#}
Loading...
-
预警次数
-
ORDERS / SALES
+
预警次数/时间
+{#
ORDERS / SALES#}
Loading...
@@ -191,8 +193,9 @@
-
@@ -235,7 +238,7 @@
-
+{# #}
@@ -366,5 +369,74 @@
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
})
+
+ $.getJSON('/monitor/index/newmedia/count/', function (res) {
+ // 基于准备好的dom,初始化echarts实例
+ var myChart = echarts.init(document.getElementById('left2'));
+ option = {
+ {#title: {#}
+ {# text: '新媒体数量/时间',#}
+ {# },#}
+ tooltip: {
+ trigger: 'axis'
+ },
+ legend: {
+ data: ['微信', '微博', '今日头条', '抖音', '其他']
+ },
+ grid: {
+ left: '3%',
+ right: '6%',
+ bottom: '1%',
+ containLabel: true
+ },
+ toolbox: {
+ feature: {
+ saveAsImage: {}
+ }
+ },
+ xAxis: {
+ type: 'category',
+ boundaryGap: false,
+ data: res.date_list
+ },
+ yAxis: {
+ type: 'value'
+ },
+ series: [
+ {
+ name: '微信',
+ type: 'line',
+ stack: '总量',
+ data: res.weixin
+ },
+ {
+ name: '微博',
+ type: 'line',
+ stack: '总量',
+ data: res.weibo
+ },
+ {
+ name: '今日头条',
+ type: 'line',
+ stack: '总量',
+ data: res.toutiao
+ },
+ {
+ name: '抖音',
+ type: 'line',
+ stack: '总量',
+ data: res.douyin
+ },
+ {
+ name: '其他',
+ type: 'line',
+ stack: '总量',
+ data: res.qita
+ }
+ ]
+ };
+ // 使用刚指定的配置项和数据显示图表。
+ myChart.setOption(option);
+ })
{% endblock %}
\ No newline at end of file
diff --git a/monitor/urls.py b/monitor/urls.py
index e3a5669..b68ca90 100644
--- a/monitor/urls.py
+++ b/monitor/urls.py
@@ -33,6 +33,7 @@ urlpatterns = [
path('monitoring/report/json/',views.monitoring_report_json,name='monitor-monitoring-report-json'),
#首页图
path('index/map/',views.index_map,name='index-map'),
+ path('index/newmedia/count/',views.index_newmedia_count,name='index-newmedia-count'),
diff --git a/monitor/views.py b/monitor/views.py
index 6eadb98..a3886e1 100644
--- a/monitor/views.py
+++ b/monitor/views.py
@@ -14,7 +14,7 @@ from datetime import timedelta
from django.views.decorators.csrf import csrf_exempt
from dashboard.models import Weixin, Weixin_data, Toutiao_data, Weibo_data, Qita_jc, Group, Toutiao, Weibo, Qita, \
- Douyin, Douyin_data, News, TimelinessMonitoring, Organization, Wrongly
+ Douyin, Douyin_data, News, TimelinessMonitoring, Organization, Wrongly, NewMedia
from monitor.models import Test
@login_required
@@ -1122,4 +1122,51 @@ def index_map(request):
"timelinessmonitoring_toutiao":timelinessmonitoring_toutiao,
"timelinessmonitoring_douyin":timelinessmonitoring_douyin,
"timelinessmonitoring_qita":timelinessmonitoring_qita,
- }))
\ No newline at end of file
+ }))
+
+def index_newmedia_count(request):
+ date_list = [x.strftime('%Y-%m-%d') for x in list(pd.date_range(start='2020-08-22',end=datetime.datetime.now()))]
+ # weixin_date = Weixin.objects.all().order_by('-created')
+ # weibo_date = Weibo.objects.all().order_by('-created')
+ # toutiao_date = Toutiao.objects.all().order_by('-created')
+ # douyin_date = Douyin.objects.all().order_by('-created')
+ # qita_date = Qita.objects.all().order_by('-created')
+ # for w_d in weixin_date:
+ # date_list.append(str(w_d.created).split(' ')[0])
+ # for w_t in weibo_date:
+ # date_list.append(str(w_t.created).split(' ')[0])
+ # for t_d in toutiao_date:
+ # date_list.append(str(t_d.created).split(' ')[0])
+ # for d_d in douyin_date:
+ # date_list.append(str(d_d.created).split(' ')[0])
+ # for q_d in qita_date:
+ # date_list.append(str(q_d.created).split(' ')[0])
+
+ weixin_list = []
+ weibo_list = []
+ toutiao_list = []
+ douyin_list = []
+ qita_list = []
+ for d in date_list:
+ print(d)
+ s = str(d).split('-')
+ print(s[0],s[1],s[2])
+ weixin = Weixin.objects.filter(created__year=s[0],created__month=s[1],created__day=s[2]).count()
+ weixin_list.append(weixin)
+ weibo = Weibo.objects.filter(created__year=s[0],created__month=s[1],created__day=s[2]).count()
+ weibo_list.append(weibo)
+ toutiao = Toutiao.objects.filter(created__year=s[0],created__month=s[1],created__day=s[2]).count()
+ toutiao_list.append(toutiao)
+ douyin = Douyin.objects.filter(created__year=s[0],created__month=s[1],created__day=s[2]).count()
+ douyin_list.append(douyin)
+ qita = Qita.objects.filter(created__year=s[0],created__month=s[1],created__day=s[2]).count()
+ qita_list.append(qita)
+ return HttpResponse(json.dumps({
+ "status":"1",
+ "date_list":list(set(date_list)),
+ "weixin":weixin_list,
+ "weibo":weibo_list,
+ "toutiao":toutiao_list,
+ "douyin":douyin_list,
+ "qita":qita_list,
+ }))