@myIvan 代码如下 var addChartData=function(row,datas){Orderdata.column=row;
var totaldata = [];
var legenddata = [];
for (var i in datas){
var newdata = {
name:datas[i]['jgmc'],
type:'line',
animation: false,
barWidth: '60%',
label:{
show: true,
formatter:function(params) {
return params.data
}
},
data:datas[i]['data']
};
legenddata.push(datas[i]['jgmc']);
totaldata.push(newdata);
}
myChart.setOption({
title:{
textStyle:{ //设置主标题风格
color:'black',//设置主标题字体颜色
fontStyle:'',//主标题文字风格
},
x:'center',
subtext:'',
padding:[5,10,5,5],//设置标题内边距,上,右,下,左
itemGap:10,//主副标题之间的间距
subtextStyle:{
color:'black',//设置主标题字体颜色
},
},
backgroundColor: '#ffffff',
xAxis: {
data: Orderdata.column,
axisLabel: {
show: true,
textStyle: {
color: '#000' //这里用参数代替了
}
},
},
yAxis: {
min:0,
max:105,
axisLabel: {
show: true,
textStyle: {
color: '#000' //这里用参数代替了
}
},
// data: ['0分','10分','20分','30分','40分','50分','60分','70分','80分','90分','100分','110分'],
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
top:'39%',
//bottom:'20%'
},
legend: {
orient: 'horizontal', // 'vertical'horizontal
x: 'center', // 'center' | 'left' | {number},
y: '45', // 'center' | 'bottom' | {number}
// backgroundColor: '#fff',
// borderColor: 'rgba(178,34,34,0.8)',
buttom:'10%',
type:'scroll',
borderWidth: 1,
padding: 3, // [5, 10, 15, 20]
data:legenddata,
textStyle: {
color: '#000' // 图例文字颜色
}
},
series: totaldata,
},true);
if ($("#echart").width() != $("#echart canvas").width() && $("#echart canvas").width() < $("#echart").width()) {
myChart.resize();
}
setTimeout(function(){ $('#echarts').attr({
"src": myChart.getDataURL(),
}); }, 100);
}