国外疫情显示

master
yangxudongll 4 years ago
parent 9f890a9545
commit ec550dbaab

@ -52,7 +52,8 @@ def GlobalInfomation():
country.append("中国")
confirmed = [x[0] for x in results]
confirmed.append(db.searchSummaryChina('2020-08-10')[0][1])
top10data=db.query_top10(nowtime)
print(top10data)
summaryData=db.querySummaryForeign(nowtime)[0]
data=jsonify(country=country, confirmed=confirmed,died=[x[1] for x in results],
crued=[x[2] for x in results],curConfirm=[x[4] for x in results],
@ -60,7 +61,9 @@ def GlobalInfomation():
TotalConfirmed=summaryData[1],TotalCurConfirm=summaryData[2],
TotalconfirmRelative=summaryData[3],TotalCrued=summaryData[4],
TotalDied=summaryData[6],TotalDiedRelative=summaryData[7],
TotalCruedRelative=summaryData[5],TotalcurConfirmRelative=summaryData[9])
TotalCruedRelative=summaryData[5],TotalcurConfirmRelative=summaryData[9],
top10confirmed=[x[0] for x in top10data],top10curconfirm=[x[1] for x in top10data],
top10country=[x[2] for x in top10data])
return data
@app.route("/")

@ -76,7 +76,7 @@ class GetFromDB():
#新增国家top10
def query_top10(self,date):
thedate=date+"%"
sql='select confirmed,confirmedRelative from ForeignCountry where pub_date like "%s" order by confirmed desc limit 10'%(thedate)
sql='select confirmed,confirmedRelative,country from ForeignCountry where pub_date like "%s" order by confirmed desc limit 10'%(thedate)
self.cursor.execute(sql)
return self.cursor.fetchall()

