echart的x换行
option = { legend: { y: 'bottom', data:['该业务正常类比例','该业务关注类比例','该业务不良类比例'] }, xAxis: { type: 'category', data: ['xx', 'xx', 'xxxxx', 'xxxxxx', 'xxxxxx', 'xxxxxxxxx'], //替换
//换行部分。。。。。 axisLabel:{ interval:0, formatter:function(value){ var ret = ''; var maxLength = 4; var rowNum = Math.ceil(value.length/maxLength); if(rowNum > 1) { for(var i = 0; i < rowNum; i++) { var temp =""; var start = i * maxLength; var end = start + maxLength; temp = value.substring(start,end) + "\n"; ret += temp; } return ret; }else { return value; } } } }, yAxis: [ { name: '关注及损失', type: 'value', interval:1, position:'left' }, { name: '正常', type:'value', interval:20, position:'right' }, ], series: [ { name:'该业务正常类比例', data: [2, 3, 3, 1, 2, 4], //替换 type: 'bar' }, { name:'该业务关注类比例', data: [1, 2, 3, 4, 5, 6], //替换 type: 'bar' }, { name:'该业务不良类比例', data: [99, 97, 97, 97, 97, 97],//替换 yAxisIndex:1, type: 'line' } ] };
图: