Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Echarts - Can't able align the title to center

Tags:

echarts

I am trying the center the title of the echarts component by setting

title:{
    text: "My Title",
    textStyle:{
        align: "center"
    }
}

But it is not working.

I have referred the official document(https://echarts.apache.org/option.html#title.textStyle.align) on this.

JSFiddle link : http://jsfiddle.net/jeffersonswartz/y8zs5coq/5/

Thanks.

like image 565
Jefferson Swartz Avatar asked Dec 03 '22 10:12

Jefferson Swartz


2 Answers

That should be title.left = 'center' instead of title.textStyle.align. Help you updated at http://jsfiddle.net/ovilia/06u9xpj4/ .

title.textStyle.align is used to align the text within the position. For example, if you set title.textStyle.width and title.textStyle.align, they can work together.

like image 188
Ovilia Avatar answered Dec 22 '22 23:12

Ovilia


This also works great:

title : {
        text:"foo",
        subtext:"bar",
        x:'center'
}
like image 20
Mike D3ViD Tyson Avatar answered Dec 23 '22 00:12

Mike D3ViD Tyson