@visactor/vseed 0.0.5 → 0.0.6

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.
Files changed (40) hide show
  1. package/dist/builder/builder/build.d.ts +2 -2
  2. package/dist/builder/builder/buildSpec.d.ts +2 -2
  3. package/dist/builder/builder/builder.d.ts +8 -5
  4. package/dist/dataReshape/constant.d.ts +1 -1
  5. package/dist/dataReshape/dataReshapeFor1D1M.d.ts +6 -1
  6. package/dist/dataReshape/dataReshapeFor2D1M.d.ts +6 -1
  7. package/dist/index.cjs +759 -348
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.js +518 -107
  10. package/dist/index.js.map +1 -1
  11. package/dist/pipeline/advanced/pipes/encoding/{encodingCartesian.d.ts → encodingXY.d.ts} +0 -1
  12. package/dist/pipeline/advanced/pipes/encoding/encodingYX.d.ts +2 -0
  13. package/dist/pipeline/advanced/pipes/encoding/index.d.ts +2 -1
  14. package/dist/pipeline/advanced/pipes/index.d.ts +1 -0
  15. package/dist/pipeline/advanced/pipes/pivot/index.d.ts +1 -0
  16. package/dist/pipeline/advanced/pipes/pivot/pivotAdapter.d.ts +2 -0
  17. package/dist/pipeline/advanced/pipes/reshape/index.d.ts +2 -0
  18. package/dist/pipeline/advanced/pipes/reshape/pivotReshapeTo1D1M.d.ts +8 -0
  19. package/dist/pipeline/advanced/pipes/reshape/pivotReshapeTo2D1M.d.ts +8 -0
  20. package/dist/pipeline/spec/pipeline/area.d.ts +1 -2
  21. package/dist/pipeline/spec/pipeline/areaPercent.d.ts +1 -2
  22. package/dist/pipeline/spec/pipeline/column.d.ts +1 -2
  23. package/dist/pipeline/spec/pipes/dataset/datasetPivot.d.ts +3 -0
  24. package/dist/pipeline/spec/pipes/dataset/index.d.ts +1 -0
  25. package/dist/pipeline/spec/pipes/index.d.ts +1 -0
  26. package/dist/pipeline/spec/pipes/init/index.d.ts +1 -0
  27. package/dist/pipeline/spec/pipes/init/pivot.d.ts +4 -0
  28. package/dist/pipeline/spec/pipes/legend/index.d.ts +1 -0
  29. package/dist/pipeline/spec/pipes/legend/pivotLegend.d.ts +2 -0
  30. package/dist/pipeline/spec/pipes/pivotChart/index.d.ts +2 -0
  31. package/dist/pipeline/spec/pipes/pivotChart/pivotAdapter.d.ts +2 -0
  32. package/dist/pipeline/spec/pipes/pivotChart/pivotIndicators.d.ts +4 -0
  33. package/dist/types/advancedVSeed.d.ts +3 -2
  34. package/dist/types/builder/builder.d.ts +3 -3
  35. package/dist/types/builder/index.d.ts +1 -0
  36. package/dist/types/builder/spec.d.ts +3 -0
  37. package/dist/types/pipeline/spec/spec.d.ts +2 -2
  38. package/dist/types/properties/datasetReshapeInfo/datasetReshapeInfo.d.ts +3 -2
  39. package/dist/types/properties/datasetReshapeInfo/index.d.ts +1 -1
  40. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -49,7 +49,7 @@ __webpack_require__.d(__webpack_exports__, {
49
49
  lightTheme: ()=>lightTheme,
50
50
  registerColumnParallel: ()=>registerColumnParallel,
51
51
  zCustomTheme: ()=>zCustomTheme,
52
- dataReshapeFor1D1M: ()=>dataReshapeFor1D1M,
52
+ dataReshapeFor1D1M: ()=>dataReshapeFor1D1M_dataReshapeFor1D1M,
53
53
  registerArea: ()=>registerArea,
54
54
  zDataset: ()=>zDataset,
55
55
  barPercentAdvancedPipeline: ()=>barPercentAdvancedPipeline,
@@ -87,38 +87,13 @@ __webpack_require__.d(__webpack_exports__, {
87
87
  barParallelSpecPipeline: ()=>barParallelSpecPipeline,
88
88
  registerBar: ()=>registerBar
89
89
  });
90
- const FoldMeasureName = '__MeaName__';
91
- const FoldMeasureValue = '__MeaValue__';
92
- const FoldMeasureId = '__MeaId__';
93
- const FoldDimensionGroup = '__DimGroup__';
90
+ const constant_FoldMeasureName = '__MeaName__';
91
+ const constant_FoldMeasureValue = '__MeaValue__';
92
+ const constant_FoldMeasureId = '__MeaId__';
93
+ const constant_UnfoldDimensionGroup = '__DimGroup__';
94
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)=>{
95
+ const external_remeda_namespaceObject = require("remeda");
96
+ const unfoldDimensions = (dataset, dimensions, measures, unfoldStartIndex = 0, foldGroupName = constant_UnfoldDimensionGroup, dimensionsSeparator = Separator)=>{
122
97
  if (unfoldStartIndex < 0 || unfoldStartIndex >= dimensions.length) throw new Error('unfoldStartIndex is out of range');
123
98
  const dimensionsToBeUnfolded = dimensions.slice(unfoldStartIndex);
124
99
  const unfoldInfo = {
@@ -139,13 +114,39 @@ const unfoldDimensions = (dataset, dimensions, measures, unfoldStartIndex = 0, f
139
114
  datum[foldGroupName] = colorItem;
140
115
  colorItems.push(colorItem);
141
116
  }
142
- unfoldInfo.colorItems = colorItems;
117
+ unfoldInfo.colorItems = (0, external_remeda_namespaceObject.unique)(colorItems);
143
118
  return {
144
119
  dataset,
145
120
  unfoldInfo
146
121
  };
147
122
  };
148
123
  const generateDimGroupName = (dimensionsToBeGrouped, datum, dimensionsSeparator)=>dimensionsToBeGrouped.map((dim)=>String(datum[dim.id])).join(dimensionsSeparator);
124
+ const foldMeasures = (dataset, measures, measureId = constant_FoldMeasureId, measureName = constant_FoldMeasureName, measureValue = constant_FoldMeasureValue)=>{
125
+ const foldInfo = {
126
+ measureId,
127
+ measureName,
128
+ measureValue,
129
+ foldMap: {}
130
+ };
131
+ const result = new Array(dataset.length * measures.length);
132
+ let index = 0;
133
+ for(let i = 0; i < dataset.length; i++)for(let j = 0; j < measures.length; j++){
134
+ const datum = {
135
+ ...dataset[i]
136
+ };
137
+ const measure = measures[j];
138
+ const { id, alias } = measure;
139
+ datum[measureId] = id;
140
+ datum[measureName] = alias;
141
+ datum[measureValue] = dataset[i][id];
142
+ foldInfo.foldMap[id] = alias;
143
+ result[index++] = datum;
144
+ }
145
+ return {
146
+ dataset: result,
147
+ foldInfo
148
+ };
149
+ };
149
150
  const emptyReshapeResult = {
150
151
  dataset: [],
151
152
  foldInfo: {
@@ -159,27 +160,85 @@ const emptyReshapeResult = {
159
160
  groupName: ''
160
161
  }
161
162
  };
162
- const dataReshapeFor2D1M = (dataset, dimensions, measures)=>{
163
+ const dataReshapeFor2D1M = (dataset, dimensions, measures, options)=>{
164
+ const { foldMeasureId = constant_FoldMeasureId, foldMeasureName = constant_FoldMeasureName, foldMeasureValue = constant_FoldMeasureValue, unfoldDimensionGroup = constant_UnfoldDimensionGroup } = options || {};
163
165
  if (0 === dimensions.length && 0 === measures.length) return emptyReshapeResult;
164
- const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, FoldMeasureId, FoldMeasureName, FoldMeasureValue);
166
+ const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, foldMeasureId, foldMeasureName, foldMeasureValue);
165
167
  if (0 === dimensions.length) {
166
168
  const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
167
169
  {
168
- id: FoldMeasureId,
170
+ id: foldMeasureId,
169
171
  alias: "\u6307\u6807Id",
170
172
  location: 'dimension'
171
173
  },
172
174
  {
173
- id: FoldMeasureName,
175
+ id: foldMeasureName,
176
+ alias: "\u6307\u6807\u540D\u79F0",
177
+ location: 'dimension'
178
+ }
179
+ ], [
180
+ {
181
+ id: foldMeasureValue,
182
+ alias: "\u6307\u6807\u503C"
183
+ }
184
+ ], 1, unfoldDimensionGroup);
185
+ return {
186
+ dataset: finalDataset,
187
+ foldInfo,
188
+ unfoldInfo
189
+ };
190
+ }
191
+ {
192
+ const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
193
+ ...dimensions,
194
+ {
195
+ id: foldMeasureName,
196
+ alias: "\u6307\u6807\u540D\u79F0",
197
+ location: 'dimension'
198
+ }
199
+ ], [
200
+ {
201
+ id: foldMeasureValue,
202
+ alias: "\u6307\u6807\u503C"
203
+ }
204
+ ], 1, unfoldDimensionGroup);
205
+ return {
206
+ dataset: finalDataset,
207
+ foldInfo,
208
+ unfoldInfo
209
+ };
210
+ }
211
+ };
212
+ const dataReshapeFor1D1M_emptyReshapeResult = {
213
+ dataset: [],
214
+ foldInfo: {
215
+ foldMap: {},
216
+ measureId: '',
217
+ measureName: '',
218
+ measureValue: ''
219
+ },
220
+ unfoldInfo: {
221
+ groupName: '',
222
+ colorItems: []
223
+ }
224
+ };
225
+ const dataReshapeFor1D1M_dataReshapeFor1D1M = (dataset, dimensions, measures, options)=>{
226
+ const { foldMeasureId = constant_FoldMeasureId, foldMeasureName = constant_FoldMeasureName, foldMeasureValue = constant_FoldMeasureValue, unfoldDimensionGroup = constant_UnfoldDimensionGroup } = options || {};
227
+ if (0 === dimensions.length && 0 === measures.length) return dataReshapeFor1D1M_emptyReshapeResult;
228
+ const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, foldMeasureId, foldMeasureName, foldMeasureValue);
229
+ if (0 === dimensions.length) {
230
+ const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
231
+ {
232
+ id: foldMeasureName,
174
233
  alias: "\u6307\u6807\u540D\u79F0",
175
234
  location: 'dimension'
176
235
  }
177
236
  ], [
178
237
  {
179
- id: FoldMeasureValue,
238
+ id: foldMeasureValue,
180
239
  alias: "\u6307\u6807\u503C"
181
240
  }
182
- ], 1, FoldDimensionGroup);
241
+ ], 0, unfoldDimensionGroup);
183
242
  return {
184
243
  dataset: finalDataset,
185
244
  foldInfo,
@@ -190,16 +249,16 @@ const dataReshapeFor2D1M = (dataset, dimensions, measures)=>{
190
249
  const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
191
250
  ...dimensions,
192
251
  {
193
- id: FoldMeasureName,
252
+ id: foldMeasureName,
194
253
  alias: "\u6307\u6807\u540D\u79F0",
195
254
  location: 'dimension'
196
255
  }
197
256
  ], [
198
257
  {
199
- id: FoldMeasureValue,
258
+ id: foldMeasureValue,
200
259
  alias: "\u6307\u6807\u503C"
201
260
  }
202
- ], 1, FoldDimensionGroup);
261
+ ], 0, unfoldDimensionGroup);
203
262
  return {
204
263
  dataset: finalDataset,
205
264
  foldInfo,
@@ -220,42 +279,86 @@ const reshapeTo2D1M = (advancedVSeed, context)=>{
220
279
  return {
221
280
  ...result,
222
281
  dataset: newDatasets,
223
- datasetReshapeInfo: {
224
- foldInfo,
225
- unfoldInfo
226
- },
282
+ datasetReshapeInfo: [
283
+ {
284
+ id: '2D1M',
285
+ foldInfo,
286
+ unfoldInfo
287
+ }
288
+ ],
227
289
  dimensions,
228
290
  measures
229
291
  };
230
292
  };
293
+ const pivotReshapeTo2D1M = (advancedVSeed, context)=>{
294
+ const result = {
295
+ ...advancedVSeed
296
+ };
297
+ const { vseed } = context;
298
+ const { dataset } = vseed;
299
+ const { dimensions, measures } = advancedVSeed;
300
+ if (!measures || !dimensions) return result;
301
+ const measureGroups = [];
302
+ if (measures) measures.forEach((measure)=>{
303
+ if (measure.children && measure.children.length > 0) measureGroups.push(measure);
304
+ });
305
+ const newDatasets = [];
306
+ const datasetReshapeInfo = [];
307
+ measureGroups.forEach((measureGroup)=>{
308
+ const measures = measureGroup.children;
309
+ if (!measures) return;
310
+ const groupId = measureGroup.id;
311
+ const { dataset: newSubDataset, foldInfo, unfoldInfo } = dataReshapeFor2D1M(dataset, dimensions, measures, {
312
+ foldMeasureId: constant_FoldMeasureId + groupId,
313
+ foldMeasureName: constant_FoldMeasureName + groupId,
314
+ foldMeasureValue: constant_FoldMeasureValue + groupId,
315
+ unfoldDimensionGroup: constant_UnfoldDimensionGroup + groupId
316
+ });
317
+ const reshapeInfo = {
318
+ id: groupId,
319
+ foldInfo,
320
+ unfoldInfo
321
+ };
322
+ newDatasets.push(newSubDataset);
323
+ datasetReshapeInfo.push(reshapeInfo);
324
+ });
325
+ return {
326
+ ...result,
327
+ dataset: newDatasets,
328
+ datasetReshapeInfo: datasetReshapeInfo
329
+ };
330
+ };
231
331
  const encodingXY = (advancedVSeed)=>{
232
332
  const result = {
233
333
  ...advancedVSeed
234
334
  };
235
335
  const { datasetReshapeInfo, dimensions } = advancedVSeed;
236
336
  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
- ];
337
+ const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
338
+ const { foldInfo, unfoldInfo } = cur;
339
+ const isSingleDimension = 0 === dimensions.length;
340
+ const x = [
341
+ isSingleDimension ? foldInfo.measureName : dimensions[0].id
342
+ ];
343
+ const y = [
344
+ foldInfo.measureValue
345
+ ];
346
+ const group = [
347
+ isSingleDimension ? foldInfo.measureName : unfoldInfo.groupName
348
+ ];
349
+ const color = [
350
+ foldInfo.measureName
351
+ ];
352
+ return [
353
+ ...prev,
354
+ {
355
+ x,
356
+ y,
357
+ group,
358
+ color
359
+ }
360
+ ];
361
+ }, []);
259
362
  return {
260
363
  ...result,
261
364
  encoding
@@ -267,28 +370,31 @@ const encodingYX = (advancedVSeed)=>{
267
370
  };
268
371
  const { datasetReshapeInfo, dimensions } = advancedVSeed;
269
372
  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
- ];
373
+ const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
374
+ const { foldInfo, unfoldInfo } = cur;
375
+ const isSingleDimension = 0 === dimensions.length;
376
+ const y = [
377
+ isSingleDimension ? foldInfo.measureName : dimensions[0].id
378
+ ];
379
+ const x = [
380
+ foldInfo.measureValue
381
+ ];
382
+ const group = [
383
+ isSingleDimension ? foldInfo.measureName : unfoldInfo.groupName
384
+ ];
385
+ const color = [
386
+ foldInfo.measureName
387
+ ];
388
+ return [
389
+ ...prev,
390
+ {
391
+ x,
392
+ y,
393
+ group,
394
+ color
395
+ }
396
+ ];
397
+ }, []);
292
398
  return {
293
399
  ...result,
294
400
  encoding
@@ -358,7 +464,6 @@ const autoDimensions = (advancedVSeed, context)=>{
358
464
  }));
