-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
plugin-timebar-modify.ts
68 lines (64 loc) · 1.61 KB
/
plugin-timebar-modify.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
import { Graph } from '@/src';
export const pluginTimeBarModifyBuildIn: TestCase = async (context) => {
const startTime = new Date('2023-08-01').getTime();
const diff = 3600 * 24 * 1000;
const timebarData = [10, 2, 3, 4, 15, 10, 5, 0, 3, 1].map((value, index) => ({
time: new Date(startTime + index * diff),
value,
label: new Date(startTime + index * diff).toLocaleString(),
}));
const graphData = {
nodes: new Array(49).fill(0).map((_, index) => ({
id: `node-${index}`,
data: {
timestamp: startTime + (index % 10) * diff,
value: index % 20,
label: new Date(startTime + (index % 10) * diff).toLocaleString(),
parentId: index < 2 ? `combo-${index}` : null,
},
})),
edges: new Array(49).fill(0).map((_, i) => ({
id: `edge-${i}`,
source: `node-${i % 30}`,
target: `node-${(i % 20) + 29}`,
data: {
edgeType: 'e1',
},
})),
combo: [
{
id: 'combo-0',
data: {
timestamp: startTime + diff,
value: 1,
label: new Date(startTime + diff).toLocaleString(),
},
},
{
id: 'combo-1',
data: {
timestamp: startTime + 3 * diff,
value: 3,
label: new Date(startTime + 3 * diff).toLocaleString(),
},
},
],
};
const graph = new Graph({
...context,
data: graphData,
layout: {
type: 'grid',
},
plugins: [
{
type: 'timebar',
key: 'timebar',
data: timebarData,
mode: 'modify',
},
],
});
await graph.render();
return graph;
};