@visactor/vseed 0.1.15 → 0.1.16

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 (69) hide show
  1. package/dist/cjs/index.cjs +3 -1
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/esm/builder/builder/buildAdvanced.js +1 -1
  4. package/dist/esm/builder/builder/buildAdvanced.js.map +1 -1
  5. package/dist/esm/builder/builder/buildSpec.js +2 -3
  6. package/dist/esm/builder/builder/buildSpec.js.map +1 -1
  7. package/dist/esm/dataReshape/foldMeasures.d.ts +1 -0
  8. package/dist/esm/dataReshape/foldMeasures.js +5 -1
  9. package/dist/esm/dataReshape/foldMeasures.js.map +1 -1
  10. package/dist/esm/pipeline/advanced/chart/pipes/default/defaultDimensions.js +4 -3
  11. package/dist/esm/pipeline/advanced/chart/pipes/default/defaultDimensions.js.map +1 -1
  12. package/dist/esm/pipeline/advanced/chart/pipes/default/defaultMeasures.js +12 -9
  13. package/dist/esm/pipeline/advanced/chart/pipes/default/defaultMeasures.js.map +1 -1
  14. package/dist/esm/pipeline/advanced/chart/pipes/init/initAdvancedVSeed.js +2 -0
  15. package/dist/esm/pipeline/advanced/chart/pipes/init/initAdvancedVSeed.js.map +1 -1
  16. package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithDualEncoding.js +4 -6
  17. package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithDualEncoding.js.map +1 -1
  18. package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithEncoding.js +2 -5
  19. package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithEncoding.js.map +1 -1
  20. package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithScatterEncoding.js +2 -4
  21. package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithScatterEncoding.js.map +1 -1
  22. package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithDualEncoding.js +4 -6
  23. package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithDualEncoding.js.map +1 -1
  24. package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithEncoding.js +2 -5
  25. package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithEncoding.js.map +1 -1
  26. package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithScatterEncoding.js +2 -4
  27. package/dist/esm/pipeline/advanced/chart/pipes/reshape/reshapeWithScatterEncoding.js.map +1 -1
  28. package/dist/esm/pipeline/advanced/table/pipes/default/defaultDimensions.js +13 -7
  29. package/dist/esm/pipeline/advanced/table/pipes/default/defaultDimensions.js.map +1 -1
  30. package/dist/esm/pipeline/advanced/table/pipes/default/defaultMeasures.js +13 -9
  31. package/dist/esm/pipeline/advanced/table/pipes/default/defaultMeasures.js.map +1 -1
  32. package/dist/esm/pipeline/advanced/table/pipes/init/initAdvancedVSeed.js +2 -0
  33. package/dist/esm/pipeline/advanced/table/pipes/init/initAdvancedVSeed.js.map +1 -1
  34. package/dist/esm/pipeline/advanced/table/pipes/reshape/reshapePivotTable.js +2 -1
  35. package/dist/esm/pipeline/advanced/table/pipes/reshape/reshapePivotTable.js.map +1 -1
  36. package/dist/esm/pipeline/spec/chart/pipes/axes/format/linearFormat.d.ts +2 -0
  37. package/dist/esm/pipeline/spec/chart/pipes/axes/format/linearFormat.js +11 -0
  38. package/dist/esm/pipeline/spec/chart/pipes/axes/format/linearFormat.js.map +1 -0
  39. package/dist/esm/pipeline/spec/chart/pipes/axes/title/defaultTitleText.d.ts +2 -0
  40. package/dist/esm/pipeline/spec/chart/pipes/axes/title/defaultTitleText.js +14 -0
  41. package/dist/esm/pipeline/spec/chart/pipes/axes/title/defaultTitleText.js.map +1 -0
  42. package/dist/esm/pipeline/spec/chart/pipes/axes/xBand.js +3 -1
  43. package/dist/esm/pipeline/spec/chart/pipes/axes/xBand.js.map +1 -1
  44. package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js +8 -11
  45. package/dist/esm/pipeline/spec/chart/pipes/axes/xLinear.js.map +1 -1
  46. package/dist/esm/pipeline/spec/chart/pipes/axes/yBand.js +3 -1
  47. package/dist/esm/pipeline/spec/chart/pipes/axes/yBand.js.map +1 -1
  48. package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js +7 -10
  49. package/dist/esm/pipeline/spec/chart/pipes/axes/yLinear.js.map +1 -1
  50. package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearPrimary.js +8 -10
  51. package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearPrimary.js.map +1 -1
  52. package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearSecondary.js +8 -10
  53. package/dist/esm/pipeline/spec/chart/pipes/axes/yLinearSecondary.js.map +1 -1
  54. package/dist/esm/pipeline/spec/chart/pipes/label/label.js +2 -2
  55. package/dist/esm/pipeline/spec/chart/pipes/label/label.js.map +1 -1
  56. package/dist/esm/pipeline/utils/format/createFormatterByMeasure.js +4 -3
  57. package/dist/esm/pipeline/utils/format/createFormatterByMeasure.js.map +1 -1
  58. package/dist/esm/pipeline/utils/index.d.ts +1 -0
  59. package/dist/esm/pipeline/utils/index.js +1 -0
  60. package/dist/esm/pipeline/utils/valid/checkVSeed.d.ts +2 -0
  61. package/dist/esm/pipeline/utils/valid/checkVSeed.js +11 -0
  62. package/dist/esm/pipeline/utils/valid/checkVSeed.js.map +1 -0
  63. package/dist/esm/pipeline/utils/valid/index.d.ts +1 -0
  64. package/dist/esm/pipeline/utils/valid/index.js +2 -0
  65. package/dist/esm/types/properties/config/axes/linearAxis.d.ts +3 -3
  66. package/dist/esm/types/properties/config/label/label.d.ts +2 -2
  67. package/dist/umd/index.js +166 -153
  68. package/dist/umd/index.js.map +1 -1
  69. package/package.json +1 -1
