-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstateages-interval-highlight-link-transpose.ts
56 lines (53 loc) · 1.32 KB
/
stateages-interval-highlight-link-transpose.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
49
50
51
52
53
54
55
56
import { G2Spec, ELEMENT_CLASS_NAME } from '../../../src';
import { step, disableDelay } from './utils';
export function stateAgesIntervalHighlightLinkTranspose(): G2Spec {
return {
type: 'interval',
height: 600,
transform: [
{ type: 'stackY' },
{ type: 'sortX', by: 'y', reverse: true, slice: 5 },
],
coordinate: { transform: [{ type: 'transpose' }] },
data: {
type: 'fetch',
value: 'data/stateages.csv',
format: 'csv',
},
legend: false,
encode: {
x: 'state',
y: 'population',
color: 'age',
},
axis: {
y: { labelFormatter: '~s' },
},
scale: {
x: { paddingInner: 0.2 },
},
state: {
active: {
linkFill: (d) => (d.state === 'CA' ? 'red' : undefined),
stroke: '#000',
strokeWidth: 1,
linkFillOpacity: 0.5,
},
inactive: {
opacity: 0.6,
},
},
interaction: {
elementHighlightByColor: {
link: true,
},
},
};
}
stateAgesIntervalHighlightLinkTranspose.preprocess = disableDelay;
stateAgesIntervalHighlightLinkTranspose.steps = ({ canvas }) => {
const { document } = canvas;
const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME);
const [e1] = elements;
return [step(e1, 'pointerover'), step(e1, 'pointerout')];
};