359
465
  return result;
360
466
  };
361
- const external_remeda_namespaceObject = require("remeda");
362
467
  const vchartBaseConfig = (advancedVSeed, context)=>{
363
468
  const { vseed } = context;
364
469
  const result = {
@@ -394,11 +499,25 @@ const vchartTheme = (advancedVSeed, context)=>{
394
499
  };
395
500
  return result;
396
501
  };
502
+ const execPipeline = (pipeline, context, initialValue = {})=>{
503
+ const result = pipeline.reduce((prev, cur)=>cur(prev, context), initialValue);
504
+ return result;
505
+ };
506
+ const pivotAdapter = (pipeline, pivotPipeline)=>(advancedVSeed, context)=>{
507
+ const { vseed } = context;
508
+ const { measures } = vseed;
509
+ if (measures && measures.find((measure)=>measure && measure.children)) return execPipeline(pivotPipeline, context, advancedVSeed);
510
+ return execPipeline(pipeline, context, advancedVSeed);
511
+ };
397
512
  const lineAdvancedPipeline = [
398
513
  initAdvancedVSeed,
399
514
  autoMeasures,
400
515
  autoDimensions,
401
- reshapeTo2D1M,
516
+ pivotAdapter([
517
+ reshapeTo2D1M
518
+ ], [
519
+ pivotReshapeTo2D1M
520
+ ]),
402
521
  encodingXY,
403
522
  vchartBaseConfig,
404
523
  vchartTheme
@@ -407,7 +526,11 @@ const barAdvancedPipeline = [
407
526
  initAdvancedVSeed,
408
527
  autoMeasures,
409
528
  autoDimensions,
410
- reshapeTo2D1M,
529
+ pivotAdapter([
530
+ reshapeTo2D1M
531
+ ], [
532
+ pivotReshapeTo2D1M
533
+ ]),
411
534
  encodingYX,
412
535
  vchartBaseConfig,
413
536
  vchartTheme
@@ -416,7 +539,11 @@ const barParallelAdvancedPipeline = [
416
539
  initAdvancedVSeed,
417
540
  autoMeasures,
418
541
  autoDimensions,
419
- reshapeTo2D1M,
542
+ pivotAdapter([
543
+ reshapeTo2D1M
544
+ ], [
545
+ pivotReshapeTo2D1M
546
+ ]),
420
547
  encodingYX,
421
548
  vchartBaseConfig,
422
549
  vchartTheme
@@ -425,7 +552,11 @@ const barPercentAdvancedPipeline = [
425
552
  initAdvancedVSeed,
426
553
  autoMeasures,
427
554
  autoDimensions,
428
- reshapeTo2D1M,
555
+ pivotAdapter([
556
+ reshapeTo2D1M
557
+ ], [
558
+ pivotReshapeTo2D1M
559
+ ]),
429
560
  encodingYX,
430
561
  vchartBaseConfig,
431
562
  vchartTheme
@@ -434,7 +565,11 @@ const columnAdvancedPipeline = [
434
565
  initAdvancedVSeed,
435
566
  autoMeasures,
436
567
  autoDimensions,
437
- reshapeTo2D1M,
568
+ pivotAdapter([
569
+ reshapeTo2D1M
570
+ ], [
571
+ pivotReshapeTo2D1M
572
+ ]),
438
573
  encodingXY,
439
574
  vchartBaseConfig,
440
575
  vchartTheme
@@ -443,7 +578,11 @@ const columnParallelAdvancedPipeline = [
443
578
  initAdvancedVSeed,
444
579
  autoMeasures,
445
580
  autoDimensions,
446
- reshapeTo2D1M,
581
+ pivotAdapter([
582
+ reshapeTo2D1M
583
+ ], [
584
+ pivotReshapeTo2D1M
585
+ ]),
447
586
  encodingXY,
448
587
  vchartBaseConfig,
449
588
  vchartTheme
@@ -452,7 +591,11 @@ const columnPercentAdvancedPipeline = [
452
591
  initAdvancedVSeed,
453
592
  autoMeasures,
454
593
  autoDimensions,
455
- reshapeTo2D1M,
594
+ pivotAdapter([
595
+ reshapeTo2D1M
596
+ ], [
597
+ pivotReshapeTo2D1M
598
+ ]),
456
599
  encodingXY,
457
600
  vchartBaseConfig,
458
601
  vchartTheme
@@ -461,7 +604,11 @@ const areaAdvancedPipeline = [
461
604
  initAdvancedVSeed,
462
605
  autoMeasures,
463
606
  autoDimensions,
464
- reshapeTo2D1M,
607
+ pivotAdapter([
608
+ reshapeTo2D1M
609
+ ], [
610
+ pivotReshapeTo2D1M
611
+ ]),
465
612
  encodingXY,
466
613
  vchartBaseConfig,
467
614
  vchartTheme
@@ -470,19 +617,54 @@ const areaPercentAdvancedPipeline = [
470
617
  initAdvancedVSeed,
471
618
  autoMeasures,
472
619
  autoDimensions,
473
- reshapeTo2D1M,
620
+ pivotAdapter([
621
+ reshapeTo2D1M
622
+ ], [
623
+ pivotReshapeTo2D1M
624
+ ]),
474
625
  encodingXY,
475
626
  vchartBaseConfig,
476
627
  vchartTheme
477
628
  ];
478
- const initLine = (spec, context)=>{
629
+ const dataset_dataset = (spec, context)=>{
630
+ const { advancedVSeed } = context;
631
+ return {
632
+ ...spec,
633
+ data: {
634
+ values: advancedVSeed.dataset
635
+ }
636
+ };
637
+ };
638
+ const datasetPivot = (spec, context)=>{
639
+ const result = {
640
+ ...spec
641
+ };
642
+ const { advancedVSeed } = context;
643
+ const { dataset, datasetReshapeInfo } = advancedVSeed;
644
+ const records = dataset.reduce((pre, cur, index)=>{
645
+ const id = datasetReshapeInfo[index].id;
646
+ pre[id] = cur;
647
+ return pre;
648
+ }, {});
649
+ return {
650
+ ...result,
651
+ records: records
652
+ };
653
+ };
654
+ const datasetPivotPlaceholder = (spec)=>({
655
+ ...spec,
656
+ data: {
657
+ id: 'placeholderDataId'
658
+ }
659
+ });
660
+ const initColumn = (spec, context)=>{
479
661
  const result = {
480
662
  ...spec
481
663
  };
482
664
  const { advancedVSeed } = context;
483
665
  const { encoding } = advancedVSeed;
484
666
  if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
485
- result.type = 'line';
667
+ result.type = 'bar';
486
668
  result.direction = 'vertical';
487
669
  result.xField = encoding[0].x[0];
488
670
  result.yField = encoding[0].y[0];
@@ -490,45 +672,102 @@ const initLine = (spec, context)=>{
490
672
  result.padding = 0;
491
673
  return result;
492
674
  };
493
- const color_color = (spec, context)=>{
675
+ const initBar = (spec, context)=>{
494
676
  const result = {
495
677
  ...spec
496
678
  };
497
679
  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
680
+ const { encoding } = advancedVSeed;
681
+ if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
682
+ result.type = 'bar';
683
+ result.direction = 'horizontal';
684
+ result.yField = encoding[0].y?.[0];
685
+ result.xField = encoding[0].x?.[0];
686
+ result.seriesField = encoding[0].group?.[0];
687
+ result.padding = 0;
688
+ return result;
689
+ };
690
+ const initBarParallel = (spec, context)=>{
691
+ const result = {
692
+ ...spec
509
693
  };
694
+ const { advancedVSeed } = context;
695
+ const { encoding, datasetReshapeInfo } = advancedVSeed;
696
+ const { unfoldInfo } = datasetReshapeInfo[0];
697
+ if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
698
+ result.type = 'bar';
699
+ result.direction = 'horizontal';
700
+ result.yField = [
701
+ encoding[0].y[0],
702
+ unfoldInfo.groupName
703
+ ];
704
+ result.xField = encoding[0].x[0];
705
+ result.seriesField = encoding[0].group[0];
706
+ result.padding = 0;
510
707
  return result;
511
708
  };
512
- const background_backgroundColor = (spec, context)=>{
709
+ const initArea = (spec, context)=>{
513
710
  const result = {
514
711
  ...spec
515
712
  };
516
713
  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
714
+ const { encoding } = advancedVSeed;
715
+ if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
716
+ result.type = 'area';
717
+ result.direction = 'vertical';
718
+ result.xField = encoding[0].x[0];
719
+ result.yField = encoding[0].y[0];
720
+ result.seriesField = encoding[0].group[0];
721
+ result.padding = 0;
722
+ return result;
723
+ };
724
+ const initLine = (spec, context)=>{
725
+ const result = {
726
+ ...spec
523
727
  };
728
+ const { advancedVSeed } = context;
729
+ const { encoding } = advancedVSeed;
730
+ if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
731
+ result.type = 'line';
732
+ result.direction = 'vertical';
733
+ result.xField = encoding[0].x[0];
734
+ result.yField = encoding[0].y[0];
735
+ result.seriesField = encoding[0].group[0];
736
+ result.padding = 0;
737
+ return result;
524
738
  };
525
- const dataset_dataset = (spec, context)=>{
739
+ const initColumnParallel = (spec, context)=>{
740
+ const result = {
741
+ ...spec
742
+ };
526
743
  const { advancedVSeed } = context;
744
+ const { encoding, datasetReshapeInfo } = advancedVSeed;
745
+ const { unfoldInfo } = datasetReshapeInfo[0];
746
+ if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
747
+ result.type = 'bar';
748
+ result.direction = 'vertical';
749
+ result.xField = [
750
+ encoding[0].x[0],
751
+ unfoldInfo.groupName
752
+ ];
753
+ result.yField = encoding[0].y[0];
754
+ result.seriesField = encoding[0].group[0];
755
+ result.padding = 0;
756
+ return result;
757
+ };
758
+ const initPivot = (spec)=>{
759
+ const result = {
760
+ ...spec
761
+ };
527
762
  return {
528
- ...spec,
529
- data: {
530
- values: advancedVSeed.dataset
531
- }
763
+ ...result,
764
+ rows: [],
765
+ columns: [],
766
+ indicators: [],
767
+ records: [],
768
+ widthMode: 'adaptive',
769
+ heightMode: 'adaptive',
770
+ indicatorsAsCol: false
532
771
  };
533
772
  };
534
773
  const xBand = (spec)=>{
@@ -546,7 +785,7 @@ const xBand = (spec)=>{
546
785
  ];
547
786
  return result;
548
787
  };
549
- const yLinear = (spec)=>{
788
+ const xLinear = (spec)=>{
550
789
  const result = {
551
790
  ...spec
552
791
  };
@@ -556,11 +795,88 @@ const yLinear = (spec)=>{
556
795
  {
557
796
  visible: true,
558
797
  type: 'linear',
798
+ orient: 'bottom',
799
+ nice: true,
800
+ zero: true
801
+ }
802
+ ];
803
+ return result;
804
+ };
805
+ const yBand = (spec)=>{
806
+ const result = {
807
+ ...spec
808
+ };
809
+ if (!result.axes) result.axes = [];
810
+ result.axes = [
811
+ ...result.axes,
812
+ {
813
+ visible: true,
814
+ type: 'band',
559
815
  orient: 'left'
560
816
  }
561
817
  ];
562
818
  return result;
563
819
  };
820
+ const yLinear = (spec)=>{
821
+ const result = {
822
+ ...spec
823
+ };
824
+ if (!result.axes) result.axes = [];
825
+ result.axes = [
826
+ ...result.axes,
827
+ {
828
+ visible: true,
829
+ type: 'linear',
830
+ orient: 'left',
831
+ nice: true,
832
+ zero: true
833
+ }
834
+ ];
835
+ return result;
836
+ };
837
+ const percent = (spec, context)=>{
838
+ const result = {
839
+ ...spec
840
+ };
841
+ result.percent = true;
842
+ return result;
843
+ };
844
+ const stack = (spec, context)=>{
845
+ const result = {
846
+ ...spec
847
+ };
848
+ result.stack = true;
849
+ return result;
850
+ };
851
+ const background_backgroundColor = (spec, context)=>{
852
+ const result = {
853
+ ...spec
854
+ };
855
+ const { advancedVSeed } = context;
856
+ const { baseConfig } = advancedVSeed;
857
+ if (!baseConfig?.vchart) return result;
858
+ const { backgroundColor } = baseConfig.vchart;
859
+ return {
860
+ ...result,
861
+ background: backgroundColor
862
+ };
863
+ };
864
+ const defaultTooltip = {
865
+ enable: true
866
+ };
867
+ const tooltip_tooltip = (spec, context)=>{
868
+ const result = {
869
+ ...spec
870
+ };
871
+ const { advancedVSeed } = context;
872
+ const baseConfig = advancedVSeed.baseConfig.vchart;
873
+ const { tooltip = defaultTooltip } = baseConfig;
874
+ const { enable } = tooltip;
875
+ result.tooltip = {
876
+ visible: enable
877
+ };
878
+ return result;
879
+ };
564
880
  const label_label = (spec, context)=>{
565
881
  const result = {
566
882
  ...spec
@@ -575,40 +891,146 @@ const label_label = (spec, context)=>{
575
891
  };
576
892
  return result;
577
893
  };
578
- const defaultTooltip = {
579
- enable: true
580
- };
581
- const tooltip_tooltip = (spec, context)=>{
894
+ const defaultLegend = {
895
+ enable: true
896
+ };
897
+ const legend_legend = (spec, context)=>{
898
+ const result = {
899
+ ...spec
900
+ };
901
+ const { advancedVSeed } = context;
902
+ const baseConfig = advancedVSeed.baseConfig.vchart;
903
+ if (!baseConfig || !baseConfig.legend) return result;
904
+ const { legend = defaultLegend } = baseConfig;
905
+ const { enable } = legend;
906
+ result.legends = {
907
+ visible: enable
908
+ };
909
+ return result;
910
+ };
911
+ const pivotLegend = (spec, context)=>{
912
+ const result = {
913
+ ...spec
914
+ };
915
+ const { advancedVSeed } = context;
916
+ const baseConfig = advancedVSeed.baseConfig.vchart;
917
+ if (!baseConfig || !baseConfig.legend) return result;
918
+ const { datasetReshapeInfo } = advancedVSeed;
919
+ const colorItems = (0, external_remeda_namespaceObject.unique)(datasetReshapeInfo.flatMap((d)=>d.unfoldInfo.colorItems));
920
+ const { legend, color } = baseConfig;
921
+ const { enable } = legend;
922
+ const { colorScheme } = color;
923
+ result.legends = {
924
+ visible: enable,
925
+ alignSelf: 'end',
926
+ type: 'discrete',
927
+ position: 'start',
928
+ data: colorItems.map((d, index)=>({
929
+ label: d,
930
+ shape: {
931
+ symbolType: 'square',
932
+ fill: colorScheme[index]
933
+ }
934
+ })),
935
+ orient: 'bottom'
936
+ };
937
+ return result;
938
+ };
939
+ const color_color = (spec, context)=>{
940
+ const result = {
941
+ ...spec
942
+ };
943
+ const { advancedVSeed } = context;
944
+ const { datasetReshapeInfo } = advancedVSeed;
945
+ const { unfoldInfo } = datasetReshapeInfo[0];
946
+ const baseConfig = advancedVSeed.baseConfig.vchart;
947
+ if (!baseConfig || !baseConfig.color) return result;
948
+ const { color } = baseConfig;
949
+ const { colorScheme, colorMapping } = color;
950
+ result.color = {
951
+ type: 'ordinal',
952
+ domain: unfoldInfo.colorItems,
953
+ range: colorScheme,
954
+ specified: colorMapping
955
+ };
956
+ return result;
957
+ };
958
+ const pivotAdapter_pivotAdapter = (pipeline, pivotPipeline)=>(spec, context)=>{
959
+ const { advancedVSeed } = context;
960
+ const { measures } = advancedVSeed;
961
+ if (measures && measures.find((measure)=>measure && measure.children)) return execPipeline(pivotPipeline, context, spec);
962
+ return execPipeline(pipeline, context, spec);
963
+ };
964
+ const pivotIndicators = (chartPipeline)=>(spec, context)=>{
965
+ const result = {
966
+ ...spec
967
+ };
968
+ const { advancedVSeed } = context;
969
+ const { measures, datasetReshapeInfo, encoding } = advancedVSeed;
970
+ const colorItems = (0, external_remeda_namespaceObject.unique)(datasetReshapeInfo.flatMap((d)=>d.unfoldInfo.colorItems));
971
+ const indicators = datasetReshapeInfo.map((reshapeInfo, index)=>{
972
+ const measure = measures?.find((d)=>d.id === reshapeInfo.id);
973
+ const newEncoding = [
974
+ encoding[index]
975
+ ];
976
+ const newDatasetReshapeInfo = [
977
+ {
978
+ ...reshapeInfo,
979
+ unfoldInfo: {
980
+ ...reshapeInfo.unfoldInfo,
981
+ colorItems
982
+ }
983
+ }
984
+ ];
985
+ const newContext = {
986
+ ...context,
987
+ advancedVSeed: {
988
+ ...advancedVSeed,
989
+ datasetReshapeInfo: newDatasetReshapeInfo,
990
+ encoding: newEncoding
991
+ }
992
+ };
993
+ const chartSpec = execPipeline(chartPipeline, newContext, {});
994
+ return {
995
+ indicatorKey: reshapeInfo.id,
996
+ title: measure?.alias,
997
+ cellType: 'chart',
998
+ chartModule: 'vchart',
999
+ chartSpec: chartSpec,
1000
+ style: {
1001
+ padding: [
1002
+ 1,
1003
+ 1,
1004
+ 0,
1005
+ 1
1006
+ ]
1007
+ }
1008
+ };
1009
+ });
1010
+ return {
1011
+ ...result,
1012
+ indicators: indicators
1013
+ };
1014
+ };
1015
+ const pivotIndicators_pivotIndicatorsAsRow = (spec)=>{
582
1016
  const result = {
583
1017
  ...spec
584
1018
  };
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
1019
+ return {
1020
+ ...result,
1021
+ indicatorsAsCol: false
591
1022
  };
592
- return result;
593
- };
594
- const defaultLegend = {
595
- enable: true
596
1023
  };
597
- const legend_legend = (spec, context)=>{
1024
+ const pivotIndicators_pivotIndicatorsAsCol = (spec)=>{
598
1025
  const result = {
599
1026
  ...spec
600
1027
  };
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
1028
+ return {
1029
+ ...result,
1030
+ indicatorsAsCol: true
608
1031
  };
609
- return result;
610
1032
  };
611
- const lineSpecPipeline = [
1033
+ const line = [
612
1034
  initLine,
613
1035
  color_color,
614
1036
  background_backgroundColor,
@@ -619,22 +1041,26 @@ const lineSpecPipeline = [
619
1041
  tooltip_tooltip,
620
1042
  legend_legend
621
1043
  ];
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 = [
1044
+ const pivotLine = [
1045
+ initPivot,
1046
+ pivotIndicators_pivotIndicatorsAsRow,
1047
+ datasetPivot,
1048
+ pivotIndicators([
1049
+ initLine,
1050
+ color_color,
1051
+ background_backgroundColor,
1052
+ datasetPivotPlaceholder,
1053
+ xBand,
1054
+ yLinear,
1055
+ label_label,
1056
+ tooltip_tooltip
1057
+ ]),
1058
+ pivotLegend
1059
+ ];
1060
+ const lineSpecPipeline = [
1061
+ pivotAdapter_pivotAdapter(line, pivotLine)
1062
+ ];
1063
+ const column = [
638
1064
  initColumn,
639
1065
  color_color,
640
1066
  background_backgroundColor,
@@ -645,26 +1071,26 @@ const columnSpecPipeline = [
645
1071
  tooltip_tooltip,
646
1072
  legend_legend
647
1073
  ];
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 = [
1074
+ const pivotColumn = [
1075
+ initPivot,
1076
+ pivotIndicators_pivotIndicatorsAsRow,
1077
+ datasetPivot,
1078
+ pivotIndicators([
1079
+ initColumn,
1080
+ color_color,
1081
+ background_backgroundColor,
1082
+ datasetPivotPlaceholder,
1083
+ xBand,
1084
+ yLinear,
1085
+ label_label,
1086
+ tooltip_tooltip
1087
+ ]),
1088
+ pivotLegend
1089
+ ];
1090
+ const columnSpecPipeline = [
1091
+ pivotAdapter_pivotAdapter(column, pivotColumn)
1092
+ ];
1093
+ const columnParallel = [
668
1094
  initColumnParallel,
669
1095
  color_color,
670
1096
  background_backgroundColor,
@@ -675,14 +1101,26 @@ const columnParallelSpecPipeline = [
675
1101
  tooltip_tooltip,
676
1102
  legend_legend
677
1103
  ];
678
- const percent = (spec, context)=>{
679
- const result = {
680
- ...spec
681
- };
682
- result.percent = true;
683
- return result;
684
- };
685
- const columnPercentSpecPipeline = [
1104
+ const pivotColumnParallel = [
1105
+ initPivot,
1106
+ pivotIndicators_pivotIndicatorsAsRow,
1107
+ datasetPivot,
1108
+ pivotIndicators([
1109
+ initColumnParallel,
1110
+ color_color,
1111
+ background_backgroundColor,
1112
+ datasetPivotPlaceholder,
1113
+ xBand,
1114
+ yLinear,
1115
+ label_label,
1116
+ tooltip_tooltip
1117
+ ]),
1118
+ pivotLegend
1119
+ ];
1120
+ const columnParallelSpecPipeline = [
1121
+ pivotAdapter_pivotAdapter(columnParallel, pivotColumnParallel)
1122
+ ];
1123
+ const columnPercent = [
686
1124
  initColumn,
687
1125
  color_color,
688
1126
  background_backgroundColor,
@@ -694,52 +1132,27 @@ const columnPercentSpecPipeline = [
694
1132
  tooltip_tooltip,
695
1133
  legend_legend
696
1134
  ];
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 = [
1135
+ const pivotColumnPercent = [
1136
+ initPivot,
1137
+ pivotIndicators_pivotIndicatorsAsRow,
1138
+ datasetPivot,
1139
+ pivotIndicators([
1140
+ initColumn,
1141
+ color_color,
1142
+ percent,
1143
+ background_backgroundColor,
1144
+ datasetPivotPlaceholder,
1145
+ xBand,
1146
+ yLinear,
1147
+ label_label,
1148
+ tooltip_tooltip
1149
+ ]),
1150
+ pivotLegend
1151
+ ];
1152
+ const columnPercentSpecPipeline = [
1153
+ pivotAdapter_pivotAdapter(columnPercent, pivotColumnPercent)
1154
+ ];
1155
+ const bar = [
743
1156
  initBar,
744
1157
  color_color,
745
1158
  background_backgroundColor,
@@ -750,26 +1163,26 @@ const barSpecPipeline = [
750
1163
  tooltip_tooltip,
751
1164
  legend_legend
752
1165
  ];
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 = [
1166
+ const pivotBar = [
1167
+ initPivot,
1168
+ pivotIndicators_pivotIndicatorsAsCol,
1169
+ datasetPivot,
1170
+ pivotIndicators([
1171
+ initBar,
1172
+ color_color,
1173
+ background_backgroundColor,
1174
+ datasetPivotPlaceholder,
1175
+ yBand,
1176
+ label_label,
1177
+ label_label,
1178
+ tooltip_tooltip
1179
+ ]),
1180
+ pivotLegend
1181
+ ];
1182
+ const barSpecPipeline = [
1183
+ pivotAdapter_pivotAdapter(bar, pivotBar)
1184
+ ];
1185
+ const barParallel = [
773
1186
  initBarParallel,
774
1187
  color_color,
775
1188
  background_backgroundColor,
@@ -780,7 +1193,26 @@ const barParallelSpecPipeline = [
780
1193
  tooltip_tooltip,
781
1194
  legend_legend
782
1195
  ];
783
- const barPercentSpecPipeline = [
1196
+ const pivotBarParallel = [
1197
+ initPivot,
1198
+ pivotIndicators_pivotIndicatorsAsCol,
1199
+ datasetPivot,
1200
+ pivotIndicators([
1201
+ initBarParallel,
1202
+ color_color,
1203
+ background_backgroundColor,
1204
+ datasetPivotPlaceholder,
1205
+ yBand,
1206
+ xLinear,
1207
+ label_label,
1208
+ tooltip_tooltip
1209
+ ]),
1210
+ pivotLegend
1211
+ ];
1212
+ const barParallelSpecPipeline = [
1213
+ pivotAdapter_pivotAdapter(barParallel, pivotBarParallel)
1214
+ ];
1215
+ const barPercent = [
784
1216
  initBar,
785
1217
  color_color,
786
1218
  background_backgroundColor,
@@ -792,29 +1224,27 @@ const barPercentSpecPipeline = [
792
1224
  tooltip_tooltip,
793
1225
  legend_legend
794
1226
  ];
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 = [
1227
+ const pivotBarPercent = [
1228
+ initPivot,
1229
+ pivotIndicators_pivotIndicatorsAsCol,
1230
+ datasetPivot,
1231
+ pivotIndicators([
1232
+ initBar,
1233
+ color_color,
1234
+ background_backgroundColor,
1235
+ percent,
1236
+ datasetPivotPlaceholder,
1237
+ yBand,
1238
+ xLinear,
1239
+ label_label,
1240
+ tooltip_tooltip
1241
+ ]),
1242
+ pivotLegend
1243
+ ];
1244
+ const barPercentSpecPipeline = [
1245
+ pivotAdapter_pivotAdapter(barPercent, pivotBarPercent)
1246
+ ];
1247
+ const area_area = [
818
1248
  initArea,
819
1249
  color_color,
820
1250
  background_backgroundColor,
@@ -826,7 +1256,27 @@ const areaSpecPipeline = [
826
1256
  tooltip_tooltip,
827
1257
  legend_legend
828
1258
  ];
829
- const areaPercentSpecPipeline = [
1259
+ const pivotArea = [
1260
+ initPivot,
1261
+ pivotIndicators_pivotIndicatorsAsRow,
1262
+ datasetPivot,
1263
+ pivotIndicators([
1264
+ initArea,
1265
+ color_color,
1266
+ background_backgroundColor,
1267
+ stack,
1268
+ datasetPivotPlaceholder,
1269
+ xBand,
1270
+ yLinear,
1271
+ label_label,
1272
+ tooltip_tooltip
1273
+ ]),
1274
+ pivotLegend
1275
+ ];
1276
+ const areaSpecPipeline = [
1277
+ pivotAdapter_pivotAdapter(area_area, pivotArea)
1278
+ ];
1279
+ const areaPercent = [
830
1280
  initArea,
831
1281
  color_color,
832
1282
  background_backgroundColor,
@@ -838,10 +1288,26 @@ const areaPercentSpecPipeline = [
838
1288
  tooltip_tooltip,
839
1289
  legend_legend
840
1290
  ];
841
- const execPipeline = (pipeline, context, initialValue = {})=>{
842
- const result = pipeline.reduce((prev, cur)=>cur(prev, context), initialValue);
843
- return result;
844
- };
1291
+ const pivotAreaPercent = [
1292
+ initPivot,
1293
+ pivotIndicators_pivotIndicatorsAsRow,
1294
+ datasetPivot,
1295
+ pivotIndicators([
1296
+ initArea,
1297
+ color_color,
1298
+ background_backgroundColor,
1299
+ percent,
1300
+ datasetPivotPlaceholder,
1301
+ xBand,
1302
+ yLinear,
1303
+ label_label,
1304
+ tooltip_tooltip
1305
+ ]),
1306
+ pivotLegend
1307
+ ];
1308
+ const areaPercentSpecPipeline = [
1309
+ pivotAdapter_pivotAdapter(areaPercent, pivotAreaPercent)
1310
+ ];
845
1311
  const isVTable = (chartType)=>[
846
1312
  'table',
847
1313
  'pivotTable'
@@ -1116,10 +1582,11 @@ const zUnfoldInfo = external_zod_namespaceObject.z.object({
1116
1582
  colorItems: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
1117
1583
  groupName: external_zod_namespaceObject.z.string()
1118
1584
  });
1119
- const zDatasetReshapeInfo = external_zod_namespaceObject.z.object({
1585
+ const zDatasetReshapeInfo = external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.object({
1586
+ id: external_zod_namespaceObject.z.string(),
1120
1587
  foldInfo: zFoldInfo,
1121
1588
  unfoldInfo: zUnfoldInfo
1122
- });
1589
+ }));
1123
1590
  const zEncoding = external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.object({
1124
1591
  x: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
1125
1592
  y: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
@@ -1162,62 +1629,6 @@ const zCustomThemeConfig = external_zod_namespaceObject.z.object({
1162
1629
  });
1163
1630
  const zCustomTheme = external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), zCustomThemeConfig).optional();
1164
1631
  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
1632
  exports.Builder = __webpack_exports__.Builder;
1222
1633
  exports.areaAdvancedPipeline = __webpack_exports__.areaAdvancedPipeline;
1223
1634
  exports.areaPercentAdvancedPipeline = __webpack_exports__.areaPercentAdvancedPipeline;