ECharts grid组件配置 坐标轴指示器线条样式设置

2018-04-23 17:02 更新

对 ECharts 中的坐标轴指示器的线条进行设置的时候,会有两种情况:

  • axisPointer.type 为 'line' 时;
  • axisPointer.type 为 'cross' 时;

grid.tooltip.axisPointer.lineStyle   |   Object


axisPointer.type 为 'line' 时有效。

grid.tooltip.axisPointer.lineStyle.color   |   Color

[ default: #555 ]

线的颜色。

颜色可以使用 RGB 表示,比如 'rgb(128, 128, 128)',如果想要加上 alpha 通道表示不透明度,可以使用 RGBA,比如 'rgba(128, 128, 128, 0.5)',也可以使用十六进制格式,比如 '#ccc'。除了纯色之外颜色也支持渐变色和纹理填充
// 线性渐变,前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1,相当于在图形包围盒中的百分比,如果 globalCoord 为 `true`,则该四个值是绝对的像素位置
 color: {
     type: 'linear',
     x: 0,
     y: 0,
     x2: 0,
     y2: 1,
     colorStops: [{
         offset: 0, color: 'red' // 0% 处的颜色
     }, {
         offset: 1, color: 'blue' // 100% 处的颜色
     }],
     globalCoord:    false // 缺省为 false
 }
 // 径向渐变,前三个参数分别是圆心 x, y 和半径,取值同线性渐变
 color: {
     type: 'radial',
     x: 0.5,
     y: 0.5,
     r: 0.5,
     colorStops: [{
         offset: 0, color: 'red' // 0% 处的颜色
     }, {
         offset: 1, color: 'blue' // 100% 处的颜色
     }],
     globalCoord: false // 缺省为 false }
 // 纹理填充
 color:
    { image: imageDom, // 支持为 HTMLImageElement, HTMLCanvasElement,不支持路径字符串
    repeat: 'repeat' // 是否平铺, 可以是 'repeat-x', 'repeat-y', 'no-repeat'
 }

grid.tooltip.axisPointer.lineStyle.width   |   number

[ default: 1 ]

线宽。


grid.tooltip.axisPointer.lineStyle.type   |   string

[ default: solid ]

线的类型。

可选:

  • 'solid'
  • 'dashed'
  • 'dotted'

grid.tooltip.axisPointer.lineStyle.shadowBlur   |   number

图形阴影的模糊大小。该属性配合 shadowColor,shadowOffsetX, shadowOffsetY 一起设置图形的阴影效果。

示例:

{
    shadowColor: 'rgba(0, 0, 0, 0.5)',
    shadowBlur: 10
}

grid.tooltip.axisPointer.lineStyle.shadowColor   |   Color

阴影颜色。支持的格式同color。


grid.tooltip.axisPointer.lineStyle.shadowOffsetX   |   number

[ default: 0 ]

阴影水平方向上的偏移距离。


grid.tooltip.axisPointer.lineStyle.shadowOffsetY   |   number

[ default: 0 ]

阴影垂直方向上的偏移距离。


grid.tooltip.axisPointer.lineStyle.opacity   |   number

图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。

grid.tooltip.axisPointer.crossStyle   |   Object


axisPointer.type 为 'cross' 时有效。

grid.tooltip.axisPointer.crossStyle.color   |   Color

[ default: #555 ]

线的颜色。

颜色可以使用 RGB 表示,比如 'rgb(128, 128, 128)',如果想要加上 alpha 通道表示不透明度,可以使用 RGBA,比如 'rgba(128, 128, 128, 0.5)',也可以使用十六进制格式,比如 '#ccc'。除了纯色之外颜色也支持渐变色和纹理填充
// 线性渐变,前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1,相当于在图形包围盒中的百分比,如果 globalCoord 为 `true`,则该四个值是绝对的像素位置
 color: {
    type: 'linear',
    x: 0,
    y: 0,
    x2: 0,
    y2: 1,
    colorStops: [{
        offset: 0, color: 'red' // 0% 处的颜色
    }, {
        offset: 1, color: 'blue' // 100% 处的颜色
    }],
    globalCoord:    false // 缺省为 false
 }
 // 径向渐变,前三个参数分别是圆心 x, y 和半径,取值同线性渐变
 color: {
    type: 'radial',
    x: 0.5,
    y: 0.5,
    r: 0.5,
    colorStops: [{
        offset: 0, color: 'red' // 0% 处的颜色
    }, {
        offset: 1, color: 'blue' // 100% 处的颜色
    }],
    globalCoord: false // 缺省为 false
 }
 // 纹理填充
 color: {
    image: imageDom, // 支持为 HTMLImageElement, HTMLCanvasElement,不支持路径字符串
    repeat: 'repeat' // 是否平铺, 可以是 'repeat-x', 'repeat-y', 'no-repeat'
 }

grid.tooltip.axisPointer.crossStyle.width   |   number

[ default: 1 ]

线宽。


grid.tooltip.axisPointer.crossStyle.type   |   string

[ default: dashed ]

线的类型。

可选:

  • 'solid'
  • 'dashed'
  • 'dotted'

grid.tooltip.axisPointer.crossStyle.shadowBlur   |   number

图形阴影的模糊大小。该属性配合 shadowColor,shadowOffsetX, shadowOffsetY 一起设置图形的阴影效果。

示例:

{
    shadowColor: 'rgba(0, 0, 0, 0.5)',
    shadowBlur: 10
}

grid.tooltip.axisPointer.crossStyle.shadowColor   |   Color

阴影颜色。支持的格式同color。


grid.tooltip.axisPointer.crossStyle.shadowOffsetX   |   number

[ default: 0 ]

阴影水平方向上的偏移距离。


grid.tooltip.axisPointer.crossStyle.shadowOffsetY   |   number

[ default: 0 ]

阴影垂直方向上的偏移距离。


grid.tooltip.axisPointer.crossStyle.opacity   |   number

图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号