-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathsequence-scatter-transformer.ts
94 lines (84 loc) · 2.06 KB
/
sequence-scatter-transformer.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { Datum } from '@visactor/vchart/src/typings';
import type { ISequenceScatterSpec } from './interface';
import { CommonChartSpecTransformer } from '@visactor/vchart';
import { processSequenceData } from '../../utils/processSequenceData';
import { DATA_KEY } from './constant';
export class SequenceScatterChartSpecTransformer extends CommonChartSpecTransformer<any> {
transformSpec(spec: any): void {
super.transformSpec(spec);
const dataSpecs = processSequenceData(spec as unknown as ISequenceScatterSpec);
spec.type = 'common';
spec.dataKey = DATA_KEY;
spec.data = dataSpecs[0].data;
spec.width = 300;
spec.height = 300;
spec.autoFit = false;
spec.series = [
{
type: 'scatter',
xField: spec.xField,
yField: spec.yField
}
];
if (spec.player) {
spec.player = {
...spec.player,
specs: dataSpecs
};
spec.animationAppear = {
duration: spec.player?.duration ?? 2000,
easing: 'linear'
};
spec.animationUpdate = {
duration: spec.player?.duration ?? 2000,
easing: 'linear'
};
}
spec.axes = [
{
orient: 'left',
type: 'linear'
},
{
orient: 'bottom',
label: { visible: true },
type: 'linear'
}
];
spec.customMark = [
// 背景图像
{
type: 'image',
dataIndex: 2,
style: {
x: 0,
y: 0,
width: 300,
height: 300,
image: (datum: Datum) => datum.imageData,
zIndex: -1
}
},
{
type: 'text',
dataIndex: 1,
style: {
text: (datum: Datum) => datum['inter'],
x: 50,
y: () => 10,
textBaseline: 'top',
textAlign: 'left',
fontSize: 100,
fontWeight: 'bolder',
fill: 'black',
fillOpacity: 0.2,
...spec.infoLabel?.style
}
}
];
spec.tooltip = {
visible: false
};
super.transformSpec(spec);
}
}