@visactor/vseed 0.0.12 → 0.0.14

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 (42) hide show
  1. package/dist/builder/builder/builder.d.ts +9 -0
  2. package/dist/dataReshape/constant.d.ts +1 -0
  3. package/dist/dataReshape/dataReshapeFor1D1M.d.ts +1 -0
  4. package/dist/dataReshape/dataReshapeFor2D1M.d.ts +1 -0
  5. package/dist/dataReshape/unfoldDimensions.d.ts +1 -1
  6. package/dist/i18n/i18n.d.ts +17 -0
  7. package/dist/i18n/index.d.ts +1 -0
  8. package/dist/index.cjs +273 -95
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +216 -53
  12. package/dist/index.js.map +1 -1
  13. package/dist/pipeline/advanced/pipes/i18n/index.d.ts +1 -0
  14. package/dist/pipeline/advanced/pipes/i18n/locale.d.ts +2 -0
  15. package/dist/pipeline/advanced/pipes/index.d.ts +1 -0
  16. package/dist/pipeline/constant.d.ts +1 -1
  17. package/dist/pipeline/utils/format/createFormatter.d.ts +2 -1
  18. package/dist/pipeline/utils/format/createNumFormatter.d.ts +2 -1
  19. package/dist/pipeline/utils/format/index.d.ts +2 -2
  20. package/dist/types/advancedVSeed.d.ts +10 -4
  21. package/dist/types/chartType/area/area.d.ts +7 -0
  22. package/dist/types/chartType/areaPercent/areaPercent.d.ts +7 -0
  23. package/dist/types/chartType/bar/bar.d.ts +7 -0
  24. package/dist/types/chartType/barParallel/barParallel.d.ts +7 -0
  25. package/dist/types/chartType/barPercent/barPercent.d.ts +7 -0
  26. package/dist/types/chartType/column/column.d.ts +7 -0
  27. package/dist/types/chartType/columnParallel/columnParallel.d.ts +7 -0
  28. package/dist/types/chartType/columnPercent/columnPercent.d.ts +7 -0
  29. package/dist/types/chartType/donut/donut.d.ts +7 -0
  30. package/dist/types/chartType/dualAxis/dualAxis.d.ts +7 -0
  31. package/dist/types/chartType/line/line.d.ts +7 -0
  32. package/dist/types/chartType/pie/pie.d.ts +7 -0
  33. package/dist/types/chartType/pivotTable/pivotTable.d.ts +7 -0
  34. package/dist/types/chartType/rose/rose.d.ts +7 -0
  35. package/dist/types/chartType/table/table.d.ts +7 -0
  36. package/dist/types/i18n/i18n.d.ts +9 -0
  37. package/dist/types/i18n/index.d.ts +1 -0
  38. package/dist/types/index.d.ts +1 -0
  39. package/dist/types/properties/datasetReshapeInfo/datasetReshapeInfo.d.ts +6 -0
  40. package/dist/types/properties/measures/measures.d.ts +8 -8
  41. package/dist/types/vseed.d.ts +13 -9
  42. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -26,6 +26,7 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  registerBar: ()=>registerBar,
28
28
  isVChart: ()=>isVChart,
29
+ autoFormatter: ()=>autoFormatter,
29
30
  zBaseConfig: ()=>zBaseConfig,
30
31
  zTooltip: ()=>zTooltip,
31
32
  pieAdvancedPipeline: ()=>pieAdvancedPipeline,