@ -115,8 +115,8 @@
</div>
<div class="map t_common">
<div class="map_tit tit_common">
<span class="tit_con">当前确诊人数最多的5个省份</span>
<div class="map_con" id="top5chart" style="width:100%;height:300px;"></div>
<span class="tit_con">当前确诊人数最多的10个国家</span>
<div class="map_con" id="top10chart" style="width:100%;height:300px;"></div>
</div>
</div>
<div id="echarts1" style="width:100%;height:4rem;margin-bottom:0.4rem;"></div>
@ -164,12 +164,12 @@
//在国内,国外疫情,防护知识间切换
console.log("+++++++++++++++++++++++++++++");
var ospan = document.querySelectorAll('.middle_con .wrap .tabs .tabs_wrap span');
console.log(ospan.length);
var num_op = 0;
var tabs_list = document.querySelectorAll('.middle_con .wrap .tabs_content .tabs_list');
console.log(tabs_list.length);
tabs_list[0].style.display = 'block';
for (var i = 0; i < ospan.length; i++) {
ospan[i].index = i;
@ -429,7 +429,7 @@ dataRange:{
};
//表格填充
function eachchina(province,confirmed,curconfirm,died) {
var str = '';
if (province.length!=0) {
@ -450,6 +450,54 @@ function eachchina(province,confirmed,curconfirm,died) {
}
}
//绘制世界top10确诊国家
var top10chart=echarts.init(document.getElementById('top10chart'));
var top10option={
title:{
text:'确诊top10',
left:'20px',
},
tooltip:{
trigger:"axis",
},
legend:{
itemWith:15,
itemHeight:15,
data:['累计确诊','新增确诊']
},
xAxis:{
type:'category',
data:[],
splitLine:{
show:true,
},
axisLabel:{interval: 0}
},
yAxis:{
splitLine:{
show:false,
}
},
series:[{
name:'累计确诊',
type:'bar',
stack:'累计',
data:[],
},{
name:'新增确诊',
type:'bar',
stack:'新增',
data:[],
}
]
};
$.ajax({
cache:false,
type:'POST',
@ -472,8 +520,7 @@ $.ajax({
confirmed=results.confirmed;
foreignName=results.country;
console.log(confirmed);
console.log(foreignName);
for(i=0;i<confirmed.length;i++){
option.series[0].data.push({name:foreignName[i],value:confirmed[i]});
}
@ -481,10 +528,20 @@ $.ajax({
curConfirmedRelative=results.confirmedRelative;
died=results.died;
$(".china.table_pro .content").html(eachchina(foreignName,confirmed,curConfirmedRelative,died));
top10confirmed=results.top10confirmed;
top10curconfirm=results.top10curconfirm;
top10country=results.top10country;
for(i=0;i<10;i++){
top10option.xAxis.data.push(top10country[i]);
top10option.series[0].data.push(top10confirmed[i]);
top10option.series[1].data.push(top10curconfirm[i]);
}
}
});
myChart.setOption(option);
top10chart.setOption(top10option);

@ -4,14 +4,9 @@
<list default="true" id="fcea9d71-f4b2-41ab-b680-ecae8402b966" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/hello.py" beforeDir="false" afterPath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/hello.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/models.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/static/js/update.js" beforeDir="false" afterPath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/static/js/update.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/templates/foreign.html" beforeDir="false" afterPath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/templates/foreign.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/templates/global.html" beforeDir="false" afterPath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/templates/global.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/templates/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/templates/index.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/DataFrame.py" beforeDir="false" afterPath="$PROJECT_DIR$/DataFrame.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/GrapData.py" beforeDir="false" afterPath="$PROJECT_DIR$/GrapData.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xinguan.sql" beforeDir="false" afterPath="$PROJECT_DIR$/xinguan.sql" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -91,22 +86,22 @@
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state x="704" y="108" width="624" height="753" key="FileChooserDialogImpl/67.27.1853.1053@67.27.1853.1053" timestamp="1596679790740" />
<state width="1814" height="398" key="GridCell.Tab.0.bottom" timestamp="1597212800889">
<state width="1814" height="437" key="GridCell.Tab.0.bottom" timestamp="1597227635575">
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state width="1814" height="398" key="GridCell.Tab.0.bottom/67.27.1853.1053@67.27.1853.1053" timestamp="1597212800889" />
<state width="1814" height="398" key="GridCell.Tab.0.center" timestamp="1597212800886">
<state width="1814" height="437" key="GridCell.Tab.0.bottom/67.27.1853.1053@67.27.1853.1053" timestamp="1597227635575" />
<state width="1814" height="437" key="GridCell.Tab.0.center" timestamp="1597227635572">
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state width="1814" height="398" key="GridCell.Tab.0.center/67.27.1853.1053@67.27.1853.1053" timestamp="1597212800886" />
<state width="1814" height="398" key="GridCell.Tab.0.left" timestamp="1597212800883">
<state width="1814" height="437" key="GridCell.Tab.0.center/67.27.1853.1053@67.27.1853.1053" timestamp="1597227635572" />
<state width="1814" height="437" key="GridCell.Tab.0.left" timestamp="1597227635571">
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state width="1814" height="398" key="GridCell.Tab.0.left/67.27.1853.1053@67.27.1853.1053" timestamp="1597212800883" />
<state width="1814" height="398" key="GridCell.Tab.0.right" timestamp="1597212800888">
<state width="1814" height="437" key="GridCell.Tab.0.left/67.27.1853.1053@67.27.1853.1053" timestamp="1597227635571" />
<state width="1814" height="437" key="GridCell.Tab.0.right" timestamp="1597227635573">
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state width="1814" height="398" key="GridCell.Tab.0.right/67.27.1853.1053@67.27.1853.1053" timestamp="1597212800888" />
<state width="1814" height="437" key="GridCell.Tab.0.right/67.27.1853.1053@67.27.1853.1053" timestamp="1597227635573" />
<state x="67" y="27" width="1521" height="1053" key="SettingsEditor" timestamp="1596677393346">
<screen x="67" y="27" width="1853" height="1053" />
</state>

@ -119,26 +119,6 @@ class SaveToDB():
autocommit=True
)
def connect(self):
self.conn = pymysql.connect(
user=self.user,
host=self.host,
port=self.port,
password=self.password,
database='xinguan',
autocommit=True
)
curser=self.conn.cursor()
curser.execute('insert into ForeignCountry(confirmed,'
'died,crued,country,curConfirm,confirmedRelative,pub_data) '
'values(1,1,1,"英国",1,1,"2020-10-18 10:00:00");')
self.__rule('ForeignCountry')
curser.execute('select * from ForeignCountry;')
data=curser.fetchall()
frame=pd.DataFrame(list(data),columns=['id','confirmed','died','crued','country','curConfirm','curConfirmRelative','pubdate'])
print(frame['country'])
curser.close()
self.conn.close()
#存储国内各省疫情信息
def InsertIntoProvince(self,data):
@ -184,7 +164,13 @@ class SaveToDB():
cursor.execute(deletesql)
#设置ID从最小开始
self.__rule('ForeignCountry')
flag=0
for i in range(len(data)):
if data[i][3]=='美国':
if flag==1:
continue
else:
flag=1
sql='insert into ForeignCountry(confirmed,died,crued,country,curConfirm,' \
'confirmedRelative,pub_date) values(%d,%d,%d,"%s",%d,%d,"%s");'%(data[i])
cursor.execute(sql)

Loading…
Cancel
Save