forked from antvis/G2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalphabet-interval-brush-tooltip.ts
48 lines (46 loc) · 1.04 KB
/
alphabet-interval-brush-tooltip.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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,
}),
);
},
},
];
};