|
@@ -18,38 +18,65 @@ export default {
|
|
name: "CityRank",
|
|
name: "CityRank",
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- fullscreen: false
|
|
|
|
|
|
+ fullscreen: false,
|
|
|
|
+ countryList: [],
|
|
|
|
+ countryData: []
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
- this.getEchartLeft1();
|
|
|
|
|
|
+ this.getConData();
|
|
|
|
+ setTimeout(this.getEchartLeft1, 2000)
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ //获取疫情数据
|
|
|
|
+ getConData() {
|
|
|
|
+ axios.get('https://www.maomin.club/fy/get', {
|
|
|
|
+ dataType: "json"
|
|
|
|
+ }).then(res => {
|
|
|
|
+ let ConData = res.data
|
|
|
|
+ let made = JSON.parse(ConData)
|
|
|
|
+ let madeData = made.component
|
|
|
|
+ let data = madeData[0]
|
|
|
|
+ for (var i = 0; i < data.topAddCountry.length; i++) {
|
|
|
|
+ this.countryList[i] = data.topAddCountry[i].name
|
|
|
|
+ this.countryData[i] = data.topAddCountry[i].value
|
|
|
|
+ }
|
|
|
|
+ }).catch(err => {
|
|
|
|
+ console.log(err)
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ //绘制图表
|
|
getEchartLeft1() {
|
|
getEchartLeft1() {
|
|
// 实例化对象
|
|
// 实例化对象
|
|
let myChart = echarts.init(document.getElementById('chart_left1'));
|
|
let myChart = echarts.init(document.getElementById('chart_left1'));
|
|
let charts = { // 按顺序排列从大到小
|
|
let charts = { // 按顺序排列从大到小
|
|
|
|
+ countryList: this.countryList,
|
|
|
|
+ countryData: this.countryData,
|
|
cityList: ['湖北', '香港', '广东', '湖南', '四川', '浙江', '上海'],
|
|
cityList: ['湖北', '香港', '广东', '湖南', '四川', '浙江', '上海'],
|
|
cityData: [68149, 8300, 2035, 1020, 843, 1300, 1473],
|
|
cityData: [68149, 8300, 2035, 1020, 843, 1300, 1473],
|
|
function(p) {
|
|
function(p) {
|
|
- return p.name + ":" + this.cityData(p.value);
|
|
|
|
|
|
+ return p.name + ":" + this.countryData(p.value);
|
|
|
|
+ console.log(top10CountryList)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ let top10CountryList = charts.countryList
|
|
|
|
+ let top10CountryData = charts.countryData
|
|
let top10CityList = charts.cityList;
|
|
let top10CityList = charts.cityList;
|
|
let top10CityData = charts.cityData;
|
|
let top10CityData = charts.cityData;
|
|
let color = ['rgba(14,109,236', 'rgba(255,91,6', 'rgba(100,255,249', 'rgba(248,195,248', 'rgba(110,234,19', 'rgba(255,168,17', 'rgba(218,111,227'];
|
|
let color = ['rgba(14,109,236', 'rgba(255,91,6', 'rgba(100,255,249', 'rgba(248,195,248', 'rgba(110,234,19', 'rgba(255,168,17', 'rgba(218,111,227'];
|
|
|
|
|
|
let lineY = [];
|
|
let lineY = [];
|
|
- for (let i = 0; i < charts.cityList.length; i++) {
|
|
|
|
|
|
+ for (let i = 0; i < charts.countryList.length; i++) {
|
|
let x = i
|
|
let x = i
|
|
if (x > color.length - 1) {
|
|
if (x > color.length - 1) {
|
|
x = color.length - 1
|
|
x = color.length - 1
|
|
}
|
|
}
|
|
let data = {
|
|
let data = {
|
|
- name: charts.cityList[i],
|
|
|
|
|
|
+ name: charts.countryList[i],
|
|
color: color[x] + ')',
|
|
color: color[x] + ')',
|
|
- value: top10CityData[i],
|
|
|
|
|
|
+ value: top10CountryData[i],
|
|
itemStyle: {
|
|
itemStyle: {
|
|
normal: {
|
|
normal: {
|
|
show: true,
|
|
show: true,
|
|
@@ -139,7 +166,7 @@ export default {
|
|
fontSize: 13
|
|
fontSize: 13
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- data: top10CityList
|
|
|
|
|
|
+ data: top10CountryList
|
|
}, {
|
|
}, {
|
|
type: 'category',
|
|
type: 'category',
|
|
axisLine: {
|
|
axisLine: {
|
|
@@ -165,7 +192,7 @@ export default {
|
|
splitLine: {
|
|
splitLine: {
|
|
show: false
|
|
show: false
|
|
},
|
|
},
|
|
- data: top10CityData.reverse()
|
|
|
|
|
|
+ data: top10CountryData.reverse()
|
|
}],
|
|
}],
|
|
series: [{
|
|
series: [{
|
|
name: '',
|
|
name: '',
|