@visactor/vseed 0.0.33 → 0.0.34

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 (68) hide show
  1. package/dist/builder/builder/buildAdvanced.d.ts +1 -1
  2. package/dist/builder/builder/buildSpec.d.ts +1 -1
  3. package/dist/builder/builder/builder.d.ts +2794 -4887
  4. package/dist/builder/register/chartType/dualAxis.d.ts +1 -0
  5. package/dist/builder/register/chartType/index.d.ts +12 -11
  6. package/dist/dataReshape/constant.d.ts +3 -1
  7. package/dist/index.cjs +1352 -202
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.js +1279 -156
  10. package/dist/index.js.map +1 -1
  11. package/dist/pipeline/advanced/chart/pipeline/dualAxis.d.ts +2 -0
  12. package/dist/pipeline/advanced/chart/pipeline/index.d.ts +1 -0
  13. package/dist/pipeline/advanced/chart/pipes/config/dualAxis.d.ts +2 -0
  14. package/dist/pipeline/advanced/chart/pipes/config/index.d.ts +1 -0
  15. package/dist/pipeline/advanced/chart/pipes/encoding/encodingAreaRange.d.ts +2 -0
  16. package/dist/pipeline/advanced/chart/pipes/encoding/index.d.ts +1 -0
  17. package/dist/pipeline/advanced/chart/pipes/init/autoDualMeasures.d.ts +2 -0
  18. package/dist/pipeline/advanced/chart/pipes/reshape/index.d.ts +2 -0
  19. package/dist/pipeline/advanced/chart/pipes/reshape/pivotReshapeTo2D2M.d.ts +8 -0
  20. package/dist/pipeline/advanced/chart/pipes/reshape/reshapeTo2D2M.d.ts +8 -0
  21. package/dist/pipeline/spec/chart/pipeline/dualAxis.d.ts +2 -0
  22. package/dist/pipeline/spec/chart/pipeline/index.d.ts +1 -0
  23. package/dist/pipeline/spec/chart/pipes/axes/index.d.ts +2 -0
  24. package/dist/pipeline/spec/chart/pipes/axes/yLinearPrimary.d.ts +2 -0
  25. package/dist/pipeline/spec/chart/pipes/axes/yLinearSecondary.d.ts +2 -0
  26. package/dist/pipeline/spec/chart/pipes/dataset/datasetDualAxis.d.ts +3 -0
  27. package/dist/pipeline/spec/chart/pipes/dataset/index.d.ts +1 -0
  28. package/dist/pipeline/spec/chart/pipes/dual/dualChartType.d.ts +3 -0
  29. package/dist/pipeline/spec/chart/pipes/dual/index.d.ts +1 -0
  30. package/dist/pipeline/spec/chart/pipes/index.d.ts +1 -0
  31. package/dist/pipeline/spec/chart/pipes/init/index.d.ts +1 -0
  32. package/dist/pipeline/spec/chart/pipes/init/initDualAxis.d.ts +3 -0
  33. package/dist/pipeline/spec/chart/pipes/label/index.d.ts +1 -0
  34. package/dist/pipeline/spec/chart/pipes/label/labelDualAxis.d.ts +3 -0
  35. package/dist/pipeline/spec/chart/pipes/tooltip/index.d.ts +1 -0
  36. package/dist/pipeline/spec/chart/pipes/tooltip/tooltipDualAxis.d.ts +3 -0
  37. package/dist/pipeline/utils/chatType.d.ts +2 -2
  38. package/dist/pipeline/utils/measures/depth.d.ts +8 -0
  39. package/dist/pipeline/utils/measures/index.d.ts +1 -0
  40. package/dist/types/advancedVSeed.d.ts +507 -14
  41. package/dist/types/builder/builder.d.ts +16 -15
  42. package/dist/types/chartType/area/area.d.ts +0 -1494
  43. package/dist/types/chartType/area/index.d.ts +2 -1
  44. package/dist/types/chartType/area/zArea.d.ts +1494 -0
  45. package/dist/types/chartType/areaPercent/areaPercent.d.ts +0 -1494
  46. package/dist/types/chartType/areaPercent/index.d.ts +2 -1
  47. package/dist/types/chartType/areaPercent/zAreaPercent.d.ts +1494 -0
  48. package/dist/types/chartType/areaRange/areaRange.d.ts +0 -1433
  49. package/dist/types/chartType/areaRange/index.d.ts +2 -1
  50. package/dist/types/chartType/areaRange/zAreaRange.d.ts +1433 -0
  51. package/dist/types/chartType/dualAxis/dualAxis.d.ts +123 -23
  52. package/dist/types/chartType/dualAxis/index.d.ts +1 -0
  53. package/dist/types/chartType/dualAxis/zDualAxis.d.ts +1963 -0
  54. package/dist/types/chartType/index.d.ts +1 -1
  55. package/dist/types/properties/chartType/dualChartType.d.ts +22 -0
  56. package/dist/types/properties/chartType/index.d.ts +2 -0
  57. package/dist/types/properties/config/config.d.ts +493 -7
  58. package/dist/types/properties/datasetReshapeInfo/datasetReshapeInfo.d.ts +7 -0
  59. package/dist/types/properties/measures/dualMeasures.d.ts +8 -0
  60. package/dist/types/properties/measures/index.d.ts +4 -1
  61. package/dist/types/properties/measures/measures.d.ts +0 -107
  62. package/dist/types/properties/measures/zDualMeasures.d.ts +287 -0
  63. package/dist/types/properties/measures/zMeasures.d.ts +108 -0
  64. package/dist/types/properties/theme/customTheme.d.ts +500 -14
  65. package/dist/types/vseed.d.ts +1961 -0
  66. package/dist/umd/index.js +1272 -140
  67. package/dist/umd/index.js.map +1 -1
  68. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8,11 +8,11 @@ const buildAdvanced = (builder)=>{
8
8
  const start = 'undefined' != typeof performance ? performance.now() : Date.now();
9
9
  const { chartType } = builder.vseed;
10
10
  if (!chartType) throw new Error('chartType is nil in buildAdvanced');
11
- const pipeline = builder.getAdvancedPipeline(chartType);
11
+ const pipeline = Builder.getAdvancedPipeline(chartType);
12
12
  if (!pipeline) throw new Error(`no advanced pipeline for chartType ${chartType}`);
13
13
  const context = {
14
14
  vseed: builder.vseed,
15
- customTheme: builder.getThemeMap()
15
+ customTheme: Builder.getThemeMap()
16
16
  };
17
17
  try {
18
18
  return execPipeline(pipeline, context);
@@ -28,7 +28,7 @@ const buildSpec = (builder, advancedVSeed)=>{
28
28
  const start = 'undefined' != typeof performance ? performance.now() : Date.now();
29
29
  const { chartType } = builder.vseed;
30
30
  if (!chartType) throw new Error('chartType is nil in buildSpec');
31
- const pipeline = builder.getSpecPipeline(chartType);
31
+ const pipeline = Builder.getSpecPipeline(chartType);
32
32
  if (!pipeline) throw new Error(`no spec pipeline for chartType ${chartType}`);
33
33
  const context = {
34
34
  vseed: builder.vseed,
@@ -111,20 +111,6 @@ class Builder {
111
111
  build = ()=>build(this);
112
112
  buildSpec = (advanced)=>buildSpec(this, advanced);
113
113
  buildAdvanced = ()=>buildAdvanced(this);
114
- getAdvancedPipeline = (chartType)=>{
115
- const customPipe = Builder._customAdvancedPipe[chartType];
116
- const pipeline = Builder._advancedPipelineMap[chartType];
117
- if (customPipe) pipeline.push(customPipe);
118
- return pipeline;
119
- };
120
- getSpecPipeline = (chartType)=>{
121
- const customPipe = Builder._customSpecPipe[chartType];
122
- const pipeline = Builder._specPipelineMap[chartType];
123
- if (customPipe) pipeline.push(customPipe);
124
- return pipeline;
125
- };
126
- getTheme = (themeKey)=>Builder._themeMap[themeKey];
127
- getThemeMap = ()=>Builder._themeMap;
128
114
  getColorItems = ()=>getColorItems(this);
129
115
  getColorIdMap = ()=>getColorIdMap(this);
130
116
  get vseed() {
@@ -151,12 +137,26 @@ class Builder {
151
137
  set performance(value) {
152
138
  this._performance = value;
153
139
  }
140
+ static getAdvancedPipeline = (chartType)=>{
141
+ const customPipe = Builder._customAdvancedPipe[chartType];
142
+ const pipeline = Builder._advancedPipelineMap[chartType];
143
+ if (customPipe) pipeline.push(customPipe);
144
+ return pipeline;
145
+ };
146
+ static getSpecPipeline = (chartType)=>{
147
+ const customPipe = Builder._customSpecPipe[chartType];
148
+ const pipeline = Builder._specPipelineMap[chartType];
149
+ if (customPipe) pipeline.push(customPipe);
150
+ return pipeline;
151
+ };
152
+ static getTheme = (themeKey)=>Builder._themeMap[themeKey];
153
+ static getThemeMap = ()=>Builder._themeMap;
154
+ static from = (vseed)=>new Builder(vseed);
154
155
  static _advancedPipelineMap = {};
155
156
  static _specPipelineMap = {};
156
157
  static _customAdvancedPipe = {};
157
158
  static _customSpecPipe = {};
158
159
  static _themeMap = {};
159
- static from = (vseed)=>new Builder(vseed);
160
160
  }
161
161
  const initAdvancedVSeed = (advancedVSeed, context)=>{
162
162
  const { vseed } = context;
@@ -256,7 +256,10 @@ const autoDimensions = (advancedVSeed, context)=>{
256
256
  if (!dataset) throw new Error('dataset is required');
257
257
  if (0 === dataset.length) return result;
258
258
  if (dimensions) {
259
- result.dimensions = dimensions;
259
+ result.dimensions = dimensions.map((dim)=>({
260
+ location: 'dimension',
261
+ ...dim
262
+ }));
260
263
  return result;
261
264
  }
262
265
  const top100dataset = dataset.slice(0, 100);
@@ -552,7 +555,7 @@ const autoPivotMeasures = (advancedVSeed, context)=>{
552
555
  const measures = findAllMeasures(vseed.measures);
553
556
  if (!dataset) throw new Error('dataset is required');
554
557
  if (0 === dataset.length) return result;
555
- if (measures) {
558
+ if (vseed.measures) {
556
559
  result.measures = findAllMeasures(measures);
557
560
  return result;
558
561
  }
@@ -850,6 +853,15 @@ const initAdvancedVSeed_initAdvancedVSeed = (advancedVSeed, context)=>{
850
853
  locale: locale || 'zh-CN'
851
854
  };
852
855
  };
856
+ const measureDepth = (measures = [])=>{
857
+ if (!measures) return 0;
858
+ let depth = 1;
859
+ preorderTraverse(measures, (node)=>{
860
+ if ('children' in node) depth = Math.max(depth, 1 + measureDepth(node.children));
861
+ return false;
862
+ });
863
+ return depth;
864
+ };
853
865
  const isTable = (vseed)=>'table' === vseed.chartType;
854
866
  const isPivotTable = (vseed)=>'pivotTable' === vseed.chartType;
855
867
  const isVTable = (vseed)=>[
@@ -859,9 +871,18 @@ const isVTable = (vseed)=>[
859
871
  const isVChart = (vseed)=>!isVTable(vseed);
860
872
  const isPivotChart = (vseed)=>{
861
873
  if (isVTable(vseed)) return false;
874
+ if ('dualAxis' === vseed.chartType) {
875
+ if (vseed.measures) {
876
+ const depth = measureDepth(vseed.measures);
877
+ if (3 === depth) return true;
878
+ return false;
879
+ }
880
+ if (vseed.dualMeasures && vseed.dualMeasures.length > 1) return true;
881
+ return false;
882
+ }
862
883
  const { measures = [], dimensions = [] } = vseed;
863
884
  const hasRowOrColumnDimension = dimensions && dimensions.some((dimension)=>'rowDimension' === dimension.location || 'columnDimension' === dimension.location);
864
- const hasMeasureGroup = measures && measures.find((measure)=>measure && measure.children);
885
+ const hasMeasureGroup = measures && measures.some((measure)=>measure && measure.children);
865
886
  return hasRowOrColumnDimension || hasMeasureGroup;
866
887
  };
867
888
  const autoMeasures_autoMeasures = (advancedVSeed, context)=>{
@@ -945,7 +966,10 @@ const autoDimensions_autoDimensions = (advancedVSeed, context)=>{
945
966
  if (!dataset) throw new Error('dataset is required');
946
967
  if (0 === dataset.length) return result;
947
968
  if (dimensions) {
948
- result.dimensions = dimensions;
969
+ result.dimensions = dimensions.map((dim)=>({
970
+ location: 'dimension',
971
+ ...dim
972
+ }));
949
973
  return result;
950
974
  }
951
975
  const top100dataset = dataset.slice(0, 100);
@@ -971,8 +995,10 @@ const pivotAdapter = (pipeline, pivotPipeline)=>(advancedVSeed, context)=>{
971
995
  return execPipeline(pipeline, context, advancedVSeed);
972
996
  };
973
997
  const FoldMeasureName = '__MeaName__';
974
- const FoldMeasureValue = '__MeaValue__';
975
998
  const FoldMeasureId = '__MeaId__';
999
+ const FoldMeasureValue = '__MeaValue__';
1000
+ const FoldPrimaryMeasureValue = '__MeaPrimaryValue__';
1001
+ const FoldSecondaryMeasureValue = '__MeaSecondaryValue__';
976
1002
  const UnfoldDimensionGroup = '__DimGroup__';
977
1003
  const UnfoldDimensionGroupId = '__DimGroupID__';
978
1004
  const Separator = '-';
@@ -1152,6 +1178,7 @@ const reshapeTo2D1M0Name = (advancedVSeed, context)=>{
1152
1178
  datasetReshapeInfo: [
1153
1179
  {
1154
1180
  id: '2D1M',
1181
+ index: 0,
1155
1182
  foldInfo,
1156
1183
  unfoldInfo
1157
1184
  }
@@ -1176,7 +1203,7 @@ const pivotReshapeTo2D1M0Name = (advancedVSeed, context)=>{
1176
1203
  const commonDimensions = dimensions.filter((dim)=>'dimension' === dim.location);
1177
1204
  const newDatasets = [];
1178
1205
  const datasetReshapeInfo = [];
1179
- measureGroups.forEach((measureGroup)=>{
1206
+ measureGroups.forEach((measureGroup, index)=>{
1180
1207
  const measures = measureGroup.children;
1181
1208
  if (!measures) return;
1182
1209
  const groupId = measureGroup.id;
@@ -1188,6 +1215,7 @@ const pivotReshapeTo2D1M0Name = (advancedVSeed, context)=>{
1188
1215
  });
1189
1216
  const reshapeInfo = {
1190
1217
  id: groupId,
1218
+ index,
1191
1219
  foldInfo,
1192
1220
  unfoldInfo
1193
1221
  };
@@ -1469,11 +1497,13 @@ const color_color = (spec, context)=>{
1469
1497
  const { unfoldInfo } = datasetReshapeInfo[0];
1470
1498
  const baseConfig = advancedVSeed.config[chartType];
1471
1499
  if (!baseConfig || !baseConfig.color) return result;
1500
+ const colorItems = unfoldInfo.colorItems;
1501
+ const colorIdMap = unfoldInfo.colorIdMap;
1472
1502
  const { color } = baseConfig;
1473
1503
  const { colorScheme, colorMapping } = color;
1474
1504
  const mappingList = [];
1475
1505
  if (colorMapping) Object.entries(colorMapping).sort((a, b)=>a[0].split(Separator).length - b[0].split(Separator).length).forEach(([key, value])=>{
1476
- const idMap = Object.entries(unfoldInfo.colorIdMap).filter(([_, v])=>v.includes(key));
1506
+ const idMap = Object.entries(colorIdMap).filter(([_, v])=>v.includes(key));
1477
1507
  for (const [colorId] of idMap)mappingList.push([
1478
1508
  colorId,
1479
1509
  value
@@ -1481,7 +1511,7 @@ const color_color = (spec, context)=>{
1481
1511
  });
1482
1512
  result.color = {
1483
1513
  type: 'ordinal',
1484
- domain: unfoldInfo.colorItems,
1514
+ domain: colorItems,
1485
1515
  range: colorScheme,
1486
1516
  specified: Object.fromEntries(mappingList)
1487
1517
  };
@@ -3191,6 +3221,7 @@ const reshapeTo2D1M = (advancedVSeed, context)=>{
3191
3221
  datasetReshapeInfo: [
3192
3222
  {
3193
3223
  id: '2D1M',
3224
+ index: 0,
3194
3225
  foldInfo,
3195
3226
  unfoldInfo
3196
3227
  }
@@ -3215,7 +3246,7 @@ const pivotReshapeTo2D1M = (advancedVSeed, context)=>{
3215
3246
  const commonDimensions = dimensions.filter((dim)=>'dimension' === dim.location);
3216
3247
  const newDatasets = [];
3217
3248
  const datasetReshapeInfo = [];
3218
- measureGroups.forEach((measureGroup)=>{
3249
+ measureGroups.forEach((measureGroup, index)=>{
3219
3250
  const measures = measureGroup.children;
3220
3251
  if (!measures) return;
3221
3252
  const groupId = measureGroup.id;
@@ -3227,6 +3258,7 @@ const pivotReshapeTo2D1M = (advancedVSeed, context)=>{
3227
3258
  });
3228
3259
  const reshapeInfo = {
3229
3260
  id: groupId,
3261
+ index,
3230
3262
  foldInfo,
3231
3263
  unfoldInfo
3232
3264
  };
@@ -4633,6 +4665,7 @@ const reshapeTo1D = (advancedVSeed, context)=>{
4633
4665
  datasetReshapeInfo: [
4634
4666
  {
4635
4667
  id: '1D2M',
4668
+ index: 0,
4636
4669
  foldInfo,
4637
4670
  unfoldInfo
4638
4671
  }
@@ -4654,7 +4687,7 @@ const pivotReshapeTo1D = (advancedVSeed, context)=>{
4654
4687
  });
4655
4688
  const newDatasets = [];
4656
4689
  const datasetReshapeInfo = [];
4657
- measureGroups.forEach((measureGroup)=>{
4690
+ measureGroups.forEach((measureGroup, index)=>{
4658
4691
  const measures = measureGroup.children;
4659
4692
  if (!measures) return;
4660
4693
  const commonDimensions = dimensions.filter((dim)=>'dimension' === dim.location);
@@ -4667,6 +4700,7 @@ const pivotReshapeTo1D = (advancedVSeed, context)=>{
4667
4700
  });
4668
4701
  const reshapeInfo = {
4669
4702
  id: groupId,
4703
+ index,
4670
4704
  foldInfo,
4671
4705
  unfoldInfo
4672
4706
  };
@@ -4679,7 +4713,7 @@ const pivotReshapeTo1D = (advancedVSeed, context)=>{
4679
4713
  datasetReshapeInfo: datasetReshapeInfo
4680
4714
  };
4681
4715
  };
4682
- const encodingXYY = (advancedVSeed)=>{
4716
+ const encodingAreaRange = (advancedVSeed)=>{
4683
4717
  const result = {
4684
4718
  ...advancedVSeed
4685
4719
  };
@@ -4756,7 +4790,7 @@ const areaRangeAdvancedPipeline = [
4756
4790
  ], [
4757
4791
  pivotReshapeTo1D
4758
4792
  ]),
4759
- encodingXYY,
4793
+ encodingAreaRange,
4760
4794
  sortXBandAxis,
4761
4795
  areaConfig,
4762
4796
  theme_theme,
@@ -5078,6 +5112,7 @@ const reshapeTo1D2M = (advancedVSeed, context)=>{
5078
5112
  datasetReshapeInfo: [
5079
5113
  {
5080
5114
  id: '1D2M',
5115
+ index: 0,
5081
5116
  foldInfo,
5082
5117
  unfoldInfo
5083
5118
  }
@@ -5099,7 +5134,7 @@ const pivotReshapeTo1D2M = (advancedVSeed, context)=>{
5099
5134
  });
5100
5135
  const newDatasets = [];
5101
5136
  const datasetReshapeInfo = [];
5102
- measureGroups.forEach((measureGroup)=>{
5137
+ measureGroups.forEach((measureGroup, index)=>{
5103
5138
  const measures = measureGroup.children;
5104
5139
  if (!measures) return;
5105
5140
  const commonDimensions = dimensions.filter((dim)=>'dimension' === dim.location);
@@ -5112,6 +5147,7 @@ const pivotReshapeTo1D2M = (advancedVSeed, context)=>{
5112
5147
  });
5113
5148
  const reshapeInfo = {
5114
5149
  id: groupId,
5150
+ index,
5115
5151
  foldInfo,
5116
5152
  unfoldInfo
5117
5153
  };
@@ -5291,69 +5327,7 @@ const registerScatter = ()=>{
5291
5327
  Builder._advancedPipelineMap.scatter = scatterAdvancedPipeline;
5292
5328
  Builder._specPipelineMap.scatter = scatterSpecPipeline;
5293
5329
  };
5294
- const dataReshapeFor1D1M_emptyReshapeResult = {
5295
- dataset: [],
5296
- foldInfo: {
5297
- foldMap: {},
5298
- measureId: '',
5299
- measureName: '',
5300
- measureValue: ''
5301
- },
5302
- unfoldInfo: {
5303
- groupName: '',
5304
- groupId: '',
5305
- colorItems: [],
5306
- colorIdMap: {}
5307
- }
5308
- };
5309
- const dataReshapeFor1D1M = (dataset, dimensions, measures, options)=>{
5310
- const { foldMeasureId = FoldMeasureId, foldMeasureName = FoldMeasureName, foldMeasureValue = FoldMeasureValue, unfoldDimensionGroup = UnfoldDimensionGroup, unfoldDimensionGroupId = UnfoldDimensionGroupId } = options || {};
5311
- if (0 === dimensions.length && 0 === measures.length) return dataReshapeFor1D1M_emptyReshapeResult;
5312
- const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, foldMeasureId, foldMeasureName, foldMeasureValue);
5313
- if (0 === dimensions.length) {
5314
- const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
5315
- {
5316
- id: foldMeasureName,
5317
- alias: i18n`指标名称`,
5318
- location: 'dimension'
5319
- }
5320
- ], [
5321
- {
5322
- id: foldMeasureValue,
5323
- alias: i18n`指标值`
5324
- }
5325
- ], 0, unfoldDimensionGroup, unfoldDimensionGroupId, foldMeasureId);
5326
- return {
5327
- dataset: finalDataset,
5328
- foldInfo,
5329
- unfoldInfo
5330
- };
5331
- }
5332
- {
5333
- const dims = 1 === measures.length ? [
5334
- ...dimensions
5335
- ] : [
5336
- ...dimensions,
5337
- {
5338
- id: foldMeasureName,
5339
- alias: i18n`指标名称`,
5340
- location: 'dimension'
5341
- }
5342
- ];
5343
- const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, dims, [
5344
- {
5345
- id: foldMeasureValue,
5346
- alias: i18n`指标值`
5347
- }
5348
- ], 0, unfoldDimensionGroup, unfoldDimensionGroupId, foldMeasureId);
5349
- return {
5350
- dataset: finalDataset,
5351
- foldInfo,
5352
- unfoldInfo
5353
- };
5354
- }
5355
- };
5356
- const reshapeTo1D1M = (advancedVSeed, context)=>{
5330
+ const reshapeTo2D2M = (advancedVSeed, context)=>{
5357
5331
  const result = {
5358
5332
  ...advancedVSeed
5359
5333
  };
@@ -5362,84 +5336,138 @@ const reshapeTo1D1M = (advancedVSeed, context)=>{
5362
5336
  const { dimensions, measures } = advancedVSeed;
5363
5337
  if (!measures || !dimensions || !dataset) return result;
5364
5338
  if (0 === measures.length) throw new Error('measures can not be empty');
5365
- const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeFor1D1M(dataset, dimensions, measures);
5339
+ if (measures.length > 2) throw new Error('measures can not be more than 2');
5340
+ const commonDimensions = dimensions.filter((dim)=>'dimension' === dim.location);
5341
+ const datasets = [];
5342
+ const foldInfoList = [];
5343
+ const unfoldInfoList = [];
5344
+ const primaryMeasures = measures[0];
5345
+ const secondaryMeasures = measures[1] || [];
5346
+ if (primaryMeasures && primaryMeasures.children) {
5347
+ const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeFor2D1M(dataset, commonDimensions, primaryMeasures.children, {
5348
+ foldMeasureValue: FoldPrimaryMeasureValue
5349
+ });
5350
+ datasets.push(newDatasets);
5351
+ foldInfoList.push(foldInfo);
5352
+ unfoldInfoList.push(unfoldInfo);
5353
+ }
5354
+ if (secondaryMeasures && secondaryMeasures.children) {
5355
+ const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeFor2D1M(dataset, commonDimensions, secondaryMeasures.children, {
5356
+ foldMeasureValue: FoldSecondaryMeasureValue
5357
+ });
5358
+ datasets.push(newDatasets);
5359
+ foldInfoList.push(foldInfo);
5360
+ unfoldInfoList.push(unfoldInfo);
5361
+ }
5362
+ const unfoldInfo = {
5363
+ groupName: unfoldInfoList[0].groupName,
5364
+ groupId: unfoldInfoList[0].groupId,
5365
+ colorItems: unfoldInfoList.flatMap((d)=>d.colorItems),
5366
+ colorIdMap: unfoldInfoList.reduce((prev, cur)=>({
5367
+ ...prev,
5368
+ ...cur.colorIdMap
5369
+ }), {})
5370
+ };
5366
5371
  return {
5367
5372
  ...result,
5368
- dataset: newDatasets,
5373
+ dataset: datasets,
5369
5374
  datasetReshapeInfo: [
5370
5375
  {
5371
- id: '1D1M',
5372
- foldInfo,
5373
- unfoldInfo
5376
+ id: '2D2M',
5377
+ index: 0,
5378
+ foldInfo: foldInfoList[0],
5379
+ foldInfoList: foldInfoList,
5380
+ unfoldInfo: unfoldInfo
5374
5381
  }
5375
5382
  ]
5376
5383
  };
5377
5384
  };
5378
- const pivotReshapeTo1D1M = (advancedVSeed, context)=>{
5385
+ const pivotReshapeTo2D2M = (advancedVSeed, context)=>{
5379
5386
  const result = {
5380
5387
  ...advancedVSeed
5381
5388
  };
5382
5389
  const { vseed } = context;
5383
5390
  const { dataset } = vseed;
5384
- const { measures } = advancedVSeed;
5385
- const dimensions = advancedVSeed.dimensions;
5386
- if (!measures || !dimensions) return result;
5387
- const measureGroups = [];
5388
- if (measures) measures.forEach((measure)=>{
5389
- if (measure.children && measure.children.length > 0) measureGroups.push(measure);
5390
- });
5391
- const newDatasets = [];
5391
+ const { dimensions, measures } = advancedVSeed;
5392
+ if (!measures || !dimensions || !dataset) return result;
5393
+ const commonDimensions = dimensions.filter((dim)=>'dimension' === dim.location);
5394
+ const datasetList = [];
5392
5395
  const datasetReshapeInfo = [];
5393
- measureGroups.forEach((measureGroup)=>{
5394
- const measures = measureGroup.children;
5395
- if (!measures) return;
5396
- const commonDimensions = dimensions.filter((dim)=>'dimension' === dim.location);
5397
- const groupId = measureGroup.id;
5398
- const { dataset: newSubDataset, foldInfo, unfoldInfo } = dataReshapeFor1D1M(dataset, commonDimensions, measures, {
5399
- foldMeasureId: FoldMeasureId,
5400
- foldMeasureName: FoldMeasureName,
5401
- foldMeasureValue: FoldMeasureValue + groupId,
5402
- unfoldDimensionGroup: UnfoldDimensionGroup
5403
- });
5396
+ measures.forEach((measureGroup, index)=>{
5397
+ const measures = measureGroup.children || [];
5398
+ if (0 === measures.length) throw new Error('measures can not be empty');
5399
+ if (measures.length > 2) throw new Error('measures can not be more than 2');
5400
+ const datasets = [];
5401
+ const foldInfoList = [];
5402
+ const unfoldInfoList = [];
5403
+ const primaryMeasures = measures[0];
5404
+ const secondaryMeasures = measures[1] || measures[0];
5405
+ if (primaryMeasures && primaryMeasures.children) {
5406
+ const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeFor2D1M(dataset, commonDimensions, primaryMeasures.children, {
5407
+ foldMeasureValue: `${FoldPrimaryMeasureValue}${index}`
5408
+ });
5409
+ datasets.push(newDatasets);
5410
+ foldInfoList.push(foldInfo);
5411
+ unfoldInfoList.push(unfoldInfo);
5412
+ }
5413
+ if (secondaryMeasures && secondaryMeasures.children) {
5414
+ const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeFor2D1M(dataset, commonDimensions, secondaryMeasures.children, {
5415
+ foldMeasureValue: `${FoldSecondaryMeasureValue}${index}`
5416
+ });
5417
+ datasets.push(newDatasets);
5418
+ foldInfoList.push(foldInfo);
5419
+ unfoldInfoList.push(unfoldInfo);
5420
+ }
5421
+ datasetList.push(datasets.flat(2));
5422
+ const unfoldInfo = {
5423
+ groupName: unfoldInfoList[0].groupName,
5424
+ groupId: unfoldInfoList[0].groupId,
5425
+ colorItems: unfoldInfoList.flatMap((d)=>d.colorItems),
5426
+ colorIdMap: unfoldInfoList.reduce((prev, cur)=>({
5427
+ ...prev,
5428
+ ...cur.colorIdMap
5429
+ }), {})
5430
+ };
5404
5431
  const reshapeInfo = {
5405
- id: groupId,
5406
- foldInfo,
5407
- unfoldInfo
5432
+ id: `2D2M-${index}`,
5433
+ index,
5434
+ foldInfo: foldInfoList[0],
5435
+ unfoldInfo: unfoldInfo,
5436
+ foldInfoList: foldInfoList
5408
5437
  };
5409
- newDatasets.push(newSubDataset);
5410
5438
  datasetReshapeInfo.push(reshapeInfo);
5411
5439
  });
5412
5440
  return {
5413
5441
  ...result,
5414
- dataset: newDatasets,
5415
- datasetReshapeInfo: datasetReshapeInfo
5442
+ dataset: datasetList,
5443
+ datasetReshapeInfo
5416
5444
  };
5417
5445
  };
5418
- const encodingPie = (advancedVSeed)=>{
5446
+ const encodingXYY = (advancedVSeed)=>{
5419
5447
  const result = {
5420
5448
  ...advancedVSeed
5421
5449
  };
5422
- const { datasetReshapeInfo } = advancedVSeed;
5423
- if (!datasetReshapeInfo) return result;
5450
+ const { datasetReshapeInfo, dimensions } = advancedVSeed;
5451
+ if (!datasetReshapeInfo || !dimensions) return result;
5452
+ const xDimension = dimensions.find((item)=>'rowDimension' !== item.location && 'columnDimension' !== item.location) || dimensions[0];
5453
+ const isZeroDimension = 0 === dimensions.length;
5424
5454
  const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
5425
- const { foldInfo, unfoldInfo } = cur;
5426
- const radius = [
5427
- foldInfo.measureValue
5428
- ];
5429
- const angle = [
5430
- unfoldInfo.groupId
5455
+ const { foldInfoList, unfoldInfo } = cur;
5456
+ const x = [
5457
+ isZeroDimension ? foldInfoList[0].measureName : xDimension?.id
5431
5458
  ];
5459
+ const y = foldInfoList.map((d)=>d.measureValue);
5432
5460
  const group = [
5433
5461
  unfoldInfo.groupId
5434
5462
  ];
5435
5463
  const color = [
5436
- unfoldInfo.groupId
5464
+ foldInfoList[0].measureName
5437
5465
  ];
5438
5466
  return [
5439
5467
  ...prev,
5440
5468
  {
5441
- angle,
5442
- radius,
5469
+ x,
5470
+ y,
5443
5471
  group,
5444
5472
  color
5445
5473
  }
@@ -5450,35 +5478,1042 @@ const encodingPie = (advancedVSeed)=>{
5450
5478
  encoding
5451
5479
  };
5452
5480
  };
5453
- const pieAdvancedPipeline = [
5481
+ const dualAxisConfig = (advancedVSeed, context)=>{
5482
+ const { vseed } = context;
5483
+ const { chartType } = vseed;
5484
+ const result = {
5485
+ ...advancedVSeed
5486
+ };
5487
+ const config = pick(vseed, [
5488
+ 'backgroundColor',
5489
+ 'color',
5490
+ 'label',
5491
+ 'legend',
5492
+ 'tooltip',
5493
+ 'dualChartType',
5494
+ 'primaryYAxis',
5495
+ 'secondaryYAxis',
5496
+ 'crosshairLine'
5497
+ ]);
5498
+ result.config = {
5499
+ ...result.config || {},
5500
+ [chartType]: {
5501
+ ...config
5502
+ }
5503
+ };
5504
+ return result;
5505
+ };
5506
+ const autoDualMeasures = (advancedVSeed, context)=>{
5507
+ const result = {
5508
+ ...advancedVSeed
5509
+ };
5510
+ const { vseed } = context;
5511
+ const { dataset, dualMeasures, measures } = vseed;
5512
+ if (!dataset) throw new Error('dataset is required');
5513
+ if (0 === dataset.length) return result;
5514
+ if (dualMeasures) {
5515
+ result.measures = dualMeasuresToMeasureTree(dualMeasures);
5516
+ return result;
5517
+ }
5518
+ if (measures && measureDepth(measures) > 1) {
5519
+ result.measures = measures;
5520
+ return result;
5521
+ }
5522
+ const top100dataset = dataset.slice(0, 100);
5523
+ const sample = top100dataset.reduce((prev, cur)=>({
5524
+ ...prev,
5525
+ ...cur
5526
+ }), {});
5527
+ const newMeasures = measures || Object.keys(sample).filter((key)=>top100dataset.some((item)=>'number' == typeof item[key]) && ![
5528
+ '',
5529
+ null,
5530
+ void 0
5531
+ ].includes(key)).map((measure)=>({
5532
+ id: measure,
5533
+ alias: measure
5534
+ }));
5535
+ if (0 === newMeasures.length) result.measures = [];
5536
+ else if (1 === newMeasures.length) result.measures = [
5537
+ {
5538
+ id: 'primary',
5539
+ alias: 'primary',
5540
+ children: newMeasures
5541
+ }
5542
+ ];
5543
+ else if (newMeasures.length > 1) result.measures = [
5544
+ {
5545
+ id: 'primary',
5546
+ alias: 'primary',
5547
+ children: newMeasures.slice(0, 1)
5548
+ },
5549
+ {
5550
+ id: 'secondary',
5551
+ alias: 'secondary',
5552
+ children: newMeasures.slice(1)
5553
+ }
5554
+ ];
5555
+ return result;
5556
+ };
5557
+ const dualMeasuresToMeasureTree = (dualMeasures)=>{
5558
+ const measureTree = dualMeasures.map((item, index)=>{
5559
+ const { primaryMeasures, secondaryMeasures, primaryAlias, secondaryAlias } = item;
5560
+ const groupChildren = [];
5561
+ if (primaryMeasures) {
5562
+ const arrPrimaryMeasures = Array.isArray(primaryMeasures) ? primaryMeasures : [
5563
+ primaryMeasures
5564
+ ];
5565
+ groupChildren.push({
5566
+ id: `${index}-primary`,
5567
+ alias: primaryAlias || arrPrimaryMeasures.map((item)=>item.alias || item.id).toString(),
5568
+ children: arrPrimaryMeasures
5569
+ });
5570
+ }
5571
+ if (secondaryMeasures) {
5572
+ const arrSecondaryMeasures = Array.isArray(secondaryMeasures) ? secondaryMeasures : [
5573
+ secondaryMeasures
5574
+ ];
5575
+ groupChildren.push({
5576
+ id: `${index}-secondary`,
5577
+ alias: secondaryAlias || arrSecondaryMeasures.map((item)=>item.alias || item.id).toString(),
5578
+ children: arrSecondaryMeasures
5579
+ });
5580
+ }
5581
+ const id = [
5582
+ primaryAlias,
5583
+ secondaryAlias,
5584
+ index
5585
+ ].filter((d)=>!isNullish(d)).join('-');
5586
+ return {
5587
+ id,
5588
+ alias: id,
5589
+ children: groupChildren
5590
+ };
5591
+ });
5592
+ if (1 === dualMeasures.length) return measureTree[0].children || [];
5593
+ return measureTree;
5594
+ };
5595
+ const dualAxisAdvancedPipeline = [
5454
5596
  initAdvancedVSeed_initAdvancedVSeed,
5455
- autoMeasures_autoMeasures,
5597
+ autoDualMeasures,
5456
5598
  autoDimensions_autoDimensions,
5457
5599
  pivotAdapter([
5458
- reshapeTo1D1M
5600
+ reshapeTo2D2M
5459
5601
  ], [
5460
- pivotReshapeTo1D1M
5602
+ pivotReshapeTo2D2M
5461
5603
  ]),
5462
- encodingPie,
5463
- pieConfig,
5604
+ encodingXYY,
5605
+ sortXBandAxis,
5606
+ sort_sortLegend,
5607
+ dualAxisConfig,
5464
5608
  theme_theme,
5609
+ markStyle_markStyle,
5465
5610
  annotation_annotation
5466
5611
  ];
5467
- const initPie = (spec, context)=>{
5612
+ const initDualAxisPrimary = (spec, context)=>{
5468
5613
  const result = {
5469
5614
  ...spec
5470
5615
  };
5471
5616
  const { advancedVSeed } = context;
5472
- const { encoding, dataset } = advancedVSeed;
5473
- if (!encoding[0].angle || !encoding[0].radius || !encoding[0].group) return result;
5474
- const showStroke = dataset.length <= 30;
5475
- result.type = 'pie';
5476
- result.outerRadius = 0.8;
5477
- result.innerRadius = 0;
5478
- result.valueField = encoding[0].radius[0];
5479
- result.categoryField = encoding[0].angle[0];
5617
+ const { encoding, datasetReshapeInfo } = advancedVSeed;
5618
+ if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
5619
+ result.id = `${datasetReshapeInfo[0].id}-primary-series`;
5620
+ result.type = 'bar';
5621
+ result.direction = 'vertical';
5622
+ result.xField = encoding[0].x[0];
5623
+ result.yField = encoding[0].y[0];
5480
5624
  result.seriesField = encoding[0].group[0];
5481
- result.padding = 0;
5625
+ result.animation = true;
5626
+ return result;
5627
+ };
5628
+ const initDualAxisSecondary = (spec, context)=>{
5629
+ const result = {
5630
+ ...spec
5631
+ };
5632
+ const { advancedVSeed } = context;
5633
+ const { encoding, datasetReshapeInfo } = advancedVSeed;
5634
+ if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
5635
+ result.id = `${datasetReshapeInfo[0].id}-secondary-series`;
5636
+ result.type = 'line';
5637
+ result.direction = 'vertical';
5638
+ result.xField = encoding[0].x[0];
5639
+ result.yField = encoding[0].y[1];
5640
+ result.seriesField = encoding[0].group[0];
5641
+ result.animation = true;
5642
+ return result;
5643
+ };
5644
+ const dualChartTypePrimary = (spec, context)=>{
5645
+ const result = {
5646
+ ...spec
5647
+ };
5648
+ const { advancedVSeed, vseed } = context;
5649
+ const { chartType } = vseed;
5650
+ const { datasetReshapeInfo } = advancedVSeed;
5651
+ const config = advancedVSeed.config?.[chartType]?.dualChartType || {
5652
+ primary: 'column',
5653
+ secondary: 'line'
5654
+ };
5655
+ if (Array.isArray(config)) return result;
5656
+ switch(config.primary){
5657
+ case 'line':
5658
+ result.type = 'line';
5659
+ break;
5660
+ case 'column':
5661
+ result.type = 'bar';
5662
+ break;
5663
+ case 'columnParallel':
5664
+ {
5665
+ const columnSpec = result;
5666
+ if (Array.isArray(columnSpec.xField)) columnSpec.xField.push(datasetReshapeInfo[0].unfoldInfo.groupId);
5667
+ else if (columnSpec.xField) columnSpec.xField = [
5668
+ columnSpec.xField,
5669
+ datasetReshapeInfo[0].unfoldInfo.groupId
5670
+ ];
5671
+ columnSpec.type = 'bar';
5672
+ break;
5673
+ }
5674
+ case 'columnPercent':
5675
+ result.type = 'bar';
5676
+ result.percent = true;
5677
+ break;
5678
+ case 'area':
5679
+ result.type = 'area';
5680
+ break;
5681
+ case 'areaPercent':
5682
+ result.type = 'area';
5683
+ result.percent = true;
5684
+ break;
5685
+ case 'scatter':
5686
+ result.type = 'scatter';
5687
+ break;
5688
+ default:
5689
+ result.type = config.primary;
5690
+ }
5691
+ return result;
5692
+ };
5693
+ const dualChartTypeSecondary = (spec, context)=>{
5694
+ const result = {
5695
+ ...spec
5696
+ };
5697
+ const { advancedVSeed, vseed } = context;
5698
+ const { chartType } = vseed;
5699
+ const { datasetReshapeInfo } = advancedVSeed;
5700
+ const config = advancedVSeed.config?.[chartType]?.dualChartType || {
5701
+ primary: 'column',
5702
+ secondary: 'line'
5703
+ };
5704
+ if (Array.isArray(config)) return result;
5705
+ switch(config.secondary){
5706
+ case 'line':
5707
+ result.type = 'line';
5708
+ break;
5709
+ case 'column':
5710
+ result.type = 'bar';
5711
+ break;
5712
+ case 'columnParallel':
5713
+ {
5714
+ const columnSpec = result;
5715
+ if (Array.isArray(columnSpec.xField)) columnSpec.xField.push(datasetReshapeInfo[0].unfoldInfo.groupId);
5716
+ else if (columnSpec.xField) columnSpec.xField = [
5717
+ columnSpec.xField,
5718
+ datasetReshapeInfo[0].unfoldInfo.groupId
5719
+ ];
5720
+ columnSpec.type = 'bar';
5721
+ break;
5722
+ }
5723
+ case 'columnPercent':
5724
+ result.type = 'bar';
5725
+ result.percent = true;
5726
+ break;
5727
+ case 'area':
5728
+ result.type = 'area';
5729
+ break;
5730
+ case 'areaPercent':
5731
+ result.type = 'area';
5732
+ result.percent = true;
5733
+ break;
5734
+ case 'scatter':
5735
+ result.type = 'scatter';
5736
+ break;
5737
+ default:
5738
+ result.type = config.secondary;
5739
+ }
5740
+ return result;
5741
+ };
5742
+ const datasetPrimary = (spec, context)=>{
5743
+ const { advancedVSeed, vseed } = context;
5744
+ const { encoding, analysis, datasetReshapeInfo } = advancedVSeed;
5745
+ const { orderMapping = {} } = analysis ?? {};
5746
+ const x = encoding[0]?.x?.[0];
5747
+ const group = encoding[0]?.group?.[0];
5748
+ const id = datasetReshapeInfo[0].id;
5749
+ const fields = {};
5750
+ if (x) {
5751
+ const order = orderMapping[x];
5752
+ if (order) fields[x] = {
5753
+ sortIndex: 0,
5754
+ domain: order,
5755
+ lockStatisticsByDomain: true
5756
+ };
5757
+ else fields[x] = {
5758
+ sortIndex: 0
5759
+ };
5760
+ }
5761
+ if (group) {
5762
+ const order = orderMapping[group];
5763
+ if (order) fields[group] = {
5764
+ sortIndex: 0,
5765
+ domain: order,
5766
+ lockStatisticsByDomain: true
5767
+ };
5768
+ else fields[group] = {
5769
+ sortIndex: 0
5770
+ };
5771
+ }
5772
+ return {
5773
+ ...spec,
5774
+ data: {
5775
+ id: `${id}-primary-dataset`,
5776
+ values: isPivotChart(vseed) ? void 0 : advancedVSeed.dataset[0],
5777
+ fields: fields
5778
+ }
5779
+ };
5780
+ };
5781
+ const datasetSecondary = (spec, context)=>{
5782
+ const { advancedVSeed, vseed } = context;
5783
+ const { encoding, analysis, datasetReshapeInfo } = advancedVSeed;
5784
+ const { orderMapping = {} } = analysis ?? {};
5785
+ const x = encoding[0]?.x?.[0];
5786
+ const group = encoding[0]?.group?.[0];
5787
+ const id = datasetReshapeInfo[0].id;
5788
+ const fields = {};
5789
+ if (x) {
5790
+ const order = orderMapping[x];
5791
+ if (order) fields[x] = {
5792
+ sortIndex: 0,
5793
+ domain: order,
5794
+ lockStatisticsByDomain: true
5795
+ };
5796
+ else fields[x] = {
5797
+ sortIndex: 0
5798
+ };
5799
+ }
5800
+ if (group) {
5801
+ const order = orderMapping[group];
5802
+ if (order) fields[group] = {
5803
+ sortIndex: 0,
5804
+ domain: order,
5805
+ lockStatisticsByDomain: true
5806
+ };
5807
+ else fields[group] = {
5808
+ sortIndex: 0
5809
+ };
5810
+ }
5811
+ return {
5812
+ ...spec,
5813
+ data: {
5814
+ id: `${id}-secondary-dataset`,
5815
+ values: isPivotChart(vseed) ? void 0 : advancedVSeed.dataset[1],
5816
+ fields: fields
5817
+ }
5818
+ };
5819
+ };
5820
+ const labelPrimary = (spec, context)=>{
5821
+ const result = {
5822
+ ...spec
5823
+ };
5824
+ const { advancedVSeed } = context;
5825
+ const { measures, datasetReshapeInfo, locale } = advancedVSeed;
5826
+ const { chartType } = advancedVSeed;
5827
+ const baseConfig = advancedVSeed.config[chartType];
5828
+ if (!baseConfig || !baseConfig.label) return result;
5829
+ const foldInfoList = datasetReshapeInfo[0].foldInfoList;
5830
+ const { measureId, measureValue } = foldInfoList[0];
5831
+ const { label } = baseConfig;
5832
+ const { enable } = label;
5833
+ result.label = {
5834
+ visible: enable,
5835
+ formatMethod: (value, datum)=>{
5836
+ const result = [];
5837
+ const formatValue = (value)=>{
5838
+ const id = datum[measureId];
5839
+ const measure = findMeasureById(measures, id);
5840
+ if (!measure) return value;
5841
+ const { format = {}, autoFormat = true } = measure;
5842
+ if (!isEmpty(format)) {
5843
+ const formatter = createFormatter(format);
5844
+ return formatter(value);
5845
+ }
5846
+ if (autoFormat) return autoFormatter(value, locale);
5847
+ return String(value);
5848
+ };
5849
+ result.push(formatValue(datum[measureValue]));
5850
+ return result.join(' ');
5851
+ }
5852
+ };
5853
+ return result;
5854
+ };
5855
+ const labelSecondary = (spec, context)=>{
5856
+ const result = {
5857
+ ...spec
5858
+ };
5859
+ const { advancedVSeed } = context;
5860
+ const { measures, datasetReshapeInfo, locale } = advancedVSeed;
5861
+ const { chartType } = advancedVSeed;
5862
+ const baseConfig = advancedVSeed.config[chartType];
5863
+ if (!baseConfig || !baseConfig.label) return result;
5864
+ if (isNullish(datasetReshapeInfo[0].foldInfoList?.[1])) return result;
5865
+ const foldInfoList = datasetReshapeInfo[0].foldInfoList;
5866
+ const { measureId, measureValue } = foldInfoList[1];
5867
+ const { label } = baseConfig;
5868
+ const { enable } = label;
5869
+ result.label = {
5870
+ visible: enable,
5871
+ formatMethod: (value, datum)=>{
5872
+ const result = [];
5873
+ const formatValue = (value)=>{
5874
+ const id = datum[measureId];
5875
+ const measure = findMeasureById(measures, id);
5876
+ if (!measure) return value;
5877
+ const { format = {}, autoFormat = true } = measure;
5878
+ if (!isEmpty(format)) {
5879
+ const formatter = createFormatter(format);
5880
+ return formatter(value);
5881
+ }
5882
+ if (autoFormat) return autoFormatter(value, locale);
5883
+ return String(value);
5884
+ };
5885
+ result.push(formatValue(datum[measureValue]));
5886
+ return result.join(' ');
5887
+ }
5888
+ };
5889
+ return result;
5890
+ };
5891
+ const tooltipPrimary = (spec, context)=>{
5892
+ const result = {
5893
+ ...spec
5894
+ };
5895
+ const { advancedVSeed } = context;
5896
+ const { measures, datasetReshapeInfo, chartType, locale, dimensions } = advancedVSeed;
5897
+ const baseConfig = advancedVSeed.config[chartType];
5898
+ const { tooltip = {
5899
+ enable: true
5900
+ } } = baseConfig;
5901
+ const { enable } = tooltip;
5902
+ const foldInfoList = datasetReshapeInfo[0].foldInfoList;
5903
+ const unfoldInfo = datasetReshapeInfo[0].unfoldInfo;
5904
+ const { measureId, measureValue, measureName } = foldInfoList[0];
5905
+ const { groupName } = unfoldInfo;
5906
+ result.tooltip = {
5907
+ visible: enable,
5908
+ mark: {
5909
+ title: {
5910
+ visible: true
5911
+ },
5912
+ content: [
5913
+ ...dimensions.map((item)=>({
5914
+ visible: true,
5915
+ hasShape: true,
5916
+ shapeType: 'rectRound',
5917
+ key: (datum)=>{
5918
+ if (item.alias || item.id) return item.alias || item.id;
5919
+ return datum && datum[item.id];
5920
+ },
5921
+ value: (datum)=>datum && datum[item.id]
5922
+ })),
5923
+ {
5924
+ visible: true,
5925
+ hasShape: true,
5926
+ key: (datum)=>datum && datum[measureName || groupName] || '',
5927
+ value: (datum)=>{
5928
+ if (!datum) return '';
5929
+ const value = datum[measureValue];
5930
+ const id = datum[measureId];
5931
+ const measure = findMeasureById(measures, id);
5932
+ if (!measure) return String(value);
5933
+ const { format = {}, autoFormat = true } = measure;
5934
+ if (!isEmpty(format)) {
5935
+ const formatter = createFormatter(format);
5936
+ return formatter(value);
5937
+ }
5938
+ if (autoFormat) return autoFormatter(value, locale);
5939
+ return String(value);
5940
+ }
5941
+ }
5942
+ ]
5943
+ },
5944
+ dimension: {
5945
+ content: [
5946
+ {
5947
+ visible: true,
5948
+ key: (datum)=>datum && datum[groupName] || '',
5949
+ value: (datum)=>{
5950
+ if (!datum) return '';
5951
+ const value = datum[measureValue];
5952
+ const id = datum[measureId];
5953
+ const measure = findMeasureById(measures, id);
5954
+ if (!measure) return String(value);
5955
+ const { format = {}, autoFormat = true } = measure;
5956
+ if (!isEmpty(format)) {
5957
+ const formatter = createFormatter(format);
5958
+ return formatter(value);
5959
+ }
5960
+ if (autoFormat) return autoFormatter(value, locale);
5961
+ return String(value);
5962
+ },
5963
+ shapeType: 'rectRound'
5964
+ }
5965
+ ]
5966
+ }
5967
+ };
5968
+ return result;
5969
+ };
5970
+ const tooltipSecondary = (spec, context)=>{
5971
+ const result = {
5972
+ ...spec
5973
+ };
5974
+ const { advancedVSeed } = context;
5975
+ const { measures, datasetReshapeInfo, chartType, locale, dimensions } = advancedVSeed;
5976
+ const baseConfig = advancedVSeed.config[chartType];
5977
+ const { tooltip = {
5978
+ enable: true
5979
+ } } = baseConfig;
5980
+ const { enable } = tooltip;
5981
+ if (isNullish(datasetReshapeInfo[0].foldInfoList?.[1])) return result;
5982
+ const foldInfoList = datasetReshapeInfo[0].foldInfoList;
5983
+ const unfoldInfo = datasetReshapeInfo[0].unfoldInfo;
5984
+ const { measureId, measureValue, measureName } = foldInfoList[1];
5985
+ const { groupName } = unfoldInfo;
5986
+ result.tooltip = {
5987
+ visible: enable,
5988
+ mark: {
5989
+ title: {
5990
+ visible: true
5991
+ },
5992
+ content: [
5993
+ ...dimensions.map((item)=>({
5994
+ visible: true,
5995
+ hasShape: true,
5996
+ shapeType: 'rectRound',
5997
+ key: (datum)=>{
5998
+ if (item.alias || item.id) return item.alias || item.id;
5999
+ return datum && datum[item.id];
6000
+ },
6001
+ value: (datum)=>datum && datum[item.id]
6002
+ })),
6003
+ {
6004
+ visible: true,
6005
+ hasShape: true,
6006
+ key: (datum)=>datum && datum[measureName || groupName] || '',
6007
+ value: (datum)=>{
6008
+ if (!datum) return '';
6009
+ const value = datum[measureValue];
6010
+ const id = datum[measureId];
6011
+ const measure = findMeasureById(measures, id);
6012
+ if (!measure) return String(value);
6013
+ const { format = {}, autoFormat = true } = measure;
6014
+ if (!isEmpty(format)) {
6015
+ const formatter = createFormatter(format);
6016
+ return formatter(value);
6017
+ }
6018
+ if (autoFormat) return autoFormatter(value, locale);
6019
+ return String(value);
6020
+ }
6021
+ }
6022
+ ]
6023
+ },
6024
+ dimension: {
6025
+ content: [
6026
+ {
6027
+ visible: true,
6028
+ key: (datum)=>datum && datum[groupName] || '',
6029
+ value: (datum)=>{
6030
+ if (!datum) return '';
6031
+ const value = datum[measureValue];
6032
+ const id = datum[measureId];
6033
+ const measure = findMeasureById(measures, id);
6034
+ if (!measure) return String(value);
6035
+ const { format = {}, autoFormat = true } = measure;
6036
+ if (!isEmpty(format)) {
6037
+ const formatter = createFormatter(format);
6038
+ return formatter(value);
6039
+ }
6040
+ if (autoFormat) return autoFormatter(value, locale);
6041
+ return String(value);
6042
+ },
6043
+ shapeType: 'rectRound'
6044
+ }
6045
+ ]
6046
+ }
6047
+ };
6048
+ return result;
6049
+ };
6050
+ const yLinearPrimary = (spec, context)=>{
6051
+ const result = {
6052
+ ...spec
6053
+ };
6054
+ const { advancedVSeed, vseed } = context;
6055
+ const { chartType } = vseed;
6056
+ const { locale, datasetReshapeInfo } = advancedVSeed;
6057
+ const config = advancedVSeed.config?.[chartType]?.primaryYAxis;
6058
+ if (datasetReshapeInfo[0].foldInfoList?.[0] && isEmpty(datasetReshapeInfo[0].foldInfoList[0].foldMap)) return result;
6059
+ const id = `${datasetReshapeInfo[0].id}-primary-axis`;
6060
+ const seriesId = `${datasetReshapeInfo[0].id}-primary-series`;
6061
+ if (!result.axes) result.axes = [];
6062
+ if (!config) {
6063
+ result.axes = [
6064
+ ...result.axes,
6065
+ {
6066
+ visible: true,
6067
+ id,
6068
+ seriesId,
6069
+ type: 'linear',
6070
+ orient: 'left',
6071
+ sync: {
6072
+ axisId: `${datasetReshapeInfo[0].id}-secondary-axis`,
6073
+ tickAlign: false,
6074
+ zeroAlign: true
6075
+ }
6076
+ }
6077
+ ];
6078
+ return result;
6079
+ }
6080
+ const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10 } = config;
6081
+ const linearAxis = {
6082
+ visible,
6083
+ id,
6084
+ seriesId,
6085
+ sync: {
6086
+ axisId: `${datasetReshapeInfo[0].id}-secondary-axis`,
6087
+ tickAlign: false,
6088
+ zeroAlign: true
6089
+ },
6090
+ type: log ? 'log' : 'linear',
6091
+ base: logBase,
6092
+ orient: 'left',
6093
+ nice,
6094
+ zero: log ? false : zero,
6095
+ inverse,
6096
+ max,
6097
+ min,
6098
+ label: {
6099
+ visible: label?.visible,
6100
+ formatMethod: (value)=>autoFormatter(value, locale),
6101
+ style: {
6102
+ fill: label?.labelColor,
6103
+ angle: label?.labelAngle,
6104
+ fontSize: label?.labelFontSize,
6105
+ fontWeight: label?.labelFontWeight
6106
+ }
6107
+ },
6108
+ title: {
6109
+ visible: title?.visible,
6110
+ text: title?.titleText,
6111
+ style: {
6112
+ fill: title?.titleColor,
6113
+ fontSize: title?.titleFontSize,
6114
+ fontWeight: title?.titleFontWeight
6115
+ }
6116
+ },
6117
+ tick: {
6118
+ visible: tick?.visible,
6119
+ tickSize: tick?.tickSize,
6120
+ inside: tick?.tickInside,
6121
+ style: {
6122
+ stroke: tick?.tickColor
6123
+ }
6124
+ },
6125
+ grid: {
6126
+ visible: grid?.visible,
6127
+ style: {
6128
+ lineWidth: grid?.gridWidth,
6129
+ stroke: grid?.gridColor
6130
+ }
6131
+ },
6132
+ domainLine: {
6133
+ visible: line?.visible,
6134
+ style: {
6135
+ lineWidth: line?.lineWidth,
6136
+ stroke: line?.lineColor
6137
+ }
6138
+ },
6139
+ innerOffset: {
6140
+ top: LINEAR_AXIS_INNER_OFFSET_TOP
6141
+ }
6142
+ };
6143
+ result.axes = [
6144
+ ...result.axes,
6145
+ linearAxis
6146
+ ];
6147
+ return result;
6148
+ };
6149
+ const yLinearSecondary = (spec, context)=>{
6150
+ const result = {
6151
+ ...spec
6152
+ };
6153
+ const { advancedVSeed, vseed } = context;
6154
+ const { chartType } = vseed;
6155
+ const { locale, datasetReshapeInfo } = advancedVSeed;
6156
+ const config = advancedVSeed.config?.[chartType]?.secondaryYAxis;
6157
+ if (isNullish(datasetReshapeInfo[0].foldInfoList?.[1])) return result;
6158
+ const id = `${datasetReshapeInfo[0].id}-secondary-axis`;
6159
+ const seriesId = `${datasetReshapeInfo[0].id}-secondary-series`;
6160
+ if (!result.axes) result.axes = [];
6161
+ if (!config) {
6162
+ result.axes = [
6163
+ ...result.axes,
6164
+ {
6165
+ visible: true,
6166
+ id,
6167
+ seriesId,
6168
+ type: 'linear',
6169
+ orient: 'right'
6170
+ }
6171
+ ];
6172
+ return result;
6173
+ }
6174
+ const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10 } = config;
6175
+ const linearAxis = {
6176
+ visible,
6177
+ id,
6178
+ seriesId,
6179
+ type: log ? 'log' : 'linear',
6180
+ base: logBase,
6181
+ orient: 'right',
6182
+ nice,
6183
+ zero: log ? false : zero,
6184
+ inverse,
6185
+ max,
6186
+ min,
6187
+ label: {
6188
+ visible: label?.visible,
6189
+ formatMethod: (value)=>autoFormatter(value, locale),
6190
+ style: {
6191
+ fill: label?.labelColor,
6192
+ angle: label?.labelAngle,
6193
+ fontSize: label?.labelFontSize,
6194
+ fontWeight: label?.labelFontWeight
6195
+ }
6196
+ },
6197
+ title: {
6198
+ visible: title?.visible,
6199
+ text: title?.titleText,
6200
+ style: {
6201
+ fill: title?.titleColor,
6202
+ fontSize: title?.titleFontSize,
6203
+ fontWeight: title?.titleFontWeight
6204
+ }
6205
+ },
6206
+ tick: {
6207
+ visible: tick?.visible,
6208
+ tickSize: tick?.tickSize,
6209
+ inside: tick?.tickInside,
6210
+ style: {
6211
+ stroke: tick?.tickColor
6212
+ }
6213
+ },
6214
+ grid: {
6215
+ visible: grid?.visible,
6216
+ style: {
6217
+ lineWidth: grid?.gridWidth,
6218
+ stroke: grid?.gridColor
6219
+ }
6220
+ },
6221
+ domainLine: {
6222
+ visible: line?.visible,
6223
+ style: {
6224
+ lineWidth: line?.lineWidth,
6225
+ stroke: line?.lineColor
6226
+ }
6227
+ },
6228
+ innerOffset: {
6229
+ top: LINEAR_AXIS_INNER_OFFSET_TOP
6230
+ }
6231
+ };
6232
+ result.axes = [
6233
+ ...result.axes,
6234
+ linearAxis
6235
+ ];
6236
+ return result;
6237
+ };
6238
+ const dualAxis = [
6239
+ series([
6240
+ initDualAxisPrimary,
6241
+ dualChartTypePrimary,
6242
+ datasetPrimary,
6243
+ labelPrimary,
6244
+ tooltipPrimary,
6245
+ progressive,
6246
+ barStyle_barStyle,
6247
+ pointStyle_pointStyle,
6248
+ pointStateDimensionHover,
6249
+ lineStyle_lineStyle,
6250
+ areaStyle_areaStyle
6251
+ ], [
6252
+ initDualAxisSecondary,
6253
+ dualChartTypeSecondary,
6254
+ datasetSecondary,
6255
+ labelSecondary,
6256
+ tooltipSecondary,
6257
+ progressive,
6258
+ barStyle_barStyle,
6259
+ pointStyle_pointStyle,
6260
+ pointStateDimensionHover,
6261
+ lineStyle_lineStyle,
6262
+ areaStyle_areaStyle
6263
+ ]),
6264
+ xBand,
6265
+ yLinearPrimary,
6266
+ yLinearSecondary,
6267
+ color_color,
6268
+ background_backgroundColor,
6269
+ discreteLegend,
6270
+ verticalCrosshairRect,
6271
+ annotationPoint_annotationPoint,
6272
+ annotationVerticalLine_annotationVerticalLine,
6273
+ annotationHorizontalLine_annotationHorizontalLine,
6274
+ annotationArea_annotationArea
6275
+ ];
6276
+ const pivotDualAxis = [
6277
+ initPivot,
6278
+ pivotGridStyle,
6279
+ pivotIndicators_pivotIndicatorsAsRow,
6280
+ datasetPivot,
6281
+ pivotIndicators_pivotIndicators([
6282
+ series([
6283
+ initDualAxisPrimary,
6284
+ datasetPrimary,
6285
+ labelPrimary,
6286
+ tooltipPrimary,
6287
+ progressive,
6288
+ barStyle_barStyle,
6289
+ pointStyle_pointStyle,
6290
+ pointStateDimensionHover,
6291
+ lineStyle_lineStyle,
6292
+ areaStyle_areaStyle
6293
+ ], [
6294
+ initDualAxisSecondary,
6295
+ datasetSecondary,
6296
+ labelSecondary,
6297
+ tooltipSecondary,
6298
+ progressive,
6299
+ barStyle_barStyle,
6300
+ pointStyle_pointStyle,
6301
+ pointStateDimensionHover,
6302
+ lineStyle_lineStyle,
6303
+ areaStyle_areaStyle
6304
+ ]),
6305
+ xBand,
6306
+ yLinearPrimary,
6307
+ yLinearSecondary,
6308
+ color_color,
6309
+ background_backgroundColor,
6310
+ verticalCrosshairRect,
6311
+ annotationPoint_annotationPoint,
6312
+ annotationVerticalLine_annotationVerticalLine,
6313
+ annotationHorizontalLine_annotationHorizontalLine,
6314
+ annotationArea_annotationArea
6315
+ ]),
6316
+ pivotRowDimensions,
6317
+ pivotColumnDimensions,
6318
+ pivotDiscreteLegend
6319
+ ];
6320
+ const dualAxisSpecPipeline = [
6321
+ pivotAdapter_pivotAdapter(dualAxis, pivotDualAxis)
6322
+ ];
6323
+ const registerDualAxis = ()=>{
6324
+ Builder._advancedPipelineMap.dualAxis = dualAxisAdvancedPipeline;
6325
+ Builder._specPipelineMap.dualAxis = dualAxisSpecPipeline;
6326
+ };
6327
+ const dataReshapeFor1D1M_emptyReshapeResult = {
6328
+ dataset: [],
6329
+ foldInfo: {
6330
+ foldMap: {},
6331
+ measureId: '',
6332
+ measureName: '',
6333
+ measureValue: ''
6334
+ },
6335
+ unfoldInfo: {
6336
+ groupName: '',
6337
+ groupId: '',
6338
+ colorItems: [],
6339
+ colorIdMap: {}
6340
+ }
6341
+ };
6342
+ const dataReshapeFor1D1M = (dataset, dimensions, measures, options)=>{
6343
+ const { foldMeasureId = FoldMeasureId, foldMeasureName = FoldMeasureName, foldMeasureValue = FoldMeasureValue, unfoldDimensionGroup = UnfoldDimensionGroup, unfoldDimensionGroupId = UnfoldDimensionGroupId } = options || {};
6344
+ if (0 === dimensions.length && 0 === measures.length) return dataReshapeFor1D1M_emptyReshapeResult;
6345
+ const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, foldMeasureId, foldMeasureName, foldMeasureValue);
6346
+ if (0 === dimensions.length) {
6347
+ const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
6348
+ {
6349
+ id: foldMeasureName,
6350
+ alias: i18n`指标名称`,
6351
+ location: 'dimension'
6352
+ }
6353
+ ], [
6354
+ {
6355
+ id: foldMeasureValue,
6356
+ alias: i18n`指标值`
6357
+ }
6358
+ ], 0, unfoldDimensionGroup, unfoldDimensionGroupId, foldMeasureId);
6359
+ return {
6360
+ dataset: finalDataset,
6361
+ foldInfo,
6362
+ unfoldInfo
6363
+ };
6364
+ }
6365
+ {
6366
+ const dims = 1 === measures.length ? [
6367
+ ...dimensions
6368
+ ] : [
6369
+ ...dimensions,
6370
+ {
6371
+ id: foldMeasureName,
6372
+ alias: i18n`指标名称`,
6373
+ location: 'dimension'
6374
+ }
6375
+ ];
6376
+ const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, dims, [
6377
+ {
6378
+ id: foldMeasureValue,
6379
+ alias: i18n`指标值`
6380
+ }
6381
+ ], 0, unfoldDimensionGroup, unfoldDimensionGroupId, foldMeasureId);
6382
+ return {
6383
+ dataset: finalDataset,
6384
+ foldInfo,
6385
+ unfoldInfo
6386
+ };
6387
+ }
6388
+ };
6389
+ const reshapeTo1D1M = (advancedVSeed, context)=>{
6390
+ const result = {
6391
+ ...advancedVSeed
6392
+ };
6393
+ const { vseed } = context;
6394
+ const { dataset } = vseed;
6395
+ const { dimensions, measures } = advancedVSeed;
6396
+ if (!measures || !dimensions || !dataset) return result;
6397
+ if (0 === measures.length) throw new Error('measures can not be empty');
6398
+ const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeFor1D1M(dataset, dimensions, measures);
6399
+ return {
6400
+ ...result,
6401
+ dataset: newDatasets,
6402
+ datasetReshapeInfo: [
6403
+ {
6404
+ id: '1D1M',
6405
+ index: 0,
6406
+ foldInfo,
6407
+ unfoldInfo
6408
+ }
6409
+ ]
6410
+ };
6411
+ };
6412
+ const pivotReshapeTo1D1M = (advancedVSeed, context)=>{
6413
+ const result = {
6414
+ ...advancedVSeed
6415
+ };
6416
+ const { vseed } = context;
6417
+ const { dataset } = vseed;
6418
+ const { measures } = advancedVSeed;
6419
+ const dimensions = advancedVSeed.dimensions;
6420
+ if (!measures || !dimensions) return result;
6421
+ const measureGroups = [];
6422
+ if (measures) measures.forEach((measure)=>{
6423
+ if (measure.children && measure.children.length > 0) measureGroups.push(measure);
6424
+ });
6425
+ const newDatasets = [];
6426
+ const datasetReshapeInfo = [];
6427
+ measureGroups.forEach((measureGroup, index)=>{
6428
+ const measures = measureGroup.children;
6429
+ if (!measures) return;
6430
+ const commonDimensions = dimensions.filter((dim)=>'dimension' === dim.location);
6431
+ const groupId = measureGroup.id;
6432
+ const { dataset: newSubDataset, foldInfo, unfoldInfo } = dataReshapeFor1D1M(dataset, commonDimensions, measures, {
6433
+ foldMeasureId: FoldMeasureId,
6434
+ foldMeasureName: FoldMeasureName,
6435
+ foldMeasureValue: FoldMeasureValue + groupId,
6436
+ unfoldDimensionGroup: UnfoldDimensionGroup
6437
+ });
6438
+ const reshapeInfo = {
6439
+ id: groupId,
6440
+ index,
6441
+ foldInfo,
6442
+ unfoldInfo
6443
+ };
6444
+ newDatasets.push(newSubDataset);
6445
+ datasetReshapeInfo.push(reshapeInfo);
6446
+ });
6447
+ return {
6448
+ ...result,
6449
+ dataset: newDatasets,
6450
+ datasetReshapeInfo: datasetReshapeInfo
6451
+ };
6452
+ };
6453
+ const encodingPie = (advancedVSeed)=>{
6454
+ const result = {
6455
+ ...advancedVSeed
6456
+ };
6457
+ const { datasetReshapeInfo } = advancedVSeed;
6458
+ if (!datasetReshapeInfo) return result;
6459
+ const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
6460
+ const { foldInfo, unfoldInfo } = cur;
6461
+ const radius = [
6462
+ foldInfo.measureValue
6463
+ ];
6464
+ const angle = [
6465
+ unfoldInfo.groupId
6466
+ ];
6467
+ const group = [
6468
+ unfoldInfo.groupId
6469
+ ];
6470
+ const color = [
6471
+ unfoldInfo.groupId
6472
+ ];
6473
+ return [
6474
+ ...prev,
6475
+ {
6476
+ angle,
6477
+ radius,
6478
+ group,
6479
+ color
6480
+ }
6481
+ ];
6482
+ }, []);
6483
+ return {
6484
+ ...result,
6485
+ encoding
6486
+ };
6487
+ };
6488
+ const pieAdvancedPipeline = [
6489
+ initAdvancedVSeed_initAdvancedVSeed,
6490
+ autoMeasures_autoMeasures,
6491
+ autoDimensions_autoDimensions,
6492
+ pivotAdapter([
6493
+ reshapeTo1D1M
6494
+ ], [
6495
+ pivotReshapeTo1D1M
6496
+ ]),
6497
+ encodingPie,
6498
+ pieConfig,
6499
+ theme_theme,
6500
+ annotation_annotation
6501
+ ];
6502
+ const initPie = (spec, context)=>{
6503
+ const result = {
6504
+ ...spec
6505
+ };
6506
+ const { advancedVSeed } = context;
6507
+ const { encoding, dataset } = advancedVSeed;
6508
+ if (!encoding[0].angle || !encoding[0].radius || !encoding[0].group) return result;
6509
+ const showStroke = dataset.length <= 30;
6510
+ result.type = 'pie';
6511
+ result.outerRadius = 0.8;
6512
+ result.innerRadius = 0;
6513
+ result.valueField = encoding[0].radius[0];
6514
+ result.categoryField = encoding[0].angle[0];
6515
+ result.seriesField = encoding[0].group[0];
6516
+ result.padding = 0;
5482
6517
  result.region = [
5483
6518
  {
5484
6519
  clip: true
@@ -6756,6 +7791,17 @@ const lightTheme = ()=>{
6756
7791
  },
6757
7792
  crosshairLine
6758
7793
  },
7794
+ dualAxis: {
7795
+ ...baseConfig,
7796
+ xAxis: bandAxis,
7797
+ primaryYAxis: linearAxis,
7798
+ secondaryYAxis: linearAxis,
7799
+ dualChartType: {
7800
+ primary: 'column',
7801
+ secondary: 'line'
7802
+ },
7803
+ crosshairRect
7804
+ },
6759
7805
  pie: {
6760
7806
  ...baseConfig
6761
7807
  },
@@ -7078,6 +8124,17 @@ const darkTheme = ()=>{
7078
8124
  },
7079
8125
  crosshairLine
7080
8126
  },
8127
+ dualAxis: {
8128
+ ...baseConfig,
8129
+ xAxis: bandAxis,
8130
+ primaryYAxis: linearAxis,
8131
+ secondaryYAxis: linearAxis,
8132
+ dualChartType: {
8133
+ primary: 'column',
8134
+ secondary: 'line'
8135
+ },
8136
+ crosshairRect
8137
+ },
7081
8138
  pie: {
7082
8139
  ...baseConfig
7083
8140
  },
@@ -7143,6 +8200,7 @@ const registerAll = ()=>{
7143
8200
  registerAreaPercent();
7144
8201
  registerAreaRange();
7145
8202
  registerScatter();
8203
+ registerDualAxis();
7146
8204
  registerPie();
7147
8205
  registerDonut();
7148
8206
  registerRose();
@@ -7182,6 +8240,26 @@ const zChartType = z["enum"]([
7182
8240
  'funnel',
7183
8241
  'heatmap'
7184
8242
  ]);
8243
+ const zDualChartType = z.object({
8244
+ primary: z["enum"]([
8245
+ 'line',
8246
+ 'column',
8247
+ 'columnPercent',
8248
+ 'columnParallel',
8249
+ 'area',
8250
+ 'areaPercent',
8251
+ 'scatter'
8252
+ ]).default('column'),
8253
+ secondary: z["enum"]([
8254
+ 'line',
8255
+ 'column',
8256
+ 'columnPercent',
8257
+ 'columnParallel',
8258
+ 'area',
8259
+ 'areaPercent',
8260
+ 'scatter'
8261
+ ]).default('line')
8262
+ });
7185
8263
  const zDatum = z.record(z.string().or(z.number()), z.any());
7186
8264
  const zDataset = z.array(zDatum);
7187
8265
  const zDimension = z.object({
@@ -7247,6 +8325,14 @@ const zMeasureGroup = z.object({
7247
8325
  });
7248
8326
  const zMeasures = z.array(zMeasure);
7249
8327
  const zMeasureTree = z.array(zMeasureGroup.or(zMeasure));
8328
+ const zDualMeasure = z.object({
8329
+ id: z.string(),
8330
+ primaryMeasures: z.array(zMeasure).or(zMeasure).optional(),
8331
+ primaryAlias: z.string().optional(),
8332
+ secondaryMeasures: z.array(zMeasure).or(zMeasure).optional(),
8333
+ secondaryAlias: z.string().optional()
8334
+ });
8335
+ const zDualMeasures = z.array(zDualMeasure);
7250
8336
  const zFoldInfo = z.object({
7251
8337
  foldMap: z.record(z.string(), z.string().or(z.undefined())),
7252
8338
  measureId: z.string(),
@@ -7261,7 +8347,9 @@ const zUnfoldInfo = z.object({
7261
8347
  });
7262
8348
  const zDatasetReshapeInfo = z.array(z.object({
7263
8349
  id: z.string(),
8350
+ index: z.number(),
7264
8351
  foldInfo: zFoldInfo,
8352
+ foldInfoList: z.array(zFoldInfo).optional(),
7265
8353
  unfoldInfo: zUnfoldInfo
7266
8354
  }));
7267
8355
  const zEncoding = z.array(z.object({
@@ -7541,7 +8629,12 @@ const zDualAxisConfig = z.object({
7541
8629
  label: zLabel.optional(),
7542
8630
  color: zColor.optional(),
7543
8631
  tooltip: zTooltip.optional(),
7544
- legend: zLegend.optional()
8632
+ legend: zLegend.optional(),
8633
+ dualChartType: z.array(zDualChartType).or(zDualChartType).optional(),
8634
+ primaryYAxis: z.array(zYLinearAxis).or(zYLinearAxis).optional(),
8635
+ secondaryYAxis: z.array(zYLinearAxis).or(zYLinearAxis).optional(),
8636
+ xAxis: zXBandAxis.optional(),
8637
+ crosshairRect: zCrosshairRect.optional()
7545
8638
  });
7546
8639
  const zScatterConfig = z.object({
7547
8640
  backgroundColor: zBackgroundColor.optional(),
@@ -7585,8 +8678,8 @@ const zConfig = z.object({
7585
8678
  area: zAreaConfig.optional(),
7586
8679
  areaPercent: zAreaPercentConfig.optional(),
7587
8680
  areaRange: zAreaRangeConfig.optional(),
7588
- dualAxis: zDualAxisConfig.optional(),
7589
8681
  scatter: zScatterConfig.optional(),
8682
+ dualAxis: zDualAxisConfig.optional(),
7590
8683
  rose: zRoseConfig.optional(),
7591
8684
  roseParallel: zRoseParallelConfig.optional(),
7592
8685
  pie: zPieConfig.optional(),
@@ -8239,6 +9332,35 @@ const zScatter = z.object({
8239
9332
  annotationArea: z.array(zAnnotationArea).or(zAnnotationArea).optional(),
8240
9333
  locale: zLocale.optional()
8241
9334
  });
9335
+ const zDualAxis = z.object({
9336
+ chartType: z.literal('dualAxis'),
9337
+ dataset: zDataset.optional(),
9338
+ dimensions: zDimensions.optional(),
9339
+ measures: zMeasureTree.optional(),
9340
+ dualMeasures: zDualMeasures.optional(),
9341
+ dualChartType: z.array(zDualChartType).or(zDualChartType).optional(),
9342
+ primaryYAxis: z.array(zYLinearAxis).or(zYLinearAxis).optional(),
9343
+ secondaryYAxis: z.array(zYLinearAxis).or(zYLinearAxis).optional(),
9344
+ xAxis: zXBandAxis.optional(),
9345
+ backgroundColor: zBackgroundColor.optional(),
9346
+ color: zColor.optional(),
9347
+ label: zLabel.optional(),
9348
+ legend: zLegend.optional(),
9349
+ tooltip: zTooltip.optional(),
9350
+ crosshairRect: zCrosshairRect.optional(),
9351
+ sort: zSort.optional(),
9352
+ sortLegend: zSortLegend.optional(),
9353
+ theme: zTheme.optional(),
9354
+ barStyle: z.array(zBarStyle).or(zBarStyle).optional(),
9355
+ pointStyle: z.array(zPointStyle).or(zPointStyle).optional(),
9356
+ lineStyle: z.array(zLineStyle).or(zLineStyle).optional(),
9357
+ areaStyle: z.array(zAreaStyle).or(zAreaStyle).optional(),
9358
+ annotationPoint: z.array(zAnnotationPoint).or(zAnnotationPoint).optional(),
9359
+ annotationVerticalLine: z.array(zAnnotationVerticalLine).or(zAnnotationVerticalLine).optional(),
9360
+ annotationHorizontalLine: z.array(zAnnotationHorizontalLine).or(zAnnotationHorizontalLine).optional(),
9361
+ annotationArea: z.array(zAnnotationArea).or(zAnnotationArea).optional(),
9362
+ locale: zLocale.optional()
9363
+ });
8242
9364
  const zRose = z.object({
8243
9365
  chartType: z.literal('rose'),
8244
9366
  dataset: zDataset.optional(),
@@ -8344,6 +9466,7 @@ const zVSeed = z.discriminatedUnion('chartType', [
8344
9466
  zAreaPercent,
8345
9467
  zAreaRange,
8346
9468
  zScatter,
9469
+ zDualAxis,
8347
9470
  zPie,
8348
9471
  zDonut,
8349
9472
  zRose,
@@ -8367,6 +9490,6 @@ const zAdvancedVSeed = z.object({
8367
9490
  annotation: zAnnotation,
8368
9491
  locale: zLocale
8369
9492
  });
8370
- export { Builder, FoldMeasureId, FoldMeasureName, FoldMeasureValue, ORIGINAL_DATA, Separator, UnfoldDimensionGroup, UnfoldDimensionGroupId, areaAdvancedPipeline, areaPercentAdvancedPipeline, areaPercentSpecPipeline, areaRangeAdvancedPipeline, areaRangeSpecPipeline, areaSpecPipeline, autoFormatter, autoNumFormatter, barAdvancedPipeline, barParallelAdvancedPipeline, barParallelSpecPipeline, barPercentAdvancedPipeline, barPercentSpecPipeline, barSpecPipeline, columnAdvancedPipeline, columnParallelAdvancedPipeline, columnParallelSpecPipeline, columnPercentAdvancedPipeline, columnPercentSpecPipeline, columnSpecPipeline, createFormatter, createNumFormatter, darkTheme, dataReshapeFor1D, dataReshapeFor1D1M, dataReshapeFor1D2M, dataReshapeFor2D1M, dataReshapeFor2D1M0Name, donutAdvancedPipeline, donutSpecPipeline, execPipeline, findAllDimensions, findAllMeasures, findDimensionById, findFirstDimension, findFirstMeasure, findMeasureById, foldMeasures, funnelAdvancedPipeline, funnelSpecPipeline, heatmapAdvancedPipeline, heatmapSpecPipeline, i18n, intl, isDimensionSelector, isMeasureSelector, isPartialDatumSelector, isPivotChart, isPivotTable, isTable, isVChart, isVTable, isValueSelector, lightTheme, lineAdvancedPipeline, lineSpecPipeline, pieAdvancedPipeline, pieSpecPipeline, pivotTableAdvancedPipeline, pivotTableSpecPipeline, preorderTraverse, radarAdvancedPipeline, radarSpecPipeline, registerAll, registerArea, registerAreaPercent, registerAreaRange, registerBar, registerBarParallel, registerBarPercent, registerColumn, registerColumnParallel, registerColumnPercent, registerCustomTheme, registerDarkTheme, registerDonut, registerFunnel, registerHeatmap, registerLightTheme, registerLine, registerPie, registerPivotTable, registerRadar, registerRose, registerRoseParallel, registerScatter, registerTable, roseAdvancedPipeline, roseParallelAdvancedPipeline, roseParallelSpecPipeline, roseSpecPipeline, scatterAdvancedPipeline, scatterSpecPipeline, selector_selector as selector, tableAdvancedPipeline, tableSpecPipeline, unfoldDimensions, updateAdvanced, updateSpec, zAdvancedVSeed, zAnalysis, zAnnotation, zAnnotationArea, zAnnotationHorizontalLine, zAnnotationPoint, zAnnotationVerticalLine, zArea, zAreaConfig, zAreaPercent, zAreaPercentConfig, zAreaRange, zAreaRangeConfig, zAreaStyle, zAxis, zBackgroundColor, zBar, zBarConfig, zBarParallel, zBarParallelConfig, zBarPercent, zBarPercentConfig, zBarStyle, zChartType, zColor, zColorLegend, zColumn, zColumnConfig, zColumnParallel, zColumnParallelConfig, zColumnPercent, zColumnPercentConfig, zConfig, zCrosshairLine, zCrosshairRect, zCustomTheme, zCustomThemeConfig, zDataset, zDatasetReshapeInfo, zDatum, zDimension, zDimensionGroup, zDimensionTree, zDimensions, zDonut, zDonutConfig, zDualAxisConfig, zEncoding, zFoldInfo, zFunnel, zFunnelConfig, zHeatmap, zHeatmapConfig, zLabel, zLegend, zLine, zLineConfig, zLineStyle, zLinearColor, zLocale, zMarkStyle, zMeasure, zMeasureGroup, zMeasureTree, zMeasures, zNumFormat, zPie, zPieConfig, zPivotTable, zPivotTableConfig, zPointStyle, zRadar, zRadarConfig, zRose, zRoseConfig, zRoseParallel, zRoseParallelConfig, zScatter, zScatterConfig, zSort, zSortLegend, zStackCornerRadius, zTable, zTableConfig, zTheme, zTooltip, zUnfoldInfo, zVSeed, zXBandAxis, zXLinearAxis, zYBandAxis, zYLinearAxis };
9493
+ export { Builder, FoldMeasureId, FoldMeasureName, FoldMeasureValue, FoldPrimaryMeasureValue, FoldSecondaryMeasureValue, ORIGINAL_DATA, Separator, UnfoldDimensionGroup, UnfoldDimensionGroupId, areaAdvancedPipeline, areaPercentAdvancedPipeline, areaPercentSpecPipeline, areaRangeAdvancedPipeline, areaRangeSpecPipeline, areaSpecPipeline, autoFormatter, autoNumFormatter, barAdvancedPipeline, barParallelAdvancedPipeline, barParallelSpecPipeline, barPercentAdvancedPipeline, barPercentSpecPipeline, barSpecPipeline, columnAdvancedPipeline, columnParallelAdvancedPipeline, columnParallelSpecPipeline, columnPercentAdvancedPipeline, columnPercentSpecPipeline, columnSpecPipeline, createFormatter, createNumFormatter, darkTheme, dataReshapeFor1D, dataReshapeFor1D1M, dataReshapeFor1D2M, dataReshapeFor2D1M, dataReshapeFor2D1M0Name, donutAdvancedPipeline, donutSpecPipeline, dualAxisAdvancedPipeline, dualAxisSpecPipeline, execPipeline, findAllDimensions, findAllMeasures, findDimensionById, findFirstDimension, findFirstMeasure, findMeasureById, foldMeasures, funnelAdvancedPipeline, funnelSpecPipeline, heatmapAdvancedPipeline, heatmapSpecPipeline, i18n, intl, isDimensionSelector, isMeasureSelector, isPartialDatumSelector, isPivotChart, isPivotTable, isTable, isVChart, isVTable, isValueSelector, lightTheme, lineAdvancedPipeline, lineSpecPipeline, measureDepth, pieAdvancedPipeline, pieSpecPipeline, pivotTableAdvancedPipeline, pivotTableSpecPipeline, preorderTraverse, radarAdvancedPipeline, radarSpecPipeline, registerAll, registerArea, registerAreaPercent, registerAreaRange, registerBar, registerBarParallel, registerBarPercent, registerColumn, registerColumnParallel, registerColumnPercent, registerCustomTheme, registerDarkTheme, registerDonut, registerFunnel, registerHeatmap, registerLightTheme, registerLine, registerPie, registerPivotTable, registerRadar, registerRose, registerRoseParallel, registerScatter, registerTable, roseAdvancedPipeline, roseParallelAdvancedPipeline, roseParallelSpecPipeline, roseSpecPipeline, scatterAdvancedPipeline, scatterSpecPipeline, selector_selector as selector, tableAdvancedPipeline, tableSpecPipeline, unfoldDimensions, updateAdvanced, updateSpec, zAdvancedVSeed, zAnalysis, zAnnotation, zAnnotationArea, zAnnotationHorizontalLine, zAnnotationPoint, zAnnotationVerticalLine, zArea, zAreaConfig, zAreaPercent, zAreaPercentConfig, zAreaRange, zAreaRangeConfig, zAreaStyle, zAxis, zBackgroundColor, zBar, zBarConfig, zBarParallel, zBarParallelConfig, zBarPercent, zBarPercentConfig, zBarStyle, zChartType, zColor, zColorLegend, zColumn, zColumnConfig, zColumnParallel, zColumnParallelConfig, zColumnPercent, zColumnPercentConfig, zConfig, zCrosshairLine, zCrosshairRect, zCustomTheme, zCustomThemeConfig, zDataset, zDatasetReshapeInfo, zDatum, zDimension, zDimensionGroup, zDimensionTree, zDimensions, zDonut, zDonutConfig, zDualAxis, zDualAxisConfig, zDualChartType, zDualMeasure, zDualMeasures, zEncoding, zFoldInfo, zFunnel, zFunnelConfig, zHeatmap, zHeatmapConfig, zLabel, zLegend, zLine, zLineConfig, zLineStyle, zLinearColor, zLocale, zMarkStyle, zMeasure, zMeasureGroup, zMeasureTree, zMeasures, zNumFormat, zPie, zPieConfig, zPivotTable, zPivotTableConfig, zPointStyle, zRadar, zRadarConfig, zRose, zRoseConfig, zRoseParallel, zRoseParallelConfig, zScatter, zScatterConfig, zSort, zSortLegend, zStackCornerRadius, zTable, zTableConfig, zTheme, zTooltip, zUnfoldInfo, zVSeed, zXBandAxis, zXLinearAxis, zYBandAxis, zYLinearAxis };
8371
9494
 
8372
9495
  //# sourceMappingURL=index.js.map