新聞中心
grid.tooltip.axisPointer | Object

坐標(biāo)軸指示器配置項(xiàng)。
tooltip.axisPointer 是配置坐標(biāo)軸指示器的快捷方式。實(shí)際上坐標(biāo)軸指示器的全部功能,都可以通過軸上的 axisPointer 配置項(xiàng)完成(例如 xAxis.axisPointer 或 angleAxis.axisPointer)。但是使用 tooltip.axisPinter 在簡單場景下會更方便一些。
注意: tooltip.axisPointer 中諸配置項(xiàng)的優(yōu)先級低于軸上的 axisPointer 的配置項(xiàng)。
坐標(biāo)軸指示器是指示坐標(biāo)軸當(dāng)前刻度的工具。
如下例,鼠標(biāo)懸浮到圖上,可以出現(xiàn)標(biāo)線和刻度文本。
點(diǎn)擊編輯實(shí)例 》》
上例中,使用了 axisPointer.link 來關(guān)聯(lián)不同的坐標(biāo)系中的 axisPointer。
坐標(biāo)軸指示器也有適合觸屏的交互方式,如下:
點(diǎn)擊編輯實(shí)例 》》
坐標(biāo)軸指示器在多軸的場景能起到輔助作用:
點(diǎn)擊編輯實(shí)例 》》
點(diǎn)擊編輯實(shí)例 》》
注意: 一般來說,axisPointer 的具體配置項(xiàng)會配置在各個(gè)軸中(如 xAxis.axisPointer)或者 tooltip 中(如 tooltip.axisPointer)。但是這幾個(gè)選項(xiàng)只能配置在全局的 axisPointer 中:axisPointer.triggerOn、axisPointer.link。
如何顯示 axisPointer:
直角坐標(biāo)系 grid、極坐標(biāo)系 polar、單軸坐標(biāo)系 single 中的每個(gè)軸都自己的 axisPointer。
他們的 axisPointer 默認(rèn)不顯示。有兩種方法可以讓他們顯示:
- 設(shè)置軸上的 axisPointer.show(例如 xAxis.axisPointer.show)為 true,則顯示此軸的 axisPointer。
- 設(shè)置 tooltip.trigger 設(shè)置為 'axis' 或者 tooltip.axisPointer.type 設(shè)置為 'cross',則此時(shí)坐標(biāo)系會自動(dòng)選擇顯示哪個(gè)軸的 axisPointer,也可以使用 tooltip.axisPointer.axis 改變這種選擇。注意,軸上如果設(shè)置了 axisPointer,會覆蓋此設(shè)置。
如何顯示 axisPointer 的 label:
axisPointer 的 label 默認(rèn)不顯示(也就是默認(rèn)只顯示指示線),除非:
- 設(shè)置軸上的 axisPointer.label.show(例如 xAxis.axisPointer.label.show)為 true,則顯示此軸的 axisPointer 的 label。
- 設(shè)置 tooltip.axisPointer.type 為 'cross' 時(shí)會自動(dòng)顯示 axisPointer 的 label。
關(guān)于觸屏的 axisPointer 的設(shè)置
設(shè)置軸上的 axisPointer.handle.show(例如 xAxis.axisPointer.handle.show 為 true 則會顯示出此 axisPointer 的拖拽按鈕。(polar 坐標(biāo)系暫不支持此功能)。
注意: 如果發(fā)現(xiàn)此時(shí) tooltip 效果不良好,可設(shè)置 tooltip.triggerOn 為 'none'(于是效果為:手指按住按鈕則顯示 tooltip,松開按鈕則隱藏 tooltip),或者 tooltip.alwaysShowContent 為 true(效果為 tooltip 一直顯示)。
參見例子。
自動(dòng)吸附到數(shù)據(jù)(snap)
對于數(shù)值軸、時(shí)間軸,如果開啟了 snap,則 axisPointer 會自動(dòng)吸附到最近的點(diǎn)上。
本文標(biāo)題:創(chuàng)新互聯(lián)ECharts教程:EChartsgrid組件配置坐標(biāo)軸指示器
文章起源:http://www.dlmjj.cn/article/djcjcpi.html


咨詢
建站咨詢