package/dist/umd/index.js CHANGED
@@ -148,8 +148,8 @@
148
148
  registerHeatmap: ()=>registerHeatmap,
149
149
  registerBarPercent: ()=>registerBarPercent,
150
150
  ColorIdEncoding: ()=>ColorIdEncoding,
151
+ checkVSeed: ()=>checkVSeed,
151
152
  roseSpecPipeline: ()=>roseSpecPipeline,
152
- zCrosshairLine: ()=>zCrosshairLine,
153
153
  registerLightTheme: ()=>registerLightTheme,
154
154
  roseAdvancedPipeline: ()=>roseAdvancedPipeline,
155
155
  zBarParallel: ()=>zBarParallel,
@@ -175,9 +175,9 @@
175
175
  isVChart: ()=>isVChart,
176
176
  radarSpecPipeline: ()=>radarSpecPipeline,
177
177
  Builder: ()=>Builder,
178
+ zCrosshairLine: ()=>zCrosshairLine,
178
179
  zMeasureTree: ()=>zMeasureTree,
179
180
  zPieConfig: ()=>zPieConfig,
180
- zPivotTable: ()=>zPivotTable,
181
181
  registerLine: ()=>registerLine,
182
182
  registerCustomTheme: ()=>registerCustomTheme,
183
183
  zColor: ()=>zColor,
@@ -196,18 +196,19 @@
196
196
  zAreaConfig: ()=>zAreaConfig,
197
197
  zMeasures: ()=>zMeasures,
198
198
  isVTable: ()=>isVTable,
199
+ zPivotTable: ()=>zPivotTable,
199
200
  zRadar: ()=>zRadar,
200
- zRadarConfig: ()=>zRadarConfig,
201
201
  zLine: ()=>zLine,
202
202
  columnSpecPipeline: ()=>columnSpecPipeline,
203
203
  zFoldInfo: ()=>zFoldInfo,
204
204
  zDatasetReshapeInfo: ()=>zDatasetReshapeInfo,
205
205
  zLinearColor: ()=>zLinearColor,
206
- zStackCornerRadius: ()=>zStackCornerRadius,
206
+ zRadarConfig: ()=>zRadarConfig,
207
207
  zAreaStyle: ()=>zAreaStyle,
208
208
  ORIGINAL_DATA: ()=>ORIGINAL_DATA,
209
- zUnfoldInfo: ()=>zUnfoldInfo,
209
+ zStackCornerRadius: ()=>zStackCornerRadius,
210
210
  zAnnotationArea: ()=>zAnnotationArea,
211
+ zUnfoldInfo: ()=>zUnfoldInfo,
211
212
  DetailEncoding: ()=>DetailEncoding,
212
213
  zRose: ()=>zRose,
213
214
  columnParallelSpecPipeline: ()=>columnParallelSpecPipeline,
@@ -337,7 +338,7 @@
337
338
  return advancedVSeed;
