@visactor/vseed 0.0.5 → 0.0.7
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/builder/builder/build.d.ts +2 -2
- package/dist/builder/builder/buildSpec.d.ts +2 -2
- package/dist/builder/builder/builder.d.ts +8 -5
- package/dist/builder/register/chartType.d.ts +1 -0
- package/dist/dataReshape/constant.d.ts +1 -1
- package/dist/dataReshape/dataReshapeFor1D1M.d.ts +6 -1
- package/dist/dataReshape/dataReshapeFor2D1M.d.ts +6 -1
- package/dist/index.cjs +1174 -349
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +920 -104
- package/dist/index.js.map +1 -1
- package/dist/pipeline/advanced/pipeline/index.d.ts +1 -0
- package/dist/pipeline/advanced/pipeline/line copy.d.ts +2 -0
- package/dist/pipeline/advanced/pipeline/pie.d.ts +2 -0
- package/dist/pipeline/advanced/pipes/encoding/encodingPolar.d.ts +2 -0
- package/dist/pipeline/advanced/pipes/encoding/{encodingCartesian.d.ts → encodingXY copy.d.ts } +0 -1
- package/dist/pipeline/advanced/pipes/encoding/encodingXY.d.ts +2 -0
- package/dist/pipeline/advanced/pipes/encoding/encodingYX.d.ts +2 -0
- package/dist/pipeline/advanced/pipes/encoding/index.d.ts +3 -1
- package/dist/pipeline/advanced/pipes/index.d.ts +1 -0
- package/dist/pipeline/advanced/pipes/pivot/index.d.ts +1 -0
- package/dist/pipeline/advanced/pipes/pivot/pivotAdapter.d.ts +2 -0
- package/dist/pipeline/advanced/pipes/reshape/index.d.ts +2 -0
- package/dist/pipeline/advanced/pipes/reshape/pivotReshapeTo1D1M.d.ts +8 -0
- package/dist/pipeline/advanced/pipes/reshape/pivotReshapeTo2D1M.d.ts +8 -0
- package/dist/pipeline/spec/pipeline/area.d.ts +1 -2
- package/dist/pipeline/spec/pipeline/areaPercent.d.ts +1 -2
- package/dist/pipeline/spec/pipeline/column.d.ts +1 -2
- package/dist/pipeline/spec/pipeline/index.d.ts +1 -0
- package/dist/pipeline/spec/pipeline/pie.d.ts +2 -0
- package/dist/pipeline/spec/pipes/dataset/datasetPivot.d.ts +3 -0
- package/dist/pipeline/spec/pipes/dataset/index.d.ts +1 -0
- package/dist/pipeline/spec/pipes/index.d.ts +1 -0
- package/dist/pipeline/spec/pipes/init/index.d.ts +2 -0
- package/dist/pipeline/spec/pipes/init/line copy.d.ts +2 -0
- package/dist/pipeline/spec/pipes/init/pie.d.ts +2 -0
- package/dist/pipeline/spec/pipes/init/pivot.d.ts +4 -0
- package/dist/pipeline/spec/pipes/legend/index.d.ts +1 -0
- package/dist/pipeline/spec/pipes/legend/pivotLegend.d.ts +2 -0
- package/dist/pipeline/spec/pipes/pivotChart/index.d.ts +5 -0
- package/dist/pipeline/spec/pipes/pivotChart/pivotAdapter.d.ts +2 -0
- package/dist/pipeline/spec/pipes/pivotChart/pivotColumnDimensions.d.ts +2 -0
- package/dist/pipeline/spec/pipes/pivotChart/pivotGridStyle copy.d.ts +2 -0
- package/dist/pipeline/spec/pipes/pivotChart/pivotGridStyle.d.ts +2 -0
- package/dist/pipeline/spec/pipes/pivotChart/pivotIndicators.d.ts +4 -0
- package/dist/pipeline/spec/pipes/pivotChart/pivotRowDimensions copy.d.ts +2 -0
- package/dist/pipeline/spec/pipes/pivotChart/pivotRowDimensions.d.ts +2 -0
- package/dist/pipeline/utils/chatType.d.ts +37 -1
- package/dist/pipeline/utils/index.d.ts +1 -1
- package/dist/types/advancedVSeed.d.ts +3 -2
- package/dist/types/builder/builder.d.ts +3 -3
- package/dist/types/builder/index.d.ts +1 -0
- package/dist/types/builder/spec.d.ts +3 -0
- package/dist/types/pipeline/spec/spec.d.ts +2 -2
- package/dist/types/properties/datasetReshapeInfo/datasetReshapeInfo.d.ts +3 -2
- package/dist/types/properties/datasetReshapeInfo/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import { clone as external_remeda_clone, mergeDeep as external_remeda_mergeDeep, pick as external_remeda_pick } from "remeda";
|
1
|
+
import { clone as external_remeda_clone, mergeDeep as external_remeda_mergeDeep, pick as external_remeda_pick, unique } from "remeda";
|
2
2
|
import { z } from "zod";
|
3
3
|
const FoldMeasureName = '__MeaName__';
|
4
4
|
const FoldMeasureValue = '__MeaValue__';
|
5
5
|
const FoldMeasureId = '__MeaId__';
|
6
|
-
const
|
6
|
+
const UnfoldDimensionGroup = '__DimGroup__';
|
7
7
|
const Separator = '-';
|
8
|
-
const unfoldDimensions = (dataset, dimensions, measures, unfoldStartIndex = 0, foldGroupName =
|
8
|
+
const unfoldDimensions = (dataset, dimensions, measures, unfoldStartIndex = 0, foldGroupName = UnfoldDimensionGroup, dimensionsSeparator = Separator)=>{
|
9
9
|
if (unfoldStartIndex < 0 || unfoldStartIndex >= dimensions.length) throw new Error('unfoldStartIndex is out of range');
|
10
10
|
const dimensionsToBeUnfolded = dimensions.slice(unfoldStartIndex);
|
11
11
|
const unfoldInfo = {
|
@@ -26,7 +26,7 @@ const unfoldDimensions = (dataset, dimensions, measures, unfoldStartIndex = 0, f
|
|
26
26
|
datum[foldGroupName] = colorItem;
|
27
27
|
colorItems.push(colorItem);
|
28
28
|
}
|
29
|
-
unfoldInfo.colorItems = colorItems;
|
29
|
+
unfoldInfo.colorItems = unique(colorItems);
|
30
30
|
return {
|
31
31
|
dataset,
|
32
32
|
unfoldInfo
|
@@ -72,27 +72,28 @@ const emptyReshapeResult = {
|
|
72
72
|
groupName: ''
|
73
73
|
}
|
74
74
|
};
|
75
|
-
const dataReshapeFor2D1M = (dataset, dimensions, measures)=>{
|
75
|
+
const dataReshapeFor2D1M = (dataset, dimensions, measures, options)=>{
|
76
|
+
const { foldMeasureId = FoldMeasureId, foldMeasureName = FoldMeasureName, foldMeasureValue = FoldMeasureValue, unfoldDimensionGroup = UnfoldDimensionGroup } = options || {};
|
76
77
|
if (0 === dimensions.length && 0 === measures.length) return emptyReshapeResult;
|
77
|
-
const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures,
|
78
|
+
const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, foldMeasureId, foldMeasureName, foldMeasureValue);
|
78
79
|
if (0 === dimensions.length) {
|
79
80
|
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
80
81
|
{
|
81
|
-
id:
|
82
|
+
id: foldMeasureId,
|
82
83
|
alias: "\u6307\u6807Id",
|
83
84
|
location: 'dimension'
|
84
85
|
},
|
85
86
|
{
|
86
|
-
id:
|
87
|
+
id: foldMeasureName,
|
87
88
|
alias: "\u6307\u6807\u540D\u79F0",
|
88
89
|
location: 'dimension'
|
89
90
|
}
|
90
91
|
], [
|
91
92
|
{
|
92
|
-
id:
|
93
|
+
id: foldMeasureValue,
|
93
94
|
alias: "\u6307\u6807\u503C"
|
94
95
|
}
|
95
|
-
], 1,
|
96
|
+
], 1, unfoldDimensionGroup);
|
96
97
|
return {
|
97
98
|
dataset: finalDataset,
|
98
99
|
foldInfo,
|
@@ -103,16 +104,16 @@ const dataReshapeFor2D1M = (dataset, dimensions, measures)=>{
|
|
103
104
|
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
104
105
|
...dimensions,
|
105
106
|
{
|
106
|
-
id:
|
107
|
+
id: foldMeasureName,
|
107
108
|
alias: "\u6307\u6807\u540D\u79F0",
|
108
109
|
location: 'dimension'
|
109
110
|
}
|
110
111
|
], [
|
111
112
|
{
|
112
|
-
id:
|
113
|
+
id: foldMeasureValue,
|
113
114
|
alias: "\u6307\u6807\u503C"
|
114
115
|
}
|
115
|
-
], 1,
|
116
|
+
], 1, unfoldDimensionGroup);
|
116
117
|
return {
|
117
118
|
dataset: finalDataset,
|
118
119
|
foldInfo,
|
@@ -133,22 +134,23 @@ const dataReshapeFor1D1M_emptyReshapeResult = {
|
|
133
134
|
colorItems: []
|
134
135
|
}
|
135
136
|
};
|
136
|
-
const
|
137
|
+
const dataReshapeFor1D1M = (dataset, dimensions, measures, options)=>{
|
138
|
+
const { foldMeasureId = FoldMeasureId, foldMeasureName = FoldMeasureName, foldMeasureValue = FoldMeasureValue, unfoldDimensionGroup = UnfoldDimensionGroup } = options || {};
|
137
139
|
if (0 === dimensions.length && 0 === measures.length) return dataReshapeFor1D1M_emptyReshapeResult;
|
138
|
-
const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures,
|
140
|
+
const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, foldMeasureId, foldMeasureName, foldMeasureValue);
|
139
141
|
if (0 === dimensions.length) {
|
140
142
|
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
141
143
|
{
|
142
|
-
id:
|
144
|
+
id: foldMeasureName,
|
143
145
|
alias: "\u6307\u6807\u540D\u79F0",
|
144
146
|
location: 'dimension'
|
145
147
|
}
|
146
148
|
], [
|
147
149
|
{
|
148
|
-
id:
|
150
|
+
id: foldMeasureValue,
|
149
151
|
alias: "\u6307\u6807\u503C"
|
150
152
|
}
|
151
|
-
], 0,
|
153
|
+
], 0, unfoldDimensionGroup);
|
152
154
|
return {
|
153
155
|
dataset: finalDataset,
|
154
156
|
foldInfo,
|
@@ -159,16 +161,16 @@ const dataReshapeFor1D1M_dataReshapeFor1D1M = (dataset, dimensions, measures)=>{
|
|
159
161
|
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
160
162
|
...dimensions,
|
161
163
|
{
|
162
|
-
id:
|
164
|
+
id: foldMeasureName,
|
163
165
|
alias: "\u6307\u6807\u540D\u79F0",
|
164
166
|
location: 'dimension'
|
165
167
|
}
|
166
168
|
], [
|
167
169
|
{
|
168
|
-
id:
|
170
|
+
id: foldMeasureValue,
|
169
171
|
alias: "\u6307\u6807\u503C"
|
170
172
|
}
|
171
|
-
], 0,
|
173
|
+
], 0, unfoldDimensionGroup);
|
172
174
|
return {
|
173
175
|
dataset: finalDataset,
|
174
176
|
foldInfo,
|
@@ -189,42 +191,148 @@ const reshapeTo2D1M = (advancedVSeed, context)=>{
|
|
189
191
|
return {
|
190
192
|
...result,
|
191
193
|
dataset: newDatasets,
|
192
|
-
datasetReshapeInfo:
|
193
|
-
|
194
|
-
|
195
|
-
|
194
|
+
datasetReshapeInfo: [
|
195
|
+
{
|
196
|
+
id: '2D1M',
|
197
|
+
foldInfo,
|
198
|
+
unfoldInfo
|
199
|
+
}
|
200
|
+
],
|
196
201
|
dimensions,
|
197
202
|
measures
|
198
203
|
};
|
199
204
|
};
|
205
|
+
const reshapeTo1D1M = (advancedVSeed, context)=>{
|
206
|
+
const result = {
|
207
|
+
...advancedVSeed
|
208
|
+
};
|
209
|
+
const { vseed } = context;
|
210
|
+
const { dataset } = vseed;
|
211
|
+
const { dimensions, measures } = advancedVSeed;
|
212
|
+
if (!measures || !dimensions || !dataset) return result;
|
213
|
+
if (0 === measures.length) throw new Error('measures can not be empty');
|
214
|
+
const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeFor1D1M(dataset, dimensions, measures);
|
215
|
+
return {
|
216
|
+
...result,
|
217
|
+
dataset: newDatasets,
|
218
|
+
datasetReshapeInfo: [
|
219
|
+
{
|
220
|
+
id: '1D1M',
|
221
|
+
foldInfo,
|
222
|
+
unfoldInfo
|
223
|
+
}
|
224
|
+
]
|
225
|
+
};
|
226
|
+
};
|
227
|
+
const pivotReshapeTo1D1M = (advancedVSeed, context)=>{
|
228
|
+
const result = {
|
229
|
+
...advancedVSeed
|
230
|
+
};
|
231
|
+
const { vseed } = context;
|
232
|
+
const { dataset } = vseed;
|
233
|
+
const { dimensions, measures } = advancedVSeed;
|
234
|
+
if (!measures || !dimensions) return result;
|
235
|
+
const measureGroups = [];
|
236
|
+
if (measures) measures.forEach((measure)=>{
|
237
|
+
if (measure.children && measure.children.length > 0) measureGroups.push(measure);
|
238
|
+
});
|
239
|
+
const newDatasets = [];
|
240
|
+
const datasetReshapeInfo = [];
|
241
|
+
measureGroups.forEach((measureGroup)=>{
|
242
|
+
const measures = measureGroup.children;
|
243
|
+
if (!measures) return;
|
244
|
+
const commonDimensions = dimensions.filter((dim)=>'dimension' === dim.location);
|
245
|
+
const groupId = measureGroup.id;
|
246
|
+
const { dataset: newSubDataset, foldInfo, unfoldInfo } = dataReshapeFor1D1M(dataset, commonDimensions, measures, {
|
247
|
+
foldMeasureId: FoldMeasureId,
|
248
|
+
foldMeasureName: FoldMeasureName,
|
249
|
+
foldMeasureValue: FoldMeasureValue + groupId,
|
250
|
+
unfoldDimensionGroup: UnfoldDimensionGroup
|
251
|
+
});
|
252
|
+
const reshapeInfo = {
|
253
|
+
id: groupId,
|
254
|
+
foldInfo,
|
255
|
+
unfoldInfo
|
256
|
+
};
|
257
|
+
newDatasets.push(newSubDataset);
|
258
|
+
datasetReshapeInfo.push(reshapeInfo);
|
259
|
+
});
|
260
|
+
return {
|
261
|
+
...result,
|
262
|
+
dataset: newDatasets,
|
263
|
+
datasetReshapeInfo: datasetReshapeInfo
|
264
|
+
};
|
265
|
+
};
|
266
|
+
const pivotReshapeTo2D1M = (advancedVSeed, context)=>{
|
267
|
+
const result = {
|
268
|
+
...advancedVSeed
|
269
|
+
};
|
270
|
+
const { vseed } = context;
|
271
|
+
const { dataset } = vseed;
|
272
|
+
const { dimensions, measures } = advancedVSeed;
|
273
|
+
if (!measures || !dimensions) return result;
|
274
|
+
const measureGroups = [];
|
275
|
+
if (measures) measures.forEach((measure)=>{
|
276
|
+
if (measure.children && measure.children.length > 0) measureGroups.push(measure);
|
277
|
+
});
|
278
|
+
const commonDimensions = dimensions.filter((dim)=>'dimension' === dim.location);
|
279
|
+
const newDatasets = [];
|
280
|
+
const datasetReshapeInfo = [];
|
281
|
+
measureGroups.forEach((measureGroup)=>{
|
282
|
+
const measures = measureGroup.children;
|
283
|
+
if (!measures) return;
|
284
|
+
const groupId = measureGroup.id;
|
285
|
+
const { dataset: newSubDataset, foldInfo, unfoldInfo } = dataReshapeFor2D1M(dataset, commonDimensions, measures, {
|
286
|
+
foldMeasureId: FoldMeasureId + groupId,
|
287
|
+
foldMeasureName: FoldMeasureName + groupId,
|
288
|
+
foldMeasureValue: FoldMeasureValue + groupId,
|
289
|
+
unfoldDimensionGroup: UnfoldDimensionGroup + groupId
|
290
|
+
});
|
291
|
+
const reshapeInfo = {
|
292
|
+
id: groupId,
|
293
|
+
foldInfo,
|
294
|
+
unfoldInfo
|
295
|
+
};
|
296
|
+
newDatasets.push(newSubDataset);
|
297
|
+
datasetReshapeInfo.push(reshapeInfo);
|
298
|
+
});
|
299
|
+
return {
|
300
|
+
...result,
|
301
|
+
dataset: newDatasets,
|
302
|
+
datasetReshapeInfo: datasetReshapeInfo
|
303
|
+
};
|
304
|
+
};
|
200
305
|
const encodingXY = (advancedVSeed)=>{
|
201
306
|
const result = {
|
202
307
|
...advancedVSeed
|
203
308
|
};
|
204
309
|
const { datasetReshapeInfo, dimensions } = advancedVSeed;
|
205
310
|
if (!datasetReshapeInfo || !dimensions) return result;
|
206
|
-
const
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
311
|
+
const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
|
312
|
+
const { foldInfo, unfoldInfo } = cur;
|
313
|
+
const isSingleDimension = 0 === dimensions.length;
|
314
|
+
const x = [
|
315
|
+
isSingleDimension ? foldInfo.measureName : dimensions[0].id
|
316
|
+
];
|
317
|
+
const y = [
|
318
|
+
foldInfo.measureValue
|
319
|
+
];
|
320
|
+
const group = [
|
321
|
+
isSingleDimension ? foldInfo.measureName : unfoldInfo.groupName
|
322
|
+
];
|
323
|
+
const color = [
|
324
|
+
foldInfo.measureName
|
325
|
+
];
|
326
|
+
return [
|
327
|
+
...prev,
|
328
|
+
{
|
329
|
+
x,
|
330
|
+
y,
|
331
|
+
group,
|
332
|
+
color
|
333
|
+
}
|
334
|
+
];
|
335
|
+
}, []);
|
228
336
|
return {
|
229
337
|
...result,
|
230
338
|
encoding
|
@@ -236,28 +344,66 @@ const encodingYX = (advancedVSeed)=>{
|
|
236
344
|
};
|
237
345
|
const { datasetReshapeInfo, dimensions } = advancedVSeed;
|
238
346
|
if (!datasetReshapeInfo || !dimensions) return result;
|
239
|
-
const
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
347
|
+
const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
|
348
|
+
const { foldInfo, unfoldInfo } = cur;
|
349
|
+
const isSingleDimension = 0 === dimensions.length;
|
350
|
+
const y = [
|
351
|
+
isSingleDimension ? foldInfo.measureName : dimensions[0].id
|
352
|
+
];
|
353
|
+
const x = [
|
354
|
+
foldInfo.measureValue
|
355
|
+
];
|
356
|
+
const group = [
|
357
|
+
isSingleDimension ? foldInfo.measureName : unfoldInfo.groupName
|
358
|
+
];
|
359
|
+
const color = [
|
360
|
+
foldInfo.measureName
|
361
|
+
];
|
362
|
+
return [
|
363
|
+
...prev,
|
364
|
+
{
|
365
|
+
x,
|
366
|
+
y,
|
367
|
+
group,
|
368
|
+
color
|
369
|
+
}
|
370
|
+
];
|
371
|
+
}, []);
|
372
|
+
return {
|
373
|
+
...result,
|
374
|
+
encoding
|
375
|
+
};
|
376
|
+
};
|
377
|
+
const encodingPolar = (advancedVSeed)=>{
|
378
|
+
const result = {
|
379
|
+
...advancedVSeed
|
380
|
+
};
|
381
|
+
const { datasetReshapeInfo, dimensions } = advancedVSeed;
|
382
|
+
if (!datasetReshapeInfo || !dimensions) return result;
|
383
|
+
const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
|
384
|
+
const { foldInfo, unfoldInfo } = cur;
|
385
|
+
const radius = [
|
386
|
+
foldInfo.measureValue
|
387
|
+
];
|
388
|
+
const angle = [
|
389
|
+
unfoldInfo.groupName
|
390
|
+
];
|
391
|
+
const group = [
|
392
|
+
unfoldInfo.groupName
|
393
|
+
];
|
394
|
+
const color = [
|
395
|
+
unfoldInfo.groupName
|
396
|
+
];
|
397
|
+
return [
|
398
|
+
...prev,
|
399
|
+
{
|
400
|
+
angle,
|
401
|
+
radius,
|
402
|
+
group,
|
403
|
+
color
|
404
|
+
}
|
405
|
+
];
|
406
|
+
}, []);
|
261
407
|
return {
|
262
408
|
...result,
|
263
409
|
encoding
|
@@ -271,6 +417,21 @@ const initAdvancedVSeed = (advancedVSeed, context)=>{
|
|
271
417
|
chartType
|
272
418
|
};
|
273
419
|
};
|
420
|
+
const execPipeline = (pipeline, context, initialValue = {})=>{
|
421
|
+
const result = pipeline.reduce((prev, cur)=>cur(prev, context), initialValue);
|
422
|
+
return result;
|
423
|
+
};
|
424
|
+
const isVTable = (chartType)=>[
|
425
|
+
'table',
|
426
|
+
'pivotTable'
|
427
|
+
].includes(chartType);
|
428
|
+
const isVChart = (chartType)=>!isVTable(chartType);
|
429
|
+
const isPivotChart = (vseed)=>{
|
430
|
+
const { measures, dimensions } = vseed;
|
431
|
+
const hasRowOrColumnDimension = dimensions && dimensions.some((dimension)=>'rowDimension' === dimension.location || 'columnDimension' === dimension.location);
|
432
|
+
const hasMeasureGroup = measures && measures.find((measure)=>measure && measure.children);
|
433
|
+
return hasRowOrColumnDimension || hasMeasureGroup;
|
434
|
+
};
|
274
435
|
const autoMeasures = (advancedVSeed, context)=>{
|
275
436
|
const result = {
|
276
437
|
...advancedVSeed
|
@@ -279,6 +440,7 @@ const autoMeasures = (advancedVSeed, context)=>{
|
|
279
440
|
const { measures, dataset } = vseed;
|
280
441
|
if (!dataset) throw new Error('dataset is required');
|
281
442
|
if (0 === dataset.length) return result;
|
443
|
+
if (isPivotChart(vseed)) return autoMeasureGroup(advancedVSeed, context);
|
282
444
|
if (measures) {
|
283
445
|
result.measures = measures;
|
284
446
|
return result;
|
@@ -298,6 +460,49 @@ const autoMeasures = (advancedVSeed, context)=>{
|
|
298
460
|
}));
|
299
461
|
return result;
|
300
462
|
};
|
463
|
+
const autoMeasureGroup = (advancedVSeed, context)=>{
|
464
|
+
const { vseed } = context;
|
465
|
+
const { measures } = vseed;
|
466
|
+
const hasMeasureGroup = measures?.some((measure)=>measure.children);
|
467
|
+
if (!measures) return advancedVSeed;
|
468
|
+
if (!hasMeasureGroup) {
|
469
|
+
const newMeasures = [
|
470
|
+
{
|
471
|
+
id: 'measureGroup',
|
472
|
+
alias: 'measureGroup',
|
473
|
+
children: measures
|
474
|
+
}
|
475
|
+
];
|
476
|
+
return {
|
477
|
+
...advancedVSeed,
|
478
|
+
measures: newMeasures
|
479
|
+
};
|
480
|
+
}
|
481
|
+
let currentGroup = createEmptyMeasureGroup();
|
482
|
+
const measureGroups = [];
|
483
|
+
for (const measure of measures)if ('children' in measure) {
|
484
|
+
if (currentGroup.children?.length) {
|
485
|
+
currentGroup.id = currentGroup.children.map((item)=>item.id).join('-');
|
486
|
+
currentGroup.alias = currentGroup.children.map((item)=>item.alias).join('-');
|
487
|
+
measureGroups.push(currentGroup);
|
488
|
+
currentGroup = createEmptyMeasureGroup();
|
489
|
+
}
|
490
|
+
measureGroups.push(measure);
|
491
|
+
} else currentGroup.children?.push(measure);
|
492
|
+
if (currentGroup.children?.length) {
|
493
|
+
currentGroup.id = currentGroup.children.map((item)=>item.id).join('-');
|
494
|
+
currentGroup.alias = currentGroup.children.map((item)=>item.alias).join('-');
|
495
|
+
measureGroups.push(currentGroup);
|
496
|
+
currentGroup = createEmptyMeasureGroup();
|
497
|
+
}
|
498
|
+
advancedVSeed.measures = measureGroups;
|
499
|
+
return advancedVSeed;
|
500
|
+
};
|
501
|
+
const createEmptyMeasureGroup = ()=>({
|
502
|
+
id: '',
|
503
|
+
alias: '',
|
504
|
+
children: []
|
505
|
+
});
|
301
506
|
const autoDimensions = (advancedVSeed, context)=>{
|
302
507
|
const result = {
|
303
508
|
...advancedVSeed
|
@@ -362,11 +567,21 @@ const vchartTheme = (advancedVSeed, context)=>{
|
|
362
567
|
};
|
363
568
|
return result;
|
364
569
|
};
|
570
|
+
const pivotAdapter = (pipeline, pivotPipeline)=>(advancedVSeed, context)=>{
|
571
|
+
const { vseed } = context;
|
572
|
+
const usePivotChart = isPivotChart(vseed);
|
573
|
+
if (usePivotChart) return execPipeline(pivotPipeline, context, advancedVSeed);
|
574
|
+
return execPipeline(pipeline, context, advancedVSeed);
|
575
|
+
};
|
365
576
|
const lineAdvancedPipeline = [
|
366
577
|
initAdvancedVSeed,
|
367
578
|
autoMeasures,
|
368
579
|
autoDimensions,
|
369
|
-
|
580
|
+
pivotAdapter([
|
581
|
+
reshapeTo2D1M
|
582
|
+
], [
|
583
|
+
pivotReshapeTo2D1M
|
584
|
+
]),
|
370
585
|
encodingXY,
|
371
586
|
vchartBaseConfig,
|
372
587
|
vchartTheme
|
@@ -375,7 +590,11 @@ const barAdvancedPipeline = [
|
|
375
590
|
initAdvancedVSeed,
|
376
591
|
autoMeasures,
|
377
592
|
autoDimensions,
|
378
|
-
|
593
|
+
pivotAdapter([
|
594
|
+
reshapeTo2D1M
|
595
|
+
], [
|
596
|
+
pivotReshapeTo2D1M
|
597
|
+
]),
|
379
598
|
encodingYX,
|
380
599
|
vchartBaseConfig,
|
381
600
|
vchartTheme
|
@@ -384,7 +603,11 @@ const barParallelAdvancedPipeline = [
|
|
384
603
|
initAdvancedVSeed,
|
385
604
|
autoMeasures,
|
386
605
|
autoDimensions,
|
387
|
-
|
606
|
+
pivotAdapter([
|
607
|
+
reshapeTo2D1M
|
608
|
+
], [
|
609
|
+
pivotReshapeTo2D1M
|
610
|
+
]),
|
388
611
|
encodingYX,
|
389
612
|
vchartBaseConfig,
|
390
613
|
vchartTheme
|
@@ -393,7 +616,11 @@ const barPercentAdvancedPipeline = [
|
|
393
616
|
initAdvancedVSeed,
|
394
617
|
autoMeasures,
|
395
618
|
autoDimensions,
|
396
|
-
|
619
|
+
pivotAdapter([
|
620
|
+
reshapeTo2D1M
|
621
|
+
], [
|
622
|
+
pivotReshapeTo2D1M
|
623
|
+
]),
|
397
624
|
encodingYX,
|
398
625
|
vchartBaseConfig,
|
399
626
|
vchartTheme
|
@@ -402,7 +629,11 @@ const columnAdvancedPipeline = [
|
|
402
629
|
initAdvancedVSeed,
|
403
630
|
autoMeasures,
|
404
631
|
autoDimensions,
|
405
|
-
|
632
|
+
pivotAdapter([
|
633
|
+
reshapeTo2D1M
|
634
|
+
], [
|
635
|
+
pivotReshapeTo2D1M
|
636
|
+
]),
|
406
637
|
encodingXY,
|
407
638
|
vchartBaseConfig,
|
408
639
|
vchartTheme
|
@@ -411,7 +642,11 @@ const columnParallelAdvancedPipeline = [
|
|
411
642
|
initAdvancedVSeed,
|
412
643
|
autoMeasures,
|
413
644
|
autoDimensions,
|
414
|
-
|
645
|
+
pivotAdapter([
|
646
|
+
reshapeTo2D1M
|
647
|
+
], [
|
648
|
+
pivotReshapeTo2D1M
|
649
|
+
]),
|
415
650
|
encodingXY,
|
416
651
|
vchartBaseConfig,
|
417
652
|
vchartTheme
|
@@ -420,7 +655,11 @@ const columnPercentAdvancedPipeline = [
|
|
420
655
|
initAdvancedVSeed,
|
421
656
|
autoMeasures,
|
422
657
|
autoDimensions,
|
423
|
-
|
658
|
+
pivotAdapter([
|
659
|
+
reshapeTo2D1M
|
660
|
+
], [
|
661
|
+
pivotReshapeTo2D1M
|
662
|
+
]),
|
424
663
|
encodingXY,
|
425
664
|
vchartBaseConfig,
|
426
665
|
vchartTheme
|
@@ -429,7 +668,11 @@ const areaAdvancedPipeline = [
|
|
429
668
|
initAdvancedVSeed,
|
430
669
|
autoMeasures,
|
431
670
|
autoDimensions,
|
432
|
-
|
671
|
+
pivotAdapter([
|
672
|
+
reshapeTo2D1M
|
673
|
+
], [
|
674
|
+
pivotReshapeTo2D1M
|
675
|
+
]),
|
433
676
|
encodingXY,
|
434
677
|
vchartBaseConfig,
|
435
678
|
vchartTheme
|
@@ -438,11 +681,28 @@ const areaPercentAdvancedPipeline = [
|
|
438
681
|
initAdvancedVSeed,
|
439
682
|
autoMeasures,
|
440
683
|
autoDimensions,
|
441
|
-
|
684
|
+
pivotAdapter([
|
685
|
+
reshapeTo2D1M
|
686
|
+
], [
|
687
|
+
pivotReshapeTo2D1M
|
688
|
+
]),
|
442
689
|
encodingXY,
|
443
690
|
vchartBaseConfig,
|
444
691
|
vchartTheme
|
445
692
|
];
|
693
|
+
const pieAdvancedPipeline = [
|
694
|
+
initAdvancedVSeed,
|
695
|
+
autoMeasures,
|
696
|
+
autoDimensions,
|
697
|
+
pivotAdapter([
|
698
|
+
reshapeTo1D1M
|
699
|
+
], [
|
700
|
+
pivotReshapeTo1D1M
|
701
|
+
]),
|
702
|
+
encodingPolar,
|
703
|
+
vchartBaseConfig,
|
704
|
+
vchartTheme
|
705
|
+
];
|
446
706
|
const dataset_dataset = (spec, context)=>{
|
447
707
|
const { advancedVSeed } = context;
|
448
708
|
return {
|
@@ -452,6 +712,28 @@ const dataset_dataset = (spec, context)=>{
|
|
452
712
|
}
|
453
713
|
};
|
454
714
|
};
|
715
|
+
const datasetPivot = (spec, context)=>{
|
716
|
+
const result = {
|
717
|
+
...spec
|
718
|
+
};
|
719
|
+
const { advancedVSeed } = context;
|
720
|
+
const { dataset, datasetReshapeInfo } = advancedVSeed;
|
721
|
+
const records = dataset.reduce((pre, cur, index)=>{
|
722
|
+
const id = datasetReshapeInfo[index].id;
|
723
|
+
pre[id] = cur;
|
724
|
+
return pre;
|
725
|
+
}, {});
|
726
|
+
return {
|
727
|
+
...result,
|
728
|
+
records: records
|
729
|
+
};
|
730
|
+
};
|
731
|
+
const datasetPivotPlaceholder = (spec)=>({
|
732
|
+
...spec,
|
733
|
+
data: {
|
734
|
+
id: 'placeholderDataId'
|
735
|
+
}
|
736
|
+
});
|
455
737
|
const initColumn = (spec, context)=>{
|
456
738
|
const result = {
|
457
739
|
...spec
|
@@ -488,7 +770,7 @@ const initBarParallel = (spec, context)=>{
|
|
488
770
|
};
|
489
771
|
const { advancedVSeed } = context;
|
490
772
|
const { encoding, datasetReshapeInfo } = advancedVSeed;
|
491
|
-
const { unfoldInfo } = datasetReshapeInfo;
|
773
|
+
const { unfoldInfo } = datasetReshapeInfo[0];
|
492
774
|
if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
|
493
775
|
result.type = 'bar';
|
494
776
|
result.direction = 'horizontal';
|
@@ -537,7 +819,7 @@ const initColumnParallel = (spec, context)=>{
|
|
537
819
|
};
|
538
820
|
const { advancedVSeed } = context;
|
539
821
|
const { encoding, datasetReshapeInfo } = advancedVSeed;
|
540
|
-
const { unfoldInfo } = datasetReshapeInfo;
|
822
|
+
const { unfoldInfo } = datasetReshapeInfo[0];
|
541
823
|
if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
|
542
824
|
result.type = 'bar';
|
543
825
|
result.direction = 'vertical';
|
@@ -550,6 +832,37 @@ const initColumnParallel = (spec, context)=>{
|
|
550
832
|
result.padding = 0;
|
551
833
|
return result;
|
552
834
|
};
|
835
|
+
const initPie = (spec, context)=>{
|
836
|
+
const result = {
|
837
|
+
...spec
|
838
|
+
};
|
839
|
+
const { advancedVSeed } = context;
|
840
|
+
const { encoding } = advancedVSeed;
|
841
|
+
if (!encoding[0].angle || !encoding[0].radius || !encoding[0].group) return result;
|
842
|
+
result.type = 'pie';
|
843
|
+
result.outerRadius = 0.8;
|
844
|
+
result.innerRadius = 0;
|
845
|
+
result.valueField = encoding[0].radius[0];
|
846
|
+
result.categoryField = encoding[0].angle[0];
|
847
|
+
result.seriesField = encoding[0].group[0];
|
848
|
+
result.padding = 0;
|
849
|
+
return result;
|
850
|
+
};
|
851
|
+
const initPivot = (spec)=>{
|
852
|
+
const result = {
|
853
|
+
...spec
|
854
|
+
};
|
855
|
+
return {
|
856
|
+
...result,
|
857
|
+
rows: [],
|
858
|
+
columns: [],
|
859
|
+
indicators: [],
|
860
|
+
records: [],
|
861
|
+
widthMode: 'adaptive',
|
862
|
+
heightMode: 'adaptive',
|
863
|
+
indicatorsAsCol: false
|
864
|
+
};
|
865
|
+
};
|
553
866
|
const xBand = (spec)=>{
|
554
867
|
const result = {
|
555
868
|
...spec
|
@@ -575,7 +888,9 @@ const xLinear = (spec)=>{
|
|
575
888
|
{
|
576
889
|
visible: true,
|
577
890
|
type: 'linear',
|
578
|
-
orient: 'bottom'
|
891
|
+
orient: 'bottom',
|
892
|
+
nice: true,
|
893
|
+
zero: true
|
579
894
|
}
|
580
895
|
];
|
581
896
|
return result;
|
@@ -605,7 +920,9 @@ const yLinear = (spec)=>{
|
|
605
920
|
{
|
606
921
|
visible: true,
|
607
922
|
type: 'linear',
|
608
|
-
orient: 'left'
|
923
|
+
orient: 'left',
|
924
|
+
nice: true,
|
925
|
+
zero: true
|
609
926
|
}
|
610
927
|
];
|
611
928
|
return result;
|
@@ -684,13 +1001,61 @@ const legend_legend = (spec, context)=>{
|
|
684
1001
|
};
|
685
1002
|
return result;
|
686
1003
|
};
|
1004
|
+
const pivotLegend = (spec, context)=>{
|
1005
|
+
const result = {
|
1006
|
+
...spec
|
1007
|
+
};
|
1008
|
+
const { advancedVSeed } = context;
|
1009
|
+
const baseConfig = advancedVSeed.baseConfig.vchart;
|
1010
|
+
if (!baseConfig || !baseConfig.legend) return result;
|
1011
|
+
const { datasetReshapeInfo } = advancedVSeed;
|
1012
|
+
const colorItems = unique(datasetReshapeInfo.flatMap((d)=>d.unfoldInfo.colorItems));
|
1013
|
+
const { legend, color } = baseConfig;
|
1014
|
+
const { enable } = legend;
|
1015
|
+
const { colorScheme } = color;
|
1016
|
+
const legends = {
|
1017
|
+
visible: enable,
|
1018
|
+
alignSelf: 'end',
|
1019
|
+
type: 'discrete',
|
1020
|
+
position: 'middle',
|
1021
|
+
data: colorItems.map((d, index)=>({
|
1022
|
+
label: d,
|
1023
|
+
shape: {
|
1024
|
+
symbolType: 'square',
|
1025
|
+
fill: colorScheme[index]
|
1026
|
+
}
|
1027
|
+
})),
|
1028
|
+
item: {
|
1029
|
+
background: {
|
1030
|
+
visible: true,
|
1031
|
+
state: {
|
1032
|
+
selectedHover: {
|
1033
|
+
fill: '#000000',
|
1034
|
+
fillOpacity: 0.05
|
1035
|
+
}
|
1036
|
+
}
|
1037
|
+
},
|
1038
|
+
label: {
|
1039
|
+
style: {
|
1040
|
+
fontSize: 12,
|
1041
|
+
fill: '#6F6F6F'
|
1042
|
+
}
|
1043
|
+
}
|
1044
|
+
},
|
1045
|
+
orient: 'bottom'
|
1046
|
+
};
|
1047
|
+
return {
|
1048
|
+
...result,
|
1049
|
+
legends
|
1050
|
+
};
|
1051
|
+
};
|
687
1052
|
const color_color = (spec, context)=>{
|
688
1053
|
const result = {
|
689
1054
|
...spec
|
690
1055
|
};
|
691
1056
|
const { advancedVSeed } = context;
|
692
1057
|
const { datasetReshapeInfo } = advancedVSeed;
|
693
|
-
const { unfoldInfo } = datasetReshapeInfo;
|
1058
|
+
const { unfoldInfo } = datasetReshapeInfo[0];
|
694
1059
|
const baseConfig = advancedVSeed.baseConfig.vchart;
|
695
1060
|
if (!baseConfig || !baseConfig.color) return result;
|
696
1061
|
const { color } = baseConfig;
|
@@ -703,7 +1068,230 @@ const color_color = (spec, context)=>{
|
|
703
1068
|
};
|
704
1069
|
return result;
|
705
1070
|
};
|
706
|
-
const
|
1071
|
+
const pivotAdapter_pivotAdapter = (pipeline, pivotPipeline)=>(spec, context)=>{
|
1072
|
+
const { vseed } = context;
|
1073
|
+
const usePivotChart = isPivotChart(vseed);
|
1074
|
+
if (usePivotChart) return execPipeline(pivotPipeline, context, spec);
|
1075
|
+
return execPipeline(pipeline, context, spec);
|
1076
|
+
};
|
1077
|
+
const pivotIndicators = (chartPipeline)=>(spec, context)=>{
|
1078
|
+
const result = {
|
1079
|
+
...spec
|
1080
|
+
};
|
1081
|
+
const { advancedVSeed } = context;
|
1082
|
+
const { measures, datasetReshapeInfo, encoding } = advancedVSeed;
|
1083
|
+
const colorItems = unique(datasetReshapeInfo.flatMap((d)=>d.unfoldInfo.colorItems));
|
1084
|
+
const indicators = datasetReshapeInfo.map((reshapeInfo, index)=>{
|
1085
|
+
const measure = measures?.find((d)=>d.id === reshapeInfo.id);
|
1086
|
+
const newEncoding = [
|
1087
|
+
encoding[index]
|
1088
|
+
];
|
1089
|
+
const newDatasetReshapeInfo = [
|
1090
|
+
{
|
1091
|
+
...reshapeInfo,
|
1092
|
+
unfoldInfo: {
|
1093
|
+
...reshapeInfo.unfoldInfo,
|
1094
|
+
colorItems
|
1095
|
+
}
|
1096
|
+
}
|
1097
|
+
];
|
1098
|
+
const newContext = {
|
1099
|
+
...context,
|
1100
|
+
advancedVSeed: {
|
1101
|
+
...advancedVSeed,
|
1102
|
+
datasetReshapeInfo: newDatasetReshapeInfo,
|
1103
|
+
encoding: newEncoding
|
1104
|
+
}
|
1105
|
+
};
|
1106
|
+
const chartSpec = execPipeline(chartPipeline, newContext, {});
|
1107
|
+
return {
|
1108
|
+
indicatorKey: reshapeInfo.id,
|
1109
|
+
title: measure?.alias,
|
1110
|
+
cellType: 'chart',
|
1111
|
+
chartModule: 'vchart',
|
1112
|
+
chartSpec: chartSpec,
|
1113
|
+
style: {
|
1114
|
+
padding: [
|
1115
|
+
1,
|
1116
|
+
1,
|
1117
|
+
0,
|
1118
|
+
1
|
1119
|
+
]
|
1120
|
+
}
|
1121
|
+
};
|
1122
|
+
});
|
1123
|
+
return {
|
1124
|
+
...result,
|
1125
|
+
indicators: indicators
|
1126
|
+
};
|
1127
|
+
};
|
1128
|
+
const pivotIndicators_pivotIndicatorsAsRow = (spec)=>{
|
1129
|
+
const result = {
|
1130
|
+
...spec
|
1131
|
+
};
|
1132
|
+
return {
|
1133
|
+
...result,
|
1134
|
+
indicatorsAsCol: false
|
1135
|
+
};
|
1136
|
+
};
|
1137
|
+
const pivotIndicators_pivotIndicatorsAsCol = (spec)=>{
|
1138
|
+
const result = {
|
1139
|
+
...spec
|
1140
|
+
};
|
1141
|
+
return {
|
1142
|
+
...result,
|
1143
|
+
indicatorsAsCol: true
|
1144
|
+
};
|
1145
|
+
};
|
1146
|
+
const pivotGridStyle = (spec)=>{
|
1147
|
+
const result = {
|
1148
|
+
...spec
|
1149
|
+
};
|
1150
|
+
const transparent = 'rgba(0,0,0,0)';
|
1151
|
+
return {
|
1152
|
+
...result,
|
1153
|
+
theme: {
|
1154
|
+
underlayBackgroundColor: transparent,
|
1155
|
+
bodyStyle: {
|
1156
|
+
borderColor: 'rgba(0,4,20,0.2)',
|
1157
|
+
borderLineWidth: [
|
1158
|
+
0,
|
1159
|
+
0,
|
1160
|
+
2,
|
1161
|
+
0
|
1162
|
+
],
|
1163
|
+
bgColor: transparent,
|
1164
|
+
padding: [
|
1165
|
+
0,
|
1166
|
+
0,
|
1167
|
+
1,
|
1168
|
+
0
|
1169
|
+
]
|
1170
|
+
},
|
1171
|
+
headerStyle: {
|
1172
|
+
borderColor: 'rgba(0,4,20,0.2)',
|
1173
|
+
fontSize: 12,
|
1174
|
+
color: '#333333',
|
1175
|
+
textAlign: 'center',
|
1176
|
+
borderLineWidth: 0,
|
1177
|
+
bgColor: transparent,
|
1178
|
+
hover: {
|
1179
|
+
cellBgColor: 'rgba(178,186,207, 0.2)'
|
1180
|
+
}
|
1181
|
+
},
|
1182
|
+
rowHeaderStyle: {
|
1183
|
+
borderColor: 'rgba(0,4,20,0.2)',
|
1184
|
+
fontSize: 12,
|
1185
|
+
color: '#333333',
|
1186
|
+
borderLineWidth: 0,
|
1187
|
+
bgColor: transparent,
|
1188
|
+
hover: {
|
1189
|
+
cellBgColor: 'rgba(178,186,207, 0.2)'
|
1190
|
+
}
|
1191
|
+
},
|
1192
|
+
cornerHeaderStyle: {
|
1193
|
+
borderColor: 'rgba(0,4,20,0.2)',
|
1194
|
+
textAlign: 'center',
|
1195
|
+
fontSize: 12,
|
1196
|
+
color: '#333333',
|
1197
|
+
fontWeight: 'bold',
|
1198
|
+
borderLineWidth: [
|
1199
|
+
0,
|
1200
|
+
0,
|
1201
|
+
0,
|
1202
|
+
0
|
1203
|
+
],
|
1204
|
+
bgColor: transparent,
|
1205
|
+
hover: {
|
1206
|
+
cellBgColor: ''
|
1207
|
+
}
|
1208
|
+
},
|
1209
|
+
cornerRightTopCellStyle: {
|
1210
|
+
borderColor: 'rgba(0,4,20,0.2)',
|
1211
|
+
borderLineWidth: 0,
|
1212
|
+
bgColor: transparent,
|
1213
|
+
hover: {
|
1214
|
+
cellBgColor: ''
|
1215
|
+
}
|
1216
|
+
},
|
1217
|
+
cornerLeftBottomCellStyle: {
|
1218
|
+
borderColor: 'rgba(0,4,20,0.2)',
|
1219
|
+
borderLineWidth: 0,
|
1220
|
+
bgColor: transparent,
|
1221
|
+
hover: {
|
1222
|
+
cellBgColor: ''
|
1223
|
+
}
|
1224
|
+
},
|
1225
|
+
cornerRightBottomCellStyle: {
|
1226
|
+
borderColor: 'rgba(0,4,20,0.2)',
|
1227
|
+
borderLineWidth: 0,
|
1228
|
+
bgColor: transparent,
|
1229
|
+
hover: {
|
1230
|
+
cellBgColor: ''
|
1231
|
+
}
|
1232
|
+
},
|
1233
|
+
rightFrozenStyle: {
|
1234
|
+
borderColor: 'rgba(0,4,20,0.2)',
|
1235
|
+
borderLineWidth: 0,
|
1236
|
+
bgColor: transparent,
|
1237
|
+
hover: {
|
1238
|
+
cellBgColor: 'rgba(178,186,207, 0.2)'
|
1239
|
+
}
|
1240
|
+
},
|
1241
|
+
bottomFrozenStyle: {
|
1242
|
+
borderColor: 'rgba(0,4,20,0.2)',
|
1243
|
+
borderLineWidth: 0,
|
1244
|
+
bgColor: transparent,
|
1245
|
+
hover: {
|
1246
|
+
cellBgColor: 'rgba(178,186,207, 0.2)'
|
1247
|
+
}
|
1248
|
+
},
|
1249
|
+
selectionStyle: {
|
1250
|
+
cellBgColor: '',
|
1251
|
+
cellBorderColor: ''
|
1252
|
+
},
|
1253
|
+
frameStyle: {
|
1254
|
+
borderLineWidth: 0,
|
1255
|
+
bgColor: transparent
|
1256
|
+
}
|
1257
|
+
}
|
1258
|
+
};
|
1259
|
+
};
|
1260
|
+
const pivotColumnDimensions = (spec, context)=>{
|
1261
|
+
const result = {
|
1262
|
+
...spec
|
1263
|
+
};
|
1264
|
+
const { advancedVSeed } = context;
|
1265
|
+
const { dimensions } = advancedVSeed;
|
1266
|
+
if (!dimensions) return result;
|
1267
|
+
const columnDimensions = dimensions.filter((dim)=>'columnDimension' === dim.location);
|
1268
|
+
const columns = columnDimensions.map((dim)=>({
|
1269
|
+
dimensionKey: dim.id,
|
1270
|
+
title: dim.alias || dim.id
|
1271
|
+
}));
|
1272
|
+
return {
|
1273
|
+
...result,
|
1274
|
+
columns: columns
|
1275
|
+
};
|
1276
|
+
};
|
1277
|
+
const pivotRowDimensions = (spec, context)=>{
|
1278
|
+
const result = {
|
1279
|
+
...spec
|
1280
|
+
};
|
1281
|
+
const { advancedVSeed } = context;
|
1282
|
+
const { dimensions } = advancedVSeed;
|
1283
|
+
if (!dimensions) return result;
|
1284
|
+
const rowDimensions = dimensions.filter((dim)=>'rowDimension' === dim.location);
|
1285
|
+
const rows = rowDimensions.map((dim)=>({
|
1286
|
+
dimensionKey: dim.id,
|
1287
|
+
title: dim.alias || dim.id
|
1288
|
+
}));
|
1289
|
+
return {
|
1290
|
+
...result,
|
1291
|
+
rows: rows
|
1292
|
+
};
|
1293
|
+
};
|
1294
|
+
const line = [
|
707
1295
|
initLine,
|
708
1296
|
color_color,
|
709
1297
|
background_backgroundColor,
|
@@ -714,7 +1302,29 @@ const lineSpecPipeline = [
|
|
714
1302
|
tooltip_tooltip,
|
715
1303
|
legend_legend
|
716
1304
|
];
|
717
|
-
const
|
1305
|
+
const pivotLine = [
|
1306
|
+
initPivot,
|
1307
|
+
pivotGridStyle,
|
1308
|
+
pivotIndicators_pivotIndicatorsAsRow,
|
1309
|
+
datasetPivot,
|
1310
|
+
pivotIndicators([
|
1311
|
+
initLine,
|
1312
|
+
color_color,
|
1313
|
+
background_backgroundColor,
|
1314
|
+
datasetPivotPlaceholder,
|
1315
|
+
xBand,
|
1316
|
+
yLinear,
|
1317
|
+
label_label,
|
1318
|
+
tooltip_tooltip
|
1319
|
+
]),
|
1320
|
+
pivotRowDimensions,
|
1321
|
+
pivotColumnDimensions,
|
1322
|
+
pivotLegend
|
1323
|
+
];
|
1324
|
+
const lineSpecPipeline = [
|
1325
|
+
pivotAdapter_pivotAdapter(line, pivotLine)
|
1326
|
+
];
|
1327
|
+
const column = [
|
718
1328
|
initColumn,
|
719
1329
|
color_color,
|
720
1330
|
background_backgroundColor,
|
@@ -725,7 +1335,29 @@ const columnSpecPipeline = [
|
|
725
1335
|
tooltip_tooltip,
|
726
1336
|
legend_legend
|
727
1337
|
];
|
728
|
-
const
|
1338
|
+
const pivotColumn = [
|
1339
|
+
initPivot,
|
1340
|
+
pivotGridStyle,
|
1341
|
+
pivotIndicators_pivotIndicatorsAsRow,
|
1342
|
+
datasetPivot,
|
1343
|
+
pivotIndicators([
|
1344
|
+
initColumn,
|
1345
|
+
color_color,
|
1346
|
+
background_backgroundColor,
|
1347
|
+
datasetPivotPlaceholder,
|
1348
|
+
xBand,
|
1349
|
+
yLinear,
|
1350
|
+
label_label,
|
1351
|
+
tooltip_tooltip
|
1352
|
+
]),
|
1353
|
+
pivotRowDimensions,
|
1354
|
+
pivotColumnDimensions,
|
1355
|
+
pivotLegend
|
1356
|
+
];
|
1357
|
+
const columnSpecPipeline = [
|
1358
|
+
pivotAdapter_pivotAdapter(column, pivotColumn)
|
1359
|
+
];
|
1360
|
+
const columnParallel = [
|
729
1361
|
initColumnParallel,
|
730
1362
|
color_color,
|
731
1363
|
background_backgroundColor,
|
@@ -736,7 +1368,29 @@ const columnParallelSpecPipeline = [
|
|
736
1368
|
tooltip_tooltip,
|
737
1369
|
legend_legend
|
738
1370
|
];
|
739
|
-
const
|
1371
|
+
const pivotColumnParallel = [
|
1372
|
+
initPivot,
|
1373
|
+
pivotGridStyle,
|
1374
|
+
pivotIndicators_pivotIndicatorsAsRow,
|
1375
|
+
datasetPivot,
|
1376
|
+
pivotIndicators([
|
1377
|
+
initColumnParallel,
|
1378
|
+
color_color,
|
1379
|
+
background_backgroundColor,
|
1380
|
+
datasetPivotPlaceholder,
|
1381
|
+
xBand,
|
1382
|
+
yLinear,
|
1383
|
+
label_label,
|
1384
|
+
tooltip_tooltip
|
1385
|
+
]),
|
1386
|
+
pivotRowDimensions,
|
1387
|
+
pivotColumnDimensions,
|
1388
|
+
pivotLegend
|
1389
|
+
];
|
1390
|
+
const columnParallelSpecPipeline = [
|
1391
|
+
pivotAdapter_pivotAdapter(columnParallel, pivotColumnParallel)
|
1392
|
+
];
|
1393
|
+
const columnPercent = [
|
740
1394
|
initColumn,
|
741
1395
|
color_color,
|
742
1396
|
background_backgroundColor,
|
@@ -748,7 +1402,30 @@ const columnPercentSpecPipeline = [
|
|
748
1402
|
tooltip_tooltip,
|
749
1403
|
legend_legend
|
750
1404
|
];
|
751
|
-
const
|
1405
|
+
const pivotColumnPercent = [
|
1406
|
+
initPivot,
|
1407
|
+
pivotGridStyle,
|
1408
|
+
pivotIndicators_pivotIndicatorsAsRow,
|
1409
|
+
datasetPivot,
|
1410
|
+
pivotIndicators([
|
1411
|
+
initColumn,
|
1412
|
+
color_color,
|
1413
|
+
percent,
|
1414
|
+
background_backgroundColor,
|
1415
|
+
datasetPivotPlaceholder,
|
1416
|
+
xBand,
|
1417
|
+
yLinear,
|
1418
|
+
label_label,
|
1419
|
+
tooltip_tooltip
|
1420
|
+
]),
|
1421
|
+
pivotRowDimensions,
|
1422
|
+
pivotColumnDimensions,
|
1423
|
+
pivotLegend
|
1424
|
+
];
|
1425
|
+
const columnPercentSpecPipeline = [
|
1426
|
+
pivotAdapter_pivotAdapter(columnPercent, pivotColumnPercent)
|
1427
|
+
];
|
1428
|
+
const bar = [
|
752
1429
|
initBar,
|
753
1430
|
color_color,
|
754
1431
|
background_backgroundColor,
|
@@ -759,7 +1436,29 @@ const barSpecPipeline = [
|
|
759
1436
|
tooltip_tooltip,
|
760
1437
|
legend_legend
|
761
1438
|
];
|
762
|
-
const
|
1439
|
+
const pivotBar = [
|
1440
|
+
initPivot,
|
1441
|
+
pivotGridStyle,
|
1442
|
+
pivotIndicators_pivotIndicatorsAsCol,
|
1443
|
+
datasetPivot,
|
1444
|
+
pivotIndicators([
|
1445
|
+
initBar,
|
1446
|
+
color_color,
|
1447
|
+
background_backgroundColor,
|
1448
|
+
datasetPivotPlaceholder,
|
1449
|
+
yBand,
|
1450
|
+
label_label,
|
1451
|
+
label_label,
|
1452
|
+
tooltip_tooltip
|
1453
|
+
]),
|
1454
|
+
pivotRowDimensions,
|
1455
|
+
pivotColumnDimensions,
|
1456
|
+
pivotLegend
|
1457
|
+
];
|
1458
|
+
const barSpecPipeline = [
|
1459
|
+
pivotAdapter_pivotAdapter(bar, pivotBar)
|
1460
|
+
];
|
1461
|
+
const barParallel = [
|
763
1462
|
initBarParallel,
|
764
1463
|
color_color,
|
765
1464
|
background_backgroundColor,
|
@@ -770,7 +1469,29 @@ const barParallelSpecPipeline = [
|
|
770
1469
|
tooltip_tooltip,
|
771
1470
|
legend_legend
|
772
1471
|
];
|
773
|
-
const
|
1472
|
+
const pivotBarParallel = [
|
1473
|
+
initPivot,
|
1474
|
+
pivotGridStyle,
|
1475
|
+
pivotIndicators_pivotIndicatorsAsCol,
|
1476
|
+
datasetPivot,
|
1477
|
+
pivotIndicators([
|
1478
|
+
initBarParallel,
|
1479
|
+
color_color,
|
1480
|
+
background_backgroundColor,
|
1481
|
+
datasetPivotPlaceholder,
|
1482
|
+
yBand,
|
1483
|
+
xLinear,
|
1484
|
+
label_label,
|
1485
|
+
tooltip_tooltip
|
1486
|
+
]),
|
1487
|
+
pivotRowDimensions,
|
1488
|
+
pivotColumnDimensions,
|
1489
|
+
pivotLegend
|
1490
|
+
];
|
1491
|
+
const barParallelSpecPipeline = [
|
1492
|
+
pivotAdapter_pivotAdapter(barParallel, pivotBarParallel)
|
1493
|
+
];
|
1494
|
+
const barPercent = [
|
774
1495
|
initBar,
|
775
1496
|
color_color,
|
776
1497
|
background_backgroundColor,
|
@@ -782,7 +1503,30 @@ const barPercentSpecPipeline = [
|
|
782
1503
|
tooltip_tooltip,
|
783
1504
|
legend_legend
|
784
1505
|
];
|
785
|
-
const
|
1506
|
+
const pivotBarPercent = [
|
1507
|
+
initPivot,
|
1508
|
+
pivotGridStyle,
|
1509
|
+
pivotIndicators_pivotIndicatorsAsCol,
|
1510
|
+
datasetPivot,
|
1511
|
+
pivotIndicators([
|
1512
|
+
initBar,
|
1513
|
+
color_color,
|
1514
|
+
background_backgroundColor,
|
1515
|
+
percent,
|
1516
|
+
datasetPivotPlaceholder,
|
1517
|
+
yBand,
|
1518
|
+
xLinear,
|
1519
|
+
label_label,
|
1520
|
+
tooltip_tooltip
|
1521
|
+
]),
|
1522
|
+
pivotRowDimensions,
|
1523
|
+
pivotColumnDimensions,
|
1524
|
+
pivotLegend
|
1525
|
+
];
|
1526
|
+
const barPercentSpecPipeline = [
|
1527
|
+
pivotAdapter_pivotAdapter(barPercent, pivotBarPercent)
|
1528
|
+
];
|
1529
|
+
const area_area = [
|
786
1530
|
initArea,
|
787
1531
|
color_color,
|
788
1532
|
background_backgroundColor,
|
@@ -794,7 +1538,30 @@ const areaSpecPipeline = [
|
|
794
1538
|
tooltip_tooltip,
|
795
1539
|
legend_legend
|
796
1540
|
];
|
797
|
-
const
|
1541
|
+
const pivotArea = [
|
1542
|
+
initPivot,
|
1543
|
+
pivotGridStyle,
|
1544
|
+
pivotIndicators_pivotIndicatorsAsRow,
|
1545
|
+
datasetPivot,
|
1546
|
+
pivotIndicators([
|
1547
|
+
initArea,
|
1548
|
+
color_color,
|
1549
|
+
background_backgroundColor,
|
1550
|
+
stack,
|
1551
|
+
datasetPivotPlaceholder,
|
1552
|
+
xBand,
|
1553
|
+
yLinear,
|
1554
|
+
label_label,
|
1555
|
+
tooltip_tooltip
|
1556
|
+
]),
|
1557
|
+
pivotRowDimensions,
|
1558
|
+
pivotColumnDimensions,
|
1559
|
+
pivotLegend
|
1560
|
+
];
|
1561
|
+
const areaSpecPipeline = [
|
1562
|
+
pivotAdapter_pivotAdapter(area_area, pivotArea)
|
1563
|
+
];
|
1564
|
+
const areaPercent = [
|
798
1565
|
initArea,
|
799
1566
|
color_color,
|
800
1567
|
background_backgroundColor,
|
@@ -806,15 +1573,58 @@ const areaPercentSpecPipeline = [
|
|
806
1573
|
tooltip_tooltip,
|
807
1574
|
legend_legend
|
808
1575
|
];
|
809
|
-
const
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
1576
|
+
const pivotAreaPercent = [
|
1577
|
+
initPivot,
|
1578
|
+
pivotGridStyle,
|
1579
|
+
pivotIndicators_pivotIndicatorsAsRow,
|
1580
|
+
datasetPivot,
|
1581
|
+
pivotIndicators([
|
1582
|
+
initArea,
|
1583
|
+
color_color,
|
1584
|
+
background_backgroundColor,
|
1585
|
+
percent,
|
1586
|
+
datasetPivotPlaceholder,
|
1587
|
+
xBand,
|
1588
|
+
yLinear,
|
1589
|
+
label_label,
|
1590
|
+
tooltip_tooltip
|
1591
|
+
]),
|
1592
|
+
pivotRowDimensions,
|
1593
|
+
pivotColumnDimensions,
|
1594
|
+
pivotLegend
|
1595
|
+
];
|
1596
|
+
const areaPercentSpecPipeline = [
|
1597
|
+
pivotAdapter_pivotAdapter(areaPercent, pivotAreaPercent)
|
1598
|
+
];
|
1599
|
+
const pie = [
|
1600
|
+
initPie,
|
1601
|
+
color_color,
|
1602
|
+
background_backgroundColor,
|
1603
|
+
dataset_dataset,
|
1604
|
+
label_label,
|
1605
|
+
tooltip_tooltip,
|
1606
|
+
legend_legend
|
1607
|
+
];
|
1608
|
+
const pivotPie = [
|
1609
|
+
initPivot,
|
1610
|
+
pivotGridStyle,
|
1611
|
+
pivotIndicators_pivotIndicatorsAsRow,
|
1612
|
+
datasetPivot,
|
1613
|
+
pivotIndicators([
|
1614
|
+
initPie,
|
1615
|
+
color_color,
|
1616
|
+
background_backgroundColor,
|
1617
|
+
datasetPivotPlaceholder,
|
1618
|
+
label_label,
|
1619
|
+
tooltip_tooltip
|
1620
|
+
]),
|
1621
|
+
pivotRowDimensions,
|
1622
|
+
pivotColumnDimensions,
|
1623
|
+
pivotLegend
|
1624
|
+
];
|
1625
|
+
const pieSpecPipeline = [
|
1626
|
+
pivotAdapter_pivotAdapter(pie, pivotPie)
|
1627
|
+
];
|
818
1628
|
const buildAdvanced = (builder)=>{
|
819
1629
|
const { chartType } = builder.vseed;
|
820
1630
|
if (!chartType) throw new Error('chartType is nil in buildAdvanced');
|
@@ -922,6 +1732,10 @@ const registerBarParallel = ()=>{
|
|
922
1732
|
Builder._advancedPipelineMap.barParallel = barParallelAdvancedPipeline;
|
923
1733
|
Builder._specPipelineMap.barParallel = barParallelSpecPipeline;
|
924
1734
|
};
|
1735
|
+
const registerPie = ()=>{
|
1736
|
+
Builder._advancedPipelineMap.pie = pieAdvancedPipeline;
|
1737
|
+
Builder._specPipelineMap.pie = pieSpecPipeline;
|
1738
|
+
};
|
925
1739
|
const darkTheme = ()=>({
|
926
1740
|
baseConfig: {
|
927
1741
|
vtable: {
|
@@ -1007,6 +1821,7 @@ const all_registerAll = ()=>{
|
|
1007
1821
|
registerBarPercent();
|
1008
1822
|
registerArea();
|
1009
1823
|
registerAreaPercent();
|
1824
|
+
registerPie();
|
1010
1825
|
registerLightTheme();
|
1011
1826
|
registerDarkTheme();
|
1012
1827
|
};
|
@@ -1083,10 +1898,11 @@ const zUnfoldInfo = z.object({
|
|
1083
1898
|
colorItems: z.array(z.string()),
|
1084
1899
|
groupName: z.string()
|
1085
1900
|
});
|
1086
|
-
const zDatasetReshapeInfo = z.object({
|
1901
|
+
const zDatasetReshapeInfo = z.array(z.object({
|
1902
|
+
id: z.string(),
|
1087
1903
|
foldInfo: zFoldInfo,
|
1088
1904
|
unfoldInfo: zUnfoldInfo
|
1089
|
-
});
|
1905
|
+
}));
|
1090
1906
|
const zEncoding = z.array(z.object({
|
1091
1907
|
x: z.array(z.string()).optional(),
|
1092
1908
|
y: z.array(z.string()).optional(),
|
@@ -1129,6 +1945,6 @@ const zCustomThemeConfig = z.object({
|
|
1129
1945
|
});
|
1130
1946
|
const zCustomTheme = z.record(z.string(), zCustomThemeConfig).optional();
|
1131
1947
|
const zTheme = z.string();
|
1132
|
-
export { Builder, areaAdvancedPipeline, areaPercentAdvancedPipeline, areaPercentSpecPipeline, areaSpecPipeline, barAdvancedPipeline, barParallelAdvancedPipeline, barParallelSpecPipeline, barPercentAdvancedPipeline, barPercentSpecPipeline, barSpecPipeline, columnAdvancedPipeline, columnParallelAdvancedPipeline, columnParallelSpecPipeline, columnPercentAdvancedPipeline, columnPercentSpecPipeline, columnSpecPipeline, darkTheme,
|
1948
|
+
export { Builder, areaAdvancedPipeline, areaPercentAdvancedPipeline, areaPercentSpecPipeline, areaSpecPipeline, barAdvancedPipeline, barParallelAdvancedPipeline, barParallelSpecPipeline, barPercentAdvancedPipeline, barPercentSpecPipeline, barSpecPipeline, columnAdvancedPipeline, columnParallelAdvancedPipeline, columnParallelSpecPipeline, columnPercentAdvancedPipeline, columnPercentSpecPipeline, columnSpecPipeline, darkTheme, dataReshapeFor1D1M, dataReshapeFor2D1M, execPipeline, foldMeasures, isPivotChart, isVChart, isVTable, lightTheme, lineAdvancedPipeline, lineSpecPipeline, pieAdvancedPipeline, pieSpecPipeline, all_registerAll as registerAll, registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerColumn, registerColumnParallel, registerColumnPercent, registerCustomTheme, registerDarkTheme, registerLightTheme, registerLine, unfoldDimensions, zBackgroundColor, zBaseConfig, zChartType, zColor, zCustomTheme, zCustomThemeConfig, zDataset, zDatasetReshapeInfo, zDatum, zDimension, zDimensions, zEncoding, zFoldInfo, zLabel, zLegend, zMeasure, zMeasureGroup, zMeasures, zTheme, zTooltip, zUnfoldInfo };
|
1133
1949
|
|
1134
1950
|
//# sourceMappingURL=index.js.map
|