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.
p9ew5o3q7/app/static/js/confirmRelative_top10_count...

123 lines
3.1 KiB

var ec=echarts.init(document.getElementById('confirmRelative_top10_country'));
var dataAxis = [];
var data = [];
var yMax = 1300;
var dataShadow = [];
for (var i = 0; i < data.length; i++) {
dataShadow.push(yMax);
}
var option1 = {
title: {
text: '新增确诊国家Top10',
subtext: ''
},
xAxis: {
data: dataAxis,
axisLabel: {
inside: true,
textStyle: {
color: 'black'
}
},
axisTick: {
show: false
},
axisLine: {
show: false
},
z: 10
},
yAxis: {
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
textStyle: {
color: '#999'
}
}
},
dataZoom: [
{
type: 'inside'
}
],
series: [
{ // For shadow
type: 'bar',
itemStyle: {
color: 'rgba(0,0,0,0.05)'
},
barGap: '-100%',
barCategoryGap: '40%',
data: dataShadow,
animation: false
},
{
type: 'bar',
itemStyle: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{offset: 0, color: '#83bff6'},
{offset: 0.5, color: '#188df0'},
{offset: 1, color: '#188df0'}
]
)
},
emphasis: {
itemStyle: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{offset: 0, color: '#2378f7'},
{offset: 0.7, color: '#2378f7'},
{offset: 1, color: '#83bff6'}
]
)
}
},
data: data
}
]
};
// Enable data zoom when user click bar.
var zoomSize = 6;
ec.on('click', function (params) {
console.log(dataAxis[Math.max(params.dataIndex - zoomSize / 2, 0)]);
ec.dispatchAction({
type: 'dataZoom',
startValue: dataAxis[Math.max(params.dataIndex - zoomSize / 2, 0)],
endValue: dataAxis[Math.min(params.dataIndex + zoomSize / 2, data.length - 1)]
});
});
$.ajax({
cache: false,
type:"GET",
url:"/confirmRelative_top10_country",
data: null,
dataType : "json",
async: false,
error: function(request) {
alert("发送请求失败6");
},
success: function(result) {
// date, area, confirmRelative
option1.title.subtext = "数据更新时间: " + result.date+" 单位:例"
for(i=0; i<result.area.length; ++i) {
dataAxis.push(result.area[i]);
data.push(result.confirmRelative[i])
}
console.info(result)
console.log(option1.xAxis.data)
}
});
ec.setOption(option1)