echarts中,如果同时设置了主标题和副标题,副标题默认显示在主标题下方。若想要主标题和副标题在同一行,可以将title设置为数组,即:将主标题伪装成副标题。
option = {
title: [{
text: "Main Title",
left:0,
textStyle: {
fontSize: 30,
},
},{
text: "Sub Title",
left:200,
textStyle: {
fontSize: 20
}
}], //!!!
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [120, 200, 150, 80, 70, 110, 130],
type: 'bar'
}]
};
效果: