简体   繁体   中英

How to get newline after the title in echarts line chart?

I would like to add new line after the title, can anyone help me how to i do that? Here i'm setting options like,

option ={
title: 'test content regarding the line chart'
}

Due to title is long, it is coming on top of legends tried like,

option ={
title: 'test content regarding the line chart \n'
}

won't workout...

Thanks,

You did it right. Just use the '\\n' to add another line and you can use the eChart editor online to test it. Pay attention on the subtext position when you change the title inserting or removing the new line at the end of the title.

https://ecomfe.github.io/echarts-examples/public/editor.html

You can use this example:

option = {
title: {
    text: ' Inserting a break on title \n and another break here \n',
    subtext: 'We also have the subtext'
},
tooltip: {
    trigger: 'axis',
    axisPointer: {
        type: 'shadow'
    }
},
legend: {
    data: ['Production']
},
grid: {
    containLabel: true
},
xAxis: {
    type: 'value',
    data: ['abc','xyz'],
    boundaryGap: [0, 0.01]
},
yAxis: {
    type: 'category',
    data: ['Month 1','Month 2']
},
series: {
        name: 'Production',
        type: 'bar',
        data: [70,80],
        isBiggerOrEqual: true
    }};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM