5

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.

Jefferson Swartz
  • 306
  • 3
  • 10

3 Answers3

16

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.

Ovilia
  • 7,066
  • 12
  • 47
  • 70
8

This also works great:

title : {
        text:"foo",
        subtext:"bar",
        x:'center'
}
Mike D3ViD Tyson
  • 1,701
  • 1
  • 21
  • 31
4

You have to set title.left property to center:

  title: {
    text: 'My Title',
    left: 'center',
  },

JSFiddle link: http://jsfiddle.net/xguL0vrk/

Also tested with ECharts 5.0.1

Paul E. Stanciu
  • 133
  • 2
  • 6