forked from antvis/G2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalphabet-interval-select.ts
46 lines (44 loc) · 1010 Bytes
/
alphabet-interval-select.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
import {
G2Spec,
ELEMENT_CLASS_NAME,
MAIN_LAYER_CLASS_NAME,
} from '../../../src';
import { step } from './utils';
export function alphabetIntervalSelect(): G2Spec {
return {
type: 'interval',
padding: 0,
data: {
type: 'fetch',
value: 'data/alphabet.csv',
},
axis: false,
legend: false,
encode: {
x: 'letter',
y: 'frequency',
color: 'steelblue',
},
state: {
selected: { fill: 'red' },
unselected: { opacity: 0.6 },
},
interaction: {
elementSelect: true,
},
};
}
alphabetIntervalSelect.steps = ({ canvas }) => {
const { document } = canvas;
const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME);
const [mainLayer] = document.getElementsByClassName(MAIN_LAYER_CLASS_NAME);
const [e, e1] = elements;
return [
step(e, 'click'),
step(e1, 'click'),
step(e1, 'click'),
step(e, 'click'),
step(e, 'click'),
step(mainLayer, 'click'), // Reset the canvas.
];
};