338
339
  } catch (e) {
339
340
  console.error(e);
340
- throw new Error("buildAdvanced error, see error info in console");
341
+ throw new Error(`buildAdvanced error: ${e.message}.\ndetails info in console`);
341
342
  } finally{
342
343
  const end = 'undefined' != typeof performance ? performance.now() : Date.now();
343
344
  builder.performance['buildAdvanced'] = `${(end - start).toFixed(4)}ms`;
@@ -346,9 +347,8 @@
346
347
  const buildSpec = (builder, advancedVSeed)=>{
347
348
  const start = 'undefined' != typeof performance ? performance.now() : Date.now();
348
349
  const { chartType } = builder.vseed;
349
- if (!chartType) throw new Error('chartType is nil in buildSpec');
350
350
  const pipeline = Builder.getSpecPipeline(chartType);
351
- if (!pipeline) throw new Error(`no spec pipeline for chartType ${chartType}`);
351
+ if (!pipeline) throw new Error(`please invoke registerAll or register ${chartType} before build, no spec pipeline for chartType ${chartType}`);
352
352
  const context = {
353
353
  vseed: builder.vseed,
354
354
  advancedVSeed
@@ -360,7 +360,7 @@
360
360
  return spec;
361
361
  } catch (e) {
362
362
  console.error(e);
363
- throw new Error("buildSpec error, see error info in console");
363
+ throw new Error(`buildSpec error: ${e.message}.\ndetails info in console`);
364
364
  } finally{
365
365
  const end = 'undefined' != typeof performance ? performance.now() : Date.now();
366
366
  builder.performance['buildSpec'] = `${(end - start).toFixed(4)}ms`;
@@ -638,27 +638,79 @@
638
638
  static _customSpecPipe = {};
639
639
  static _themeMap = {};
640
640
  }
641
+ function chunk_VCYTMP4D_n(e) {
642
+ return void 0 === e ? !0 : "string" == typeof e || Array.isArray(e) ? 0 === e.length : 0 === Object.keys(e).length;
643
+ }
644
+ const checkVSeed = (vseed)=>{
645
+ const { chartType, dataset, dimensions, measures } = vseed;
646
+ if (!chartType) throw new Error('chartType is required');
647
+ if (!dataset || chunk_VCYTMP4D_n(dataset)) throw new Error('dataset is required, and must be an array');
648
+ if (dimensions && !Array.isArray(dimensions)) throw new Error('dimensions must be an array');
649
+ if (measures && !Array.isArray(measures)) throw new Error('measures must be an array');
650
+ };
641
651
  const initAdvancedVSeed = (advancedVSeed, context)=>{
642
652
  const { vseed } = context;
643
653
  const { chartType, locale } = vseed;
654
+ checkVSeed(vseed);
644
655
  return {
645
656
  ...advancedVSeed,
646
657
  chartType,
647
658
  locale: locale || 'zh-CN'
648
659
  };
649
660
  };
661
+ function chunk_D6FCK2GA_u(o, n, a) {
662
+ let t = (r)=>o(r, ...n);
663
+ return void 0 === a ? t : Object.assign(t, {
664
+ lazy: a,
665
+ lazyArgs: n
666
+ });
667
+ }
668
+ function chunk_WIMGWYZL_u(r, n, o) {
669
+ let a = r.length - n.length;
670
+ if (0 === a) return r(...n);
671
+ if (1 === a) return chunk_D6FCK2GA_u(r, n, o);
672
+ throw new Error("Wrong number of arguments");
673
+ }
674
+ function chunk_BCBB46UE_d(...n) {
675
+ return chunk_WIMGWYZL_u(chunk_BCBB46UE_u, n);
676
+ }
677
+ function chunk_BCBB46UE_u(n, o = [], t = []) {
678
+ if ("function" == typeof n) return n;
679
+ if ("object" != typeof n || null === n) return structuredClone(n);
680
+ let r = Object.getPrototypeOf(n);
681
+ if (!Array.isArray(n) && null !== r && r !== Object.prototype) return structuredClone(n);
682
+ let e = o.indexOf(n);
683
+ return -1 !== e ? t[e] : (o.push(n), Array.isArray(n) ? chunk_BCBB46UE_p(n, o, t) : chunk_BCBB46UE_i(n, o, t));
684
+ }
685
+ function chunk_BCBB46UE_i(n, o, t) {
686
+ let r = {};
687
+ t.push(r);
688
+ for (let [e, c] of Object.entries(n))r[e] = chunk_BCBB46UE_u(c, o, t);
689
+ return r;
690
+ }
691
+ function chunk_BCBB46UE_p(n, o, t) {
692
+ let r = [];
693
+ t.push(r);
694
+ for (let [e, c] of n.entries())r[e] = chunk_BCBB46UE_u(c, o, t);
695
+ return r;
696
+ }
697
+ const isMeasure = (measure)=>!('children' in measure);
698
+ const isMeasureGroup = (measure)=>'children' in measure;
699
+ const isMeasures = (measures)=>measures.every(isMeasure);
650
700
  const defaultMeasures_defaultMeasures = (advancedVSeed, context)=>{
651
701
  const { vseed } = context;
652
702
  const { measures, dataset } = vseed;
653
- if (measures && measures.length > 0) return {
654
- ...advancedVSeed,
655
- measures
656
- };
657
- if (!dataset) throw new Error('dataset is required');
658
- if (0 === dataset.length) return {
659
- ...advancedVSeed,
660
- measures: []
661
- };
703
+ if (measures && measures.length > 0) {
704
+ const clonedMeasures = chunk_BCBB46UE_d(measures);
705
+ preorderTraverse(clonedMeasures, (node)=>{
706
+ if (isMeasure(node)) node.alias = node.alias || node.id;
707
+ return false;
708
+ });
709
+ return {
710
+ ...advancedVSeed,
711
+ measures: clonedMeasures
712
+ };
713
+ }
662
714
  const top100dataset = dataset.slice(0, 100);
663
715
  const sample = top100dataset.reduce((prev, cur)=>({
664
716
  ...prev,
@@ -677,6 +729,8 @@
677
729
  measures: defaultMeasures
678
730
  };
679
731
  };
732
+ const isDimension = (dimension)=>!('children' in dimension);
733
+ const isDimensionGroup = (dimension)=>'children' in dimension;
680
734
  const findMeasureById = (measures = [], id)=>{
681
735
  if (!measures) return;
682
736
  let result;
@@ -718,12 +772,17 @@
718
772
  };
719
773
  const { vseed } = context;
720
774
  const { dimensions, dataset } = vseed;
721
- if (dimensions && dimensions.length > 0) return {
722
- ...result,
723
- dimensions
724
- };
725
- if (!dataset) throw new Error('dataset is required');
726
- if (0 === dataset.length) return result;
775
+ if (dimensions && dimensions.length > 0) {
776
+ const clonedDimensions = chunk_BCBB46UE_d(dimensions);
777
+ preorderTraverse(clonedDimensions, (node)=>{
778
+ if (isDimension(node)) node.alias = node.alias || node.id;
779
+ return false;
780
+ });
781
+ return {
782
+ ...advancedVSeed,
783
+ dimensions: clonedDimensions
784
+ };
785
+ }
727
786
  const measures = findAllMeasures(advancedVSeed.measures);
728
787
  const top100dataset = dataset.slice(0, 100);
729
788
  const sample = top100dataset.reduce((prev, cur)=>({
@@ -751,19 +810,6 @@
751
810
  dataset
752
811
  };
753
812
  };
754
- function chunk_D6FCK2GA_u(o, n, a) {
755
- let t = (r)=>o(r, ...n);
756
- return void 0 === a ? t : Object.assign(t, {
757
- lazy: a,
758
- lazyArgs: n
759
- });
760
- }
761
- function chunk_WIMGWYZL_u(r, n, o) {
762
- let a = r.length - n.length;
763
- if (0 === a) return r(...n);
764
- if (1 === a) return chunk_D6FCK2GA_u(r, n, o);
765
- throw new Error("Wrong number of arguments");
766
- }
767
813
  function chunk_2T7K3PFL_i(...e) {
768
814
  return chunk_WIMGWYZL_u(chunk_2T7K3PFL_o, e);
769
815
  }
@@ -821,29 +867,6 @@
821
867
  }
822
868
  return r;
823
869
  }
824
- function chunk_BCBB46UE_d(...n) {
825
- return chunk_WIMGWYZL_u(chunk_BCBB46UE_u, n);
826
- }
827
- function chunk_BCBB46UE_u(n, o = [], t = []) {
828
- if ("function" == typeof n) return n;
829
- if ("object" != typeof n || null === n) return structuredClone(n);
830
- let r = Object.getPrototypeOf(n);
831
- if (!Array.isArray(n) && null !== r && r !== Object.prototype) return structuredClone(n);
832
- let e = o.indexOf(n);
833
- return -1 !== e ? t[e] : (o.push(n), Array.isArray(n) ? chunk_BCBB46UE_p(n, o, t) : chunk_BCBB46UE_i(n, o, t));
834
- }
835
- function chunk_BCBB46UE_i(n, o, t) {
836
- let r = {};
837
- t.push(r);
838
- for (let [e, c] of Object.entries(n))r[e] = chunk_BCBB46UE_u(c, o, t);
839
- return r;
840
- }
841
- function chunk_BCBB46UE_p(n, o, t) {
842
- let r = [];
843
- t.push(r);
844
- for (let [e, c] of n.entries())r[e] = chunk_BCBB46UE_u(c, o, t);
845
- return r;
846
- }
847
870
  function chunk_SFZGYJFI_t(r) {
848
871
  return "string" == typeof r;
849
872
  }
@@ -931,9 +954,6 @@
931
954
  }
932
955
  };
933
956
  };
