Static data can be displayed normally,through ajax chart does not display properly
function getCheckDoctor(){
var echartDoctorWork1 = echarts.init(document.getElementById('check-doctor'));
var option = {
title: {
text: ''
},
tooltip: {
trigger: 'axis'
},
legend: {
data: ''
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
show: true,
orient: 'vertical',
left: 'right',
top: 'center'
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ''
},
yAxis: {
type: 'value',
name: '',
scale: true
},
series: ''
}
// get data by ajax
$.ajax({
type: 'get',
url: 'zl.json',
dataType: 'json',
success: function(res){
var data = res.data
var series = []; // 多组柱状图数据
var docArr = []; // 医生名称数组
for(var i=2;i<data.length;i++){
//push docArr
docArr.push(Object.keys(data[i]).toString())
//push series
series.push({
name: Object.keys(data[i]).toString(),
type: 'line',
stack: '总量'+i,
data: Object.values(data[i])
})
}
option.xAxis.data = Object.values(data[1])
console.log(Object.values(data[1]))
// 赋值后台返回医生名称数组
option.legend.data = docArr
// 赋值柱状图数组
option.series = series
echartDoctorWork1.setOption(option)
}
})
}
Static data can be displayed normally,through ajax chart does not display properly Static data can be displayed normally,through ajax chart does not display properly Static data can be displayed normally,through ajax chart does not display properly Static data can be displayed normally,through ajax chart does not display properly Static data can be displayed normally,through ajax chart does not display properly Static data can be displayed normally,through ajax chart does not display properly enter image description here
Aucun commentaire:
Enregistrer un commentaire