调整了一些国家的中英文对照关系,解决地图上没有显示问题

master
yangxudongll 5 years ago
parent 12c5820631
commit e0dff55fa1

@ -16,13 +16,22 @@ def searchProvinceConfirmed():
print("------------------------------------")
db=GetFromDB()
results=db.searchProvinceConfirmed('2020-08-07')
print(results)
data=jsonify(areas=[x[0] for x in results],confirmed=[x[1] for x in results])
return data
@app.route("/gloabalInfo/",methods=['POST'])
def GlobalInfomation():
print('----------------------------------')
db = GetFromDB()
results=db.searchForeignInformation('2020-08-10')
#由于查询到的数据中没有中国的信息,因此需要查询中国的信息加到世界信息中
data=jsonify(country=[x[3] for x in results], confirmed=[x[0] for x in results],died=[x[1] for x in results],
crued=[x[2] for x in results],curConfirm=[x[4] for x in results],confirmedRelative=[x[5] for x in results])
return data
@app.route("/")
def hello():
return render_template('hello.html')
return render_template('global.html')
if __name__=='__main__':
app.run(host='192.168.1.30')

@ -35,4 +35,13 @@ class GetFromDB():
thedate = date + "%"
sql='select area,confirmed from ProvinceTable where pub_date like "%s"'%(thedate)
self.cursor.execute(sql)
return self.cursor.fetchall()
#查询各国现存确诊和累计确诊,死亡人数等相关信息
def searchForeignInformation(self,date):
thedate = date + "%"
sql='select confirmed,died,crued,country,curConfirm,confirmedRelative from ForeignCountry where pub_date like "%s"'%(thedate)
self.cursor.execute(sql)
return self.cursor.fetchall()

File diff suppressed because one or more lines are too long

