You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
64 lines
1.6 KiB
var myCharts2 = echarts.init(document.getElementById("main2"));
|
|
|
|
var option2 = {
|
|
title: {
|
|
text: '现有确诊人数最多的十个国家',
|
|
subtext: '',
|
|
left: 'center',
|
|
textStyle:{
|
|
fontFamily:'微软雅黑'
|
|
}
|
|
},
|
|
tooltip: {
|
|
trigger: 'item',
|
|
formatter: '{a} <br/>{b} : {c} ({d}%)'
|
|
},
|
|
legend: {
|
|
type: 'scroll',
|
|
orient: 'vertical',
|
|
right: 10,
|
|
top: 20,
|
|
bottom: 20,
|
|
data: []
|
|
},
|
|
series: [
|
|
{
|
|
name: '国家',
|
|
type: 'pie',
|
|
radius: '55%',
|
|
center: ['40%', '50%'],
|
|
data: [],
|
|
emphasis: {
|
|
itemStyle: {
|
|
shadowBlur: 10,
|
|
shadowOffsetX: 0,
|
|
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
|
}
|
|
}
|
|
}
|
|
]
|
|
};
|
|
|
|
// 向后台发起请求,获取数据
|
|
$.ajax({
|
|
cache: false,
|
|
type:"GET",
|
|
url:"/country_topn_curconfirm",
|
|
data: null,
|
|
dataType : "json",
|
|
async: false,
|
|
error: function(request) {
|
|
alert("发送请求失败");
|
|
},
|
|
success: function(result) {
|
|
// pub_date, privinces, curConfirms
|
|
option2.title.subtext = "数据更新时间: " + result.pub_date
|
|
for(i=0; i<result.privinces.length; ++i) {
|
|
option2.legend.data.push(result.privinces[i])
|
|
option2.series[0].data.push({name:result.privinces[i], value:result.curConfirms[i]})
|
|
}
|
|
console.info(result)
|
|
}
|
|
});
|
|
|
|
myCharts2.setOption(option2); |