阅读(4324) (0)

yAxis坐标轴指示器文本标签的样式设置

2017-09-12 09:44:16 更新

在 ECharts 中使用 textStyle 来对 yAxis 的坐标轴指示器的文本标签进行文字样式的设置。我们利用它可以设置标签文字的颜色、文字字体风格、字体系列以及文字阴影等等。详细的设置如下文内容所示:

yAxis.axisPointer.label.textStyle   |   boolean

对 yAxis 坐标轴指示器文本标签的样式进行设置

yAxis.axisPointer.label.textStyle.color   |   Color

[ default: '#fff' ]

设置 yAxis 坐标轴指示器文本标签文字的颜色。

yAxis.axisPointer.label.textStyle.fontStyle   |   string

[ default: 'normal' ]

设置 yAxis 坐标轴指示器文本标签文字字体的风格

可选:

  • 'normal'
  • 'italic'
  • 'oblique'

yAxis.axisPointer.label.textStyle.fontWeight   |   string

[ default: normal ]

设置 yAxis 坐标轴指示器文本标签文字字体的粗细

可选:

  • 'normal'
  • 'bold'
  • 'bolder'
  • 'lighter'
  • 100 | 200 | 300 | 400...

yAxis.axisPointer.label.textStyle.fontFamily   |   string

[ default: 'sans-serif' ]

设置 yAxis 坐标轴指示器文本标签文字的字体系列

还可以是 'serif' , 'monospace', 'Arial', 'Courier New', 'Microsoft YaHei', ...

yAxis.axisPointer.label.textStyle.fontSize   |   number

[ default: 12 ]

设置 yAxis 坐标轴指示器文本标签文字的字体大小

yAxis.axisPointer.label.textStyle.lineHeight   |   number

设置 yAxis 坐标轴指示器文本标签的行高。

rich 中如果没有设置 lineHeight,则会取父层级的 lineHeight。例如:

{
    lineHeight: 56,
    rich: {
        a: {
            // 没有设置 `lineHeight`,则 `lineHeight` 为 56
        }
    }
}

yAxis.axisPointer.label.textStyle.width   |   number, string

设置 yAxis 坐标轴指示器文本标签文字块的宽度。

一般不用指定,不指定则自动是文字的宽度。在想做表格项或者使用图片(参见 backgroundColor)时,可能会使用它。

注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。

width 也可以是百分比字符串,如 '100%'。表示的是所在文本块的 contentWidth(即不包含文本块的 padding)的百分之多少。之所以以 contentWidth 做基数,因为每个文本片段只能基于 content box 布局。如果以 outerWidth 做基数,则百分比的计算在实用中不具有意义,可能会超出。

注意,如果不定义 rich 属性,则不能指定 width 和 height。

yAxis.axisPointer.label.textStyle.height   |   number, string

设置 yAxis 坐标轴指示器文本标签文字块的高度。

一般不用指定,不指定则自动是文字的高度。在使用图片(参见 backgroundColor)时,可能会使用它。

注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
注意,如果不定义 rich 属性,则不能指定 width 和 height。

yAxis.axisPointer.label.textStyle.textBorderColor   |   string

[ default: 'transparent' ]

设置 yAxis 坐标轴指示器文本标签文字本身的描边颜色。

yAxis.axisPointer.label.textStyle.textBorderWidth   |   number

[ default: 0 ]

设置 yAxis 坐标轴指示器文本标签文字本身的描边宽度。

yAxis.axisPointer.label.textStyle.textShadowColor   |   string

[ default: 'transparent' ]

设置 yAxis 坐标轴指示器文本标签文字本身的阴影颜色。

yAxis.axisPointer.label.textStyle.textShadowBlur   |   number

[ default: 0 ]

设置 yAxis 坐标轴指示器文本标签文字本身的阴影长度。

yAxis.axisPointer.label.textStyle.textShadowOffsetX   |   number

[ default: 0 ]

设置 yAxis 坐标轴指示器文本标签文字本身的阴影 X 偏移。

yAxis.axisPointer.label.textStyle.textShadowOffsetY   |   number

[ default: 0 ]

设置 yAxis 坐标轴指示器文本标签文字本身的阴影 Y 偏移。