Skip to content

Commit

Permalink
fix(tooltip): hide tooltip when move mask (#4860)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored and hustcc committed May 16, 2023
1 parent 9fb0b08 commit d855f8e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null
48 changes: 48 additions & 0 deletions __tests__/plots/tooltip/alphabet-interval-brush-tooltip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { CustomEvent } from '@antv/g';
import { G2Spec, PLOT_CLASS_NAME } from '../../../src';
import { brush } from '../interaction/penguins-point-brush';

export function alphabetIntervalBrushTooltip(): G2Spec {
return {
type: 'interval',
transform: [{ type: 'sortX', by: 'y', reverse: true }],
data: {
type: 'fetch',
value: 'data/alphabet.csv',
},
encode: {
x: 'letter',
y: 'frequency',
color: 'steelblue',
},
state: {
active: { fill: 'red' },
},
interaction: {
brushHighlight: true,
},
};
}

alphabetIntervalBrushTooltip.steps = ({ canvas }) => {
const { document } = canvas;
const plot = document.getElementsByClassName(PLOT_CLASS_NAME)[0];
return [
{
skip: true,
changeState: () => {
brush(plot, 400, 300, 600, 400);
},
},
{
changeState: () => {
plot.dispatchEvent(
new CustomEvent('pointerover', {
offsetX: 500,
offsetY: 360,
}),
);
},
},
];
};
1 change: 1 addition & 0 deletions __tests__/plots/tooltip/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ export { profitIntervalLegendFilterOrdinal } from './profit-interval-legend-filt
export { aaplLineSliderFilter } from './appl-line-slider-filter';
export { aaplLineAreaBasicSample } from './aapl-line-area-basic-sample';
export { aaplAreaMissingDataTranspose } from './aapl-area-missing-data-transpose';
export { alphabetIntervalBrushTooltip } from './alphabet-interval-brush-tooltip';
5 changes: 4 additions & 1 deletion src/interaction/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,10 @@ export function tooltip(
const pointerover = throttle(
(event) => {
const { target: element } = event;
if (!elementSet.has(element)) return;
if (!elementSet.has(element)) {
hideTooltip(root, single);
return;
}
const k = groupKey(element);
const group = keyGroup.get(k);
const data =
Expand Down

0 comments on commit d855f8e

Please sign in to comment.