@@ -39,6 +40,7 @@ __webpack_require__.d(__webpack_exports__, {
39
40
  zMeasures: ()=>zMeasures,
40
41
  zCrosshairRect: ()=>zCrosshairRect,
41
42
  FoldMeasureName: ()=>FoldMeasureName,
43
+ intl: ()=>intl,
42
44
  darkTheme: ()=>darkTheme,
43
45
  createNumFormatter: ()=>createNumFormatter,
44
46
  columnPercentAdvancedPipeline: ()=>columnPercentAdvancedPipeline,
@@ -60,6 +62,7 @@ __webpack_require__.d(__webpack_exports__, {
60
62
  columnAdvancedPipeline: ()=>columnAdvancedPipeline,
61
63
  columnParallelSpecPipeline: ()=>columnParallelSpecPipeline,
62
64
  zLabel: ()=>zLabel,
65
+ i18n: ()=>i18n,
63
66
  registerColumn: ()=>registerColumn,
64
67
  zAnnotationPoint: ()=>zAnnotationPoint,
65
68
  lightTheme: ()=>lightTheme,
@@ -74,6 +77,7 @@ __webpack_require__.d(__webpack_exports__, {
74
77
  registerArea: ()=>registerArea,
75
78
  findMeasureById: ()=>findMeasureById,
76
79
  zDataset: ()=>zDataset,
80
+ UnfoldDimensionGroupId: ()=>UnfoldDimensionGroupId,
77
81
  zNumFormat: ()=>zNumFormat,
78
82
  barPercentAdvancedPipeline: ()=>barPercentAdvancedPipeline,
79
83
  areaPercentAdvancedPipeline: ()=>areaPercentAdvancedPipeline,
@@ -86,6 +90,7 @@ __webpack_require__.d(__webpack_exports__, {
86
90
  zTheme: ()=>zTheme,
87
91
  zEncoding: ()=>zEncoding,
88
92
  registerAreaPercent: ()=>registerAreaPercent,
93
+ autoNumFormatter: ()=>autoNumFormatter,
89
94
  zXLinearAxis: ()=>zXLinearAxis,
90
95
  zConfig: ()=>zConfig,
91
96
  zDatum: ()=>zDatum,
@@ -112,11 +117,11 @@ __webpack_require__.d(__webpack_exports__, {
112
117
  zChartType: ()=>zChartType,
113
118
  createFormatter: ()=>createFormatter,
114
119
  unfoldDimensions: ()=>unfoldDimensions,
120
+ columnPercentSpecPipeline: ()=>columnPercentSpecPipeline,
115
121
  areaAdvancedPipeline: ()=>areaAdvancedPipeline,
116
- areaPercentSpecPipeline: ()=>areaPercentSpecPipeline,
117
122
  Builder: ()=>Builder,
118
123
  barParallelSpecPipeline: ()=>barParallelSpecPipeline,
119
- columnPercentSpecPipeline: ()=>columnPercentSpecPipeline,
124
+ areaPercentSpecPipeline: ()=>areaPercentSpecPipeline,
120
125
  registerAll: ()=>all_registerAll
121
126
  });
122
127
  const initAdvancedVSeed = (advancedVSeed, context)=>{
@@ -127,6 +132,10 @@ const initAdvancedVSeed = (advancedVSeed, context)=>{
127
132
  chartType
128
133
  };
129
134
  };
135
+ const execPipeline = (pipeline, context, initialValue = {})=>{
136
+ const result = pipeline.reduce((prev, cur)=>cur(prev, context), initialValue);
137
+ return result;
138
+ };
130
139
  const isVTable = (chartType)=>[
131
140
  'table',
132
141
  'pivotTable'
@@ -138,6 +147,146 @@ const isPivotChart = (vseed)=>{
138
147
  const hasMeasureGroup = measures && measures.find((measure)=>measure && measure.children);
139
148
  return hasRowOrColumnDimension || hasMeasureGroup;
140
149
  };
150
+ const external_remeda_namespaceObject = require("remeda");
151
+ var i18n_namespaceObject = JSON.parse('{"指标名称":{"en-US":"MeasureName","zh-CN":"指标名称"},"指标Id":{"en-US":"MeasureId","zh-CN":"指标Id"},"指标值":{"en-US":"MeasureValue","zh-CN":"指标值"}}');
152
+ class Intl {
153
+ static instance;
154
+ translateMap = i18n_namespaceObject;
155
+ locale = 'zh-CN';
156
+ canTranslate = (value)=>!!this.translateMap[value];
157
+ i18n = (segments, ...values)=>{
158
+ const text = segments.map((segment, index)=>segment + (values[index] || '')).join('');
159
+ const translatedText = this.translateMap?.[text]?.[this.locale];
160
+ if ((0, external_remeda_namespaceObject.isNullish)(translatedText)) {
161
+ console.warn(`i18n ${this.locale} no translate: ${text}`);
162
+ return text;
163
+ }
164
+ return translatedText;
165
+ };
166
+ setLocale = (locale)=>{
167
+ this.locale = locale;
168
+ };
169
+ getLocale = ()=>this.locale;
170
+ static getInstance() {
171
+ if (!Intl.instance) Intl.instance = new Intl();
172
+ return Intl.instance;
173
+ }
174
+ }
175
+ const intl = Intl.getInstance();
176
+ const i18n = intl.i18n;
177
+ const createNumFormatter = (format)=>{
178
+ const { type = 'number', ratio = 1, symbol = '', thousandSeparator = true, decimalPlaces = 2, round = 'round', prefix = '', suffix = '' } = format || {};
179
+ return (value)=>{
180
+ let num = Number(value);
181
+ let typeSymbol = '';
182
+ if (Number.isNaN(num)) return num.toString();
183
+ if ('percent' === type) {
184
+ num *= 100;
185
+ typeSymbol = '%';
186
+ } else if ('permille' === type) {
187
+ num *= 1000;
188
+ typeSymbol = "\u2030";
189
+ } else if ('number' === type) num /= ratio || 1;
190
+ const multiplier = 10 ** decimalPlaces;
191
+ num = Math[round](num * multiplier) / multiplier;
192
+ let numStr = num.toFixed(decimalPlaces);
193
+ if (thousandSeparator) {
194
+ const parts = numStr.split('.');
195
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
196
+ numStr = parts.join('.');
197
+ }
198
+ return `${prefix}${numStr}${typeSymbol}${symbol}${suffix}`;
199
+ };
200
+ };
201
+ const autoNumFormatter = (value, locale = intl.getLocale())=>{
202
+ if (null == value) return String(value);
203
+ const num = Number(value);
204
+ if (Number.isNaN(num)) return String(value);
205
+ const countDecimalPlaces = (num)=>{
206
+ if (Number.isInteger(num)) return 0;
207
+ const str = num.toString();
208
+ if (str.indexOf('e-') > -1) return parseInt(str.split('e-')[1]);
209
+ const decimalPart = str.split('.')[1];
210
+ if (!decimalPart) return 0;
211
+ const decimalPlaces = decimalPart.replace(/0+$/, '').length;
212
+ return Math.max(2, decimalPlaces);
213
+ };
214
+ const numFormat = {
215
+ type: 'number',
216
+ decimalPlaces: countDecimalPlaces(num),
217
+ round: 'round',
218
+ thousandSeparator: true
219
+ };
220
+ const rules = NUMBER_FORMAT_RULES[locale] || NUMBER_FORMAT_RULES['default'];
221
+ for (const rule of rules)if (num >= rule.threshold) {
222
+ numFormat.ratio = rule.ratio;
223
+ numFormat.symbol = rule.symbol;
224
+ break;
225
+ }
226
+ return createNumFormatter(numFormat)(value);
227
+ };
228
+ const NUMBER_FORMAT_RULES = {
229
+ 'zh-CN': [
230
+ {
231
+ threshold: 100000000,
232
+ ratio: 100000000,
233
+ symbol: "\u4EBF"
234
+ },
235
+ {
236
+ threshold: 10000,
237
+ ratio: 10000,
238
+ symbol: "\u4E07"
239
+ }
240
+ ],
241
+ 'en-US': [
242
+ {
243
+ threshold: 1000000000,
244
+ ratio: 1000000000,
245
+ symbol: 'B'
246
+ },
247
+ {
248
+ threshold: 1000000,
249
+ ratio: 1000000,
250
+ symbol: 'M'
251
+ },
252
+ {
253
+ threshold: 1000,
254
+ ratio: 1000,
255
+ symbol: 'K'
256
+ }
257
+ ],
258
+ default: [
259
+ {
260
+ threshold: 1000000000,
261
+ ratio: 1000000000,
262
+ symbol: 'B'
263
+ },
264
+ {
265
+ threshold: 1000000,
266
+ ratio: 1000000,
267
+ symbol: 'M'
268
+ },
269
+ {
270
+ threshold: 1000,
271
+ ratio: 1000,
272
+ symbol: 'K'
273
+ }
274
+ ]
275
+ };
276
+ const createFormatter = (format)=>createNumFormatter(format);
277
+ const autoFormatter = (value, locale)=>autoNumFormatter(value, locale);
278
+ function findMeasureById(measures, id) {
279
+ if (!measures) return;
280
+ const stack = [
281
+ ...measures
282
+ ];
283
+ while(stack.length > 0){
284
+ const current = stack.pop();
285
+ if (!current) continue;
286
+ if (current.id === id && !('children' in current)) return current;
287
+ if ('children' in current && current.children) stack.push(...current.children);
288
+ }
289
+ }
141
290
  const autoMeasures = (advancedVSeed, context)=>{
142
291
  const result = {
143
292
  ...advancedVSeed
@@ -242,31 +391,40 @@ const FoldMeasureName = '__MeaName__';
242
391
  const FoldMeasureValue = '__MeaValue__';
243
392
  const FoldMeasureId = '__MeaId__';
244
393
  const UnfoldDimensionGroup = '__DimGroup__';
394
+ const UnfoldDimensionGroupId = '__DimGroupID__';
245
395
  const Separator = '-';
246
396
  const ORIGINAL_DATA = '__OriginalData__';
247
- const external_remeda_namespaceObject = require("remeda");
248
- const unfoldDimensions = (dataset, dimensions, measures, unfoldStartIndex = 0, foldGroupName = UnfoldDimensionGroup, dimensionsSeparator = Separator)=>{
397
+ const unfoldDimensions = (dataset, dimensions, measures, unfoldStartIndex = 0, unfoldGroupName = UnfoldDimensionGroup, unfoldGroupId = UnfoldDimensionGroupId, foldMeasureId = FoldMeasureId, dimensionsSeparator = Separator)=>{
249
398
  if (unfoldStartIndex < 0 || unfoldStartIndex >= dimensions.length) throw new Error('unfoldStartIndex is out of range');
250
399
  const dimensionsToBeUnfolded = dimensions.slice(unfoldStartIndex);
251
400
  const unfoldInfo = {
252
- groupName: foldGroupName,
253
- colorItems: []
401
+ groupName: unfoldGroupName,
402
+ groupId: unfoldGroupId,
403
+ colorItems: [],
404
+ colorIdMap: {}
254
405
  };
255
406
  if (0 === dimensions.length || 0 === measures.length) return {
256
407
  dataset,
257
408
  unfoldInfo: {
258
- groupName: foldGroupName,
259
- colorItems: []
409
+ groupName: unfoldGroupName,
410
+ groupId: unfoldGroupId,
411
+ colorItems: [],
412
+ colorIdMap: {}
260
413
  }
261
414
  };
262
415
  const colorItems = [];
416
+ const colorMap = {};
263
417
  for(let i = 0; i < dataset.length; i++){
264
418
  const datum = dataset[i];
265
- const colorItem = generateDimGroupName(dimensionsToBeUnfolded, datum, dimensionsSeparator);
266
- datum[foldGroupName] = colorItem;
267
- colorItems.push(colorItem);
419
+ const colorName = generateDimGroupName(dimensionsToBeUnfolded, datum, dimensionsSeparator);
420
+ const colorId = colorName + (datum[foldMeasureId] || '');
421
+ datum[unfoldGroupName] = colorName;
422
+ datum[unfoldGroupId] = colorId;
423
+ colorItems.push(colorId);
424
+ colorMap[colorId] = colorName;
268
425
  }
269
426
  unfoldInfo.colorItems = (0, external_remeda_namespaceObject.unique)(colorItems);
427
+ unfoldInfo.colorIdMap = colorMap;
270
428
  return {
271
429
  dataset,
272
430
  unfoldInfo
@@ -292,7 +450,7 @@ const foldMeasures = (dataset, measures, measureId = FoldMeasureId, measureName
292
450
  const { id, alias } = measure;
293
451
  datum[id] = dataset[i][id];
294
452
  datum[measureId] = id;
295
- datum[measureName] = alias;
453
+ datum[measureName] = alias || id;
296
454
  datum[measureValue] = dataset[i][id];
297
455
  foldInfo.foldMap[id] = alias;
298
456
  result[index++] = datum;
@@ -311,32 +469,34 @@ const emptyReshapeResult = {
311
469
  measureValue: ''
312
470
  },
313
471
  unfoldInfo: {
472
+ groupName: '',
473
+ groupId: '',
314
474
  colorItems: [],
315
- groupName: ''
475
+ colorIdMap: {}
316
476
  }
317
477
  };
318
478
  const dataReshapeFor2D1M = (dataset, dimensions, measures, options)=>{
319
- const { foldMeasureId = FoldMeasureId, foldMeasureName = FoldMeasureName, foldMeasureValue = FoldMeasureValue, unfoldDimensionGroup = UnfoldDimensionGroup } = options || {};
479
+ const { foldMeasureId = FoldMeasureId, foldMeasureName = FoldMeasureName, foldMeasureValue = FoldMeasureValue, unfoldDimensionGroup = UnfoldDimensionGroup, unfoldDimensionGroupId = UnfoldDimensionGroupId } = options || {};
320
480
  if (0 === dimensions.length && 0 === measures.length) return emptyReshapeResult;
321
481
  const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, foldMeasureId, foldMeasureName, foldMeasureValue);
322
482
  if (0 === dimensions.length) {
323
483
  const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
324
484
  {
325
485
  id: foldMeasureId,
326
- alias: "\u6307\u6807Id",
486
+ alias: i18n`指标Id`,
327
487
  location: 'dimension'
328
488
  },
329
489
  {
330
490
  id: foldMeasureName,
331
- alias: "\u6307\u6807\u540D\u79F0",
491
+ alias: i18n`指标名称`,
332
492
  location: 'dimension'
333
493
  }
334
494
  ], [
335
495
  {
336
496
  id: foldMeasureValue,
337
- alias: "\u6307\u6807\u503C"
497
+ alias: i18n`指标值`
338
498
  }
339
- ], 1, unfoldDimensionGroup);
499
+ ], 1, unfoldDimensionGroup, unfoldDimensionGroupId, foldMeasureId);
340
500
  return {
341
501
  dataset: finalDataset,
342
502
  foldInfo,
@@ -348,15 +508,15 @@ const dataReshapeFor2D1M = (dataset, dimensions, measures, options)=>{
348
508
  ...dimensions,
349
509
  {
350
510
  id: foldMeasureName,
351
- alias: "\u6307\u6807\u540D\u79F0",
511
+ alias: i18n`指标名称`,
352
512
  location: 'dimension'
353
513
  }
354
514
  ], [
355
515
  {
356
516
  id: foldMeasureValue,
357
- alias: "\u6307\u6807\u503C"
517
+ alias: i18n`指标值`
358
518
  }
359
- ], 1, unfoldDimensionGroup);
519
+ ], 1, unfoldDimensionGroup, unfoldDimensionGroupId, foldMeasureId);
360
520
  return {
361
521
  dataset: finalDataset,
362
522
  foldInfo,
@@ -374,26 +534,28 @@ const dataReshapeFor1D1M_emptyReshapeResult = {
374
534
  },
375
535
  unfoldInfo: {
376
536
  groupName: '',
377
- colorItems: []
537
+ groupId: '',
538
+ colorItems: [],
539
+ colorIdMap: {}
378
540
  }
379
541
  };
380
542
  const dataReshapeFor1D1M = (dataset, dimensions, measures, options)=>{
381
- const { foldMeasureId = FoldMeasureId, foldMeasureName = FoldMeasureName, foldMeasureValue = FoldMeasureValue, unfoldDimensionGroup = UnfoldDimensionGroup } = options || {};
543
+ const { foldMeasureId = FoldMeasureId, foldMeasureName = FoldMeasureName, foldMeasureValue = FoldMeasureValue, unfoldDimensionGroup = UnfoldDimensionGroup, unfoldDimensionGroupId = UnfoldDimensionGroupId } = options || {};
382
544
  if (0 === dimensions.length && 0 === measures.length) return dataReshapeFor1D1M_emptyReshapeResult;
383
545
  const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, foldMeasureId, foldMeasureName, foldMeasureValue);
384
546
  if (0 === dimensions.length) {
385
547
  const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
386
548
  {
387
549
  id: foldMeasureName,
388
- alias: "\u6307\u6807\u540D\u79F0",
550
+ alias: i18n`指标名称`,
389
551
  location: 'dimension'
390
552
  }
391
553
  ], [
392
554
  {
393
555
  id: foldMeasureValue,
394
- alias: "\u6307\u6807\u503C"
556
+ alias: i18n`指标值`
395
557
  }
396
- ], 0, unfoldDimensionGroup);
558
+ ], 0, unfoldDimensionGroup, unfoldDimensionGroupId, foldMeasureId);
397
559
  return {
398
560
  dataset: finalDataset,
399
561
  foldInfo,
@@ -405,15 +567,15 @@ const dataReshapeFor1D1M = (dataset, dimensions, measures, options)=>{
405
567
  ...dimensions,
406
568
  {
407
569
  id: foldMeasureName,
408
- alias: "\u6307\u6807\u540D\u79F0",
570
+ alias: i18n`指标名称`,
409
571
  location: 'dimension'
410
572
  }
411
573
  ], [
412
574
  {
413
575
  id: foldMeasureValue,
414
- alias: "\u6307\u6807\u503C"
576
+ alias: i18n`指标值`
415
577
  }
416
- ], 0, unfoldDimensionGroup);
578
+ ], 0, unfoldDimensionGroup, unfoldDimensionGroupId, foldMeasureId);
417
579
  return {
418
580
  dataset: finalDataset,
419
581
  foldInfo,
@@ -553,7 +715,6 @@ const encodingXY = (advancedVSeed)=>{
553
715
  if (!datasetReshapeInfo || !dimensions) return result;
554
716
  const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
555
717
  const { foldInfo, unfoldInfo } = cur;
556
- const isSingleDimension = 1 === dimensions.length;
557
718
  const isZeroDimension = 0 === dimensions.length;
558
719
  const x = [
559
720
  isZeroDimension ? foldInfo.measureName : dimensions[0].id
@@ -562,7 +723,7 @@ const encodingXY = (advancedVSeed)=>{
562
723
  foldInfo.measureValue
563
724
  ];
564
725
  const group = [
565
- isSingleDimension || isZeroDimension ? foldInfo.measureName : unfoldInfo.groupName
726
+ unfoldInfo.groupId
566
727
  ];
567
728
  const color = [
568
729
  foldInfo.measureName
@@ -591,7 +752,6 @@ const encodingYX = (advancedVSeed)=>{
591
752
  const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
592
753
  const { foldInfo, unfoldInfo } = cur;
593
754
  const isZeroDimension = 0 === dimensions.length;
594
- const isSingleDimension = 1 === dimensions.length;
595
755
  const y = [
596
756
  isZeroDimension ? foldInfo.measureName : dimensions[0].id
597
757
  ];
@@ -599,7 +759,7 @@ const encodingYX = (advancedVSeed)=>{
599
759
  foldInfo.measureValue
600
760
  ];
601
761
  const group = [
602
- isSingleDimension || isZeroDimension ? foldInfo.measureName : unfoldInfo.groupName
762
+ unfoldInfo.groupId
603
763
  ];
604
764
  const color = [
605
765
  foldInfo.measureName
@@ -631,13 +791,13 @@ const encodingPolar = (advancedVSeed)=>{
631
791
  foldInfo.measureValue
632
792
  ];
633
793
  const angle = [
634
- unfoldInfo.groupName
794
+ unfoldInfo.groupId
635
795
  ];
636
796
  const group = [
637
- unfoldInfo.groupName
797
+ unfoldInfo.groupId
638
798
  ];
639
799
  const color = [
640
- unfoldInfo.groupName
800
+ unfoldInfo.groupId
641
801
  ];
642
802
  return [
643
803
  ...prev,
@@ -759,10 +919,6 @@ const vchartTheme = (advancedVSeed, context)=>{
759
919
  }
760
920
  return result;
761
921
  };
762
- const execPipeline = (pipeline, context, initialValue = {})=>{
763
- const result = pipeline.reduce((prev, cur)=>cur(prev, context), initialValue);
764
- return result;
765
- };
766
922
  const pivotAdapter = (pipeline, pivotPipeline)=>(advancedVSeed, context)=>{
767
923
  const { vseed } = context;
768
924
  const usePivotChart = isPivotChart(vseed);
@@ -795,8 +951,17 @@ const annotation_annotation = (advancedVSeed, context)=>{
795
951
  annotation
796
952
  };
797
953
  };
954
+ const locale_locale = (advancedVSeed, context)=>{
955
+ const { vseed } = context;
956
+ const { locale } = vseed;
957
+ return {
958
+ ...advancedVSeed,
959
+ locale: locale || 'zh-CN'
960
+ };
961
+ };
798
962
  const lineAdvancedPipeline = [
799
963
  initAdvancedVSeed,
964
+ locale_locale,
800
965
  autoMeasures,
801
966
  autoDimensions,
802
967
  pivotAdapter([
@@ -813,6 +978,7 @@ const lineAdvancedPipeline = [
813
978
  ];
814
979
  const barAdvancedPipeline = [
815
980
  initAdvancedVSeed,
981
+ locale_locale,
816
982
  autoMeasures,
817
983
  autoDimensions,
818
984
  pivotAdapter([
@@ -829,6 +995,7 @@ const barAdvancedPipeline = [
829
995
  ];
830
996
  const barParallelAdvancedPipeline = [
831
997
  initAdvancedVSeed,
998
+ locale_locale,
832
999
  autoMeasures,
833
1000
  autoDimensions,
834
1001
  pivotAdapter([
@@ -845,6 +1012,7 @@ const barParallelAdvancedPipeline = [
845
1012
  ];
846
1013
  const barPercentAdvancedPipeline = [
847
1014
  initAdvancedVSeed,
1015
+ locale_locale,
848
1016
  autoMeasures,
849
1017
  autoDimensions,
850
1018
  pivotAdapter([
@@ -861,6 +1029,7 @@ const barPercentAdvancedPipeline = [
861
1029
  ];
862
1030
  const columnAdvancedPipeline = [
863
1031
  initAdvancedVSeed,
1032
+ locale_locale,
864
1033
  autoMeasures,
865
1034
  autoDimensions,
866
1035
  pivotAdapter([
@@ -877,6 +1046,7 @@ const columnAdvancedPipeline = [
877
1046
  ];
878
1047
  const columnParallelAdvancedPipeline = [
879
1048
  initAdvancedVSeed,
1049
+ locale_locale,
880
1050
  autoMeasures,
881
1051
  autoDimensions,
882
1052
  pivotAdapter([
@@ -893,6 +1063,7 @@ const columnParallelAdvancedPipeline = [
893
1063
  ];
894
1064
  const columnPercentAdvancedPipeline = [
895
1065
  initAdvancedVSeed,
1066
+ locale_locale,
896
1067
  autoMeasures,
897
1068
  autoDimensions,
898
1069
  pivotAdapter([
@@ -909,6 +1080,7 @@ const columnPercentAdvancedPipeline = [
909
1080
  ];
910
1081
  const areaAdvancedPipeline = [
911
1082
  initAdvancedVSeed,
1083
+ locale_locale,
912
1084
  autoMeasures,
913
1085
  autoDimensions,
914
1086
  pivotAdapter([
@@ -925,6 +1097,7 @@ const areaAdvancedPipeline = [
925
1097
  ];
926
1098
  const areaPercentAdvancedPipeline = [
927
1099
  initAdvancedVSeed,
1100
+ locale_locale,
928
1101
  autoMeasures,
929
1102
  autoDimensions,
930
1103
  pivotAdapter([
@@ -941,6 +1114,7 @@ const areaPercentAdvancedPipeline = [
941
1114
  ];
942
1115
  const pieAdvancedPipeline = [
943
1116
  initAdvancedVSeed,
1117
+ locale_locale,
944
1118
  autoMeasures,
945
1119
  autoDimensions,
946
1120
  pivotAdapter([
@@ -1244,13 +1418,14 @@ const xBand = (spec, context)=>{
1244
1418
  return result;
1245
1419
  };
1246
1420
  const ANNOTATION_Z_INDEX = 1000;
1247
- const LINEAR_AXIS_INNER_OFFSET_TOP = 5;
1421
+ const LINEAR_AXIS_INNER_OFFSET_TOP = 7;
1248
1422
  const xLinear = (spec, context)=>{
1249
1423
  const result = {
1250
1424
  ...spec
1251
1425
  };
1252
1426
  const { advancedVSeed, vseed } = context;
1253
1427
  const { chartType } = vseed;
1428
+ const { locale } = advancedVSeed;
1254
1429
  const config = advancedVSeed.config?.[chartType]?.xAxis;
1255
1430
  if (!result.axes) result.axes = [];
1256
1431
  if (!config) {
@@ -1276,6 +1451,7 @@ const xLinear = (spec, context)=>{
1276
1451
  min,
1277
1452
  label: {
1278
1453
  visible: label?.visible,
1454
+ formatMethod: (value)=>autoFormatter(value, locale),
1279
1455
  style: {
1280
1456
  fill: label?.labelColor,
1281
1457
  angle: label?.labelAngle,
@@ -1425,6 +1601,7 @@ const yLinear = (spec, context)=>{
1425
1601
  };
1426
1602
  const { advancedVSeed, vseed } = context;
1427
1603
  const { chartType } = vseed;
1604
+ const { locale } = advancedVSeed;
1428
1605
  const config = advancedVSeed.config?.[chartType]?.yAxis;
1429
1606
  if (!result.axes) result.axes = [];
1430
1607
  if (!config) {
@@ -1450,6 +1627,7 @@ const yLinear = (spec, context)=>{
1450
1627
  min,
1451
1628
  label: {
1452
1629
  visible: label?.visible,
1630
+ formatMethod: (value)=>autoFormatter(value, locale),
1453
1631
  style: {
1454
1632
  fill: label?.labelColor,
1455
1633
  angle: label?.labelAngle,
@@ -1534,43 +1712,6 @@ const background_backgroundColor = (spec, context)=>{
1534
1712
  background: backgroundColor
1535
1713
  };
1536
1714
  };
1537
- function findMeasureById(measures, id) {
1538
- if (!measures) return;
1539
- const stack = [
1540
- ...measures
1541
- ];
1542
- while(stack.length > 0){
1543
- const current = stack.pop();
1544
- if (!current) continue;
1545
- if (current.id === id && !('children' in current)) return current;
1546
- if ('children' in current && current.children) stack.push(...current.children);
1547
- }
1548
- }
1549
- const createNumFormatter = (format)=>{
1550
- const { type = 'number', ratio = 1, symbol = '', thousandSeparator = true, decimalPlaces = 2, round = 'round', prefix = '', suffix = '' } = format || {};
1551
- return (value)=>{
1552
- let num = Number(value);
1553
- let typeSymbol = '';
1554
- if (Number.isNaN(num)) return num.toString();
1555
- if ('percent' === type) {
1556
- num *= 100;
1557
- typeSymbol = '%';
1558
- } else if ('permille' === type) {
1559
- num *= 1000;
1560
- typeSymbol = "\u2030";
1561
- } else if ('number' === type) num /= ratio || 1;
1562
- const multiplier = 10 ** decimalPlaces;
1563
- num = Math[round](num * multiplier) / multiplier;
1564
- let numStr = num.toFixed(decimalPlaces);
1565
- if (thousandSeparator) {
1566
- const parts = numStr.split('.');
1567
- parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
1568
- numStr = parts.join('.');
1569
- }
1570
- return `${prefix}${numStr}${typeSymbol}${symbol}${suffix}`;
1571
- };
1572
- };
1573
- const createFormatter = (format)=>createNumFormatter(format);
1574
1715
  const defaultTooltip = {
1575
1716
  enable: true
1576
1717
  };
@@ -1598,10 +1739,11 @@ const tooltip_tooltip = (spec, context)=>{
1598
1739
  const measure = findMeasureById(measures, id);
1599
1740
  if (!measure) return String(value);
1600
1741
  const { format = {}, autoFormat = true } = measure;
1601
- if (format || autoFormat) {
1742
+ if (!(0, external_remeda_namespaceObject.isEmpty)(format)) {
1602
1743
  const formatter = createFormatter(format);
1603
1744
  return formatter(value);
1604
1745
  }
1746
+ if (autoFormat) return autoFormatter(value);
1605
1747
  return String(value);
1606
1748
  }
1607
1749
  }
@@ -1619,10 +1761,11 @@ const tooltip_tooltip = (spec, context)=>{
1619
1761
  const measure = findMeasureById(measures, id);
1620
1762
  if (!measure) return String(value);
1621
1763
  const { format = {}, autoFormat = true } = measure;
1622
- if (format || autoFormat) {
1764
+ if (!(0, external_remeda_namespaceObject.isEmpty)(format)) {
1623
1765
  const formatter = createFormatter(format);
1624
1766
  return formatter(value);
1625
1767
  }
1768
+ if (autoFormat) return autoFormatter(value);
1626
1769
  return String(value);
1627
1770
  }
1628
1771
  }
@@ -1636,23 +1779,30 @@ const label_label = (spec, context)=>{
1636
1779
  ...spec
1637
1780
  };
1638
1781
  const { advancedVSeed } = context;
1639
- const { measures, datasetReshapeInfo } = advancedVSeed;
1782
+ const { measures, datasetReshapeInfo, locale } = advancedVSeed;
1640
1783
  const baseConfig = advancedVSeed.baseConfig.vchart;
1641
1784
  if (!baseConfig || !baseConfig.label) return result;
1642
- const { measureId } = datasetReshapeInfo[0].foldInfo;
1785
+ const { measureId, measureValue } = datasetReshapeInfo[0].foldInfo;
1643
1786
  const { label } = baseConfig;
1644
1787
  const { enable } = label;
1645
1788
  result.label = {
1646
1789
  visible: enable,
1647
1790
  formatMethod: (value, datum)=>{
1648
- const id = datum[measureId];
1649
- const measure = findMeasureById(measures, id);
1650
- if (!measure) return value;
1651
- const { format = {}, autoFormat = true } = measure;
1652
- if (format || autoFormat) {
1653
- const formatter = createFormatter(format);
1654
- return formatter(value);
1655
- }
1791
+ const result = [];
1792
+ const formatValue = (value)=>{
1793
+ const id = datum[measureId];
1794
+ const measure = findMeasureById(measures, id);
1795
+ if (!measure) return value;
1796
+ const { format = {}, autoFormat = true } = measure;
1797
+ if (!(0, external_remeda_namespaceObject.isEmpty)(format)) {
1798
+ const formatter = createFormatter(format);
1799
+ return formatter(value);
1800
+ }
1801
+ if (autoFormat) return autoFormatter(value, locale);
1802
+ return String(value);
1803
+ };
1804
+ result.push(formatValue(datum[measureValue]));
1805
+ return result.join(' ');
1656
1806
  }
1657
1807
  };
1658
1808
  return result;
@@ -1662,6 +1812,8 @@ const discreteLegend = (spec, context)=>{
1662
1812
  ...spec
1663
1813
  };
1664
1814
  const { advancedVSeed } = context;
1815
+ const { datasetReshapeInfo } = advancedVSeed;
1816
+ const { unfoldInfo } = datasetReshapeInfo[0];
1665
1817
  const baseConfig = advancedVSeed.baseConfig.vchart;
1666
1818
  if (!baseConfig || !baseConfig.legend) return result;
1667
1819
  const { legend } = baseConfig;
@@ -1735,6 +1887,7 @@ const discreteLegend = (spec, context)=>{
1735
1887
  }
1736
1888
  },
1737
1889
  label: {
1890
+ formatMethod: (value)=>unfoldInfo.colorIdMap[String(value)] ?? value,
1738
1891
  style: {
1739
1892
  fontSize: labelFontSize,
1740
1893
  fill: labelFontColor,
@@ -1762,6 +1915,10 @@ const pivotDiscreteLegend = (spec, context)=>{
1762
1915
  if (!baseConfig || !baseConfig.legend) return result;
1763
1916
  const { datasetReshapeInfo } = advancedVSeed;
1764
1917
  const colorItems = (0, external_remeda_namespaceObject.unique)(datasetReshapeInfo.flatMap((d)=>d.unfoldInfo.colorItems));
1918
+ const colorIdMap = datasetReshapeInfo.reduce((prev, cur)=>({
1919
+ ...prev,
1920
+ ...cur.unfoldInfo.colorIdMap
1921
+ }), {});
1765
1922
  const { legend, color } = baseConfig;
1766
1923
  const { colorScheme } = color;
1767
1924
  const { enable, position = 'bottom', labelFontColor, labelFontSize = 12, labelFontWeight, maxSize, border, shapeType = 'rectRound' } = legend || {};
@@ -1836,6 +1993,7 @@ const pivotDiscreteLegend = (spec, context)=>{
1836
1993
  }
1837
1994
  },
1838
1995
  label: {
1996
+ formatMethod: (value)=>colorIdMap[String(value)] ?? value,
1839
1997
  style: {
1840
1998
  fontSize: labelFontSize,
1841
1999
  fill: labelFontColor,
@@ -1868,11 +2026,19 @@ const color_color = (spec, context)=>{
1868
2026
  if (!baseConfig || !baseConfig.color) return result;
1869
2027
  const { color } = baseConfig;
1870
2028
  const { colorScheme, colorMapping } = color;
2029
+ const mappingList = [];
2030
+ if (colorMapping) Object.entries(colorMapping).forEach(([key, value])=>{
2031
+ const idMap = Object.entries(unfoldInfo.colorIdMap).filter(([_, v])=>key === v);
2032
+ for (const [colorId] of idMap)mappingList.push([
2033
+ colorId,
2034
+ value
2035
+ ]);
2036
+ });
1871
2037
  result.color = {
1872
2038
  type: 'ordinal',
1873
2039
  domain: unfoldInfo.colorItems,
1874
2040
  range: colorScheme,
1875
- specified: colorMapping
2041
+ specified: Object.fromEntries(mappingList)
1876
2042
  };
1877
2043
  return result;
1878
2044
  };
@@ -2353,8 +2519,7 @@ const lineStyle_lineStyle = (spec, context)=>{
2353
2519
  },
2354
2520
  style: {
2355
2521
  curveType: curveType,
2356
- fill: lineColor,
2357
- fillOpacity: lineColorOpacity,
2522
+ strokeOpacity: lineColorOpacity,
2358
2523
  stroke: lineColor,
2359
2524
  lineWidth: lineWidth,
2360
2525
  lineDash: lineDash
@@ -2689,7 +2854,7 @@ const annotationArea_annotationArea = (spec, context)=>{
2689
2854
  right: 'insideRight'
2690
2855
  };
2691
2856
  const markArea = annotationAreaList.flatMap((annotationArea)=>{
2692
- const { selector: selectorPoint, text = '', textPosition = 'top', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'center', textBaseline = 'top', backgroundBorderColor, backgroundBorderRadius = 4, backgroundBorderWidth = 1, backgroundColor = '#191d24', backgroundPadding = 4, backgroundVisible = true, outerPadding = 0, areaColor = '#888888', areaColorOpacity = 0.15, areaBorderColor, areaBorderRadius, areaBorderWidth } = annotationArea;
2857
+ const { selector: selectorPoint, text = '', textPosition = 'top', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'center', textBaseline = 'top', backgroundBorderColor, backgroundBorderRadius = 4, backgroundBorderWidth = 1, backgroundColor = '#191d24', backgroundPadding = 10, backgroundVisible = true, outerPadding = 4, areaColor = '#888888', areaColorOpacity = 0.15, areaBorderColor, areaBorderRadius, areaBorderWidth } = annotationArea;
2693
2858
  const dataset = advancedVSeed.dataset.flat();
2694
2859
  const selectedData = dataset.filter((datum)=>selector_selector(datum, selectorPoint));
2695
2860
  return {
@@ -3552,6 +3717,7 @@ class Builder {
3552
3717
  _spec = null;
3553
3718
  constructor(vseed){
3554
3719
  this._vseed = vseed;
3720
+ this._vseed.locale = vseed.locale || intl.getLocale();
3555
3721
  }
3556
3722
  build = ()=>build(this);
3557
3723
  buildSpec = (advanced)=>buildSpec(this, advanced);
@@ -4161,7 +4327,7 @@ const zMeasure = external_zod_namespaceObject.z.object({
4161
4327
  alias: external_zod_namespaceObject.z.string().optional(),
4162
4328
  visible: external_zod_namespaceObject.z.boolean().default(true).optional(),
4163
4329
  autoFormat: external_zod_namespaceObject.z.boolean().default(true).optional(),
4164
- format: zNumFormat.optional()
4330
+ format: zNumFormat["default"]({}).optional()
4165
4331
  });
4166
4332
  const zMeasureGroup = external_zod_namespaceObject.z.object({
4167
4333
  id: external_zod_namespaceObject.z.string(),
@@ -4180,6 +4346,8 @@ const zFoldInfo = external_zod_namespaceObject.z.object({
4180
4346
  });
4181
4347
  const zUnfoldInfo = external_zod_namespaceObject.z.object({
4182
4348
  colorItems: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
4349
+ groupId: external_zod_namespaceObject.z.string(),
4350
+ colorIdMap: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.string()),
4183
4351
  groupName: external_zod_namespaceObject.z.string()
4184
4352
  });
4185
4353
  const zDatasetReshapeInfo = external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.object({
@@ -4803,10 +4971,13 @@ exports.FoldMeasureValue = __webpack_exports__.FoldMeasureValue;
4803
4971
  exports.ORIGINAL_DATA = __webpack_exports__.ORIGINAL_DATA;
4804
4972
  exports.Separator = __webpack_exports__.Separator;
4805
4973
  exports.UnfoldDimensionGroup = __webpack_exports__.UnfoldDimensionGroup;
4974
+ exports.UnfoldDimensionGroupId = __webpack_exports__.UnfoldDimensionGroupId;
4806
4975
  exports.areaAdvancedPipeline = __webpack_exports__.areaAdvancedPipeline;
4807
4976
  exports.areaPercentAdvancedPipeline = __webpack_exports__.areaPercentAdvancedPipeline;
4808
4977
  exports.areaPercentSpecPipeline = __webpack_exports__.areaPercentSpecPipeline;
4809
4978
  exports.areaSpecPipeline = __webpack_exports__.areaSpecPipeline;
4979
+ exports.autoFormatter = __webpack_exports__.autoFormatter;
4980
+ exports.autoNumFormatter = __webpack_exports__.autoNumFormatter;
4810
4981
  exports.barAdvancedPipeline = __webpack_exports__.barAdvancedPipeline;
4811
4982
  exports.barParallelAdvancedPipeline = __webpack_exports__.barParallelAdvancedPipeline;
4812
4983
  exports.barParallelSpecPipeline = __webpack_exports__.barParallelSpecPipeline;
@@ -4827,6 +4998,8 @@ exports.dataReshapeFor2D1M = __webpack_exports__.dataReshapeFor2D1M;
4827
4998
  exports.execPipeline = __webpack_exports__.execPipeline;
4828
4999
  exports.findMeasureById = __webpack_exports__.findMeasureById;
4829
5000
  exports.foldMeasures = __webpack_exports__.foldMeasures;
5001
+ exports.i18n = __webpack_exports__.i18n;
5002
+ exports.intl = __webpack_exports__.intl;
4830
5003
  exports.isPivotChart = __webpack_exports__.isPivotChart;
4831
5004
  exports.isVChart = __webpack_exports__.isVChart;
4832
5005
  exports.isVTable = __webpack_exports__.isVTable;
@@ -4898,10 +5071,13 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
4898
5071
  "ORIGINAL_DATA",
4899
5072
  "Separator",
4900
5073
  "UnfoldDimensionGroup",
5074
+ "UnfoldDimensionGroupId",
4901
5075
  "areaAdvancedPipeline",
4902
5076
  "areaPercentAdvancedPipeline",
4903
5077
  "areaPercentSpecPipeline",
4904
5078
  "areaSpecPipeline",
5079
+ "autoFormatter",
5080
+ "autoNumFormatter",
4905
5081
  "barAdvancedPipeline",
4906
5082
  "barParallelAdvancedPipeline",
4907
5083
  "barParallelSpecPipeline",
@@ -4922,6 +5098,8 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
4922
5098
  "execPipeline",
4923
5099
  "findMeasureById",
4924
5100
  "foldMeasures",
5101
+ "i18n",
5102
+ "intl",
4925
5103
  "isPivotChart",
4926
5104
  "isVChart",
4927
5105
  "isVTable",