934
- const isMeasure = (measure)=>!('children' in measure);
935
- const isMeasureGroup = (measure)=>'children' in measure;
936
- const isMeasures = (measures)=>measures.every(isMeasure);
937
957
  const dimensionTreeToColumns = (spec, context)=>{
938
958
  const { advancedVSeed } = context;
939
959
  const dimensions = advancedVSeed.dimensions;
@@ -1040,15 +1060,13 @@
1040
1060
  };
1041
1061
  const createFormatter = (format, locale)=>createNumFormatter(format, locale);
1042
1062
  const autoFormatter = (value, locale = intl.getLocale())=>autoNumFormatter(value, locale);
1043
- function chunk_VCYTMP4D_n(e) {
1044
- return void 0 === e ? !0 : "string" == typeof e || Array.isArray(e) ? 0 === e.length : 0 === Object.keys(e).length;
1045
- }
1046
1063
  const createFormatterByMeasure = (measure)=>{
1047
1064
  if (!measure) return (v)=>String(v);
1048
- const { numFormat, format, autoFormat = true } = measure;
1065
+ const { numFormat, format, autoFormat } = measure;
1049
1066
  const formatterFormat = numFormat || format || {};
1067
+ if (true === autoFormat) return autoFormatter;
1068
+ if (chunk_JK3VNB42_n(autoFormat) && chunk_VCYTMP4D_n(formatterFormat)) return autoFormatter;
1050
1069
  if (!chunk_VCYTMP4D_n(formatterFormat)) return createFormatter(formatterFormat);
1051
- if (autoFormat) return autoFormatter;
1052
1070
  return (v)=>String(v);
1053
1071
  };
1054
1072
  const measureTreeToColumns = (spec, context)=>{
@@ -1337,7 +1355,7 @@
1337
1355
  return o;
1338
1356
  }
1339
1357
  const foldMeasures = (dataset, measures, options)=>{
1340
- const { measureId, measureName, measureValue, colorMeasureId } = options || {};
1358
+ const { measureId, measureName, measureValue, colorMeasureId, allowEmptyFold = true } = options || {};
1341
1359
  const foldInfo = {
1342
1360
  measureId,
1343
1361
  measureName,
@@ -1352,6 +1370,10 @@
1352
1370
  },
1353
1371
  foldMap: {}
1354
1372
  };
1373
+ if (!allowEmptyFold && 0 === measures.length) return {
1374
+ dataset,
1375
+ foldInfo
1376
+ };
1355
1377
  const result = new Array(dataset.length * measures.length);
1356
1378
  let index = 0;
1357
1379
  const ids = measures.map((d)=>d.id);
@@ -1397,7 +1419,8 @@
1397
1419
  const { dataset: newDatasets, foldInfo } = foldMeasures(dataset, findAllMeasures(measures), {
1398
1420
  measureId: FoldMeasureId,
1399
1421
  measureName: FoldMeasureName,
1400
- measureValue: FoldMeasureValue
1422
+ measureValue: FoldMeasureValue,
1423
+ allowEmptyFold: false
1401
1424
  });
