echarts图例与与title重合问题,如何让图例换行
//让legend换行,不与title重合
var tit = ['','','',''];
var title = tit.concat(json.title);
//console.log(title);
option = {
title: {
text: '车系保值率排行榜', //title居中显示
x:'center'
},
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
legend: {
data:title // ['','','','宝马','奔驰','奥迪','劳斯莱斯','宾利','别克','兰博基尼','本田','丰田'],
},
grid: {
left: '3%', //图表距离左右上下之间的距离
right: '4%',
top: '15%',
bottom: '13%',
containLabel: true
},
第一步:定义一个数组,里面包含几个空字符串,格式如:var tit = ['','','',''];
第二步:将第一步的数组与后台给的图例数组,使用concat方法,合并两个数组,是数组格式为 var title = ['','','','','宝马','奔驰','奥迪']; 这样就可以实现title与图例换行显示。