@ -0,0 +1,286 @@
{% extends 'base.html'%}
{% block title %}首页{% endblock %}
{% block head %}
<script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js">
</script>
<script src="{{url_for('static',filename='js/china.js')}}">
</script>
<script src="{{url_for('static',filename='js/world.js')}}">
</script>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
{% endblock %}
{% block main%}
<div id="boss">
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" id="topdate" type="date" placeholder="2020-08-07" aria-label="Search">
<input class="form-control mr-sm-2" id="topnum" type="search" placeholder="省份个数" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
<div id="main" style="width: 400px;height:400px;">
</div>
</div>
<script type="text/javascript">
// 基于准备好的dom初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
option = {
title: {
text:'世界累计确诊图',
subtitle:'2020-08-10',
left: 'center',
top: 'top'
},
/* tooltip: {
trigger: 'item',
formatter: function (params) {
var value = (params.value + '').split('.');
value = value[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g, '$1,')
+ '.' + value[1];
return params.seriesName + '<br/>' + params.name + ' : ' + value;
}
},*/
visualMap: {
min: 0,
max: 11000000,
text:['High','Low'],
realtime: false,
calculable: true,
inRange: {color: ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
},
},
series: [
{
name: 'World Population (2010)',
type: 'map',
mapType: 'world',
roam: true,
itemStyle:{
emphasis:{label:{show:true}}
},
status:"true",
nameMap: {
"Afghanistan": "阿富汗",
"Angola": "安哥拉",
"Albania": "阿尔巴尼亚",
"Algeria": "阿尔及利亚",
"Argentina": "阿根廷",
"Armenia": "亚美尼亚",
"Australia": "澳大利亚",
"Austria": "奥地利",
"Azerbaijan": "阿塞拜疆",
"Bahamas": "巴哈马",
"Bangladesh": "孟加拉国",
"Belgium": "比利时",
"Benin": "贝宁",
"Burkina Faso": "布基纳法索",
"Burundi": "布隆迪",
"Bulgaria": "保加利亚",
"Bosnia and Herz.": "波斯尼亚和黑塞哥维那",
"Belarus": "白俄罗斯",
"Belize": "伯利兹",
"Bermuda": "百慕大群岛",
"Bolivia": "玻利维亚",
"Brazil": "巴西",
"Brunei": "文莱",
"Bhutan": "不丹",
"Botswana": "博茨瓦纳",
"Cambodia": "柬埔寨",
"Cameroon": "喀麦隆",
"Canada": "加拿大",
"Central African Rep.": "中非共和国",
"Chad": "乍得",
"Chile": "智利",
"China": "中国",
"Colombia": "哥伦比亚",
"Congo": "刚果",
"Costa Rica": "哥斯达黎加",
"Côte d'Ivoire": "科特迪瓦",
"Croatia": "克罗地亚",
"Cuba": "古巴",
"Cyprus": "塞浦路斯",
"Czech Rep.": "捷克共和国",
"Dem. Rep. Korea": "韩国",
"Dem. Rep. Congo": "刚果(金)",
"Denmark": "丹麦",
"Djibouti": "吉布提",
"Dominican Rep.": "多米尼加共和国",
"Ecuador": "厄瓜多尔",
"Egypt": "埃及",
"El Salvador": "萨尔瓦多",
"Eq. Guinea": "赤道几内亚",
"Eritrea": "厄立特里亚",
"Estonia": "爱沙尼亚",
"Ethiopia": "埃塞俄比亚",
"Falkland Is.": "福克兰群岛",
"Fiji": "斐济",
"Finland": "芬兰",
"France": "法国",
"French Guiana": "法属圭亚那",
"Fr. S. Antarctic Lands": "法属南部领地",
"Gabon": "加蓬",
"Gambia": "冈比亚",
"Germany": "德国",
"Georgia": "佐治亚州",
"Ghana": "加纳",
"Greece": "希腊",
"Greenland": "格陵兰岛",
"Guatemala": "危地马拉",
"Guinea": "几内亚",
"Guinea-Bissau": "几内亚比绍",
"Guyana": "圭亚那",
"Haiti": "海地",
"Heard I. and McDonald Is.": "赫德岛和麦克唐纳群岛",
"Honduras": "洪都拉斯",
"Hungary": "匈牙利",
"Iceland": "冰岛",
"India": "印度",
"Indonesia": "印度尼西亚",
"Iran": "伊朗",
"Iraq": "伊拉克",
"Ireland": "爱尔兰",
"Israel": "以色列",
"Italy": "意大利",
"Ivory Coast": "象牙海岸",
"Jamaica": "牙买加",
"Japan": "日本",
"Jordan": "乔丹",
"Kashmir": "克什米尔",
"Kazakhstan": "哈萨克斯坦",
"Kenya": "肯尼亚",
"Kosovo": "科索沃",
"Kuwait": "科威特",
"Kyrgyzstan": "吉尔吉斯斯坦",
"Laos": "老挝",
"Lao PDR": "老挝人民民主共和国",
"Latvia": "拉脱维亚",
"Lebanon": "黎巴嫩",
"Lesotho": "莱索托",
"Liberia": "利比里亚",
"Libya": "利比亚",
"Lithuania": "立陶宛",
"Luxembourg": "卢森堡",
"Madagascar": "马达加斯加",
"Macedonia": "马其顿",
"Malawi": "马拉维",
"Malaysia": "马来西亚",
"Mali": "马里",
"Mauritania": "毛里塔尼亚",
"Mexico": "墨西哥",
"Moldova": "摩尔多瓦",
"Mongolia": "蒙古国",
"Montenegro": "黑山",
"Morocco": "摩洛哥",
"Mozambique": "莫桑比克",
"Myanmar": "缅甸",
"Namibia": "纳米比亚",
"Netherlands": "荷兰",
"New Caledonia": "新喀里多尼亚",
"New Zealand": "新西兰",
"Nepal": "尼泊尔",
"Nicaragua": "尼加拉瓜",
"Niger": "尼日尔",
"Nigeria": "尼日利亚",
"Korea": "朝鲜",
"Northern Cyprus": "北塞浦路斯",
"Norway": "挪威",
"Oman": "阿曼",
"Pakistan": "巴基斯坦",
"Panama": "巴拿马",
"Papua New Guinea": "巴布亚新几内亚",
"Paraguay": "巴拉圭",
"Peru": "秘鲁",
"Republic of the Congo": "刚果共和国",
"Philippines": "菲律宾",
"Poland": "波兰",
"Portugal": "葡萄牙",
"Puerto Rico": "波多黎各",
"Qatar": "卡塔尔",
"Republic of Serbia": "塞尔维亚共和国",
"Romania": "罗马尼亚",
"Russia": "俄罗斯",
"Rwanda": "卢旺达",
"Samoa": "萨摩亚",
"Saudi Arabia": "沙特阿拉伯",
"Senegal": "塞内加尔",
"Serbia": "塞尔维亚",
"Sierra Leone": "塞拉利昂",
"Slovakia": "斯洛伐克",
"Slovenia": "斯洛文尼亚",
"Solomon Is.": "所罗门群岛",
"Somaliland": "索马里兰",
"Somalia": "索马里",
"South Africa": "南非",
"S. Geo. and S. Sandw. Is.": "南乔治亚和南桑德威奇群岛",
"S. Sudan": "南苏丹",
"Spain": "西班牙",
"Sri Lanka": "斯里兰卡",
"Sudan": "苏丹",
"Suriname": "苏里南",
"Swaziland": "斯威士兰",
"Sweden": "瑞典",
"Switzerland": "瑞士",
"Syria": "叙利亚",
"Tajikistan": "塔吉克斯坦",
"Tanzania": "坦桑尼亚",
"Thailand": "泰国",
"Timor-Leste": "东帝汶",
"Togo": "多哥",
"Trinidad and Tobago": "特立尼达和多巴哥",
"Tunisia": "突尼斯",
"Turkey": "土耳其",
"Turkmenistan": "土库曼斯坦",
"Uganda": "乌干达",
"Ukraine": "乌克兰",
"United Arab Emirates": "阿拉伯联合酋长国",
"United Kingdom": "大不列颠联合王国",
"United Republic of Tanzania": "坦桑尼亚联合共和国",
"United States": "美国",
"United States of America": "美利坚合众国",
"Uruguay": "乌拉圭",
"Uzbekistan": "乌兹别克斯坦",
"Vanuatu": "瓦努阿图",
"Venezuela": "委内瑞拉",
"Vietnam": "越南",
"West Bank": "西岸",
"W. Sahara": "西撒哈拉",
"Yemen": "也门",
"Zambia": "赞比亚",
"Zimbabwe": "津巴布韦"
},
data: [],
}
]
};
$.ajax({
cache:false,
data:[],
url:'/gloabalInfo',
type:'POST',
async:false,
error:function(request){
alert("fail");
},
success:function(results){
confirmed=results.confirmed;
country=results.country;
console.log(confirmed);
console.log(country);
for(i=0;i<confirmed.length;i++){
option.series[0].data.push({name:country[i],value:confirmed[i]});
}
}
});
myChart.setOption(option);
</script>
{%endblock%}

