#add message

This commit is contained in:
xieshen 2020-11-04 11:52:36 +08:00
parent 86e9c4f4b7
commit 2815c4bba5
4 changed files with 71 additions and 25 deletions

View File

@ -175,19 +175,18 @@
<div class="r1_graph2 db_box">
<span class='bold'>新媒体数量/时间</span>
<div id="left2" style="width: 100%;height:200px;background-color: white"></div>
<div id="left2" style="width: 100%;height:150px;background-color: white"></div>
{# <span class='pull-right'><small>USERS ONLINE</small></span>#}
<div class="clearfix"></div>
<span class="db_linesparkline">Loading...</span>
{# <div class="clearfix"></div>#}
</div>
<div class="r1_graph3 db_box">
<span class='bold'>预警次数/时间</span>
<div id="left3" style="width: 100%;height:140px;background-color: white"></div>
{# <span class='pull-right'><small>ORDERS / SALES</small></span>#}
<div class="clearfix"></div>
<span class="db_compositebar">Loading...</span>
{# <div class="clearfix"></div>#}
</div>
</div>
@ -387,6 +386,7 @@
left: '3%',
right: '6%',
bottom: '1%',
top: '20px',
containLabel: true
},
toolbox: {
@ -438,5 +438,50 @@
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
})
$.getJSON('/monitor/index/warning/count/', function (res) {
// 基于准备好的dom初始化echarts实例
var myChart = echarts.init(document.getElementById('left3'));
option = {
{#title: {#}
{# text: '新媒体数量/时间',#}
{# },#}
tooltip: {
trigger: 'axis'
},
legend: {
data: ['预警']
},
grid: {
left: '3%',
right: '6%',
bottom: '1%',
top: '20px',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: res.date_list
},
yAxis: {
type: 'value'
},
series: [
{
name: '预警',
type: 'line',
stack: '总量',
data: res.data
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
})
</script>
{% endblock %}

View File

@ -151,7 +151,7 @@
show: false
},
data: [
{value: 1, name: '预警次数5'},
{value: 1, name: '预警次数6'},
]
}
]

View File

@ -34,6 +34,7 @@ urlpatterns = [
#首页图
path('index/map/',views.index_map,name='index-map'),
path('index/newmedia/count/',views.index_newmedia_count,name='index-newmedia-count'),
path('index/warning/count/',views.index_warning_count,name='index-warning-count'),

View File

@ -16,7 +16,7 @@ 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, NewMedia
from monitor.models import Test
import pandas as pd
@login_required
def new_media_public_opinion_weixin(request):
weixin = Weixin.objects.all()
@ -1125,23 +1125,8 @@ def index_map(request):
}))
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])
date_list = [x.strftime('%Y-%m-%d') for x in list(pd.date_range(start='2020-09-01',end=datetime.datetime.now()))]
print(date_list)
weixin_list = []
weibo_list = []
toutiao_list = []
@ -1163,10 +1148,25 @@ def index_newmedia_count(request):
qita_list.append(qita)
return HttpResponse(json.dumps({
"status":"1",
"date_list":list(set(date_list)),
"date_list":date_list,
"weixin":weixin_list,
"weibo":weibo_list,
"toutiao":toutiao_list,
"douyin":douyin_list,
"qita":qita_list,
}))
def index_warning_count(request):
date_list = [x.strftime('%Y-%m-%d') for x in list(pd.date_range(start='2020-09-01',end=datetime.datetime.now()))]
data = []
for d in date_list:
s = str(d).split('-')
news = News.objects.filter(type='3',date=d).count()
data.append(news)
return HttpResponse(json.dumps({
"status":"1",
"data":data,
"date_list":date_list
}))