forked from antvis/G2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmock-line-flex.ts
72 lines (70 loc) · 1.61 KB
/
mock-line-flex.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { CustomEvent } from '@antv/g';
import { G2Spec, PLOT_CLASS_NAME } from '../../../src';
export function mockLineFlex(): G2Spec {
return {
type: 'spaceFlex',
width: 928,
height: 320,
paddingLeft: 90,
paddingBottom: 60,
children: [
{
type: 'view',
data: [
{ x: 1, y: 2 },
{ x: 2, y: 6 },
{ x: 3, y: 4 },
{ x: 4, y: 9 },
],
axis: {
x: { title: 'X', line: true, lineLineWidth: 1, grid: false },
y: {
title: 'Y',
line: true,
lineLineWidth: 1,
grid: true,
gridLineWidth: 2,
},
},
children: [{ type: 'line', encode: { x: 'x', y: 'y' } }],
},
{
type: 'view',
data: [
{ x: 1, y: 3 },
{ x: 2, y: 6 },
{ x: 3, y: 7 },
{ x: 4, y: 9 },
],
axis: {
x: { title: 'X', line: true, lineLineWidth: 1, grid: false },
y: {
title: 'Y',
line: true,
lineLineWidth: 1,
grid: true,
gridLineWidth: 2,
},
},
children: [{ type: 'line', encode: { x: 'x', y: 'y' } }],
},
],
};
}
mockLineFlex.steps = ({ canvas }) => {
const { document } = canvas;
const plot = document.getElementsByClassName(PLOT_CLASS_NAME)[1];
return [
{
changeState: async () => {
plot.dispatchEvent(
// @ts-ignore
new CustomEvent('pointermove', {
offsetX: 600,
offsetY: 50,
}),
);
},
},
];
};