@ -88,6 +88,7 @@
confirmed=results.confirmed;
console.log(cityName);
console.log(confirmed);
for(i=0;i<cityName.length;i++){
option.series[0].data.push({name:cityName[i],value:confirmed[i]});
}

@ -1,7 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="fcea9d71-f4b2-41ab-b680-ecae8402b966" name="Default Changelist" comment="" />
<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$/../数据分析和可视化/新冠疫情/templates/hello.html" beforeDir="false" afterPath="$PROJECT_DIR$/../数据分析和可视化/新冠疫情/templates/hello.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/GrapData.py" beforeDir="false" afterPath="$PROJECT_DIR$/GrapData.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -80,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="1596968618945">
<state width="1814" height="398" key="GridCell.Tab.0.bottom" timestamp="1597041384348">
<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="1596968618945" />
<state width="1814" height="398" key="GridCell.Tab.0.center" timestamp="1596968618944">
<state width="1814" height="398" key="GridCell.Tab.0.bottom/67.27.1853.1053@67.27.1853.1053" timestamp="1597041384348" />
<state width="1814" height="398" key="GridCell.Tab.0.center" timestamp="1597041384344">
<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="1596968618944" />
<state width="1814" height="398" key="GridCell.Tab.0.left" timestamp="1596968618944">
<state width="1814" height="398" key="GridCell.Tab.0.center/67.27.1853.1053@67.27.1853.1053" timestamp="1597041384344" />
<state width="1814" height="398" key="GridCell.Tab.0.left" timestamp="1597041384343">
<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="1596968618944" />
<state width="1814" height="398" key="GridCell.Tab.0.right" timestamp="1596968618945">
<state width="1814" height="398" key="GridCell.Tab.0.left/67.27.1853.1053@67.27.1853.1053" timestamp="1597041384343" />
<state width="1814" height="398" key="GridCell.Tab.0.right" timestamp="1597041384346">
<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="1596968618945" />
<state width="1814" height="398" key="GridCell.Tab.0.right/67.27.1853.1053@67.27.1853.1053" timestamp="1597041384346" />
<state x="67" y="27" width="1521" height="1053" key="SettingsEditor" timestamp="1596677393346">
<screen x="67" y="27" width="1853" height="1053" />
</state>
@ -114,12 +120,12 @@
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/GrapData.py</url>
<line>42</line>
<line>43</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/GrapData.py</url>
<line>44</line>
<line>45</line>
<option name="timeStamp" value="2" />
</line-breakpoint>
</breakpoints>

@ -5,6 +5,7 @@ import re
import json
from bs4 import BeautifulSoup
from DataFrame import *
import pandas as pd
class Spider():
def __init__(self):
@ -111,6 +112,8 @@ class Spider():
print(foreign)
return foreignTuples
#抓取国外疫情信息概况
def grapSummaryForeign(self):
data=requests.get(self.url,headers=self.headers)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save