forked from antvis/G2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmock-pie-interaction.ts
40 lines (37 loc) · 1.03 KB
/
mock-pie-interaction.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
import { deepMix } from '@antv/util';
import { G2Spec } from '../../../src';
import { LEGEND_ITEMS_CLASS_NAME } from '../../../src/interaction/legendFilter';
import { step } from './utils';
function Pie(options, context) {
const { encode = {}, ...rest } = options;
const { value, ...restEncode } = encode;
return deepMix(rest, {
type: 'interval',
transform: [{ type: 'stackY' }],
coordinate: { type: 'theta' },
encode: {
...restEncode,
y: value,
},
});
}
export function mockPieInteraction(): G2Spec {
return {
type: Pie,
data: [
{ genre: 'Sports', sold: 275 },
{ genre: 'Strategy', sold: 115 },
{ genre: 'Action', sold: 120 },
{ genre: 'Shooter', sold: 350 },
{ genre: 'Other', sold: 150 },
],
// @ts-ignore
encode: { value: 'sold', color: 'genre' },
animate: false,
};
}
mockPieInteraction.steps = ({ canvas }) => {
const { document } = canvas;
const [e] = document.getElementsByClassName(LEGEND_ITEMS_CLASS_NAME);
return [step(e, 'click')];
};