@visactor/vseed 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1351 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +1134 -0
- package/dist/index.js.map +1 -0
- package/package.json +1 -1
- package/dist/.rsdoctor/chunkGraph/0 +0 -1
- package/dist/.rsdoctor/configs/0 +0 -1
- package/dist/.rsdoctor/envinfo/0 +0 -1
- package/dist/.rsdoctor/errors/0 +0 -1
- package/dist/.rsdoctor/loader/0 +0 -1
- package/dist/.rsdoctor/manifest.json +0 -52
- package/dist/.rsdoctor/moduleCodeMap/0 +0 -1
- package/dist/.rsdoctor/moduleGraph/0 +0 -1
- package/dist/.rsdoctor/otherReports/0 +0 -1
- package/dist/.rsdoctor/packageGraph/0 +0 -1
- package/dist/.rsdoctor/plugin/0 +0 -1
- package/dist/.rsdoctor/resolver/0 +0 -1
- package/dist/.rsdoctor/summary/0 +0 -1
- package/dist/index.html +0 -1
- package/dist/static/js/271.b02e15b2.js +0 -16
- package/dist/static/js/index.7ac2af0b.js +0 -1
package/dist/index.cjs
ADDED
@@ -0,0 +1,1351 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __webpack_require__ = {};
|
3
|
+
(()=>{
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
6
|
+
enumerable: true,
|
7
|
+
get: definition[key]
|
8
|
+
});
|
9
|
+
};
|
10
|
+
})();
|
11
|
+
(()=>{
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
13
|
+
})();
|
14
|
+
(()=>{
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
17
|
+
value: 'Module'
|
18
|
+
});
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
20
|
+
value: true
|
21
|
+
});
|
22
|
+
};
|
23
|
+
})();
|
24
|
+
var __webpack_exports__ = {};
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
27
|
+
columnPercentSpecPipeline: ()=>columnPercentSpecPipeline,
|
28
|
+
isVChart: ()=>isVChart,
|
29
|
+
registerAll: ()=>all_registerAll,
|
30
|
+
execPipeline: ()=>execPipeline,
|
31
|
+
areaSpecPipeline: ()=>areaSpecPipeline,
|
32
|
+
registerCustomTheme: ()=>registerCustomTheme,
|
33
|
+
registerLine: ()=>registerLine,
|
34
|
+
zColor: ()=>zColor,
|
35
|
+
zMeasureGroup: ()=>zMeasureGroup,
|
36
|
+
zUnfoldInfo: ()=>zUnfoldInfo,
|
37
|
+
zMeasures: ()=>zMeasures,
|
38
|
+
darkTheme: ()=>darkTheme,
|
39
|
+
columnPercentAdvancedPipeline: ()=>columnPercentAdvancedPipeline,
|
40
|
+
isVTable: ()=>isVTable,
|
41
|
+
columnSpecPipeline: ()=>columnSpecPipeline,
|
42
|
+
zFoldInfo: ()=>zFoldInfo,
|
43
|
+
zDatasetReshapeInfo: ()=>zDatasetReshapeInfo,
|
44
|
+
columnParallelSpecPipeline: ()=>columnParallelSpecPipeline,
|
45
|
+
columnAdvancedPipeline: ()=>columnAdvancedPipeline,
|
46
|
+
zLabel: ()=>zLabel,
|
47
|
+
registerColumn: ()=>registerColumn,
|
48
|
+
zDimension: ()=>zDimension,
|
49
|
+
lightTheme: ()=>lightTheme,
|
50
|
+
registerColumnParallel: ()=>registerColumnParallel,
|
51
|
+
zCustomTheme: ()=>zCustomTheme,
|
52
|
+
dataReshapeFor1D1M: ()=>dataReshapeFor1D1M,
|
53
|
+
registerArea: ()=>registerArea,
|
54
|
+
zDataset: ()=>zDataset,
|
55
|
+
barPercentAdvancedPipeline: ()=>barPercentAdvancedPipeline,
|
56
|
+
areaPercentAdvancedPipeline: ()=>areaPercentAdvancedPipeline,
|
57
|
+
zBackgroundColor: ()=>zBackgroundColor,
|
58
|
+
registerBarParallel: ()=>registerBarParallel,
|
59
|
+
zMeasure: ()=>zMeasure,
|
60
|
+
zDimensions: ()=>zDimensions,
|
61
|
+
zLegend: ()=>zLegend,
|
62
|
+
zTheme: ()=>zTheme,
|
63
|
+
zEncoding: ()=>zEncoding,
|
64
|
+
registerAreaPercent: ()=>registerAreaPercent,
|
65
|
+
zDatum: ()=>zDatum,
|
66
|
+
barAdvancedPipeline: ()=>barAdvancedPipeline,
|
67
|
+
zCustomThemeConfig: ()=>zCustomThemeConfig,
|
68
|
+
columnParallelAdvancedPipeline: ()=>columnParallelAdvancedPipeline,
|
69
|
+
registerColumnPercent: ()=>registerColumnPercent,
|
70
|
+
registerBarPercent: ()=>registerBarPercent,
|
71
|
+
foldMeasures: ()=>foldMeasures,
|
72
|
+
dataReshapeFor2D1M: ()=>dataReshapeFor2D1M,
|
73
|
+
registerLightTheme: ()=>registerLightTheme,
|
74
|
+
registerDarkTheme: ()=>registerDarkTheme,
|
75
|
+
zChartType: ()=>zChartType,
|
76
|
+
barParallelAdvancedPipeline: ()=>barParallelAdvancedPipeline,
|
77
|
+
barPercentSpecPipeline: ()=>barPercentSpecPipeline,
|
78
|
+
lineAdvancedPipeline: ()=>lineAdvancedPipeline,
|
79
|
+
zTooltip: ()=>zTooltip,
|
80
|
+
barSpecPipeline: ()=>barSpecPipeline,
|
81
|
+
lineSpecPipeline: ()=>lineSpecPipeline,
|
82
|
+
zBaseConfig: ()=>zBaseConfig,
|
83
|
+
unfoldDimensions: ()=>unfoldDimensions,
|
84
|
+
areaAdvancedPipeline: ()=>areaAdvancedPipeline,
|
85
|
+
areaPercentSpecPipeline: ()=>areaPercentSpecPipeline,
|
86
|
+
Builder: ()=>Builder,
|
87
|
+
barParallelSpecPipeline: ()=>barParallelSpecPipeline,
|
88
|
+
registerBar: ()=>registerBar
|
89
|
+
});
|
90
|
+
const FoldMeasureName = '__MeaName__';
|
91
|
+
const FoldMeasureValue = '__MeaValue__';
|
92
|
+
const FoldMeasureId = '__MeaId__';
|
93
|
+
const FoldDimensionGroup = '__DimGroup__';
|
94
|
+
const Separator = '-';
|
95
|
+
const foldMeasures = (dataset, measures, measureId = FoldMeasureId, measureName = FoldMeasureName, measureValue = FoldMeasureValue)=>{
|
96
|
+
const foldInfo = {
|
97
|
+
measureId,
|
98
|
+
measureName,
|
99
|
+
measureValue,
|
100
|
+
foldMap: {}
|
101
|
+
};
|
102
|
+
const result = new Array(dataset.length * measures.length);
|
103
|
+
let index = 0;
|
104
|
+
for(let i = 0; i < dataset.length; i++)for(let j = 0; j < measures.length; j++){
|
105
|
+
const datum = {
|
106
|
+
...dataset[i]
|
107
|
+
};
|
108
|
+
const measure = measures[j];
|
109
|
+
const { id, alias } = measure;
|
110
|
+
datum[measureId] = id;
|
111
|
+
datum[measureName] = alias;
|
112
|
+
datum[measureValue] = dataset[i][id];
|
113
|
+
foldInfo.foldMap[id] = alias;
|
114
|
+
result[index++] = datum;
|
115
|
+
}
|
116
|
+
return {
|
117
|
+
dataset: result,
|
118
|
+
foldInfo
|
119
|
+
};
|
120
|
+
};
|
121
|
+
const unfoldDimensions = (dataset, dimensions, measures, unfoldStartIndex = 0, foldGroupName = FoldDimensionGroup, dimensionsSeparator = Separator)=>{
|
122
|
+
if (unfoldStartIndex < 0 || unfoldStartIndex >= dimensions.length) throw new Error('unfoldStartIndex is out of range');
|
123
|
+
const dimensionsToBeUnfolded = dimensions.slice(unfoldStartIndex);
|
124
|
+
const unfoldInfo = {
|
125
|
+
groupName: foldGroupName,
|
126
|
+
colorItems: []
|
127
|
+
};
|
128
|
+
if (0 === dimensions.length || 0 === measures.length) return {
|
129
|
+
dataset,
|
130
|
+
unfoldInfo: {
|
131
|
+
groupName: foldGroupName,
|
132
|
+
colorItems: []
|
133
|
+
}
|
134
|
+
};
|
135
|
+
const colorItems = [];
|
136
|
+
for(let i = 0; i < dataset.length; i++){
|
137
|
+
const datum = dataset[i];
|
138
|
+
const colorItem = generateDimGroupName(dimensionsToBeUnfolded, datum, dimensionsSeparator);
|
139
|
+
datum[foldGroupName] = colorItem;
|
140
|
+
colorItems.push(colorItem);
|
141
|
+
}
|
142
|
+
unfoldInfo.colorItems = colorItems;
|
143
|
+
return {
|
144
|
+
dataset,
|
145
|
+
unfoldInfo
|
146
|
+
};
|
147
|
+
};
|
148
|
+
const generateDimGroupName = (dimensionsToBeGrouped, datum, dimensionsSeparator)=>dimensionsToBeGrouped.map((dim)=>String(datum[dim.id])).join(dimensionsSeparator);
|
149
|
+
const emptyReshapeResult = {
|
150
|
+
dataset: [],
|
151
|
+
foldInfo: {
|
152
|
+
foldMap: {},
|
153
|
+
measureId: '',
|
154
|
+
measureName: '',
|
155
|
+
measureValue: ''
|
156
|
+
},
|
157
|
+
unfoldInfo: {
|
158
|
+
colorItems: [],
|
159
|
+
groupName: ''
|
160
|
+
}
|
161
|
+
};
|
162
|
+
const dataReshapeFor2D1M = (dataset, dimensions, measures)=>{
|
163
|
+
if (0 === dimensions.length && 0 === measures.length) return emptyReshapeResult;
|
164
|
+
const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, FoldMeasureId, FoldMeasureName, FoldMeasureValue);
|
165
|
+
if (0 === dimensions.length) {
|
166
|
+
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
167
|
+
{
|
168
|
+
id: FoldMeasureId,
|
169
|
+
alias: "\u6307\u6807Id",
|
170
|
+
location: 'dimension'
|
171
|
+
},
|
172
|
+
{
|
173
|
+
id: FoldMeasureName,
|
174
|
+
alias: "\u6307\u6807\u540D\u79F0",
|
175
|
+
location: 'dimension'
|
176
|
+
}
|
177
|
+
], [
|
178
|
+
{
|
179
|
+
id: FoldMeasureValue,
|
180
|
+
alias: "\u6307\u6807\u503C"
|
181
|
+
}
|
182
|
+
], 1, FoldDimensionGroup);
|
183
|
+
return {
|
184
|
+
dataset: finalDataset,
|
185
|
+
foldInfo,
|
186
|
+
unfoldInfo
|
187
|
+
};
|
188
|
+
}
|
189
|
+
{
|
190
|
+
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
191
|
+
...dimensions,
|
192
|
+
{
|
193
|
+
id: FoldMeasureName,
|
194
|
+
alias: "\u6307\u6807\u540D\u79F0",
|
195
|
+
location: 'dimension'
|
196
|
+
}
|
197
|
+
], [
|
198
|
+
{
|
199
|
+
id: FoldMeasureValue,
|
200
|
+
alias: "\u6307\u6807\u503C"
|
201
|
+
}
|
202
|
+
], 1, FoldDimensionGroup);
|
203
|
+
return {
|
204
|
+
dataset: finalDataset,
|
205
|
+
foldInfo,
|
206
|
+
unfoldInfo
|
207
|
+
};
|
208
|
+
}
|
209
|
+
};
|
210
|
+
const reshapeTo2D1M = (advancedVSeed, context)=>{
|
211
|
+
const result = {
|
212
|
+
...advancedVSeed
|
213
|
+
};
|
214
|
+
const { vseed } = context;
|
215
|
+
const { dataset } = vseed;
|
216
|
+
const { dimensions, measures } = advancedVSeed;
|
217
|
+
if (!measures || !dimensions || !dataset) return result;
|
218
|
+
if (0 === measures.length) throw new Error('measures can not be empty');
|
219
|
+
const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeFor2D1M(dataset, dimensions, measures);
|
220
|
+
return {
|
221
|
+
...result,
|
222
|
+
dataset: newDatasets,
|
223
|
+
datasetReshapeInfo: {
|
224
|
+
foldInfo,
|
225
|
+
unfoldInfo
|
226
|
+
},
|
227
|
+
dimensions,
|
228
|
+
measures
|
229
|
+
};
|
230
|
+
};
|
231
|
+
const encodingXY = (advancedVSeed)=>{
|
232
|
+
const result = {
|
233
|
+
...advancedVSeed
|
234
|
+
};
|
235
|
+
const { datasetReshapeInfo, dimensions } = advancedVSeed;
|
236
|
+
if (!datasetReshapeInfo || !dimensions) return result;
|
237
|
+
const { foldInfo, unfoldInfo } = datasetReshapeInfo;
|
238
|
+
const isSingleDimension = 0 === dimensions.length;
|
239
|
+
const x = [
|
240
|
+
isSingleDimension ? foldInfo.measureName : dimensions[0].id
|
241
|
+
];
|
242
|
+
const y = [
|
243
|
+
foldInfo.measureValue
|
244
|
+
];
|
245
|
+
const group = [
|
246
|
+
isSingleDimension ? foldInfo.measureName : unfoldInfo.groupName
|
247
|
+
];
|
248
|
+
const color = [
|
249
|
+
foldInfo.measureName
|
250
|
+
];
|
251
|
+
const encoding = [
|
252
|
+
{
|
253
|
+
x,
|
254
|
+
y,
|
255
|
+
group,
|
256
|
+
color
|
257
|
+
}
|
258
|
+
];
|
259
|
+
return {
|
260
|
+
...result,
|
261
|
+
encoding
|
262
|
+
};
|
263
|
+
};
|
264
|
+
const encodingYX = (advancedVSeed)=>{
|
265
|
+
const result = {
|
266
|
+
...advancedVSeed
|
267
|
+
};
|
268
|
+
const { datasetReshapeInfo, dimensions } = advancedVSeed;
|
269
|
+
if (!datasetReshapeInfo || !dimensions) return result;
|
270
|
+
const { foldInfo, unfoldInfo } = datasetReshapeInfo;
|
271
|
+
const isSingleDimension = 0 === dimensions.length;
|
272
|
+
const y = [
|
273
|
+
isSingleDimension ? foldInfo.measureName : dimensions[0].id
|
274
|
+
];
|
275
|
+
const x = [
|
276
|
+
foldInfo.measureValue
|
277
|
+
];
|
278
|
+
const group = [
|
279
|
+
isSingleDimension ? foldInfo.measureName : unfoldInfo.groupName
|
280
|
+
];
|
281
|
+
const color = [
|
282
|
+
foldInfo.measureName
|
283
|
+
];
|
284
|
+
const encoding = [
|
285
|
+
{
|
286
|
+
x,
|
287
|
+
y,
|
288
|
+
group,
|
289
|
+
color
|
290
|
+
}
|
291
|
+
];
|
292
|
+
return {
|
293
|
+
...result,
|
294
|
+
encoding
|
295
|
+
};
|
296
|
+
};
|
297
|
+
const initAdvancedVSeed = (advancedVSeed, context)=>{
|
298
|
+
const { vseed } = context;
|
299
|
+
const { chartType = 'table' } = vseed;
|
300
|
+
return {
|
301
|
+
...advancedVSeed,
|
302
|
+
chartType
|
303
|
+
};
|
304
|
+
};
|
305
|
+
const autoMeasures = (advancedVSeed, context)=>{
|
306
|
+
const result = {
|
307
|
+
...advancedVSeed
|
308
|
+
};
|
309
|
+
const { vseed } = context;
|
310
|
+
const { measures, dataset } = vseed;
|
311
|
+
if (!dataset) throw new Error('dataset is required');
|
312
|
+
if (0 === dataset.length) return result;
|
313
|
+
if (measures) {
|
314
|
+
result.measures = measures;
|
315
|
+
return result;
|
316
|
+
}
|
317
|
+
const top100dataset = dataset.slice(0, 100);
|
318
|
+
const sample = top100dataset.reduce((prev, cur)=>({
|
319
|
+
...prev,
|
320
|
+
...cur
|
321
|
+
}), {});
|
322
|
+
result.measures = Object.keys(sample).filter((key)=>top100dataset.some((item)=>'number' == typeof item[key]) && ![
|
323
|
+
'',
|
324
|
+
null,
|
325
|
+
void 0
|
326
|
+
].includes(key)).map((measure)=>({
|
327
|
+
id: measure,
|
328
|
+
alias: measure
|
329
|
+
}));
|
330
|
+
return result;
|
331
|
+
};
|
332
|
+
const autoDimensions = (advancedVSeed, context)=>{
|
333
|
+
const result = {
|
334
|
+
...advancedVSeed
|
335
|
+
};
|
336
|
+
const { vseed } = context;
|
337
|
+
const { dimensions, dataset } = vseed;
|
338
|
+
const { measures = [] } = advancedVSeed;
|
339
|
+
if (!dataset) throw new Error('dataset is required');
|
340
|
+
if (0 === dataset.length) return result;
|
341
|
+
if (dimensions) {
|
342
|
+
result.dimensions = dimensions;
|
343
|
+
return result;
|
344
|
+
}
|
345
|
+
const top100dataset = dataset.slice(0, 100);
|
346
|
+
const sample = top100dataset.reduce((prev, cur)=>({
|
347
|
+
...prev,
|
348
|
+
...cur
|
349
|
+
}), {});
|
350
|
+
result.dimensions = Object.keys(sample).filter((key)=>top100dataset.some((item)=>'string' == typeof item[key]) && ![
|
351
|
+
'',
|
352
|
+
null,
|
353
|
+
void 0
|
354
|
+
].includes(key) && !measures.some((measure)=>measure.id === key)).map((dim)=>({
|
355
|
+
id: dim,
|
356
|
+
alias: dim,
|
357
|
+
location: 'dimension'
|
358
|
+
}));
|
359
|
+
return result;
|
360
|
+
};
|
361
|
+
const external_remeda_namespaceObject = require("remeda");
|
362
|
+
const vchartBaseConfig = (advancedVSeed, context)=>{
|
363
|
+
const { vseed } = context;
|
364
|
+
const result = {
|
365
|
+
...advancedVSeed
|
366
|
+
};
|
367
|
+
const config = (0, external_remeda_namespaceObject.pick)(vseed, [
|
368
|
+
'backgroundColor',
|
369
|
+
'color',
|
370
|
+
'label',
|
371
|
+
'legend',
|
372
|
+
'tooltip'
|
373
|
+
]);
|
374
|
+
result.baseConfig = {
|
375
|
+
vchart: {
|
376
|
+
...config
|
377
|
+
}
|
378
|
+
};
|
379
|
+
return result;
|
380
|
+
};
|
381
|
+
const vchartTheme = (advancedVSeed, context)=>{
|
382
|
+
const { customTheme, vseed } = context;
|
383
|
+
const { theme = 'light' } = vseed;
|
384
|
+
const result = {
|
385
|
+
...advancedVSeed
|
386
|
+
};
|
387
|
+
if (!customTheme || !customTheme[theme]) return result;
|
388
|
+
const config = result.baseConfig?.vchart;
|
389
|
+
const themeConfig = customTheme?.[theme].baseConfig?.vchart;
|
390
|
+
if (!themeConfig || !config) return result;
|
391
|
+
const mergedConfig = (0, external_remeda_namespaceObject.mergeDeep)(themeConfig, (0, external_remeda_namespaceObject.clone)(config));
|
392
|
+
result.baseConfig = {
|
393
|
+
vchart: mergedConfig
|
394
|
+
};
|
395
|
+
return result;
|
396
|
+
};
|
397
|
+
const lineAdvancedPipeline = [
|
398
|
+
initAdvancedVSeed,
|
399
|
+
autoMeasures,
|
400
|
+
autoDimensions,
|
401
|
+
reshapeTo2D1M,
|
402
|
+
encodingXY,
|
403
|
+
vchartBaseConfig,
|
404
|
+
vchartTheme
|
405
|
+
];
|
406
|
+
const barAdvancedPipeline = [
|
407
|
+
initAdvancedVSeed,
|
408
|
+
autoMeasures,
|
409
|
+
autoDimensions,
|
410
|
+
reshapeTo2D1M,
|
411
|
+
encodingYX,
|
412
|
+
vchartBaseConfig,
|
413
|
+
vchartTheme
|
414
|
+
];
|
415
|
+
const barParallelAdvancedPipeline = [
|
416
|
+
initAdvancedVSeed,
|
417
|
+
autoMeasures,
|
418
|
+
autoDimensions,
|
419
|
+
reshapeTo2D1M,
|
420
|
+
encodingYX,
|
421
|
+
vchartBaseConfig,
|
422
|
+
vchartTheme
|
423
|
+
];
|
424
|
+
const barPercentAdvancedPipeline = [
|
425
|
+
initAdvancedVSeed,
|
426
|
+
autoMeasures,
|
427
|
+
autoDimensions,
|
428
|
+
reshapeTo2D1M,
|
429
|
+
encodingYX,
|
430
|
+
vchartBaseConfig,
|
431
|
+
vchartTheme
|
432
|
+
];
|
433
|
+
const columnAdvancedPipeline = [
|
434
|
+
initAdvancedVSeed,
|
435
|
+
autoMeasures,
|
436
|
+
autoDimensions,
|
437
|
+
reshapeTo2D1M,
|
438
|
+
encodingXY,
|
439
|
+
vchartBaseConfig,
|
440
|
+
vchartTheme
|
441
|
+
];
|
442
|
+
const columnParallelAdvancedPipeline = [
|
443
|
+
initAdvancedVSeed,
|
444
|
+
autoMeasures,
|
445
|
+
autoDimensions,
|
446
|
+
reshapeTo2D1M,
|
447
|
+
encodingXY,
|
448
|
+
vchartBaseConfig,
|
449
|
+
vchartTheme
|
450
|
+
];
|
451
|
+
const columnPercentAdvancedPipeline = [
|
452
|
+
initAdvancedVSeed,
|
453
|
+
autoMeasures,
|
454
|
+
autoDimensions,
|
455
|
+
reshapeTo2D1M,
|
456
|
+
encodingXY,
|
457
|
+
vchartBaseConfig,
|
458
|
+
vchartTheme
|
459
|
+
];
|
460
|
+
const areaAdvancedPipeline = [
|
461
|
+
initAdvancedVSeed,
|
462
|
+
autoMeasures,
|
463
|
+
autoDimensions,
|
464
|
+
reshapeTo2D1M,
|
465
|
+
encodingXY,
|
466
|
+
vchartBaseConfig,
|
467
|
+
vchartTheme
|
468
|
+
];
|
469
|
+
const areaPercentAdvancedPipeline = [
|
470
|
+
initAdvancedVSeed,
|
471
|
+
autoMeasures,
|
472
|
+
autoDimensions,
|
473
|
+
reshapeTo2D1M,
|
474
|
+
encodingXY,
|
475
|
+
vchartBaseConfig,
|
476
|
+
vchartTheme
|
477
|
+
];
|
478
|
+
const initLine = (spec, context)=>{
|
479
|
+
const result = {
|
480
|
+
...spec
|
481
|
+
};
|
482
|
+
const { advancedVSeed } = context;
|
483
|
+
const { encoding } = advancedVSeed;
|
484
|
+
if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
|
485
|
+
result.type = 'line';
|
486
|
+
result.direction = 'vertical';
|
487
|
+
result.xField = encoding[0].x[0];
|
488
|
+
result.yField = encoding[0].y[0];
|
489
|
+
result.seriesField = encoding[0].group[0];
|
490
|
+
result.padding = 0;
|
491
|
+
return result;
|
492
|
+
};
|
493
|
+
const color_color = (spec, context)=>{
|
494
|
+
const result = {
|
495
|
+
...spec
|
496
|
+
};
|
497
|
+
const { advancedVSeed } = context;
|
498
|
+
const { datasetReshapeInfo } = advancedVSeed;
|
499
|
+
const { unfoldInfo } = datasetReshapeInfo;
|
500
|
+
const baseConfig = advancedVSeed.baseConfig.vchart;
|
501
|
+
if (!baseConfig || !baseConfig.color) return result;
|
502
|
+
const { color } = baseConfig;
|
503
|
+
const { colorScheme, colorMapping } = color;
|
504
|
+
result.color = {
|
505
|
+
type: 'ordinal',
|
506
|
+
domain: unfoldInfo.colorItems,
|
507
|
+
range: colorScheme,
|
508
|
+
specified: colorMapping
|
509
|
+
};
|
510
|
+
return result;
|
511
|
+
};
|
512
|
+
const background_backgroundColor = (spec, context)=>{
|
513
|
+
const result = {
|
514
|
+
...spec
|
515
|
+
};
|
516
|
+
const { advancedVSeed } = context;
|
517
|
+
const { baseConfig } = advancedVSeed;
|
518
|
+
if (!baseConfig?.vchart) return result;
|
519
|
+
const { backgroundColor } = baseConfig.vchart;
|
520
|
+
return {
|
521
|
+
...result,
|
522
|
+
background: backgroundColor
|
523
|
+
};
|
524
|
+
};
|
525
|
+
const dataset_dataset = (spec, context)=>{
|
526
|
+
const { advancedVSeed } = context;
|
527
|
+
return {
|
528
|
+
...spec,
|
529
|
+
data: {
|
530
|
+
values: advancedVSeed.dataset
|
531
|
+
}
|
532
|
+
};
|
533
|
+
};
|
534
|
+
const xBand = (spec)=>{
|
535
|
+
const result = {
|
536
|
+
...spec
|
537
|
+
};
|
538
|
+
if (!result.axes) result.axes = [];
|
539
|
+
result.axes = [
|
540
|
+
...result.axes,
|
541
|
+
{
|
542
|
+
visible: true,
|
543
|
+
type: 'band',
|
544
|
+
orient: 'bottom'
|
545
|
+
}
|
546
|
+
];
|
547
|
+
return result;
|
548
|
+
};
|
549
|
+
const yLinear = (spec)=>{
|
550
|
+
const result = {
|
551
|
+
...spec
|
552
|
+
};
|
553
|
+
if (!result.axes) result.axes = [];
|
554
|
+
result.axes = [
|
555
|
+
...result.axes,
|
556
|
+
{
|
557
|
+
visible: true,
|
558
|
+
type: 'linear',
|
559
|
+
orient: 'left'
|
560
|
+
}
|
561
|
+
];
|
562
|
+
return result;
|
563
|
+
};
|
564
|
+
const label_label = (spec, context)=>{
|
565
|
+
const result = {
|
566
|
+
...spec
|
567
|
+
};
|
568
|
+
const { advancedVSeed } = context;
|
569
|
+
const baseConfig = advancedVSeed.baseConfig.vchart;
|
570
|
+
if (!baseConfig || !baseConfig.label) return result;
|
571
|
+
const { label } = baseConfig;
|
572
|
+
const { enable } = label;
|
573
|
+
result.label = {
|
574
|
+
visible: enable
|
575
|
+
};
|
576
|
+
return result;
|
577
|
+
};
|
578
|
+
const defaultTooltip = {
|
579
|
+
enable: true
|
580
|
+
};
|
581
|
+
const tooltip_tooltip = (spec, context)=>{
|
582
|
+
const result = {
|
583
|
+
...spec
|
584
|
+
};
|
585
|
+
const { advancedVSeed } = context;
|
586
|
+
const baseConfig = advancedVSeed.baseConfig.vchart;
|
587
|
+
const { tooltip = defaultTooltip } = baseConfig;
|
588
|
+
const { enable } = tooltip;
|
589
|
+
result.tooltip = {
|
590
|
+
visible: enable
|
591
|
+
};
|
592
|
+
return result;
|
593
|
+
};
|
594
|
+
const defaultLegend = {
|
595
|
+
enable: true
|
596
|
+
};
|
597
|
+
const legend_legend = (spec, context)=>{
|
598
|
+
const result = {
|
599
|
+
...spec
|
600
|
+
};
|
601
|
+
const { advancedVSeed } = context;
|
602
|
+
const baseConfig = advancedVSeed.baseConfig.vchart;
|
603
|
+
if (!baseConfig || !baseConfig.legend) return result;
|
604
|
+
const { legend = defaultLegend } = baseConfig;
|
605
|
+
const { enable } = legend;
|
606
|
+
result.legends = {
|
607
|
+
visible: enable
|
608
|
+
};
|
609
|
+
return result;
|
610
|
+
};
|
611
|
+
const lineSpecPipeline = [
|
612
|
+
initLine,
|
613
|
+
color_color,
|
614
|
+
background_backgroundColor,
|
615
|
+
dataset_dataset,
|
616
|
+
xBand,
|
617
|
+
yLinear,
|
618
|
+
label_label,
|
619
|
+
tooltip_tooltip,
|
620
|
+
legend_legend
|
621
|
+
];
|
622
|
+
const initColumn = (spec, context)=>{
|
623
|
+
const result = {
|
624
|
+
...spec
|
625
|
+
};
|
626
|
+
const { advancedVSeed } = context;
|
627
|
+
const { encoding } = advancedVSeed;
|
628
|
+
if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
|
629
|
+
result.type = 'bar';
|
630
|
+
result.direction = 'vertical';
|
631
|
+
result.xField = encoding[0].x[0];
|
632
|
+
result.yField = encoding[0].y[0];
|
633
|
+
result.seriesField = encoding[0].group[0];
|
634
|
+
result.padding = 0;
|
635
|
+
return result;
|
636
|
+
};
|
637
|
+
const columnSpecPipeline = [
|
638
|
+
initColumn,
|
639
|
+
color_color,
|
640
|
+
background_backgroundColor,
|
641
|
+
dataset_dataset,
|
642
|
+
xBand,
|
643
|
+
yLinear,
|
644
|
+
label_label,
|
645
|
+
tooltip_tooltip,
|
646
|
+
legend_legend
|
647
|
+
];
|
648
|
+
const initColumnParallel = (spec, context)=>{
|
649
|
+
const result = {
|
650
|
+
...spec
|
651
|
+
};
|
652
|
+
const { advancedVSeed } = context;
|
653
|
+
const { encoding, datasetReshapeInfo } = advancedVSeed;
|
654
|
+
const { unfoldInfo } = datasetReshapeInfo;
|
655
|
+
if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
|
656
|
+
result.type = 'bar';
|
657
|
+
result.direction = 'vertical';
|
658
|
+
result.xField = [
|
659
|
+
encoding[0].x[0],
|
660
|
+
unfoldInfo.groupName
|
661
|
+
];
|
662
|
+
result.yField = encoding[0].y[0];
|
663
|
+
result.seriesField = encoding[0].group[0];
|
664
|
+
result.padding = 0;
|
665
|
+
return result;
|
666
|
+
};
|
667
|
+
const columnParallelSpecPipeline = [
|
668
|
+
initColumnParallel,
|
669
|
+
color_color,
|
670
|
+
background_backgroundColor,
|
671
|
+
dataset_dataset,
|
672
|
+
xBand,
|
673
|
+
yLinear,
|
674
|
+
label_label,
|
675
|
+
tooltip_tooltip,
|
676
|
+
legend_legend
|
677
|
+
];
|
678
|
+
const percent = (spec, context)=>{
|
679
|
+
const result = {
|
680
|
+
...spec
|
681
|
+
};
|
682
|
+
result.percent = true;
|
683
|
+
return result;
|
684
|
+
};
|
685
|
+
const columnPercentSpecPipeline = [
|
686
|
+
initColumn,
|
687
|
+
color_color,
|
688
|
+
background_backgroundColor,
|
689
|
+
percent,
|
690
|
+
dataset_dataset,
|
691
|
+
xBand,
|
692
|
+
yLinear,
|
693
|
+
label_label,
|
694
|
+
tooltip_tooltip,
|
695
|
+
legend_legend
|
696
|
+
];
|
697
|
+
const initBar = (spec, context)=>{
|
698
|
+
const result = {
|
699
|
+
...spec
|
700
|
+
};
|
701
|
+
const { advancedVSeed } = context;
|
702
|
+
const { encoding } = advancedVSeed;
|
703
|
+
if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
|
704
|
+
result.type = 'bar';
|
705
|
+
result.direction = 'horizontal';
|
706
|
+
result.yField = encoding[0].y?.[0];
|
707
|
+
result.xField = encoding[0].x?.[0];
|
708
|
+
result.seriesField = encoding[0].group?.[0];
|
709
|
+
result.padding = 0;
|
710
|
+
return result;
|
711
|
+
};
|
712
|
+
const xLinear = (spec)=>{
|
713
|
+
const result = {
|
714
|
+
...spec
|
715
|
+
};
|
716
|
+
if (!result.axes) result.axes = [];
|
717
|
+
result.axes = [
|
718
|
+
...result.axes,
|
719
|
+
{
|
720
|
+
visible: true,
|
721
|
+
type: 'linear',
|
722
|
+
orient: 'bottom'
|
723
|
+
}
|
724
|
+
];
|
725
|
+
return result;
|
726
|
+
};
|
727
|
+
const yBand = (spec)=>{
|
728
|
+
const result = {
|
729
|
+
...spec
|
730
|
+
};
|
731
|
+
if (!result.axes) result.axes = [];
|
732
|
+
result.axes = [
|
733
|
+
...result.axes,
|
734
|
+
{
|
735
|
+
visible: true,
|
736
|
+
type: 'band',
|
737
|
+
orient: 'left'
|
738
|
+
}
|
739
|
+
];
|
740
|
+
return result;
|
741
|
+
};
|
742
|
+
const barSpecPipeline = [
|
743
|
+
initBar,
|
744
|
+
color_color,
|
745
|
+
background_backgroundColor,
|
746
|
+
dataset_dataset,
|
747
|
+
xLinear,
|
748
|
+
yBand,
|
749
|
+
label_label,
|
750
|
+
tooltip_tooltip,
|
751
|
+
legend_legend
|
752
|
+
];
|
753
|
+
const initBarParallel = (spec, context)=>{
|
754
|
+
const result = {
|
755
|
+
...spec
|
756
|
+
};
|
757
|
+
const { advancedVSeed } = context;
|
758
|
+
const { encoding, datasetReshapeInfo } = advancedVSeed;
|
759
|
+
const { unfoldInfo } = datasetReshapeInfo;
|
760
|
+
if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
|
761
|
+
result.type = 'bar';
|
762
|
+
result.direction = 'horizontal';
|
763
|
+
result.yField = [
|
764
|
+
encoding[0].y[0],
|
765
|
+
unfoldInfo.groupName
|
766
|
+
];
|
767
|
+
result.xField = encoding[0].x[0];
|
768
|
+
result.seriesField = encoding[0].group[0];
|
769
|
+
result.padding = 0;
|
770
|
+
return result;
|
771
|
+
};
|
772
|
+
const barParallelSpecPipeline = [
|
773
|
+
initBarParallel,
|
774
|
+
color_color,
|
775
|
+
background_backgroundColor,
|
776
|
+
dataset_dataset,
|
777
|
+
xLinear,
|
778
|
+
yBand,
|
779
|
+
label_label,
|
780
|
+
tooltip_tooltip,
|
781
|
+
legend_legend
|
782
|
+
];
|
783
|
+
const barPercentSpecPipeline = [
|
784
|
+
initBar,
|
785
|
+
color_color,
|
786
|
+
background_backgroundColor,
|
787
|
+
percent,
|
788
|
+
dataset_dataset,
|
789
|
+
xLinear,
|
790
|
+
yBand,
|
791
|
+
label_label,
|
792
|
+
tooltip_tooltip,
|
793
|
+
legend_legend
|
794
|
+
];
|
795
|
+
const initArea = (spec, context)=>{
|
796
|
+
const result = {
|
797
|
+
...spec
|
798
|
+
};
|
799
|
+
const { advancedVSeed } = context;
|
800
|
+
const { encoding } = advancedVSeed;
|
801
|
+
if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
|
802
|
+
result.type = 'area';
|
803
|
+
result.direction = 'vertical';
|
804
|
+
result.xField = encoding[0].x[0];
|
805
|
+
result.yField = encoding[0].y[0];
|
806
|
+
result.seriesField = encoding[0].group[0];
|
807
|
+
result.padding = 0;
|
808
|
+
return result;
|
809
|
+
};
|
810
|
+
const stack = (spec, context)=>{
|
811
|
+
const result = {
|
812
|
+
...spec
|
813
|
+
};
|
814
|
+
result.stack = true;
|
815
|
+
return result;
|
816
|
+
};
|
817
|
+
const areaSpecPipeline = [
|
818
|
+
initArea,
|
819
|
+
color_color,
|
820
|
+
background_backgroundColor,
|
821
|
+
stack,
|
822
|
+
dataset_dataset,
|
823
|
+
xBand,
|
824
|
+
yLinear,
|
825
|
+
label_label,
|
826
|
+
tooltip_tooltip,
|
827
|
+
legend_legend
|
828
|
+
];
|
829
|
+
const areaPercentSpecPipeline = [
|
830
|
+
initArea,
|
831
|
+
color_color,
|
832
|
+
background_backgroundColor,
|
833
|
+
percent,
|
834
|
+
dataset_dataset,
|
835
|
+
xBand,
|
836
|
+
yLinear,
|
837
|
+
label_label,
|
838
|
+
tooltip_tooltip,
|
839
|
+
legend_legend
|
840
|
+
];
|
841
|
+
const execPipeline = (pipeline, context, initialValue = {})=>{
|
842
|
+
const result = pipeline.reduce((prev, cur)=>cur(prev, context), initialValue);
|
843
|
+
return result;
|
844
|
+
};
|
845
|
+
const isVTable = (chartType)=>[
|
846
|
+
'table',
|
847
|
+
'pivotTable'
|
848
|
+
].includes(chartType);
|
849
|
+
const isVChart = (chartType)=>!isVTable(chartType);
|
850
|
+
const buildAdvanced = (builder)=>{
|
851
|
+
const { chartType } = builder.vseed;
|
852
|
+
if (!chartType) throw new Error('chartType is nil in buildAdvanced');
|
853
|
+
const pipeline = builder.getAdvancedPipeline(chartType);
|
854
|
+
if (!pipeline) throw new Error(`no advanced pipeline for chartType ${chartType}`);
|
855
|
+
const context = {
|
856
|
+
vseed: builder.vseed,
|
857
|
+
customTheme: builder.getThemeMap()
|
858
|
+
};
|
859
|
+
try {
|
860
|
+
return execPipeline(pipeline, context);
|
861
|
+
} catch (e) {
|
862
|
+
console.error(e);
|
863
|
+
throw new Error("buildAdvanced error, see error info in console");
|
864
|
+
}
|
865
|
+
};
|
866
|
+
const buildSpec = (builder, advancedVSeed)=>{
|
867
|
+
const { chartType } = builder.vseed;
|
868
|
+
if (!chartType) throw new Error('chartType is nil in buildSpec');
|
869
|
+
const pipeline = builder.getSpecPipeline(chartType);
|
870
|
+
if (!pipeline) throw new Error(`no spec pipeline for chartType ${chartType}`);
|
871
|
+
const context = {
|
872
|
+
vseed: builder.vseed,
|
873
|
+
advancedVSeed
|
874
|
+
};
|
875
|
+
try {
|
876
|
+
return execPipeline(pipeline, context);
|
877
|
+
} catch (e) {
|
878
|
+
console.error(e);
|
879
|
+
throw new Error("buildSpec error, see error info in console");
|
880
|
+
}
|
881
|
+
};
|
882
|
+
const build = (builder)=>{
|
883
|
+
console.log('debug vseed', builder.vseed);
|
884
|
+
const advancedVSeed = builder.buildAdvanced();
|
885
|
+
console.log('debug advancedVSeed', advancedVSeed);
|
886
|
+
if (!advancedVSeed) throw new Error('advancedVSeed is null');
|
887
|
+
const spec = builder.buildSpec(advancedVSeed);
|
888
|
+
console.log('debug spec', spec);
|
889
|
+
return spec;
|
890
|
+
};
|
891
|
+
class Builder {
|
892
|
+
_vseed;
|
893
|
+
_advancedVSeed = null;
|
894
|
+
constructor(vseed){
|
895
|
+
this._vseed = vseed;
|
896
|
+
}
|
897
|
+
build = ()=>build(this);
|
898
|
+
buildSpec = (advanced)=>buildSpec(this, advanced);
|
899
|
+
buildAdvanced = ()=>buildAdvanced(this);
|
900
|
+
getAdvancedPipeline = (chartType)=>Builder._advancedPipelineMap[chartType];
|
901
|
+
getSpecPipeline = (chartType)=>Builder._specPipelineMap[chartType];
|
902
|
+
getTheme = (themeKey)=>Builder._themeMap[themeKey];
|
903
|
+
getThemeMap = ()=>Builder._themeMap;
|
904
|
+
get vseed() {
|
905
|
+
return this._vseed;
|
906
|
+
}
|
907
|
+
set vseed(value) {
|
908
|
+
this._vseed = value;
|
909
|
+
}
|
910
|
+
get advancedVSeed() {
|
911
|
+
return this._advancedVSeed;
|
912
|
+
}
|
913
|
+
set advancedVSeed(value) {
|
914
|
+
this._advancedVSeed = value;
|
915
|
+
}
|
916
|
+
static _advancedPipelineMap = {};
|
917
|
+
static _specPipelineMap = {};
|
918
|
+
static _themeMap = {};
|
919
|
+
static from = (vseed)=>new Builder(vseed);
|
920
|
+
}
|
921
|
+
const registerColumn = ()=>{
|
922
|
+
Builder._advancedPipelineMap.column = columnAdvancedPipeline;
|
923
|
+
Builder._specPipelineMap.column = columnSpecPipeline;
|
924
|
+
};
|
925
|
+
const registerBar = ()=>{
|
926
|
+
Builder._advancedPipelineMap.bar = barAdvancedPipeline;
|
927
|
+
Builder._specPipelineMap.bar = barSpecPipeline;
|
928
|
+
};
|
929
|
+
const registerLine = ()=>{
|
930
|
+
Builder._advancedPipelineMap.line = lineAdvancedPipeline;
|
931
|
+
Builder._specPipelineMap.line = lineSpecPipeline;
|
932
|
+
};
|
933
|
+
const registerArea = ()=>{
|
934
|
+
Builder._advancedPipelineMap.area = areaAdvancedPipeline;
|
935
|
+
Builder._specPipelineMap.area = areaSpecPipeline;
|
936
|
+
};
|
937
|
+
const registerAreaPercent = ()=>{
|
938
|
+
Builder._advancedPipelineMap.areaPercent = areaPercentAdvancedPipeline;
|
939
|
+
Builder._specPipelineMap.areaPercent = areaPercentSpecPipeline;
|
940
|
+
};
|
941
|
+
const registerBarPercent = ()=>{
|
942
|
+
Builder._advancedPipelineMap.barPercent = barPercentAdvancedPipeline;
|
943
|
+
Builder._specPipelineMap.barPercent = barPercentSpecPipeline;
|
944
|
+
};
|
945
|
+
const registerColumnPercent = ()=>{
|
946
|
+
Builder._advancedPipelineMap.columnPercent = columnPercentAdvancedPipeline;
|
947
|
+
Builder._specPipelineMap.columnPercent = columnPercentSpecPipeline;
|
948
|
+
};
|
949
|
+
const registerColumnParallel = ()=>{
|
950
|
+
Builder._advancedPipelineMap.columnParallel = columnParallelAdvancedPipeline;
|
951
|
+
Builder._specPipelineMap.columnParallel = columnParallelSpecPipeline;
|
952
|
+
};
|
953
|
+
const registerBarParallel = ()=>{
|
954
|
+
Builder._advancedPipelineMap.barParallel = barParallelAdvancedPipeline;
|
955
|
+
Builder._specPipelineMap.barParallel = barParallelSpecPipeline;
|
956
|
+
};
|
957
|
+
const lightTheme = ()=>({
|
958
|
+
baseConfig: {
|
959
|
+
vtable: {
|
960
|
+
backgroundColor: '#ffffff'
|
961
|
+
},
|
962
|
+
vchart: {
|
963
|
+
backgroundColor: '#ffffff',
|
964
|
+
color: {
|
965
|
+
colorScheme: [
|
966
|
+
'#8D72F6',
|
967
|
+
'#5766EC',
|
968
|
+
'#66A3FE',
|
969
|
+
'#51D5E6',
|
970
|
+
'#4EC0B3',
|
971
|
+
'#F9DF90',
|
972
|
+
'#F9AD71',
|
973
|
+
'#ED8888',
|
974
|
+
'#E9A0C3',
|
975
|
+
'#D77DD3'
|
976
|
+
]
|
977
|
+
},
|
978
|
+
label: {
|
979
|
+
enable: true
|
980
|
+
},
|
981
|
+
tooltip: {
|
982
|
+
enable: true
|
983
|
+
},
|
984
|
+
legend: {
|
985
|
+
enable: true
|
986
|
+
}
|
987
|
+
}
|
988
|
+
}
|
989
|
+
});
|
990
|
+
const darkTheme = ()=>({
|
991
|
+
baseConfig: {
|
992
|
+
vtable: {
|
993
|
+
backgroundColor: '#141414'
|
994
|
+
},
|
995
|
+
vchart: {
|
996
|
+
backgroundColor: '#141414',
|
997
|
+
color: {
|
998
|
+
colorScheme: [
|
999
|
+
'#2E62F1',
|
1000
|
+
'#4DC36A',
|
1001
|
+
'#FF8406',
|
1002
|
+
'#FFCC00',
|
1003
|
+
'#4F44CF',
|
1004
|
+
'#5AC8FA',
|
1005
|
+
'#003A8C',
|
1006
|
+
'#B08AE2',
|
1007
|
+
'#FF6341',
|
1008
|
+
'#98DD62'
|
1009
|
+
]
|
1010
|
+
},
|
1011
|
+
label: {
|
1012
|
+
enable: true
|
1013
|
+
},
|
1014
|
+
tooltip: {
|
1015
|
+
enable: true
|
1016
|
+
},
|
1017
|
+
legend: {
|
1018
|
+
enable: true
|
1019
|
+
}
|
1020
|
+
}
|
1021
|
+
}
|
1022
|
+
});
|
1023
|
+
const registerCustomTheme = (key, themeConfig)=>{
|
1024
|
+
Builder._themeMap[key] = themeConfig;
|
1025
|
+
};
|
1026
|
+
const registerLightTheme = ()=>{
|
1027
|
+
registerCustomTheme('light', lightTheme());
|
1028
|
+
};
|
1029
|
+
const registerDarkTheme = ()=>{
|
1030
|
+
registerCustomTheme('dark', darkTheme());
|
1031
|
+
};
|
1032
|
+
const all_registerAll = ()=>{
|
1033
|
+
registerLine();
|
1034
|
+
registerColumn();
|
1035
|
+
registerColumnParallel();
|
1036
|
+
registerColumnPercent();
|
1037
|
+
registerBar();
|
1038
|
+
registerBarParallel();
|
1039
|
+
registerBarPercent();
|
1040
|
+
registerArea();
|
1041
|
+
registerAreaPercent();
|
1042
|
+
registerLightTheme();
|
1043
|
+
registerDarkTheme();
|
1044
|
+
};
|
1045
|
+
const external_zod_namespaceObject = require("zod");
|
1046
|
+
const zChartType = external_zod_namespaceObject.z["enum"]([
|
1047
|
+
'table',
|
1048
|
+
'pivotTable',
|
1049
|
+
'line',
|
1050
|
+
'column',
|
1051
|
+
'columnPercent',
|
1052
|
+
'columnParallel',
|
1053
|
+
'bar',
|
1054
|
+
'barPercent',
|
1055
|
+
'barParallel',
|
1056
|
+
'area',
|
1057
|
+
'areaPercent',
|
1058
|
+
'rose',
|
1059
|
+
'pie',
|
1060
|
+
'donut',
|
1061
|
+
'dualAxis'
|
1062
|
+
]);
|
1063
|
+
const zDatum = external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string().or(external_zod_namespaceObject.z.number()), external_zod_namespaceObject.z.any());
|
1064
|
+
const zDataset = external_zod_namespaceObject.z.array(zDatum);
|
1065
|
+
const zDimension = external_zod_namespaceObject.z.object({
|
1066
|
+
id: external_zod_namespaceObject.z.string(),
|
1067
|
+
alias: external_zod_namespaceObject.z.string().optional(),
|
1068
|
+
visible: external_zod_namespaceObject.z.boolean().default(true).optional(),
|
1069
|
+
location: external_zod_namespaceObject.z["enum"]([
|
1070
|
+
'dimension',
|
1071
|
+
'rowDimension',
|
1072
|
+
'columnDimension'
|
1073
|
+
])
|
1074
|
+
});
|
1075
|
+
const zDimensions = external_zod_namespaceObject.z.array(zDimension).optional();
|
1076
|
+
const zMeasure = external_zod_namespaceObject.z.object({
|
1077
|
+
id: external_zod_namespaceObject.z.string(),
|
1078
|
+
alias: external_zod_namespaceObject.z.string().optional(),
|
1079
|
+
visible: external_zod_namespaceObject.z.boolean().default(true).optional(),
|
1080
|
+
autoFormat: external_zod_namespaceObject.z.boolean().default(true).optional(),
|
1081
|
+
format: external_zod_namespaceObject.z.object({
|
1082
|
+
type: external_zod_namespaceObject.z["enum"]([
|
1083
|
+
'number',
|
1084
|
+
'percent',
|
1085
|
+
'permille'
|
1086
|
+
]).optional().default('number'),
|
1087
|
+
ratio: external_zod_namespaceObject.z.number().optional().default(1),
|
1088
|
+
symbol: external_zod_namespaceObject.z.string().optional().default(''),
|
1089
|
+
thousandSeparator: external_zod_namespaceObject.z.boolean().optional().default(false),
|
1090
|
+
decimalPlaces: external_zod_namespaceObject.z.number().optional().default(2),
|
1091
|
+
round: external_zod_namespaceObject.z["enum"]([
|
1092
|
+
'round',
|
1093
|
+
'floor',
|
1094
|
+
'ceil'
|
1095
|
+
]).optional().default('round'),
|
1096
|
+
prefix: external_zod_namespaceObject.z.string().optional().default(''),
|
1097
|
+
suffix: external_zod_namespaceObject.z.string().optional().default('')
|
1098
|
+
}).optional()
|
1099
|
+
});
|
1100
|
+
const zMeasureGroup = external_zod_namespaceObject.z.object({
|
1101
|
+
id: external_zod_namespaceObject.z.string(),
|
1102
|
+
alias: external_zod_namespaceObject.z.string().optional(),
|
1103
|
+
visible: external_zod_namespaceObject.z.boolean().default(true).optional(),
|
1104
|
+
get children () {
|
1105
|
+
return external_zod_namespaceObject.z.array(zMeasureGroup.or(zMeasure)).optional();
|
1106
|
+
}
|
1107
|
+
});
|
1108
|
+
const zMeasures = external_zod_namespaceObject.z.array(zMeasureGroup.or(zMeasure)).optional();
|
1109
|
+
const zFoldInfo = external_zod_namespaceObject.z.object({
|
1110
|
+
foldMap: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.string().or(external_zod_namespaceObject.z.undefined())),
|
1111
|
+
measureId: external_zod_namespaceObject.z.string(),
|
1112
|
+
measureName: external_zod_namespaceObject.z.string(),
|
1113
|
+
measureValue: external_zod_namespaceObject.z.string()
|
1114
|
+
});
|
1115
|
+
const zUnfoldInfo = external_zod_namespaceObject.z.object({
|
1116
|
+
colorItems: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
|
1117
|
+
groupName: external_zod_namespaceObject.z.string()
|
1118
|
+
});
|
1119
|
+
const zDatasetReshapeInfo = external_zod_namespaceObject.z.object({
|
1120
|
+
foldInfo: zFoldInfo,
|
1121
|
+
unfoldInfo: zUnfoldInfo
|
1122
|
+
});
|
1123
|
+
const zEncoding = external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.object({
|
1124
|
+
x: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
1125
|
+
y: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
1126
|
+
color: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
1127
|
+
group: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
1128
|
+
angle: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
1129
|
+
radius: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
1130
|
+
tooltip: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional()
|
1131
|
+
}));
|
1132
|
+
const zBackgroundColor = external_zod_namespaceObject.z.string().default('transparent').optional();
|
1133
|
+
const zLabel = external_zod_namespaceObject.z.object({
|
1134
|
+
enable: external_zod_namespaceObject.z.boolean().default(true).optional()
|
1135
|
+
});
|
1136
|
+
const zColor = external_zod_namespaceObject.z.object({
|
1137
|
+
colorScheme: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
1138
|
+
colorMapping: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.string()).optional()
|
1139
|
+
});
|
1140
|
+
const zTooltip = external_zod_namespaceObject.z.object({
|
1141
|
+
enable: external_zod_namespaceObject.z.boolean().default(true).optional()
|
1142
|
+
});
|
1143
|
+
const zLegend = external_zod_namespaceObject.z.object({
|
1144
|
+
enable: external_zod_namespaceObject.z.boolean().default(true).optional()
|
1145
|
+
});
|
1146
|
+
const zVChartBaseConfig = external_zod_namespaceObject.z.object({
|
1147
|
+
backgroundColor: zBackgroundColor,
|
1148
|
+
label: zLabel.optional(),
|
1149
|
+
color: zColor.optional(),
|
1150
|
+
tooltip: zTooltip.optional(),
|
1151
|
+
legend: zLegend.optional()
|
1152
|
+
});
|
1153
|
+
const zVTableBaseConfig = external_zod_namespaceObject.z.object({
|
1154
|
+
backgroundColor: zBackgroundColor
|
1155
|
+
});
|
1156
|
+
const zBaseConfig = external_zod_namespaceObject.z.object({
|
1157
|
+
vchart: zVChartBaseConfig.optional(),
|
1158
|
+
vtable: zVTableBaseConfig.optional()
|
1159
|
+
});
|
1160
|
+
const zCustomThemeConfig = external_zod_namespaceObject.z.object({
|
1161
|
+
baseConfig: zBaseConfig.optional()
|
1162
|
+
});
|
1163
|
+
const zCustomTheme = external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), zCustomThemeConfig).optional();
|
1164
|
+
const zTheme = external_zod_namespaceObject.z.string();
|
1165
|
+
const dataReshapeFor1D1M_emptyReshapeResult = {
|
1166
|
+
dataset: [],
|
1167
|
+
foldInfo: {
|
1168
|
+
foldMap: {},
|
1169
|
+
measureId: '',
|
1170
|
+
measureName: '',
|
1171
|
+
measureValue: ''
|
1172
|
+
},
|
1173
|
+
unfoldInfo: {
|
1174
|
+
groupName: '',
|
1175
|
+
colorItems: []
|
1176
|
+
}
|
1177
|
+
};
|
1178
|
+
const dataReshapeFor1D1M = (dataset, dimensions, measures)=>{
|
1179
|
+
if (0 === dimensions.length && 0 === measures.length) return dataReshapeFor1D1M_emptyReshapeResult;
|
1180
|
+
const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, FoldMeasureId, FoldMeasureName, FoldMeasureValue);
|
1181
|
+
if (0 === dimensions.length) {
|
1182
|
+
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
1183
|
+
{
|
1184
|
+
id: FoldMeasureName,
|
1185
|
+
alias: "\u6307\u6807\u540D\u79F0",
|
1186
|
+
location: 'dimension'
|
1187
|
+
}
|
1188
|
+
], [
|
1189
|
+
{
|
1190
|
+
id: FoldMeasureValue,
|
1191
|
+
alias: "\u6307\u6807\u503C"
|
1192
|
+
}
|
1193
|
+
], 0, FoldDimensionGroup);
|
1194
|
+
return {
|
1195
|
+
dataset: finalDataset,
|
1196
|
+
foldInfo,
|
1197
|
+
unfoldInfo
|
1198
|
+
};
|
1199
|
+
}
|
1200
|
+
{
|
1201
|
+
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
1202
|
+
...dimensions,
|
1203
|
+
{
|
1204
|
+
id: FoldMeasureName,
|
1205
|
+
alias: "\u6307\u6807\u540D\u79F0",
|
1206
|
+
location: 'dimension'
|
1207
|
+
}
|
1208
|
+
], [
|
1209
|
+
{
|
1210
|
+
id: FoldMeasureValue,
|
1211
|
+
alias: "\u6307\u6807\u503C"
|
1212
|
+
}
|
1213
|
+
], 0, FoldDimensionGroup);
|
1214
|
+
return {
|
1215
|
+
dataset: finalDataset,
|
1216
|
+
foldInfo,
|
1217
|
+
unfoldInfo
|
1218
|
+
};
|
1219
|
+
}
|
1220
|
+
};
|
1221
|
+
exports.Builder = __webpack_exports__.Builder;
|
1222
|
+
exports.areaAdvancedPipeline = __webpack_exports__.areaAdvancedPipeline;
|
1223
|
+
exports.areaPercentAdvancedPipeline = __webpack_exports__.areaPercentAdvancedPipeline;
|
1224
|
+
exports.areaPercentSpecPipeline = __webpack_exports__.areaPercentSpecPipeline;
|
1225
|
+
exports.areaSpecPipeline = __webpack_exports__.areaSpecPipeline;
|
1226
|
+
exports.barAdvancedPipeline = __webpack_exports__.barAdvancedPipeline;
|
1227
|
+
exports.barParallelAdvancedPipeline = __webpack_exports__.barParallelAdvancedPipeline;
|
1228
|
+
exports.barParallelSpecPipeline = __webpack_exports__.barParallelSpecPipeline;
|
1229
|
+
exports.barPercentAdvancedPipeline = __webpack_exports__.barPercentAdvancedPipeline;
|
1230
|
+
exports.barPercentSpecPipeline = __webpack_exports__.barPercentSpecPipeline;
|
1231
|
+
exports.barSpecPipeline = __webpack_exports__.barSpecPipeline;
|
1232
|
+
exports.columnAdvancedPipeline = __webpack_exports__.columnAdvancedPipeline;
|
1233
|
+
exports.columnParallelAdvancedPipeline = __webpack_exports__.columnParallelAdvancedPipeline;
|
1234
|
+
exports.columnParallelSpecPipeline = __webpack_exports__.columnParallelSpecPipeline;
|
1235
|
+
exports.columnPercentAdvancedPipeline = __webpack_exports__.columnPercentAdvancedPipeline;
|
1236
|
+
exports.columnPercentSpecPipeline = __webpack_exports__.columnPercentSpecPipeline;
|
1237
|
+
exports.columnSpecPipeline = __webpack_exports__.columnSpecPipeline;
|
1238
|
+
exports.darkTheme = __webpack_exports__.darkTheme;
|
1239
|
+
exports.dataReshapeFor1D1M = __webpack_exports__.dataReshapeFor1D1M;
|
1240
|
+
exports.dataReshapeFor2D1M = __webpack_exports__.dataReshapeFor2D1M;
|
1241
|
+
exports.execPipeline = __webpack_exports__.execPipeline;
|
1242
|
+
exports.foldMeasures = __webpack_exports__.foldMeasures;
|
1243
|
+
exports.isVChart = __webpack_exports__.isVChart;
|
1244
|
+
exports.isVTable = __webpack_exports__.isVTable;
|
1245
|
+
exports.lightTheme = __webpack_exports__.lightTheme;
|
1246
|
+
exports.lineAdvancedPipeline = __webpack_exports__.lineAdvancedPipeline;
|
1247
|
+
exports.lineSpecPipeline = __webpack_exports__.lineSpecPipeline;
|
1248
|
+
exports.registerAll = __webpack_exports__.registerAll;
|
1249
|
+
exports.registerArea = __webpack_exports__.registerArea;
|
1250
|
+
exports.registerAreaPercent = __webpack_exports__.registerAreaPercent;
|
1251
|
+
exports.registerBar = __webpack_exports__.registerBar;
|
1252
|
+
exports.registerBarParallel = __webpack_exports__.registerBarParallel;
|
1253
|
+
exports.registerBarPercent = __webpack_exports__.registerBarPercent;
|
1254
|
+
exports.registerColumn = __webpack_exports__.registerColumn;
|
1255
|
+
exports.registerColumnParallel = __webpack_exports__.registerColumnParallel;
|
1256
|
+
exports.registerColumnPercent = __webpack_exports__.registerColumnPercent;
|
1257
|
+
exports.registerCustomTheme = __webpack_exports__.registerCustomTheme;
|
1258
|
+
exports.registerDarkTheme = __webpack_exports__.registerDarkTheme;
|
1259
|
+
exports.registerLightTheme = __webpack_exports__.registerLightTheme;
|
1260
|
+
exports.registerLine = __webpack_exports__.registerLine;
|
1261
|
+
exports.unfoldDimensions = __webpack_exports__.unfoldDimensions;
|
1262
|
+
exports.zBackgroundColor = __webpack_exports__.zBackgroundColor;
|
1263
|
+
exports.zBaseConfig = __webpack_exports__.zBaseConfig;
|
1264
|
+
exports.zChartType = __webpack_exports__.zChartType;
|
1265
|
+
exports.zColor = __webpack_exports__.zColor;
|
1266
|
+
exports.zCustomTheme = __webpack_exports__.zCustomTheme;
|
1267
|
+
exports.zCustomThemeConfig = __webpack_exports__.zCustomThemeConfig;
|
1268
|
+
exports.zDataset = __webpack_exports__.zDataset;
|
1269
|
+
exports.zDatasetReshapeInfo = __webpack_exports__.zDatasetReshapeInfo;
|
1270
|
+
exports.zDatum = __webpack_exports__.zDatum;
|
1271
|
+
exports.zDimension = __webpack_exports__.zDimension;
|
1272
|
+
exports.zDimensions = __webpack_exports__.zDimensions;
|
1273
|
+
exports.zEncoding = __webpack_exports__.zEncoding;
|
1274
|
+
exports.zFoldInfo = __webpack_exports__.zFoldInfo;
|
1275
|
+
exports.zLabel = __webpack_exports__.zLabel;
|
1276
|
+
exports.zLegend = __webpack_exports__.zLegend;
|
1277
|
+
exports.zMeasure = __webpack_exports__.zMeasure;
|
1278
|
+
exports.zMeasureGroup = __webpack_exports__.zMeasureGroup;
|
1279
|
+
exports.zMeasures = __webpack_exports__.zMeasures;
|
1280
|
+
exports.zTheme = __webpack_exports__.zTheme;
|
1281
|
+
exports.zTooltip = __webpack_exports__.zTooltip;
|
1282
|
+
exports.zUnfoldInfo = __webpack_exports__.zUnfoldInfo;
|
1283
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
1284
|
+
"Builder",
|
1285
|
+
"areaAdvancedPipeline",
|
1286
|
+
"areaPercentAdvancedPipeline",
|
1287
|
+
"areaPercentSpecPipeline",
|
1288
|
+
"areaSpecPipeline",
|
1289
|
+
"barAdvancedPipeline",
|
1290
|
+
"barParallelAdvancedPipeline",
|
1291
|
+
"barParallelSpecPipeline",
|
1292
|
+
"barPercentAdvancedPipeline",
|
1293
|
+
"barPercentSpecPipeline",
|
1294
|
+
"barSpecPipeline",
|
1295
|
+
"columnAdvancedPipeline",
|
1296
|
+
"columnParallelAdvancedPipeline",
|
1297
|
+
"columnParallelSpecPipeline",
|
1298
|
+
"columnPercentAdvancedPipeline",
|
1299
|
+
"columnPercentSpecPipeline",
|
1300
|
+
"columnSpecPipeline",
|
1301
|
+
"darkTheme",
|
1302
|
+
"dataReshapeFor1D1M",
|
1303
|
+
"dataReshapeFor2D1M",
|
1304
|
+
"execPipeline",
|
1305
|
+
"foldMeasures",
|
1306
|
+
"isVChart",
|
1307
|
+
"isVTable",
|
1308
|
+
"lightTheme",
|
1309
|
+
"lineAdvancedPipeline",
|
1310
|
+
"lineSpecPipeline",
|
1311
|
+
"registerAll",
|
1312
|
+
"registerArea",
|
1313
|
+
"registerAreaPercent",
|
1314
|
+
"registerBar",
|
1315
|
+
"registerBarParallel",
|
1316
|
+
"registerBarPercent",
|
1317
|
+
"registerColumn",
|
1318
|
+
"registerColumnParallel",
|
1319
|
+
"registerColumnPercent",
|
1320
|
+
"registerCustomTheme",
|
1321
|
+
"registerDarkTheme",
|
1322
|
+
"registerLightTheme",
|
1323
|
+
"registerLine",
|
1324
|
+
"unfoldDimensions",
|
1325
|
+
"zBackgroundColor",
|
1326
|
+
"zBaseConfig",
|
1327
|
+
"zChartType",
|
1328
|
+
"zColor",
|
1329
|
+
"zCustomTheme",
|
1330
|
+
"zCustomThemeConfig",
|
1331
|
+
"zDataset",
|
1332
|
+
"zDatasetReshapeInfo",
|
1333
|
+
"zDatum",
|
1334
|
+
"zDimension",
|
1335
|
+
"zDimensions",
|
1336
|
+
"zEncoding",
|
1337
|
+
"zFoldInfo",
|
1338
|
+
"zLabel",
|
1339
|
+
"zLegend",
|
1340
|
+
"zMeasure",
|
1341
|
+
"zMeasureGroup",
|
1342
|
+
"zMeasures",
|
1343
|
+
"zTheme",
|
1344
|
+
"zTooltip",
|
1345
|
+
"zUnfoldInfo"
|
1346
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
1347
|
+
Object.defineProperty(exports, '__esModule', {
|
1348
|
+
value: true
|
1349
|
+
});
|
1350
|
+
|
1351
|
+
//# sourceMappingURL=index.cjs.map
|