1402
1425
  const datasetReshapeInfo = [
1403
1426
  {
@@ -1691,6 +1714,7 @@
1691
1714
  const initAdvancedVSeed_initAdvancedVSeed = (advancedVSeed, context)=>{
1692
1715
  const { vseed } = context;
1693
1716
  const { chartType, locale } = vseed;
1717
+ checkVSeed(vseed);
1694
1718
  return {
1695
1719
  ...advancedVSeed,
1696
1720
  chartType,
@@ -1700,15 +1724,17 @@
1700
1724
  const default_defaultMeasures_defaultMeasures = (advancedVSeed, context)=>{
1701
1725
  const { vseed } = context;
1702
1726
  const { measures, dataset } = vseed;
1703
- if (measures && measures.length > 0) return {
1704
- ...advancedVSeed,
1705
- measures: chunk_BCBB46UE_d(measures)
1706
- };
1707
- if (!dataset) throw new Error('dataset is required');
1708
- if (0 === dataset.length) return {
1709
- ...advancedVSeed,
1710
- measures: []
1711
- };
1727
+ if (measures && measures.length > 0) {
1728
+ const clonedMeasures = chunk_BCBB46UE_d(measures);
1729
+ preorderTraverse(clonedMeasures, (node)=>{
1730
+ if (isMeasure(node)) node.alias = node.alias || node.id;
1731
+ return false;
1732
+ });
1733
+ return {
1734
+ ...advancedVSeed,
1735
+ measures: clonedMeasures
1736
+ };
1737
+ }
1712
1738
  const top100dataset = dataset.slice(0, 100);
1713
1739
  const sample = top100dataset.reduce((prev, cur)=>({
1714
1740
  ...prev,
@@ -1735,10 +1761,11 @@
1735
1761
  const { dimensions, dataset } = vseed;
1736
1762
  if (dimensions && dimensions.length > 0) return {
1737
1763
  ...result,
1738
- dimensions: chunk_BCBB46UE_d(dimensions)
1764
+ dimensions: chunk_BCBB46UE_d(dimensions.map((dim)=>({
1765
+ ...dim,
1766
+ alias: dim.alias || dim.id
1767
+ })))
1739
1768
  };
1740
- if (!dataset) throw new Error('dataset is required');
1741
- if (0 === dataset.length) return result;
1742
1769
  const measures = findAllMeasures(advancedVSeed.measures);
1743
1770
  const top100dataset = dataset.slice(0, 100);
1744
1771
  const sample = top100dataset.reduce((prev, cur)=>({
@@ -1944,8 +1971,6 @@
1944
1971
  measures: measureTree
1945
1972
  };
1946
1973
  };
1947
- const isDimension = (dimension)=>!('children' in dimension);
1948
- const isDimensionGroup = (dimension)=>'children' in dimension;
1949
1974
  const deleteDimensionTreeByCallback = (dimensionTree, callback)=>{
1950
1975
  if (!dimensionTree) return dimensionTree;
1951
1976
  const stack = [
@@ -2101,12 +2126,9 @@
2101
2126
  };
2102
2127
  const { vseed } = context;
2103
2128
  const { dataset, chartType } = vseed;
2104
- const { dimensions, measures, encoding } = advancedVSeed;
2105
- if (!measures || !dimensions || !dataset || !encoding) return result;
2106
- if (0 === measures.length) throw new Error('measures can not be empty');
2107
- const hasEncoding = (vseed.dimensions || []).some((item)=>item.encoding);
2129
+ const { dimensions = [], measures = [], encoding } = advancedVSeed;
2108
2130
  const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeByEncoding(dataset, T(dimensions, (item)=>item.id), T(findAllMeasures(measures), (item)=>item.id), encoding, {
2109
- colorItemAsId: hasEncoding,
2131
+ colorItemAsId: false,
2110
2132
  colorMeasureId: getColorMeasureId(advancedVSeed)
2111
2133
  });
2112
2134
  return {
@@ -2130,14 +2152,11 @@
2130
2152
  };
2131
2153
  const { vseed } = context;
2132
2154
  const { dataset } = vseed;
2133
- const { dimensions, measures, encoding } = advancedVSeed;
2134
- if (!measures || !dimensions || !dataset || !encoding) return result;
2135
- if (0 === measures.length) throw new Error('measures can not be empty');
2155
+ const { dimensions = [], measures = [], encoding } = advancedVSeed;
2136
2156
  const measureGroups = [];
2137
2157
  if (measures) measures.forEach((measure)=>{
2138
2158
  if (measure.children && measure.children.length > 0) measureGroups.push(measure);
2139
2159
  });
2140
- const hasEncoding = (vseed.dimensions || []).some((item)=>item.encoding);
2141
2160
  const datasets = [];
2142
2161
  const datasetReshapeInfo = [];
2143
2162
  measureGroups.forEach((measureGroup, index)=>{
@@ -2145,7 +2164,7 @@
2145
2164
  if (!measures) return;
2146
2165
  const groupId = measureGroup.id;
2147
2166
  const { dataset: newSubDataset, foldInfo, unfoldInfo } = dataReshapeByEncoding(dataset, T(dimensions, (item)=>item.id), T(measures, (item)=>item.id), encoding, {
2148
- colorItemAsId: hasEncoding,
2167
+ colorItemAsId: false,
2149
2168
  foldMeasureValue: `${FoldMeasureValue}${groupId}`,
2150
2169
  colorMeasureId: getColorMeasureId(advancedVSeed)
2151
2170
  });
@@ -2574,12 +2593,23 @@
2574
2593
  result.progressiveThreshold = 8000;
2575
2594
  return result;
2576
2595
  };
2596
+ const defaultTitleText = (measures, dimensions, idList = [])=>{
2597
+ const allMeasures = findAllMeasures(measures);
2598
+ return idList.map((id)=>{
2599
+ const alias = [
2600
+ ...allMeasures,
2601
+ ...dimensions
2602
+ ].find((f)=>f.id === id)?.alias || '';
2603
+ return alias;
2604
+ }).join(' & ');
2605
+ };
2577
2606
  const xBand = (spec, context)=>{
2578
2607
  const result = {
2579
2608
  ...spec
2580
2609
  };
2581
2610
  const { advancedVSeed, vseed } = context;
2582
2611
  const { chartType } = vseed;
2612
+ const { measures, dimensions, encoding } = advancedVSeed;
2583
2613
  const config = advancedVSeed.config?.[chartType]?.xAxis;
2584
2614
  if (!result.axes) result.axes = [];
2585
2615
  if (!config) {
@@ -2624,7 +2654,7 @@
2624
2654
  },
2625
2655
  title: {
2626
2656
  visible: title?.visible,
2627
- text: title?.titleText,
2657
+ text: title?.titleText || defaultTitleText(measures, dimensions, encoding.x),
2628
2658
  style: {
2629
2659
  fill: title?.titleColor,
2630
2660
  fontSize: title?.titleFontSize,
@@ -2668,13 +2698,19 @@
2668
2698
  ];
2669
2699
  return result;
2670
2700
  };
2701
+ const createLinearFormat = (value, autoFormat, numFormat, formatter)=>{
2702
+ if (chunk_JK3VNB42_n(autoFormat) && chunk_VCYTMP4D_n(numFormat)) return autoFormatter(value);
2703
+ if (true === autoFormat) return autoFormatter(value);
2704
+ if (!chunk_VCYTMP4D_n(numFormat)) return formatter(value);
2705
+ return String(value);
2706
+ };
2671
2707
  const yLinear = (spec, context)=>{
2672
2708
  const result = {
2673
2709
  ...spec
2674
2710
  };
2675
2711
  const { advancedVSeed, vseed } = context;
2676
2712
  const { chartType } = vseed;
2677
- const { locale } = advancedVSeed;
2713
+ const { measures, dimensions, encoding } = advancedVSeed;
2678
2714
  const config = advancedVSeed.config?.[chartType]?.yAxis;
2679
2715
  if (!result.axes) result.axes = [];
2680
2716
  if (!config) {
@@ -2688,7 +2724,7 @@
2688
2724
  ];
2689
2725
  return result;
2690
2726
  }
2691
- const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat = true, numFormat = {} } = config;
2727
+ const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat, numFormat = {} } = config;
2692
2728
  const formatter = createNumFormatter(numFormat);
2693
2729
  const linearAxis = {
2694
2730
  visible,
@@ -2702,11 +2738,7 @@
2702
2738
  min,
2703
2739
  label: {
2704
2740
  visible: label?.visible,
2705
- formatMethod: (value)=>{
2706
- if (!chunk_VCYTMP4D_n(numFormat)) return formatter(value);
2707
- if (autoFormat) return autoFormatter(value, locale);
2708
- return value;
2709
- },
2741
+ formatMethod: (value)=>createLinearFormat(value, autoFormat, numFormat, formatter),
2710
2742
  style: {
2711
2743
  fill: label?.labelColor,
2712
2744
  angle: label?.labelAngle,
@@ -2716,7 +2748,7 @@
2716
2748
  },
2717
2749
  title: {
2718
2750
  visible: title?.visible,
2719
- text: title?.titleText,
2751
+ text: title?.titleText || defaultTitleText(measures, dimensions, encoding.y),
2720
2752
  style: {
2721
2753
  fill: title?.titleColor,
2722
2754
  fontSize: title?.titleFontSize,
@@ -3295,7 +3327,7 @@
3295
3327
  ]);
3296
3328
  return result;
3297
3329
  };
3298
- const generateMeasureValue = (value, measure, labelAutoFormat = true, numFormat = {})=>{
3330
+ const generateMeasureValue = (value, measure, labelAutoFormat, numFormat = {})=>{
3299
3331
  if (!measure) return value;
3300
3332
  const format = chunk_5S4PYKVY_t(numFormat, measure.numFormat || measure.format);
3301
3333
  const mergedMeasure = {
@@ -3314,7 +3346,7 @@
3314
3346
  return formatter(percentValue);
3315
3347
  };
3316
3348
  const buildLabel = (label, vseedMeasures = [], vseedDimensions = [], advancedVSeedMeasures, encoding, foldInfoList)=>{
3317
- const { enable, wrap, showValue, showValuePercent, labelOverlap, labelColorSmartInvert, labelColor, labelFontSize, labelFontWeight, labelBackgroundColor, labelPosition, autoFormat = true, numFormat = {} } = label;
3349
+ const { enable, wrap, showValue, showValuePercent, labelOverlap, labelColorSmartInvert, labelColor, labelFontSize, labelFontWeight, labelBackgroundColor, labelPosition, autoFormat, numFormat = {} } = label;
3318
3350
  const labelDims = T((vseedDimensions || []).filter((item)=>encoding.label?.includes(item.id)), (item)=>item.id);
3319
3351
  const labelMeas = T((vseedMeasures || []).filter((item)=>encoding.label?.includes(item.id)), (item)=>item.id);
3320
3352
  const percentFormat = chunk_5S4PYKVY_t(numFormat, {
@@ -5196,8 +5228,8 @@
5196
5228
  ...spec
5197
5229
  };
5198
5230
  const { advancedVSeed, vseed } = context;
5231
+ const { encoding, dimensions, measures } = advancedVSeed;
5199
5232
  const { chartType } = vseed;
5200
- const { locale } = advancedVSeed;
5201
5233
  const config = advancedVSeed.config?.[chartType]?.xAxis;
5202
5234
  if (!result.axes) result.axes = [];
5203
5235
  if (!config) {
@@ -5211,8 +5243,8 @@
5211
5243
  ];
5212
5244
  return result;
5213
5245
  }
5214
- const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat = true, numFormat = {} } = config;
5215
- const formatter = createNumFormatter(numFormat, locale);
5246
+ const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat, numFormat = {} } = config;
5247
+ const formatter = createNumFormatter(numFormat);
5216
5248
  const linearAxis = {
5217
5249
  visible,
5218
5250
  type: log ? 'log' : 'linear',
@@ -5225,11 +5257,7 @@
5225
5257
  min,
5226
5258
  label: {
5227
5259
  visible: label?.visible,
5228
- formatMethod: (value)=>{
5229
- if (!chunk_VCYTMP4D_n(numFormat)) return formatter(value);
5230
- if (autoFormat) return autoFormatter(value, locale);
5231
- return value;
5232
- },
5260
+ formatMethod: (value)=>createLinearFormat(value, autoFormat, numFormat, formatter),
5233
5261
  style: {
5234
5262
  fill: label?.labelColor,
5235
5263
  angle: label?.labelAngle,
@@ -5239,7 +5267,7 @@
5239
5267
  },
5240
5268
  title: {
5241
5269
  visible: title?.visible,
5242
- text: title?.titleText,
5270
+ text: title?.titleText || defaultTitleText(measures, dimensions, encoding.x),
5243
5271
  style: {
5244
5272
  fill: title?.titleColor,
5245
5273
  fontSize: title?.titleFontSize,
@@ -5284,6 +5312,7 @@
5284
5312
  };
5285
5313
  const { advancedVSeed, vseed } = context;
5286
5314
  const { chartType } = vseed;
5315
+ const { measures, dimensions, encoding } = advancedVSeed;
5287
5316
  const config = advancedVSeed.config?.[chartType]?.yAxis;
5288
5317
  if (!result.axes) result.axes = [];
5289
5318
  if (!config) {
@@ -5329,7 +5358,7 @@
5329
5358
  },
5330
5359
  title: {
5331
5360
  visible: title?.visible,
5332
- text: title?.titleText,
5361
+ text: title?.titleText || defaultTitleText(measures, dimensions, encoding.y),
5333
5362
  style: {
5334
5363
  fill: title?.titleColor,
5335
5364
  fontSize: title?.titleFontSize,
@@ -6077,10 +6106,8 @@
6077
6106
  };
6078
6107
  const { vseed } = context;
6079
6108
  const { dataset } = vseed;
6080
- const { dimensions, measures, encoding, chartType } = advancedVSeed;
6081
- if (!measures || !dimensions || !dataset || !encoding) return result;
6082
- if (0 === measures.length) throw new Error('measures can not be empty');
6083
- if (measures.length > 2) throw new Error('measures can not be more than 2');
6109
+ const { dimensions = [], measures = [], encoding, chartType } = advancedVSeed;
6110
+ if (measures.length > 2) throw new Error('measures can not be more than 2 groups in scatter');
6084
6111
  const foldInfoList = [];
6085
6112
  const unfoldInfoList = [];
6086
6113
  const datasets = [];
@@ -6136,8 +6163,7 @@
6136
6163
  };
6137
6164
  const { vseed } = context;
6138
6165
  const { dataset } = vseed;
6139
- const { dimensions, measures, encoding, chartType } = advancedVSeed;
6140
- if (!measures || !dimensions || !dataset || !encoding) return result;
6166
+ const { dimensions = [], measures = [], encoding, chartType } = advancedVSeed;
6141
6167
  const measureGroups = [];
6142
6168
  const depth = measureDepth(measures);
6143
6169
  if (3 === depth) measures.forEach((measure)=>{
@@ -6147,8 +6173,7 @@
6147
6173
  const datasetList = [];
6148
6174
  const datasetReshapeInfo = [];
6149
6175
  measureGroups.forEach((measures, index)=>{
6150
- if (0 === measures.length) throw new Error('measures can not be empty');
6151
- if (measures.length > 2) throw new Error('measures can not be more than 2');
6176
+ if (measures.length > 2) throw new Error('measures can not be more than 2 groups in scatter');
6152
6177
  const foldInfoList = [];
6153
6178
  const unfoldInfoList = [];
6154
6179
  const datasets = [];
@@ -6631,19 +6656,16 @@
6631
6656
  };
6632
6657
  const { vseed } = context;
6633
6658
  const { dataset } = vseed;
6634
- const { dimensions, measures, encoding, chartType } = advancedVSeed;
6635
- if (!measures || !dimensions || !dataset || !encoding) return result;
6636
- if (0 === measures.length) throw new Error('measures can not be empty');
6637
- if (measures.length > 2) throw new Error('measures can not be more than 2');
6659
+ const { dimensions = [], measures = [], encoding, chartType } = advancedVSeed;
6660
+ if (measures.length > 2) throw new Error('measures can not be more than 2 groups in dualAxis');
6638
6661
  const foldInfoList = [];
6639
6662
  const unfoldInfoList = [];
6640
6663
  const datasets = [];
6641
6664
  const primaryMeasures = measures[0];
6642
6665
  const secondaryMeasures = measures[1] || [];
6643
- const hasEncoding = (vseed.dimensions || []).some((item)=>item.encoding);
6644
6666
  if (primaryMeasures && primaryMeasures.children) {
6645
6667
  const { dataset: newDataset, foldInfo, unfoldInfo } = dataReshapeByEncoding(dataset, T(dimensions, (item)=>item.id), T(primaryMeasures.children, (item)=>item.id), encoding, {
6646
- colorItemAsId: hasEncoding,
6668
+ colorItemAsId: false,
6647
6669
  foldMeasureValue: FoldPrimaryMeasureValue,
6648
6670
  colorMeasureId: getColorMeasureId(advancedVSeed)
6649
6671
  });
@@ -6653,6 +6675,7 @@
6653
6675
  }
6654
6676
  if (secondaryMeasures && secondaryMeasures.children) {
6655
6677
  const { dataset: newDataset, foldInfo, unfoldInfo } = dataReshapeByEncoding(dataset, T(dimensions, (item)=>item.id), T(secondaryMeasures.children, (item)=>item.id), encoding, {
6678
+ colorItemAsId: false,
6656
6679
  foldMeasureValue: FoldSecondaryMeasureValue,
6657
6680
  colorMeasureId: getColorMeasureId(advancedVSeed)
6658
6681
  });
@@ -6688,9 +6711,7 @@
6688
6711
  };
6689
6712
  const { vseed } = context;
6690
6713
  const { dataset } = vseed;
6691
- const { dimensions, measures, encoding, chartType } = advancedVSeed;
6692
- if (!measures || !dimensions || !dataset || !encoding) return result;
6693
- const hasEncoding = (vseed.dimensions || []).some((item)=>item.encoding);
6714
+ const { dimensions = [], measures = [], encoding, chartType } = advancedVSeed;
6694
6715
  const datasetList = [];
6695
6716
  const datasetReshapeInfo = [];
6696
6717
  const measureGroups = [];
@@ -6700,8 +6721,7 @@
6700
6721
  });
6701
6722
  else if (2 === depth) measureGroups.push(measures);
6702
6723
  measureGroups.forEach((measures, index)=>{
6703
- if (0 === measures.length) throw new Error('measures can not be empty');
6704
- if (measures.length > 2) throw new Error('measures can not be more than 2');
6724
+ if (measures.length > 2) throw new Error('measures can not be more than 2 groups in dualAxis');
6705
6725
  const foldInfoList = [];
6706
6726
  const unfoldInfoList = [];
6707
6727
  const datasets = [];
@@ -6709,7 +6729,7 @@
6709
6729
  const secondaryMeasures = measures[1] || [];
6710
6730
  if (primaryMeasures && primaryMeasures.children) {
6711
6731
  const { dataset: newDataset, foldInfo, unfoldInfo } = dataReshapeByEncoding(dataset, T(dimensions, (item)=>item.id), T(primaryMeasures.children, (item)=>item.id), encoding, {
6712
- colorItemAsId: hasEncoding,
6732
+ colorItemAsId: false,
6713
6733
  foldMeasureValue: `${FoldPrimaryMeasureValue}${index}`,
6714
6734
  colorMeasureId: getColorMeasureId(advancedVSeed)
6715
6735
  });
@@ -6719,6 +6739,7 @@
6719
6739
  }
6720
6740
  if (secondaryMeasures && secondaryMeasures.children) {
6721
6741
  const { dataset: newDataset, foldInfo, unfoldInfo } = dataReshapeByEncoding(dataset, T(dimensions, (item)=>item.id), T(secondaryMeasures.children, (item)=>item.id), encoding, {
6742
+ colorItemAsId: false,
6722
6743
  foldMeasureValue: `${FoldSecondaryMeasureValue}${index}`,
6723
6744
  colorMeasureId: getColorMeasureId(advancedVSeed)
6724
6745
  });
@@ -7176,7 +7197,7 @@
7176
7197
  };
7177
7198
  const { advancedVSeed, vseed } = context;
7178
7199
  const { chartType } = vseed;
7179
- const { locale, datasetReshapeInfo } = advancedVSeed;
7200
+ const { datasetReshapeInfo, encoding, measures, dimensions } = advancedVSeed;
7180
7201
  const { index, id: reshapeInfoId, foldInfoList } = datasetReshapeInfo[0];
7181
7202
  const primaryYAxis = advancedVSeed.config?.[chartType]?.primaryYAxis;
7182
7203
  const yAxisConfig = Array.isArray(primaryYAxis) ? primaryYAxis[index] || primaryYAxis[0] : primaryYAxis;
@@ -7204,8 +7225,8 @@
7204
7225
  ];
7205
7226
  return result;
7206
7227
  }
7207
- const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat = true, numFormat = {} } = yAxisConfig;
7208
- const formatter = createNumFormatter(numFormat, locale);
7228
+ const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, autoFormat, numFormat = {} } = yAxisConfig;
7229
+ const formatter = createNumFormatter(numFormat);
7209
7230
  const linearAxis = {
7210
7231
  visible: isEmptySecondary ? false : visible,
7211
7232
  id,
@@ -7220,11 +7241,7 @@
7220
7241
  min,
7221
7242
  label: {
7222
7243
  visible: label?.visible,
7223
- formatMethod: (value)=>{
7224
- if (!chunk_VCYTMP4D_n(numFormat)) return formatter(value);
7225
- if (autoFormat) return autoFormatter(value, locale);
7226
- return value;
7227
- },
7244
+ formatMethod: (value)=>createLinearFormat(value, autoFormat, numFormat, formatter),
7228
7245
  style: {
7229
7246
  fill: label?.labelColor,
7230
7247
  angle: label?.labelAngle,
@@ -7234,7 +7251,7 @@
7234
7251
  },
7235
7252
  title: {
7236
7253
  visible: title?.visible,
7237
- text: title?.titleText,
7254
+ text: title?.titleText || defaultTitleText(measures, dimensions, encoding.y),
7238
7255
  style: {
7239
7256
  fill: title?.titleColor,
7240
7257
  fontSize: title?.titleFontSize,
@@ -7279,7 +7296,7 @@
7279
7296
  };
7280
7297
  const { advancedVSeed, vseed } = context;
7281
7298
  const { chartType } = vseed;
7282
- const { locale, datasetReshapeInfo } = advancedVSeed;
7299
+ const { datasetReshapeInfo, measures, dimensions, encoding } = advancedVSeed;
7283
7300
  const { index, id: reshapeInfoId, foldInfoList } = datasetReshapeInfo[0];
7284
7301
  const secondaryYAxis = advancedVSeed.config?.[chartType]?.secondaryYAxis;
7285
7302
  const yAxisConfig = Array.isArray(secondaryYAxis) ? secondaryYAxis[index] || secondaryYAxis[0] : secondaryYAxis;
@@ -7313,8 +7330,8 @@
7313
7330
  ];
7314
7331
  return result;
7315
7332
  }
7316
- const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, numFormat = {}, autoFormat = true } = yAxisConfig;
7317
- const formatter = createNumFormatter(numFormat, locale);
7333
+ const { visible = true, label, tick, title, grid, line, zero, nice, inverse, max, min, log, logBase = 10, numFormat = {}, autoFormat } = yAxisConfig;
7334
+ const formatter = createNumFormatter(numFormat);
7318
7335
  const linearAxis = {
7319
7336
  visible: isEmptySecondary ? false : visible,
7320
7337
  id,
@@ -7330,11 +7347,7 @@
7330
7347
  min,
7331
7348
  label: {
7332
7349
  visible: label?.visible,
7333
- formatMethod: (value)=>{
7334
- if (!chunk_VCYTMP4D_n(numFormat)) return formatter(value);
7335
- if (autoFormat) return autoFormatter(value, locale);
7336
- return value;
7337
- },
7350
+ formatMethod: (value)=>createLinearFormat(value, autoFormat, numFormat, formatter),
7338
7351
  style: {
7339
7352
  fill: label?.labelColor,
7340
7353
  angle: label?.labelAngle,
@@ -7344,7 +7357,7 @@
7344
7357
  },
7345
7358
  title: {
7346
7359
  visible: title?.visible,
7347
- text: title?.titleText,
7360
+ text: title?.titleText || defaultTitleText(measures, dimensions, encoding.y),
7348
7361
  style: {
7349
7362
  fill: title?.titleColor,
7350
7363
  fontSize: title?.titleFontSize,