From 8e6cddf71f21d450557eece79622f23f4dd1a488 Mon Sep 17 00:00:00 2001 From: simaQ Date: Wed, 1 Apr 2020 14:26:50 +0800 Subject: [PATCH] =?UTF-8?q?feat(interaction):=20tooltip=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=A7=BB=E5=8A=A8=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chart/chart.ts | 2 +- src/index.ts | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/chart/chart.ts b/src/chart/chart.ts index 097486adf1..44c537845a 100644 --- a/src/chart/chart.ts +++ b/src/chart/chart.ts @@ -40,7 +40,7 @@ export default class Chart extends View { pixelRatio, localRefresh = true, visible = true, - defaultInteractions = ['tooltip', 'legend-filter', 'legend-active','continuous-filter'], + defaultInteractions = [ 'tooltip', 'legend-filter', 'legend-active', 'continuous-filter' ], options, limitInPlot, theme, diff --git a/src/index.ts b/src/index.ts index dd11679fe7..db3b547181 100644 --- a/src/index.ts +++ b/src/index.ts @@ -266,8 +266,14 @@ function isPointInView(context: IInteractionContext) { // 注册 tooltip 的 interaction registerInteraction('tooltip', { - start: [{ trigger: 'plot:mousemove', action: 'tooltip:show', throttle: { wait: 50, leading: true, trailing: false } }], - end: [{ trigger: 'plot:mouseleave', action: 'tooltip:hide' }], + start: [ + { trigger: 'plot:mousemove', action: 'tooltip:show', throttle: { wait: 50, leading: true, trailing: false } }, + { trigger: 'plot:touchmove', action: 'tooltip:show', throttle: { wait: 50, leading: true, trailing: false } }, + ], + end: [ + { trigger: 'plot:mouseleave', action: 'tooltip:hide' }, + { trigger: 'plot:touchend', action: 'tooltip:hide' } + ], }); // 移动到 elment 上 active @@ -488,8 +494,7 @@ registerInteraction('legend-filter', { { trigger: 'legend-item:mouseleave', action: 'cursor:default' }, ], start: [ - { trigger: 'legend-item:click', action: 'list-unchecked:toggle' }, - { trigger: 'legend-item:click', action: 'data-filter:filter' }, + { trigger: 'legend-item:click', action: [ 'list-unchecked:toggle', 'data-filter:filter' ] }, ], }); @@ -509,8 +514,7 @@ registerInteraction('legend-visible-filter', { { trigger: 'legend-item:mouseleave', action: 'cursor:default' }, ], start: [ - { trigger: 'legend-item:click', action: 'list-unchecked:toggle' }, - { trigger: 'legend-item:click', action: 'element-filter:filter' }, + { trigger: 'legend-item:click', action: ['list-unchecked:toggle', 'element-filter:filter'] }, ], });