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'。除了純色之外顏色也支持漸變色和紋理填充
// 線性漸變,前四個參數(shù)分別是 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
 }
 // 徑向漸變,前三個參數(shù)分別是圓心 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 的數(shù)字,為 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'。除了純色之外顏色也支持漸變色和紋理填充
// 線性漸變,前四個參數(shù)分別是 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
 }
 // 徑向漸變,前三個參數(shù)分別是圓心 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 的數(shù)字,為 0 時不繪制該圖形。

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號