-
Notifications
You must be signed in to change notification settings - Fork 1
/
1d-data.js
41 lines (36 loc) · 1.13 KB
/
1d-data.js
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
class Data1D {
apply(globalCtx) {
const name = 'Data1D';
globalCtx.globalData.hooks.initData.tap(name, (dataOptions, source, sourceMeta) => {
this.init(globalCtx, dataOptions, source, sourceMeta);
});
globalCtx.globalData.hooks.resetData.tap(name, (dataOptions, source) => {
this.resetData(dataOptions, source);
});
}
init(globalCtx, dataOptions, source, sourceMeta) {
Object.assign(source, {
data: [],
legend: [],
});
Object.assign(sourceMeta, {
formatter: null,
});
this.resetData(dataOptions, source, sourceMeta);
}
resetData(dataOptions, source, sourceMeta) {
const s = dataOptions.series;
Object.assign(source, {
originSeries: dataOptions.series,
legend: s.map(seri => ({
name: seri.name,
disabled: false,
})),
data: s.map(seri => seri.value),
});
Object.assign(sourceMeta, {
formatter: dataOptions.format || (d => d),
});
}
}
export default Data1D;