yAxis坐標(biāo)軸指示器線條的樣式設(shè)置

2018-09-12 10:32 更新

本節(jié)將使用 lineStyle 來設(shè)置 ECharts 中 y 軸坐標(biāo)軸指示器線條的樣式,但要記住,只有當(dāng) axisPointer.type 為 'line' 時 lineStyle 才是有效的。坐標(biāo)軸指示器的線條樣式的具體設(shè)置如下所示:

yAxis.axisPointer.lineStyle   |   Object

設(shè)置 yAxis 坐標(biāo)軸指示器線條的樣式。

注意:只當(dāng) axisPointer.type 為 'line' 時有效。

yAxis.axisPointer.lineStyle.color   |   Color

[ default: #555 ]

設(shè)置 yAxis 坐標(biāo)軸指示器線條的顏色。

顏色可以使用 RGB 表示,比如 'rgb(128, 128, 128)',如果想要加上 alpha 通道表示不透明度,可以使用 RGBA,比如 'rgba(128, 128, 128, 0.5)',也可以使用十六進(jìn)制格式,比如 '#ccc'。除了純色之外顏色也支持漸變色和紋理填充
// 線性漸變,前四個參數(shù)分別是 x0, y0, x2, y2, 范圍從 0 - 1,相當(dāng)于在圖形包圍盒中的百分比,如果 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'
}

yAxis.axisPointer.lineStyle.width   |   number

[ default: 1 ]

設(shè)置 yAxis 坐標(biāo)軸指示器線條的寬度。

yAxis.axisPointer.lineStyle.type   |   string

[ default: solid ]

設(shè)置 yAxis 坐標(biāo)軸指示器線條的類型。

可選:

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

yAxis.axisPointer.lineStyle.shadowBlur   |   number

設(shè)置 yAxis 坐標(biāo)軸指示器線條圖形陰影的模糊大小。

該屬性配合 shadowColor,shadowOffsetX, shadowOffsetY 一起設(shè)置圖形的陰影效果。

示例:

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

yAxis.axisPointer.lineStyle.shadowColor   |   Color

設(shè)置 yAxis 坐標(biāo)軸指示器線條陰影顏色。支持的格式同color。

yAxis.axisPointer.lineStyle.shadowOffsetX   |   number

[ default: 0 ]

設(shè)置 yAxis 坐標(biāo)軸指示器線條陰影在水平方向上的偏移距離。

yAxis.axisPointer.lineStyle.shadowOffsetY   |   number

[ default: 0 ]

設(shè)置 yAxis 坐標(biāo)軸指示器線條陰影在垂直方向上的偏移距離。

yAxis.axisPointer.lineStyle.opacity   |   number

設(shè)置 yAxis 坐標(biāo)軸指示器線條圖形的透明度。

支持從 0 到 1 的數(shù)字,為 0 時不繪制該圖形。
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號