@visactor/vseed 0.0.11 → 0.0.13

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/builder/builder/builder.d.ts +4339 -477
  2. package/dist/builder/register/theme.d.ts +4 -1
  3. package/dist/dataSelector/selector.d.ts +1 -1
  4. package/dist/i18n/i18n.d.ts +17 -0
  5. package/dist/i18n/index.d.ts +1 -0
  6. package/dist/index.cjs +1064 -190
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.js +1015 -183
  10. package/dist/index.js.map +1 -1
  11. package/dist/pipeline/advanced/pipes/config/config.d.ts +3 -3
  12. package/dist/pipeline/advanced/pipes/i18n/index.d.ts +1 -0
  13. package/dist/pipeline/advanced/pipes/i18n/locale.d.ts +2 -0
  14. package/dist/pipeline/advanced/pipes/index.d.ts +1 -0
  15. package/dist/pipeline/constant.d.ts +2 -0
  16. package/dist/pipeline/spec/pipes/crosshair/horizontalCrosshairRect.d.ts +2 -0
  17. package/dist/pipeline/spec/pipes/crosshair/index.d.ts +3 -0
  18. package/dist/pipeline/spec/pipes/crosshair/verticalCrosshairLine.d.ts +2 -0
  19. package/dist/pipeline/spec/pipes/crosshair/verticalCrosshairRect.d.ts +2 -0
  20. package/dist/pipeline/spec/pipes/index.d.ts +1 -0
  21. package/dist/pipeline/spec/pipes/markStyle/areaStyle.d.ts +2 -0
  22. package/dist/pipeline/spec/pipes/markStyle/index.d.ts +3 -0
  23. package/dist/pipeline/spec/pipes/markStyle/lineStyle.d.ts +2 -0
  24. package/dist/pipeline/spec/pipes/markStyle/pointStyle.d.ts +2 -0
  25. package/dist/pipeline/spec/pipes/stack/index.d.ts +1 -0
  26. package/dist/pipeline/spec/pipes/stack/stackCornerRadius.d.ts +2 -0
  27. package/dist/pipeline/utils/chatType.d.ts +16 -16
  28. package/dist/pipeline/utils/format/createFormatter.d.ts +3 -0
  29. package/dist/pipeline/utils/format/createNumFormatter.d.ts +3 -0
  30. package/dist/pipeline/utils/format/index.d.ts +2 -0
  31. package/dist/pipeline/utils/index.d.ts +4 -2
  32. package/dist/pipeline/utils/measures/findMeasureById.d.ts +2 -0
  33. package/dist/pipeline/utils/measures/index.d.ts +1 -0
  34. package/dist/types/advancedVSeed.d.ts +2445 -320
  35. package/dist/types/chartType/area/area.d.ts +40 -1
  36. package/dist/types/chartType/areaPercent/areaPercent.d.ts +43 -4
  37. package/dist/types/chartType/bar/bar.d.ts +20 -2
  38. package/dist/types/chartType/barParallel/barParallel.d.ts +20 -2
  39. package/dist/types/chartType/barPercent/barPercent.d.ts +20 -2
  40. package/dist/types/chartType/column/column.d.ts +20 -2
  41. package/dist/types/chartType/columnParallel/columnParallel.d.ts +20 -2
  42. package/dist/types/chartType/columnPercent/columnPercent.d.ts +20 -2
  43. package/dist/types/chartType/donut/donut.d.ts +7 -0
  44. package/dist/types/chartType/dualAxis/dualAxis.d.ts +7 -0
  45. package/dist/types/chartType/line/line.d.ts +34 -4
  46. package/dist/types/chartType/pie/pie.d.ts +7 -0
  47. package/dist/types/chartType/pivotTable/pivotTable.d.ts +7 -0
  48. package/dist/types/chartType/rose/rose.d.ts +7 -0
  49. package/dist/types/chartType/table/table.d.ts +7 -0
  50. package/dist/types/i18n/i18n.d.ts +9 -0
  51. package/dist/types/i18n/index.d.ts +1 -0
  52. package/dist/types/index.d.ts +1 -0
  53. package/dist/types/properties/config/config.d.ts +105 -36
  54. package/dist/types/properties/config/crosshair.d.ts +17 -0
  55. package/dist/types/properties/config/index.d.ts +2 -0
  56. package/dist/types/properties/config/stackCornerRadius.d.ts +3 -0
  57. package/dist/types/properties/markStyle/areaStyle.d.ts +129 -0
  58. package/dist/types/properties/markStyle/index.d.ts +3 -0
  59. package/dist/types/properties/markStyle/lineStyle.d.ts +160 -0
  60. package/dist/types/properties/markStyle/markStyle.d.ts +543 -2
  61. package/dist/types/properties/markStyle/pointStyle.d.ts +168 -0
  62. package/dist/types/properties/measures/format/formatter.d.ts +1 -0
  63. package/dist/types/properties/measures/format/index.d.ts +2 -0
  64. package/dist/types/properties/measures/format/numFormat.d.ts +20 -0
  65. package/dist/types/properties/measures/index.d.ts +2 -2
  66. package/dist/types/properties/measures/measures.d.ts +40 -40
  67. package/dist/types/properties/theme/customTheme.d.ts +3094 -72
  68. package/dist/types/vseed.d.ts +29 -25
  69. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { clone as external_remeda_clone, isArray, isNumber, isString, mergeDeep as external_remeda_mergeDeep, omit, pick as external_remeda_pick, unique } from "remeda";
1
+ import { clone as external_remeda_clone, groupBy, isArray, isEmpty, isNullish, isNumber, isString, mergeDeep as external_remeda_mergeDeep, omit, pick as external_remeda_pick, unique } from "remeda";
2
2
  import { z } from "zod";
3
3
  const initAdvancedVSeed = (advancedVSeed, context)=>{
4
4
  const { vseed } = context;
@@ -23,6 +23,145 @@ const isPivotChart = (vseed)=>{
23
23
  const hasMeasureGroup = measures && measures.find((measure)=>measure && measure.children);
24
24
  return hasRowOrColumnDimension || hasMeasureGroup;
25
25
  };
26
+ var i18n_namespaceObject = JSON.parse('{"指标名称":{"en-US":"MeasureName","zh-CN":"指标名称"},"指标Id":{"en-US":"MeasureId","zh-CN":"指标Id"},"指标值":{"en-US":"MeasureValue","zh-CN":"指标值"}}');
27
+ class Intl {
28
+ static instance;
29
+ translateMap = i18n_namespaceObject;
30
+ locale = 'zh-CN';
31
+ canTranslate = (value)=>!!this.translateMap[value];
32
+ i18n = (segments, ...values)=>{
33
+ const text = segments.map((segment, index)=>segment + (values[index] || '')).join('');
34
+ const translatedText = this.translateMap?.[text]?.[this.locale];
35
+ if (isNullish(translatedText)) {
36
+ console.warn(`i18n ${this.locale} no translate: ${text}`);
37
+ return text;
38
+ }
39
+ return translatedText;
40
+ };
41
+ setLocale = (locale)=>{
42
+ this.locale = locale;
43
+ };
44
+ getLocale = ()=>this.locale;
45
+ static getInstance() {
46
+ if (!Intl.instance) Intl.instance = new Intl();
47
+ return Intl.instance;
48
+ }
49
+ }
50
+ const intl = Intl.getInstance();
51
+ const i18n = intl.i18n;
52
+ const createNumFormatter = (format)=>{
53
+ const { type = 'number', ratio = 1, symbol = '', thousandSeparator = true, decimalPlaces = 2, round = 'round', prefix = '', suffix = '' } = format || {};
54
+ return (value)=>{
55
+ let num = Number(value);
56
+ let typeSymbol = '';
57
+ if (Number.isNaN(num)) return num.toString();
58
+ if ('percent' === type) {
59
+ num *= 100;
60
+ typeSymbol = '%';
61
+ } else if ('permille' === type) {
62
+ num *= 1000;
63
+ typeSymbol = "\u2030";
64
+ } else if ('number' === type) num /= ratio || 1;
65
+ const multiplier = 10 ** decimalPlaces;
66
+ num = Math[round](num * multiplier) / multiplier;
67
+ let numStr = num.toFixed(decimalPlaces);
68
+ if (thousandSeparator) {
69
+ const parts = numStr.split('.');
70
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
71
+ numStr = parts.join('.');
72
+ }
73
+ return `${prefix}${numStr}${typeSymbol}${symbol}${suffix}`;
74
+ };
75
+ };
76
+ const autoNumFormatter = (value, locale = intl.getLocale())=>{
77
+ if (null == value) return String(value);
78
+ const num = Number(value);
79
+ if (Number.isNaN(num)) return String(value);
80
+ const countDecimalPlaces = (num)=>{
81
+ if (Number.isInteger(num)) return 0;
82
+ const str = num.toString();
83
+ if (str.indexOf('e-') > -1) return parseInt(str.split('e-')[1]);
84
+ const decimalPart = str.split('.')[1];
85
+ if (!decimalPart) return 0;
86
+ const decimalPlaces = decimalPart.replace(/0+$/, '').length;
87
+ return Math.max(2, decimalPlaces);
88
+ };
89
+ const numFormat = {
90
+ type: 'number',
91
+ decimalPlaces: countDecimalPlaces(num),
92
+ round: 'round',
93
+ thousandSeparator: true
94
+ };
95
+ const rules = NUMBER_FORMAT_RULES[locale] || NUMBER_FORMAT_RULES['default'];
96
+ for (const rule of rules)if (num >= rule.threshold) {
97
+ numFormat.ratio = rule.ratio;
98
+ numFormat.symbol = rule.symbol;
99
+ break;
100
+ }
101
+ return createNumFormatter(numFormat)(value);
102
+ };
103
+ const NUMBER_FORMAT_RULES = {
104
+ 'zh-CN': [
105
+ {
106
+ threshold: 100000000,
107
+ ratio: 100000000,
108
+ symbol: "\u4EBF"
109
+ },
110
+ {
111
+ threshold: 10000,
112
+ ratio: 10000,
113
+ symbol: "\u4E07"
114
+ }
115
+ ],
116
+ 'en-US': [
117
+ {
118
+ threshold: 1000000000,
119
+ ratio: 1000000000,
120
+ symbol: 'B'
121
+ },
122
+ {
123
+ threshold: 1000000,
124
+ ratio: 1000000,
125
+ symbol: 'M'
126
+ },
127
+ {
128
+ threshold: 1000,
129
+ ratio: 1000,
130
+ symbol: 'K'
131
+ }
132
+ ],
133
+ default: [
134
+ {
135
+ threshold: 1000000000,
136
+ ratio: 1000000000,
137
+ symbol: 'B'
138
+ },
139
+ {
140
+ threshold: 1000000,
141
+ ratio: 1000000,
142
+ symbol: 'M'
143
+ },
144
+ {
145
+ threshold: 1000,
146
+ ratio: 1000,
147
+ symbol: 'K'
148
+ }
149
+ ]
150
+ };
151
+ const createFormatter = (format)=>createNumFormatter(format);
152
+ const autoFormatter = (value, locale)=>autoNumFormatter(value, locale);
153
+ function findMeasureById(measures, id) {
154
+ if (!measures) return;
155
+ const stack = [
156
+ ...measures
157
+ ];
158
+ while(stack.length > 0){
159
+ const current = stack.pop();
160
+ if (!current) continue;
161
+ if (current.id === id && !('children' in current)) return current;
162
+ if ('children' in current && current.children) stack.push(...current.children);
163
+ }
164
+ }
26
165
  const autoMeasures = (advancedVSeed, context)=>{
27
166
  const result = {
28
167
  ...advancedVSeed
@@ -73,16 +212,16 @@ const autoMeasureGroup = (advancedVSeed, context)=>{
73
212
  const measureGroups = [];
74
213
  for (const measure of measures)if ('children' in measure) {
75
214
  if (currentGroup.children?.length) {
76
- currentGroup.id = currentGroup.children.map((item)=>item.id).join('-');
77
215
  currentGroup.alias = currentGroup.children.map((item)=>item.alias).join('-');
216
+ currentGroup.id = currentGroup.alias + currentGroup.children.map((item)=>item.id).join('-');
78
217
  measureGroups.push(currentGroup);
79
218
  currentGroup = createEmptyMeasureGroup();
80
219
  }
81
220
  measureGroups.push(measure);
82
221
  } else currentGroup.children?.push(measure);
83
222
  if (currentGroup.children?.length) {
84
- currentGroup.id = currentGroup.children.map((item)=>item.id).join('-');
85
223
  currentGroup.alias = currentGroup.children.map((item)=>item.alias).join('-');
224
+ currentGroup.id = currentGroup.alias + currentGroup.children.map((item)=>item.id).join('-');
86
225
  measureGroups.push(currentGroup);
87
226
  currentGroup = createEmptyMeasureGroup();
88
227
  }
@@ -207,18 +346,18 @@ const dataReshapeFor2D1M = (dataset, dimensions, measures, options)=>{
207
346
  const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
208
347
  {
209
348
  id: foldMeasureId,
210
- alias: "\u6307\u6807Id",
349
+ alias: i18n`指标Id`,
211
350
  location: 'dimension'
212
351
  },
213
352
  {
214
353
  id: foldMeasureName,
215
- alias: "\u6307\u6807\u540D\u79F0",
354
+ alias: i18n`指标名称`,
216
355
  location: 'dimension'
217
356
  }
218
357
  ], [
219
358
  {
220
359
  id: foldMeasureValue,
221
- alias: "\u6307\u6807\u503C"
360
+ alias: i18n`指标值`
222
361
  }
223
362
  ], 1, unfoldDimensionGroup);
224
363
  return {
@@ -232,13 +371,13 @@ const dataReshapeFor2D1M = (dataset, dimensions, measures, options)=>{
232
371
  ...dimensions,
233
372
  {
234
373
  id: foldMeasureName,
235
- alias: "\u6307\u6807\u540D\u79F0",
374
+ alias: i18n`指标名称`,
236
375
  location: 'dimension'
237
376
  }
238
377
  ], [
239
378
  {
240
379
  id: foldMeasureValue,
241
- alias: "\u6307\u6807\u503C"
380
+ alias: i18n`指标值`
242
381
  }
243
382
  ], 1, unfoldDimensionGroup);
244
383
  return {
@@ -269,13 +408,13 @@ const dataReshapeFor1D1M = (dataset, dimensions, measures, options)=>{
269
408
  const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
270
409
  {
271
410
  id: foldMeasureName,
272
- alias: "\u6307\u6807\u540D\u79F0",
411
+ alias: i18n`指标名称`,
273
412
  location: 'dimension'
274
413
  }
275
414
  ], [
276
415
  {
277
416
  id: foldMeasureValue,
278
- alias: "\u6307\u6807\u503C"
417
+ alias: i18n`指标值`
279
418
  }
280
419
  ], 0, unfoldDimensionGroup);
281
420
  return {
@@ -289,13 +428,13 @@ const dataReshapeFor1D1M = (dataset, dimensions, measures, options)=>{
289
428
  ...dimensions,
290
429
  {
291
430
  id: foldMeasureName,
292
- alias: "\u6307\u6807\u540D\u79F0",
431
+ alias: i18n`指标名称`,
293
432
  location: 'dimension'
294
433
  }
295
434
  ], [
296
435
  {
297
436
  id: foldMeasureValue,
298
- alias: "\u6307\u6807\u503C"
437
+ alias: i18n`指标值`
299
438
  }
300
439
  ], 0, unfoldDimensionGroup);
301
440
  return {
@@ -565,7 +704,28 @@ const lineConfig = (advancedVSeed, context)=>{
565
704
  };
566
705
  const config = external_remeda_pick(vseed, [
567
706
  'xAxis',
568
- 'yAxis'
707
+ 'yAxis',
708
+ 'crosshairLine'
709
+ ]);
710
+ result.config = {
711
+ ...result.config || {},
712
+ [chartType]: {
713
+ ...config
714
+ }
715
+ };
716
+ return result;
717
+ };
718
+ const columnConfig = (advancedVSeed, context)=>{
719
+ const { vseed } = context;
720
+ const { chartType } = vseed;
721
+ const result = {
722
+ ...advancedVSeed
723
+ };
724
+ const config = external_remeda_pick(vseed, [
725
+ 'xAxis',
726
+ 'yAxis',
727
+ 'crosshairRect',
728
+ 'stackCornerRadius'
569
729
  ]);
570
730
  result.config = {
571
731
  ...result.config || {},
@@ -590,14 +750,13 @@ const pieConfig = (advancedVSeed, context)=>{
590
750
  };
591
751
  return result;
592
752
  };
593
- const barConfig = lineConfig;
594
- const barParallelConfig = lineConfig;
595
- const barPercentConfig = lineConfig;
596
- const columnConfig = lineConfig;
597
- const columnParallelConfig = lineConfig;
598
- const columnPercentConfig = lineConfig;
599
753
  const areaConfig = lineConfig;
600
754
  const areaPercentConfig = lineConfig;
755
+ const barConfig = columnConfig;
756
+ const barParallelConfig = columnConfig;
757
+ const barPercentConfig = columnConfig;
758
+ const columnParallelConfig = columnConfig;
759
+ const columnPercentConfig = columnConfig;
601
760
  const vchartTheme = (advancedVSeed, context)=>{
602
761
  const { customTheme, vseed } = context;
603
762
  const { theme = 'light', chartType } = vseed;
@@ -632,7 +791,10 @@ const pivotAdapter = (pipeline, pivotPipeline)=>(advancedVSeed, context)=>{
632
791
  const markStyle_markStyle = (advancedVSeed, context)=>{
633
792
  const { vseed } = context;
634
793
  const markStyle = external_remeda_pick(vseed, [
635
- 'barStyle'
794
+ 'barStyle',
795
+ 'pointStyle',
796
+ 'lineStyle',
797
+ 'areaStyle'
636
798
  ]);
637
799
  return {
638
800
  ...advancedVSeed,
@@ -652,8 +814,17 @@ const annotation_annotation = (advancedVSeed, context)=>{
652
814
  annotation
653
815
  };
654
816
  };
817
+ const locale_locale = (advancedVSeed, context)=>{
818
+ const { vseed } = context;
819
+ const { locale } = vseed;
820
+ return {
821
+ ...advancedVSeed,
822
+ locale: locale || 'zh-CN'
823
+ };
824
+ };
655
825
  const lineAdvancedPipeline = [
656
826
  initAdvancedVSeed,
827
+ locale_locale,
657
828
  autoMeasures,
658
829
  autoDimensions,
659
830
  pivotAdapter([
@@ -665,10 +836,12 @@ const lineAdvancedPipeline = [
665
836
  vchartBaseConfig,
666
837
  lineConfig,
667
838
  vchartTheme,
839
+ markStyle_markStyle,
668
840
  annotation_annotation
669
841
  ];
670
842
  const barAdvancedPipeline = [
671
843
  initAdvancedVSeed,
844
+ locale_locale,
672
845
  autoMeasures,
673
846
  autoDimensions,
674
847
  pivotAdapter([
@@ -685,6 +858,7 @@ const barAdvancedPipeline = [
685
858
  ];
686
859
  const barParallelAdvancedPipeline = [
687
860
  initAdvancedVSeed,
861
+ locale_locale,
688
862
  autoMeasures,
689
863
  autoDimensions,
690
864
  pivotAdapter([
@@ -701,6 +875,7 @@ const barParallelAdvancedPipeline = [
701
875
  ];
702
876
  const barPercentAdvancedPipeline = [
703
877
  initAdvancedVSeed,
878
+ locale_locale,
704
879
  autoMeasures,
705
880
  autoDimensions,
706
881
  pivotAdapter([
@@ -717,6 +892,7 @@ const barPercentAdvancedPipeline = [
717
892
  ];
718
893
  const columnAdvancedPipeline = [
719
894
  initAdvancedVSeed,
895
+ locale_locale,
720
896
  autoMeasures,
721
897
  autoDimensions,
722
898
  pivotAdapter([
@@ -733,6 +909,7 @@ const columnAdvancedPipeline = [
733
909
  ];
734
910
  const columnParallelAdvancedPipeline = [
735
911
  initAdvancedVSeed,
912
+ locale_locale,
736
913
  autoMeasures,
737
914
  autoDimensions,
738
915
  pivotAdapter([
@@ -749,6 +926,7 @@ const columnParallelAdvancedPipeline = [
749
926
  ];
750
927
  const columnPercentAdvancedPipeline = [
751
928
  initAdvancedVSeed,
929
+ locale_locale,
752
930
  autoMeasures,
753
931
  autoDimensions,
754
932
  pivotAdapter([
@@ -765,6 +943,7 @@ const columnPercentAdvancedPipeline = [
765
943
  ];
766
944
  const areaAdvancedPipeline = [
767
945
  initAdvancedVSeed,
946
+ locale_locale,
768
947
  autoMeasures,
769
948
  autoDimensions,
770
949
  pivotAdapter([
@@ -776,10 +955,12 @@ const areaAdvancedPipeline = [
776
955
  areaConfig,
777
956
  vchartBaseConfig,
778
957
  vchartTheme,
958
+ markStyle_markStyle,
779
959
  annotation_annotation
780
960
  ];
781
961
  const areaPercentAdvancedPipeline = [
782
962
  initAdvancedVSeed,
963
+ locale_locale,
783
964
  autoMeasures,
784
965
  autoDimensions,
785
966
  pivotAdapter([
@@ -791,10 +972,12 @@ const areaPercentAdvancedPipeline = [
791
972
  areaPercentConfig,
792
973
  vchartBaseConfig,
793
974
  vchartTheme,
975
+ markStyle_markStyle,
794
976
  annotation_annotation
795
977
  ];
796
978
  const pieAdvancedPipeline = [
797
979
  initAdvancedVSeed,
980
+ locale_locale,
798
981
  autoMeasures,
799
982
  autoDimensions,
800
983
  pivotAdapter([
@@ -1081,7 +1264,15 @@ const xBand = (spec, context)=>{
1081
1264
  lineWidth: line?.lineWidth,
1082
1265
  stroke: line?.lineColor
1083
1266
  }
1084
- }
1267
+ },
1268
+ paddingInner: [
1269
+ 0.15,
1270
+ 0.1
1271
+ ],
1272
+ paddingOuter: [
1273
+ 0.075,
1274
+ 0.1
1275
+ ]
1085
1276
  };
1086
1277
  result.axes = [
1087
1278
  ...result.axes,
@@ -1089,12 +1280,15 @@ const xBand = (spec, context)=>{
1089
1280
  ];
1090
1281
  return result;
1091
1282
  };
1283
+ const ANNOTATION_Z_INDEX = 1000;
1284
+ const LINEAR_AXIS_INNER_OFFSET_TOP = 7;
1092
1285
  const xLinear = (spec, context)=>{
1093
1286
  const result = {
1094
1287
  ...spec
1095
1288
  };
1096
1289
  const { advancedVSeed, vseed } = context;
1097
1290
  const { chartType } = vseed;
1291
+ const { locale } = advancedVSeed;
1098
1292
  const config = advancedVSeed.config?.[chartType]?.xAxis;
1099
1293
  if (!result.axes) result.axes = [];
1100
1294
  if (!config) {
@@ -1120,6 +1314,7 @@ const xLinear = (spec, context)=>{
1120
1314
  min,
1121
1315
  label: {
1122
1316
  visible: label?.visible,
1317
+ formatMethod: (value)=>autoFormatter(value, locale),
1123
1318
  style: {
1124
1319
  fill: label?.labelColor,
1125
1320
  angle: label?.labelAngle,
@@ -1157,6 +1352,9 @@ const xLinear = (spec, context)=>{
1157
1352
  lineWidth: line?.lineWidth,
1158
1353
  stroke: line?.lineColor
1159
1354
  }
1355
+ },
1356
+ innerOffset: {
1357
+ top: LINEAR_AXIS_INNER_OFFSET_TOP
1160
1358
  }
1161
1359
  };
1162
1360
  result.axes = [
@@ -1244,7 +1442,15 @@ const yBand = (spec, context)=>{
1244
1442
  lineWidth: line?.lineWidth,
1245
1443
  stroke: line?.lineColor
1246
1444
  }
1247
- }
1445
+ },
1446
+ paddingInner: [
1447
+ 0.15,
1448
+ 0.1
1449
+ ],
1450
+ paddingOuter: [
1451
+ 0.075,
1452
+ 0.1
1453
+ ]
1248
1454
  };
1249
1455
  result.axes = [
1250
1456
  ...result.axes,
@@ -1258,6 +1464,7 @@ const yLinear = (spec, context)=>{
1258
1464
  };
1259
1465
  const { advancedVSeed, vseed } = context;
1260
1466
  const { chartType } = vseed;
1467
+ const { locale } = advancedVSeed;
1261
1468
  const config = advancedVSeed.config?.[chartType]?.yAxis;
1262
1469
  if (!result.axes) result.axes = [];
1263
1470
  if (!config) {
@@ -1283,6 +1490,7 @@ const yLinear = (spec, context)=>{
1283
1490
  min,
1284
1491
  label: {
1285
1492
  visible: label?.visible,
1493
+ formatMethod: (value)=>autoFormatter(value, locale),
1286
1494
  style: {
1287
1495
  fill: label?.labelColor,
1288
1496
  angle: label?.labelAngle,
@@ -1320,6 +1528,9 @@ const yLinear = (spec, context)=>{
1320
1528
  lineWidth: line?.lineWidth,
1321
1529
  stroke: line?.lineColor
1322
1530
  }
1531
+ },
1532
+ innerOffset: {
1533
+ top: LINEAR_AXIS_INNER_OFFSET_TOP
1323
1534
  }
1324
1535
  };
1325
1536
  result.axes = [
@@ -1342,6 +1553,15 @@ const stackInverse = (spec)=>{
1342
1553
  result.stackInverse = true;
1343
1554
  return result;
1344
1555
  };
1556
+ const stackCornerRadius_stackCornerRadius = (spec, context)=>{
1557
+ const { advancedVSeed, vseed } = context;
1558
+ const { chartType } = vseed;
1559
+ const stackCornerRadius = advancedVSeed.config?.[chartType]?.stackCornerRadius;
1560
+ return {
1561
+ ...spec,
1562
+ stackCornerRadius
1563
+ };
1564
+ };
1345
1565
  const background_backgroundColor = (spec, context)=>{
1346
1566
  const result = {
1347
1567
  ...spec
@@ -1363,11 +1583,57 @@ const tooltip_tooltip = (spec, context)=>{
1363
1583
  ...spec
1364
1584
  };
1365
1585
  const { advancedVSeed } = context;
1586
+ const { measures, datasetReshapeInfo } = advancedVSeed;
1366
1587
  const baseConfig = advancedVSeed.baseConfig.vchart;
1367
1588
  const { tooltip = defaultTooltip } = baseConfig;
1368
1589
  const { enable } = tooltip;
1590
+ const { measureId, measureName, measureValue } = datasetReshapeInfo[0].foldInfo;
1369
1591
  result.tooltip = {
1370
- visible: enable
1592
+ visible: enable,
1593
+ mark: {
1594
+ content: [
1595
+ {
1596
+ visible: true,
1597
+ key: (datum)=>datum && datum[measureName] || '',
1598
+ value: (datum)=>{
1599
+ if (!datum) return '';
1600
+ const value = datum[measureValue];
1601
+ const id = datum[measureId];
1602
+ const measure = findMeasureById(measures, id);
1603
+ if (!measure) return String(value);
1604
+ const { format = {}, autoFormat = true } = measure;
1605
+ if (!isEmpty(format)) {
1606
+ const formatter = createFormatter(format);
1607
+ return formatter(value);
1608
+ }
1609
+ if (autoFormat) return autoFormatter(value);
1610
+ return String(value);
1611
+ }
1612
+ }
1613
+ ]
1614
+ },
1615
+ dimension: {
1616
+ content: [
1617
+ {
1618
+ visible: true,
1619
+ key: (datum)=>datum && datum[measureName] || '',
1620
+ value: (datum)=>{
1621
+ if (!datum) return '';
1622
+ const value = datum[measureValue];
1623
+ const id = datum[measureId];
1624
+ const measure = findMeasureById(measures, id);
1625
+ if (!measure) return String(value);
1626
+ const { format = {}, autoFormat = true } = measure;
1627
+ if (!isEmpty(format)) {
1628
+ const formatter = createFormatter(format);
1629
+ return formatter(value);
1630
+ }
1631
+ if (autoFormat) return autoFormatter(value);
1632
+ return String(value);
1633
+ }
1634
+ }
1635
+ ]
1636
+ }
1371
1637
  };
1372
1638
  return result;
1373
1639
  };
@@ -1376,12 +1642,26 @@ const label_label = (spec, context)=>{
1376
1642
  ...spec
1377
1643
  };
1378
1644
  const { advancedVSeed } = context;
1645
+ const { measures, datasetReshapeInfo, locale } = advancedVSeed;
1379
1646
  const baseConfig = advancedVSeed.baseConfig.vchart;
1380
1647
  if (!baseConfig || !baseConfig.label) return result;
1648
+ const { measureId } = datasetReshapeInfo[0].foldInfo;
1381
1649
  const { label } = baseConfig;
1382
1650
  const { enable } = label;
1383
1651
  result.label = {
1384
- visible: enable
1652
+ visible: enable,
1653
+ formatMethod: (value, datum)=>{
1654
+ const id = datum[measureId];
1655
+ const measure = findMeasureById(measures, id);
1656
+ if (!measure) return value;
1657
+ const { format = {}, autoFormat = true } = measure;
1658
+ if (!isEmpty(format)) {
1659
+ const formatter = createFormatter(format);
1660
+ return formatter(value);
1661
+ }
1662
+ if (autoFormat) return autoFormatter(value, locale);
1663
+ return String(value);
1664
+ }
1385
1665
  };
1386
1666
  return result;
1387
1667
  };
@@ -1684,6 +1964,7 @@ const pivotGridStyle = (spec)=>{
1684
1964
  ...spec
1685
1965
  };
1686
1966
  const transparent = 'rgba(0,0,0,0)';
1967
+ const hoverBackgroundColor = 'rgba(178,186,207, 0.2)';
1687
1968
  return {
1688
1969
  ...result,
1689
1970
  theme: {
@@ -1702,7 +1983,10 @@ const pivotGridStyle = (spec)=>{
1702
1983
  0,
1703
1984
  1,
1704
1985
  0
1705
- ]
1986
+ ],
1987
+ hover: {
1988
+ cellBgColor: 'transparent'
1989
+ }
1706
1990
  },
1707
1991
  headerStyle: {
1708
1992
  borderColor: 'rgba(0,4,20,0.2)',
@@ -1712,7 +1996,7 @@ const pivotGridStyle = (spec)=>{
1712
1996
  borderLineWidth: 0,
1713
1997
  bgColor: transparent,
1714
1998
  hover: {
1715
- cellBgColor: 'rgba(178,186,207, 0.2)'
1999
+ cellBgColor: hoverBackgroundColor
1716
2000
  }
1717
2001
  },
1718
2002
  rowHeaderStyle: {
@@ -1722,7 +2006,7 @@ const pivotGridStyle = (spec)=>{
1722
2006
  borderLineWidth: 0,
1723
2007
  bgColor: transparent,
1724
2008
  hover: {
1725
- cellBgColor: 'rgba(178,186,207, 0.2)'
2009
+ cellBgColor: hoverBackgroundColor
1726
2010
  }
1727
2011
  },
1728
2012
  cornerHeaderStyle: {
@@ -1739,7 +2023,7 @@ const pivotGridStyle = (spec)=>{
1739
2023
  ],
1740
2024
  bgColor: transparent,
1741
2025
  hover: {
1742
- cellBgColor: ''
2026
+ cellBgColor: hoverBackgroundColor
1743
2027
  }
1744
2028
  },
1745
2029
  cornerRightTopCellStyle: {
@@ -1747,7 +2031,7 @@ const pivotGridStyle = (spec)=>{
1747
2031
  borderLineWidth: 0,
1748
2032
  bgColor: transparent,
1749
2033
  hover: {
1750
- cellBgColor: ''
2034
+ cellBgColor: hoverBackgroundColor
1751
2035
  }
1752
2036
  },
1753
2037
  cornerLeftBottomCellStyle: {
@@ -1755,7 +2039,7 @@ const pivotGridStyle = (spec)=>{
1755
2039
  borderLineWidth: 0,
1756
2040
  bgColor: transparent,
1757
2041
  hover: {
1758
- cellBgColor: ''
2042
+ cellBgColor: hoverBackgroundColor
1759
2043
  }
1760
2044
  },
1761
2045
  cornerRightBottomCellStyle: {
@@ -1763,7 +2047,7 @@ const pivotGridStyle = (spec)=>{
1763
2047
  borderLineWidth: 0,
1764
2048
  bgColor: transparent,
1765
2049
  hover: {
1766
- cellBgColor: ''
2050
+ cellBgColor: hoverBackgroundColor
1767
2051
  }
1768
2052
  },
1769
2053
  rightFrozenStyle: {
@@ -1771,7 +2055,7 @@ const pivotGridStyle = (spec)=>{
1771
2055
  borderLineWidth: 0,
1772
2056
  bgColor: transparent,
1773
2057
  hover: {
1774
- cellBgColor: 'rgba(178,186,207, 0.2)'
2058
+ cellBgColor: hoverBackgroundColor
1775
2059
  }
1776
2060
  },
1777
2061
  bottomFrozenStyle: {
@@ -1779,7 +2063,7 @@ const pivotGridStyle = (spec)=>{
1779
2063
  borderLineWidth: 0,
1780
2064
  bgColor: transparent,
1781
2065
  hover: {
1782
- cellBgColor: 'rgba(178,186,207, 0.2)'
2066
+ cellBgColor: hoverBackgroundColor
1783
2067
  }
1784
2068
  },
1785
2069
  selectionStyle: {
@@ -1827,8 +2111,10 @@ const pivotRowDimensions = (spec, context)=>{
1827
2111
  rows: rows
1828
2112
  };
1829
2113
  };
1830
- const selector_selector = (datum, selector)=>{
2114
+ const selector_selector = (vchartDatum, selector)=>{
1831
2115
  if (!selector) return true;
2116
+ const vchartKeys = Object.keys(vchartDatum).filter((k)=>k.toLocaleLowerCase().startsWith('__vchart'));
2117
+ const datum = omit(vchartDatum, vchartKeys);
1832
2118
  const selectors = Array.isArray(selector) ? selector : [
1833
2119
  selector
1834
2120
  ];
@@ -1917,52 +2203,218 @@ const barStyle_barStyle = (spec, context)=>{
1917
2203
  const { advancedVSeed } = context;
1918
2204
  const { markStyle, encoding } = advancedVSeed;
1919
2205
  const { barStyle } = markStyle;
1920
- if (!barStyle) return spec;
1921
2206
  const result = {
1922
- ...spec
2207
+ ...spec,
2208
+ bar: {
2209
+ state: {
2210
+ hover: {
2211
+ stroke: (datum, context)=>{
2212
+ const field = encoding[0]?.group?.[0];
2213
+ const color = context.seriesColor(datum[field]);
2214
+ return color;
2215
+ },
2216
+ lineWidth: 4,
2217
+ fillOpacity: 0.6
2218
+ }
2219
+ }
2220
+ }
1923
2221
  };
1924
- const { selector: barSelector, barBorderColor, barBorderStyle, barBorderWidth, barColor, barColorOpacity, barRadius } = barStyle;
2222
+ if (!barStyle) return result;
2223
+ const barStyles = Array.isArray(barStyle) ? barStyle : [
2224
+ barStyle
2225
+ ];
2226
+ const customMap = barStyles.reduce((result, style, index)=>{
2227
+ const { barBorderColor, barBorderStyle, barBorderWidth, barColor, barColorOpacity, barRadius } = style;
2228
+ const lineDash = 'dashed' === barBorderStyle ? [
2229
+ 5,
2230
+ 2
2231
+ ] : 'dotted' === barBorderStyle ? [
2232
+ 2,
2233
+ 5
2234
+ ] : [
2235
+ 0,
2236
+ 0
2237
+ ];
2238
+ return {
2239
+ ...result,
2240
+ [`custom${index + 1}`]: {
2241
+ level: index + 1,
2242
+ filter: (datum)=>{
2243
+ if (selector_selector(datum, style.selector)) return true;
2244
+ return false;
2245
+ },
2246
+ style: {
2247
+ fill: barColor,
2248
+ fillOpacity: barColorOpacity,
2249
+ stroke: barBorderColor,
2250
+ lineWidth: barBorderWidth,
2251
+ lineDash: lineDash,
2252
+ cornerRadius: barRadius
2253
+ }
2254
+ }
2255
+ };
2256
+ }, {});
1925
2257
  return {
1926
2258
  ...result,
1927
2259
  bar: {
1928
- style: {
1929
- fill: barColor ? (datum, context)=>{
1930
- if (selector_selector(datum, barSelector)) return barColor;
1931
- return context.seriesColor(datum[encoding[0]?.group?.[0]]);
1932
- } : void 0,
1933
- fillOpacity: barColorOpacity ? (datum)=>{
1934
- if (selector_selector(datum, barSelector)) return barColorOpacity;
1935
- return 1;
1936
- } : void 0,
1937
- stroke: barBorderColor ? (datum, context)=>{
1938
- if (selector_selector(datum, barSelector)) return barBorderColor;
1939
- return context.seriesColor(datum[encoding[0]?.group?.[0]]);
1940
- } : void 0,
1941
- lineWidth: barBorderWidth ? (datum)=>{
1942
- if (selector_selector(datum, barSelector)) return barBorderWidth;
1943
- return 0;
1944
- } : void 0,
1945
- lineDash: barBorderStyle ? (datum)=>{
1946
- if (selector_selector(datum, barSelector)) {
1947
- if ('solid' === barBorderStyle) ;
1948
- else if ('dashed' === barBorderStyle) return [
1949
- 5,
1950
- 5
1951
- ];
1952
- else if ('dotted' === barBorderStyle) return [
1953
- 1,
1954
- 5
1955
- ];
1956
- }
1957
- return [
1958
- 0,
1959
- 0
1960
- ];
1961
- } : void 0,
1962
- cornerRadius: barRadius ? (datum)=>{
1963
- if (selector_selector(datum, barSelector)) return barRadius;
1964
- return 0;
1965
- } : void 0
2260
+ state: {
2261
+ ...customMap
2262
+ }
2263
+ }
2264
+ };
2265
+ };
2266
+ const pointStyle_pointStyle = (spec, context)=>{
2267
+ const { advancedVSeed } = context;
2268
+ const { markStyle } = advancedVSeed;
2269
+ const { pointStyle } = markStyle;
2270
+ const result = {
2271
+ ...spec,
2272
+ point: {
2273
+ state: {
2274
+ dimension_hover: {
2275
+ scaleX: 1.4,
2276
+ scaleY: 1.4
2277
+ }
2278
+ }
2279
+ }
2280
+ };
2281
+ if (!pointStyle) return result;
2282
+ const pointStyles = Array.isArray(pointStyle) ? pointStyle : [
2283
+ pointStyle
2284
+ ];
2285
+ const customMap = pointStyles.reduce((result, style, index)=>{
2286
+ const { pointBorderColor, pointBorderStyle, pointBorderWidth, pointColor, pointColorOpacity, pointSize } = style;
2287
+ const lineDash = 'dashed' === pointBorderStyle ? [
2288
+ 5,
2289
+ 2
2290
+ ] : 'dotted' === pointBorderStyle ? [
2291
+ 2,
2292
+ 5
2293
+ ] : [
2294
+ 0,
2295
+ 0
2296
+ ];
2297
+ return {
2298
+ ...result,
2299
+ [`custom${index + 1}`]: {
2300
+ level: index + 1,
2301
+ filter: (datum)=>{
2302
+ if (selector_selector(datum, style.selector)) return true;
2303
+ return false;
2304
+ },
2305
+ style: {
2306
+ size: pointSize,
2307
+ fill: pointColor,
2308
+ fillOpacity: pointColorOpacity,
2309
+ stroke: pointBorderColor,
2310
+ lineWidth: pointBorderWidth,
2311
+ lineDash: lineDash
2312
+ }
2313
+ }
2314
+ };
2315
+ }, {});
2316
+ return {
2317
+ ...result,
2318
+ point: {
2319
+ state: {
2320
+ ...customMap
2321
+ }
2322
+ }
2323
+ };
2324
+ };
2325
+ const lineStyle_lineStyle = (spec, context)=>{
2326
+ const { advancedVSeed } = context;
2327
+ const { markStyle, encoding, dataset } = advancedVSeed;
2328
+ const { lineStyle } = markStyle;
2329
+ if (!lineStyle) return spec;
2330
+ const result = {
2331
+ ...spec
2332
+ };
2333
+ const lineStyles = Array.isArray(lineStyle) ? lineStyle : [
2334
+ lineStyle
2335
+ ];
2336
+ const group = encoding[0]?.group?.[0];
2337
+ const lineGroups = groupBy(dataset, (d)=>d[group ?? '']);
2338
+ const customMap = lineStyles.reduce((result, style, index)=>{
2339
+ const { lineColor, lineColorOpacity, lineSmooth, lineStyle, lineWidth } = style;
2340
+ const dashSegment = (lineWidth ?? 2) * 2;
2341
+ const dashGap = lineWidth ?? 2;
2342
+ const lineDash = 'dashed' === lineStyle ? [
2343
+ dashSegment,
2344
+ dashSegment
2345
+ ] : 'dotted' === lineStyle ? [
2346
+ dashGap / 2,
2347
+ 2 * dashGap
2348
+ ] : [
2349
+ 0,
2350
+ 0
2351
+ ];
2352
+ const curveType = lineSmooth ? 'monotone' : 'linear';
2353
+ return {
2354
+ ...result,
2355
+ [`custom${index + 1}`]: {
2356
+ level: index + 1,
2357
+ filter: (datum)=>{
2358
+ const lineData = lineGroups[datum[group ?? '']];
2359
+ for (const d of lineData)if (selector_selector(d, style.selector)) return true;
2360
+ return false;
2361
+ },
2362
+ style: {
2363
+ curveType: curveType,
2364
+ fill: lineColor,
2365
+ fillOpacity: lineColorOpacity,
2366
+ stroke: lineColor,
2367
+ lineWidth: lineWidth,
2368
+ lineDash: lineDash
2369
+ }
2370
+ }
2371
+ };
2372
+ }, {});
2373
+ return {
2374
+ ...result,
2375
+ line: {
2376
+ state: {
2377
+ ...customMap
2378
+ }
2379
+ }
2380
+ };
2381
+ };
2382
+ const areaStyle_areaStyle = (spec, context)=>{
2383
+ const { advancedVSeed } = context;
2384
+ const { markStyle, encoding, dataset } = advancedVSeed;
2385
+ const { areaStyle } = markStyle;
2386
+ if (!areaStyle) return spec;
2387
+ const result = {
2388
+ ...spec
2389
+ };
2390
+ const areaStyles = Array.isArray(areaStyle) ? areaStyle : [
2391
+ areaStyle
2392
+ ];
2393
+ const group = encoding[0]?.group?.[0];
2394
+ const lineGroups = groupBy(dataset, (d)=>d[group ?? '']);
2395
+ const customMap = areaStyles.reduce((result, style, index)=>{
2396
+ const { areaColor, areaColorOpacity } = style;
2397
+ return {
2398
+ ...result,
2399
+ [`custom${index + 1}`]: {
2400
+ level: index + 1,
2401
+ filter: (datum)=>{
2402
+ const lineData = lineGroups[datum[group ?? '']];
2403
+ for (const d of lineData)if (selector_selector(d, style.selector)) return true;
2404
+ return false;
2405
+ },
2406
+ style: {
2407
+ fill: areaColor,
2408
+ fillOpacity: areaColorOpacity
2409
+ }
2410
+ }
2411
+ };
2412
+ }, {});
2413
+ return {
2414
+ ...result,
2415
+ area: {
2416
+ state: {
2417
+ ...customMap
1966
2418
  }
1967
2419
  }
1968
2420
  };
@@ -1985,20 +2437,15 @@ const annotationPoint_annotationPoint = (spec, context)=>{
1985
2437
  const dataset = advancedVSeed.dataset.flat();
1986
2438
  const selectedData = dataset.filter((datum)=>selector_selector(datum, selectorPoint));
1987
2439
  return selectedData.map((datum)=>({
2440
+ zIndex: ANNOTATION_Z_INDEX,
1988
2441
  regionRelative: true,
1989
2442
  position: (data, context)=>{
1990
2443
  const targetDatum = data.find((item)=>isSubset(datum, item));
1991
2444
  if (targetDatum) {
1992
2445
  const { x, y } = context.dataToPosition(targetDatum);
1993
- const xBandWidth = context.scaleX?.bandwidth?.();
1994
- const yBandWidth = context.scaleY?.bandwidth?.();
1995
- if (xBandWidth) return {
1996
- x: x,
1997
- y: y
1998
- };
1999
- if (yBandWidth) return {
2446
+ return {
2000
2447
  x,
2001
- y: y
2448
+ y
2002
2449
  };
2003
2450
  }
2004
2451
  },
@@ -2058,6 +2505,7 @@ const annotationVerticalLine_annotationVerticalLine = (spec, context)=>{
2058
2505
  const dataset = advancedVSeed.dataset.flat();
2059
2506
  const generateOneMarkLine = (x)=>({
2060
2507
  x: x,
2508
+ zIndex: ANNOTATION_Z_INDEX,
2061
2509
  line: {
2062
2510
  visible: lineVisible,
2063
2511
  style: {
@@ -2154,6 +2602,7 @@ const annotationHorizontalLine_annotationHorizontalLine = (spec, context)=>{
2154
2602
  const dataset = advancedVSeed.dataset.flat();
2155
2603
  const generateOneMarkLine = (y)=>({
2156
2604
  y,
2605
+ zIndex: ANNOTATION_Z_INDEX,
2157
2606
  line: {
2158
2607
  visible: lineVisible,
2159
2608
  style: {
@@ -2248,20 +2697,19 @@ const annotationArea_annotationArea = (spec, context)=>{
2248
2697
  right: 'insideRight'
2249
2698
  };
2250
2699
  const markArea = annotationAreaList.flatMap((annotationArea)=>{
2251
- 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 = 8, areaColor = '#888888', areaColorOpacity = 0.15, areaBorderColor, areaBorderRadius, areaBorderWidth } = annotationArea;
2700
+ 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;
2252
2701
  const dataset = advancedVSeed.dataset.flat();
2253
2702
  const selectedData = dataset.filter((datum)=>selector_selector(datum, selectorPoint));
2254
2703
  return {
2704
+ zIndex: ANNOTATION_Z_INDEX,
2255
2705
  regionRelative: true,
2256
2706
  positions: (data, context)=>{
2257
- console.log('debug selectedData', selectedData);
2258
2707
  const positionData = data.filter((item)=>selectedData.some((datum)=>isSubset(datum, item)));
2259
2708
  const xyList = positionData.map((datum)=>context.dataToPosition(datum));
2260
- const xScale = context.scaleX;
2261
- const yScale = context.scaleY;
2262
- const xBandWidth = xScale?.bandwidth?.();
2263
- const yBandWidth = yScale?.bandwidth?.();
2264
- if (xBandWidth) {
2709
+ const yAxisHelper = context.getYAxisHelper();
2710
+ const xAxisHelper = context.getXAxisHelper();
2711
+ if ('function' == typeof xAxisHelper?.getBandwidth) {
2712
+ const yScale = yAxisHelper.getScale();
2265
2713
  const minX = Math.min(...xyList.map((item)=>item.x)) - outerPadding;
2266
2714
  const maxX = Math.max(...xyList.map((item)=>item.x)) + outerPadding;
2267
2715
  const minY = Math.min(...yScale.range());
@@ -2285,7 +2733,8 @@ const annotationArea_annotationArea = (spec, context)=>{
2285
2733
  }
2286
2734
  ];
2287
2735
  }
2288
- if (yBandWidth) {
2736
+ if ('function' == typeof yAxisHelper?.getBandwidth) {
2737
+ const xScale = xAxisHelper.getScale();
2289
2738
  const minY = Math.min(...xyList.map((item)=>item.y)) - outerPadding;
2290
2739
  const maxY = Math.max(...xyList.map((item)=>item.y)) + outerPadding;
2291
2740
  const minX = Math.min(...xScale.range());
@@ -2373,15 +2822,17 @@ const annotationAreaBand = (spec, context)=>{
2373
2822
  const dataset = advancedVSeed.dataset.flat();
2374
2823
  const selectedData = dataset.filter((datum)=>selector_selector(datum, selectorPoint));
2375
2824
  return {
2825
+ zIndex: ANNOTATION_Z_INDEX,
2376
2826
  regionRelative: true,
2377
2827
  positions: (data, context)=>{
2378
2828
  const positionData = data.filter((item)=>selectedData.some((datum)=>isSubset(datum, item)));
2379
2829
  const xyList = positionData.map((datum)=>context.dataToPosition(datum));
2380
- const xScale = context.scaleX;
2381
- const yScale = context.scaleY;
2382
- const xBandWidth = xScale?.bandwidth?.();
2383
- const yBandWidth = yScale?.bandwidth?.();
2384
- if (xBandWidth) {
2830
+ const yAxisHelper = context.getYAxisHelper();
2831
+ const xAxisHelper = context.getXAxisHelper();
2832
+ if ('function' == typeof xAxisHelper?.getBandwidth) {
2833
+ const depth = context.fieldX.length ?? 0;
2834
+ const xBandWidth = xAxisHelper?.getBandwidth?.(depth - 1);
2835
+ const yScale = yAxisHelper.getScale();
2385
2836
  const minX = Math.min(...xyList.map((item)=>item.x)) - outerPadding;
2386
2837
  const maxX = Math.max(...xyList.map((item)=>item.x)) + xBandWidth + outerPadding;
2387
2838
  const minY = Math.min(...yScale.range());
@@ -2405,7 +2856,10 @@ const annotationAreaBand = (spec, context)=>{
2405
2856
  }
2406
2857
  ];
2407
2858
  }
2408
- if (yBandWidth) {
2859
+ if ('function' == typeof yAxisHelper?.getBandwidth) {
2860
+ const depth = context.fieldY.length ?? 0;
2861
+ const yBandWidth = yAxisHelper?.getBandwidth?.(depth - 1);
2862
+ const xScale = xAxisHelper.getScale();
2409
2863
  const minY = Math.min(...xyList.map((item)=>item.y)) - outerPadding;
2410
2864
  const maxY = Math.max(...xyList.map((item)=>item.y)) + yBandWidth + outerPadding;
2411
2865
  const minX = Math.min(...xScale.range());
@@ -2470,6 +2924,118 @@ const annotationAreaBand = (spec, context)=>{
2470
2924
  markArea: markArea
2471
2925
  };
2472
2926
  };
2927
+ const verticalCrosshairLine = (spec, context)=>{
2928
+ const result = {
2929
+ ...spec
2930
+ };
2931
+ const { advancedVSeed, vseed } = context;
2932
+ const { chartType } = vseed;
2933
+ const config = advancedVSeed.config?.[chartType]?.crosshairLine;
2934
+ if (!config) return result;
2935
+ if (!result.crosshair) result.crosshair = {};
2936
+ const { visible = true, lineColor, labelColor, labelVisible, labelBackgroundColor } = config;
2937
+ const crosshair = result.crosshair;
2938
+ crosshair.xField = {
2939
+ visible,
2940
+ line: {
2941
+ type: 'line',
2942
+ style: {
2943
+ lineWidth: 1,
2944
+ opacity: 1,
2945
+ stroke: lineColor,
2946
+ lineDash: [
2947
+ 4,
2948
+ 2
2949
+ ]
2950
+ }
2951
+ },
2952
+ label: {
2953
+ visible: labelVisible,
2954
+ labelBackground: {
2955
+ visible: labelVisible,
2956
+ style: {
2957
+ fill: labelBackgroundColor
2958
+ }
2959
+ },
2960
+ style: {
2961
+ fill: labelColor
2962
+ }
2963
+ }
2964
+ };
2965
+ return result;
2966
+ };
2967
+ const verticalCrosshairRect = (spec, context)=>{
2968
+ const result = {
2969
+ ...spec
2970
+ };
2971
+ const { advancedVSeed, vseed } = context;
2972
+ const { chartType } = vseed;
2973
+ const config = advancedVSeed.config?.[chartType]?.crosshairRect;
2974
+ if (!config) return result;
2975
+ if (!result.crosshair) result.crosshair = {};
2976
+ const { visible = true, rectColor, labelColor, labelVisible, labelBackgroundColor } = config;
2977
+ const crosshair = result.crosshair;
2978
+ crosshair.xField = {
2979
+ visible,
2980
+ line: {
2981
+ type: 'rect',
2982
+ style: {
2983
+ lineWidth: 0,
2984
+ opacity: 0.2,
2985
+ fill: rectColor
2986
+ }
2987
+ },
2988
+ label: {
2989
+ visible: labelVisible,
2990
+ labelBackground: {
2991
+ visible: labelVisible,
2992
+ style: {
2993
+ fill: labelBackgroundColor
2994
+ }
2995
+ },
2996
+ style: {
2997
+ fill: labelColor
2998
+ }
2999
+ }
3000
+ };
3001
+ return result;
3002
+ };
3003
+ const horizontalCrosshairRect = (spec, context)=>{
3004
+ const result = {
3005
+ ...spec
3006
+ };
3007
+ const { advancedVSeed, vseed } = context;
3008
+ const { chartType } = vseed;
3009
+ const config = advancedVSeed.config?.[chartType]?.crosshairRect;
3010
+ if (!config) return result;
3011
+ if (!result.crosshair) result.crosshair = {};
3012
+ const { visible = true, rectColor, labelColor, labelVisible, labelBackgroundColor } = config;
3013
+ const crosshair = result.crosshair;
3014
+ crosshair.yField = {
3015
+ visible,
3016
+ line: {
3017
+ type: 'rect',
3018
+ style: {
3019
+ lineWidth: 0,
3020
+ opacity: 0.2,
3021
+ fill: rectColor
3022
+ }
3023
+ },
3024
+ label: {
3025
+ visible: labelVisible,
3026
+ labelBackground: {
3027
+ visible: labelVisible,
3028
+ style: {
3029
+ fill: labelBackgroundColor
3030
+ }
3031
+ },
3032
+ style: {
3033
+ fill: labelColor
3034
+ }
3035
+ }
3036
+ };
3037
+ return result;
3038
+ };
2473
3039
  const line_line = [
2474
3040
  initLine,
2475
3041
  color_color,
@@ -2479,7 +3045,10 @@ const line_line = [
2479
3045
  yLinear,
2480
3046
  label_label,
2481
3047
  tooltip_tooltip,
3048
+ verticalCrosshairLine,
2482
3049
  discreteLegend,
3050
+ pointStyle_pointStyle,
3051
+ lineStyle_lineStyle,
2483
3052
  annotationPoint_annotationPoint,
2484
3053
  annotationVerticalLine_annotationVerticalLine,
2485
3054
  annotationHorizontalLine_annotationHorizontalLine,
@@ -2499,6 +3068,9 @@ const pivotLine = [
2499
3068
  yLinear,
2500
3069
  label_label,
2501
3070
  tooltip_tooltip,
3071
+ verticalCrosshairLine,
3072
+ pointStyle_pointStyle,
3073
+ lineStyle_lineStyle,
2502
3074
  annotationPoint_annotationPoint,
2503
3075
  annotationVerticalLine_annotationVerticalLine,
2504
3076
  annotationHorizontalLine_annotationHorizontalLine,
@@ -2513,6 +3085,7 @@ const lineSpecPipeline = [
2513
3085
  ];
2514
3086
  const column = [
2515
3087
  initColumn,
3088
+ stackCornerRadius_stackCornerRadius,
2516
3089
  stackInverse,
2517
3090
  color_color,
2518
3091
  background_backgroundColor,
@@ -2521,6 +3094,7 @@ const column = [
2521
3094
  yLinear,
2522
3095
  label_label,
2523
3096
  tooltip_tooltip,
3097
+ verticalCrosshairRect,
2524
3098
  discreteLegend,
2525
3099
  barStyle_barStyle,
2526
3100
  annotationPoint_annotationPoint,
@@ -2535,6 +3109,7 @@ const pivotColumn = [
2535
3109
  datasetPivot,
2536
3110
  pivotIndicators([
2537
3111
  initColumn,
3112
+ stackCornerRadius_stackCornerRadius,
2538
3113
  stackInverse,
2539
3114
  color_color,
2540
3115
  background_backgroundColor,
@@ -2543,6 +3118,7 @@ const pivotColumn = [
2543
3118
  yLinear,
2544
3119
  label_label,
2545
3120
  tooltip_tooltip,
3121
+ verticalCrosshairRect,
2546
3122
  barStyle_barStyle,
2547
3123
  annotationPoint_annotationPoint,
2548
3124
  annotationVerticalLine_annotationVerticalLine,
@@ -2558,6 +3134,7 @@ const columnSpecPipeline = [
2558
3134
  ];
2559
3135
  const columnParallel = [
2560
3136
  initColumnParallel,
3137
+ stackCornerRadius_stackCornerRadius,
2561
3138
  color_color,
2562
3139
  background_backgroundColor,
2563
3140
  dataset_dataset,
@@ -2566,6 +3143,7 @@ const columnParallel = [
2566
3143
  label_label,
2567
3144
  tooltip_tooltip,
2568
3145
  discreteLegend,
3146
+ verticalCrosshairRect,
2569
3147
  barStyle_barStyle,
2570
3148
  annotationPoint_annotationPoint,
2571
3149
  annotationVerticalLine_annotationVerticalLine,
@@ -2579,6 +3157,7 @@ const pivotColumnParallel = [
2579
3157
  datasetPivot,
2580
3158
  pivotIndicators([
2581
3159
  initColumnParallel,
3160
+ stackCornerRadius_stackCornerRadius,
2582
3161
  color_color,
2583
3162
  background_backgroundColor,
2584
3163
  datasetPivotPlaceholder,
@@ -2586,6 +3165,7 @@ const pivotColumnParallel = [
2586
3165
  yLinear,
2587
3166
  label_label,
2588
3167
  tooltip_tooltip,
3168
+ verticalCrosshairRect,
2589
3169
  barStyle_barStyle,
2590
3170
  annotationPoint_annotationPoint,
2591
3171
  annotationVerticalLine_annotationVerticalLine,
@@ -2601,6 +3181,7 @@ const columnParallelSpecPipeline = [
2601
3181
  ];
2602
3182
  const columnPercent = [
2603
3183
  initColumn,
3184
+ stackCornerRadius_stackCornerRadius,
2604
3185
  stackInverse,
2605
3186
  color_color,
2606
3187
  background_backgroundColor,
@@ -2610,6 +3191,7 @@ const columnPercent = [
2610
3191
  yLinear,
2611
3192
  label_label,
2612
3193
  tooltip_tooltip,
3194
+ verticalCrosshairRect,
2613
3195
  discreteLegend,
2614
3196
  barStyle_barStyle,
2615
3197
  annotationPoint_annotationPoint,
@@ -2624,6 +3206,7 @@ const pivotColumnPercent = [
2624
3206
  datasetPivot,
2625
3207
  pivotIndicators([
2626
3208
  initColumn,
3209
+ stackCornerRadius_stackCornerRadius,
2627
3210
  stackInverse,
2628
3211
  color_color,
2629
3212
  percent,
@@ -2633,6 +3216,7 @@ const pivotColumnPercent = [
2633
3216
  yLinear,
2634
3217
  label_label,
2635
3218
  tooltip_tooltip,
3219
+ verticalCrosshairRect,
2636
3220
  barStyle_barStyle,
2637
3221
  annotationPoint_annotationPoint,
2638
3222
  annotationVerticalLine_annotationVerticalLine,
@@ -2648,6 +3232,7 @@ const columnPercentSpecPipeline = [
2648
3232
  ];
2649
3233
  const bar = [
2650
3234
  initBar,
3235
+ stackCornerRadius_stackCornerRadius,
2651
3236
  color_color,
2652
3237
  background_backgroundColor,
2653
3238
  dataset_dataset,
@@ -2655,6 +3240,7 @@ const bar = [
2655
3240
  yBand,
2656
3241
  label_label,
2657
3242
  tooltip_tooltip,
3243
+ horizontalCrosshairRect,
2658
3244
  discreteLegend,
2659
3245
  barStyle_barStyle,
2660
3246
  annotationPoint_annotationPoint,
@@ -2669,6 +3255,7 @@ const pivotBar = [
2669
3255
  datasetPivot,
2670
3256
  pivotIndicators([
2671
3257
  initBar,
3258
+ stackCornerRadius_stackCornerRadius,
2672
3259
  color_color,
2673
3260
  background_backgroundColor,
2674
3261
  datasetPivotPlaceholder,
@@ -2676,6 +3263,7 @@ const pivotBar = [
2676
3263
  label_label,
2677
3264
  label_label,
2678
3265
  tooltip_tooltip,
3266
+ horizontalCrosshairRect,
2679
3267
  barStyle_barStyle,
2680
3268
  annotationPoint_annotationPoint,
2681
3269
  annotationVerticalLine_annotationVerticalLine,
@@ -2691,6 +3279,7 @@ const barSpecPipeline = [
2691
3279
  ];
2692
3280
  const barParallel = [
2693
3281
  initBarParallel,
3282
+ stackCornerRadius_stackCornerRadius,
2694
3283
  color_color,
2695
3284
  background_backgroundColor,
2696
3285
  dataset_dataset,
@@ -2698,6 +3287,7 @@ const barParallel = [
2698
3287
  yBand,
2699
3288
  label_label,
2700
3289
  tooltip_tooltip,
3290
+ horizontalCrosshairRect,
2701
3291
  discreteLegend,
2702
3292
  barStyle_barStyle,
2703
3293
  annotationPoint_annotationPoint,
@@ -2712,6 +3302,7 @@ const pivotBarParallel = [
2712
3302
  datasetPivot,
2713
3303
  pivotIndicators([
2714
3304
  initBarParallel,
3305
+ stackCornerRadius_stackCornerRadius,
2715
3306
  color_color,
2716
3307
  background_backgroundColor,
2717
3308
  datasetPivotPlaceholder,
@@ -2719,6 +3310,7 @@ const pivotBarParallel = [
2719
3310
  xLinear,
2720
3311
  label_label,
2721
3312
  tooltip_tooltip,
3313
+ horizontalCrosshairRect,
2722
3314
  barStyle_barStyle,
2723
3315
  annotationPoint_annotationPoint,
2724
3316
  annotationVerticalLine_annotationVerticalLine,
@@ -2734,6 +3326,7 @@ const barParallelSpecPipeline = [
2734
3326
  ];
2735
3327
  const barPercent = [
2736
3328
  initBar,
3329
+ stackCornerRadius_stackCornerRadius,
2737
3330
  color_color,
2738
3331
  background_backgroundColor,
2739
3332
  percent,
@@ -2742,6 +3335,7 @@ const barPercent = [
2742
3335
  yBand,
2743
3336
  label_label,
2744
3337
  tooltip_tooltip,
3338
+ horizontalCrosshairRect,
2745
3339
  discreteLegend,
2746
3340
  barStyle_barStyle,
2747
3341
  annotationPoint_annotationPoint,
@@ -2756,6 +3350,7 @@ const pivotBarPercent = [
2756
3350
  datasetPivot,
2757
3351
  pivotIndicators([
2758
3352
  initBar,
3353
+ stackCornerRadius_stackCornerRadius,
2759
3354
  color_color,
2760
3355
  background_backgroundColor,
2761
3356
  percent,
@@ -2764,6 +3359,7 @@ const pivotBarPercent = [
2764
3359
  xLinear,
2765
3360
  label_label,
2766
3361
  tooltip_tooltip,
3362
+ horizontalCrosshairRect,
2767
3363
  barStyle_barStyle,
2768
3364
  annotationPoint_annotationPoint,
2769
3365
  annotationVerticalLine_annotationVerticalLine,
@@ -2787,7 +3383,11 @@ const area_area = [
2787
3383
  yLinear,
2788
3384
  label_label,
2789
3385
  tooltip_tooltip,
3386
+ verticalCrosshairLine,
2790
3387
  discreteLegend,
3388
+ pointStyle_pointStyle,
3389
+ lineStyle_lineStyle,
3390
+ areaStyle_areaStyle,
2791
3391
  annotationPoint_annotationPoint,
2792
3392
  annotationVerticalLine_annotationVerticalLine,
2793
3393
  annotationHorizontalLine_annotationHorizontalLine,
@@ -2808,6 +3408,10 @@ const pivotArea = [
2808
3408
  yLinear,
2809
3409
  label_label,
2810
3410
  tooltip_tooltip,
3411
+ verticalCrosshairLine,
3412
+ pointStyle_pointStyle,
3413
+ lineStyle_lineStyle,
3414
+ areaStyle_areaStyle,
2811
3415
  annotationPoint_annotationPoint,
2812
3416
  annotationVerticalLine_annotationVerticalLine,
2813
3417
  annotationHorizontalLine_annotationHorizontalLine,
@@ -2831,7 +3435,11 @@ const areaPercent = [
2831
3435
  yLinear,
2832
3436
  label_label,
2833
3437
  tooltip_tooltip,
3438
+ verticalCrosshairLine,
2834
3439
  discreteLegend,
3440
+ pointStyle_pointStyle,
3441
+ lineStyle_lineStyle,
3442
+ areaStyle_areaStyle,
2835
3443
  annotationPoint_annotationPoint,
2836
3444
  annotationVerticalLine_annotationVerticalLine,
2837
3445
  annotationHorizontalLine_annotationHorizontalLine,
@@ -2853,6 +3461,10 @@ const pivotAreaPercent = [
2853
3461
  yLinear,
2854
3462
  label_label,
2855
3463
  tooltip_tooltip,
3464
+ verticalCrosshairLine,
3465
+ pointStyle_pointStyle,
3466
+ lineStyle_lineStyle,
3467
+ areaStyle_areaStyle,
2856
3468
  annotationPoint_annotationPoint,
2857
3469
  annotationVerticalLine_annotationVerticalLine,
2858
3470
  annotationHorizontalLine_annotationHorizontalLine,
@@ -2948,6 +3560,7 @@ class Builder {
2948
3560
  _spec = null;
2949
3561
  constructor(vseed){
2950
3562
  this._vseed = vseed;
3563
+ this._vseed.locale = vseed.locale || intl.getLocale();
2951
3564
  }
2952
3565
  build = ()=>build(this);
2953
3566
  buildSpec = (advanced)=>buildSpec(this, advanced);
@@ -3059,7 +3672,7 @@ const darkTheme = ()=>{
3059
3672
  labelAutoHideGap: 4,
3060
3673
  labelAutoLimit: true,
3061
3674
  labelAutoLimitLength: 100,
3062
- labelAutoRotate: true,
3675
+ labelAutoRotate: false,
3063
3676
  labelAutoRotateAngleRange: [
3064
3677
  0,
3065
3678
  -45,
@@ -3096,6 +3709,33 @@ const darkTheme = ()=>{
3096
3709
  lineWidth: 1
3097
3710
  }
3098
3711
  };
3712
+ const barBandAxis = {
3713
+ ...bandAxis,
3714
+ labelAutoHide: false,
3715
+ labelAutoHideGap: 1,
3716
+ labelAutoLimit: false,
3717
+ labelAutoLimitLength: void 0,
3718
+ labelAutoRotate: false,
3719
+ labelAutoRotateAngleRange: [
3720
+ 0,
3721
+ -45,
3722
+ -90
3723
+ ]
3724
+ };
3725
+ const crosshairLine = {
3726
+ visible: true,
3727
+ labelVisible: true,
3728
+ lineColor: '#E2E3E6',
3729
+ labelColor: '#4B4F54',
3730
+ labelBackgroundColor: '#ffffff'
3731
+ };
3732
+ const crosshairRect = {
3733
+ visible: true,
3734
+ labelVisible: true,
3735
+ lineColor: '#E2E3E6',
3736
+ labelColor: '#4B4F54',
3737
+ labelBackgroundColor: '#ffffff'
3738
+ };
3099
3739
  return {
3100
3740
  baseConfig: {
3101
3741
  vtable: {
@@ -3138,39 +3778,84 @@ const darkTheme = ()=>{
3138
3778
  config: {
3139
3779
  line: {
3140
3780
  xAxis: bandAxis,
3141
- yAxis: linearAxis
3781
+ yAxis: linearAxis,
3782
+ crosshairLine: crosshairLine
3142
3783
  },
3143
3784
  column: {
3144
3785
  xAxis: bandAxis,
3145
- yAxis: linearAxis
3786
+ yAxis: linearAxis,
3787
+ crosshairRect: crosshairRect,
3788
+ stackCornerRadius: [
3789
+ 4,
3790
+ 4,
3791
+ 0,
3792
+ 0
3793
+ ]
3146
3794
  },
3147
3795
  columnParallel: {
3148
3796
  xAxis: bandAxis,
3149
- yAxis: linearAxis
3797
+ yAxis: linearAxis,
3798
+ crosshairRect: crosshairRect,
3799
+ stackCornerRadius: [
3800
+ 4,
3801
+ 4,
3802
+ 0,
3803
+ 0
3804
+ ]
3150
3805
  },
3151
3806
  columnPercent: {
3152
3807
  xAxis: bandAxis,
3153
- yAxis: linearAxis
3808
+ yAxis: linearAxis,
3809
+ crosshairRect: crosshairRect,
3810
+ stackCornerRadius: [
3811
+ 4,
3812
+ 4,
3813
+ 0,
3814
+ 0
3815
+ ]
3154
3816
  },
3155
3817
  bar: {
3156
3818
  xAxis: linearAxis,
3157
- yAxis: bandAxis
3819
+ yAxis: barBandAxis,
3820
+ crosshairRect: crosshairRect,
3821
+ stackCornerRadius: [
3822
+ 0,
3823
+ 4,
3824
+ 4,
3825
+ 0
3826
+ ]
3158
3827
  },
3159
3828
  barParallel: {
3160
3829
  xAxis: linearAxis,
3161
- yAxis: bandAxis
3830
+ yAxis: barBandAxis,
3831
+ crosshairRect: crosshairRect,
3832
+ stackCornerRadius: [
3833
+ 0,
3834
+ 4,
3835
+ 4,
3836
+ 0
3837
+ ]
3162
3838
  },
3163
3839
  barPercent: {
3164
3840
  xAxis: linearAxis,
3165
- yAxis: bandAxis
3841
+ yAxis: barBandAxis,
3842
+ crosshairRect: crosshairRect,
3843
+ stackCornerRadius: [
3844
+ 0,
3845
+ 4,
3846
+ 4,
3847
+ 0
3848
+ ]
3166
3849
  },
3167
3850
  area: {
3168
3851
  xAxis: bandAxis,
3169
- yAxis: linearAxis
3852
+ yAxis: linearAxis,
3853
+ crosshairLine: crosshairLine
3170
3854
  },
3171
3855
  areaPercent: {
3172
3856
  xAxis: bandAxis,
3173
- yAxis: linearAxis
3857
+ yAxis: linearAxis,
3858
+ crosshairLine: crosshairLine
3174
3859
  }
3175
3860
  }
3176
3861
  };
@@ -3216,7 +3901,7 @@ const lightTheme = ()=>{
3216
3901
  labelAutoHideGap: 4,
3217
3902
  labelAutoLimit: true,
3218
3903
  labelAutoLimitLength: 100,
3219
- labelAutoRotate: true,
3904
+ labelAutoRotate: false,
3220
3905
  labelAutoRotateAngleRange: [
3221
3906
  0,
3222
3907
  -45,
@@ -3266,6 +3951,20 @@ const lightTheme = ()=>{
3266
3951
  -90
3267
3952
  ]
3268
3953
  };
3954
+ const crosshairLine = {
3955
+ visible: true,
3956
+ labelVisible: true,
3957
+ lineColor: '#3641594d',
3958
+ labelColor: '#ffffff',
3959
+ labelBackgroundColor: '#364159'
3960
+ };
3961
+ const crosshairRect = {
3962
+ visible: true,
3963
+ labelVisible: true,
3964
+ rectColor: '#3641594d',
3965
+ labelColor: '#ffffff',
3966
+ labelBackgroundColor: '#364159'
3967
+ };
3269
3968
  return {
3270
3969
  baseConfig: {
3271
3970
  vtable: {
@@ -3308,45 +4007,94 @@ const lightTheme = ()=>{
3308
4007
  config: {
3309
4008
  line: {
3310
4009
  xAxis: bandAxis,
3311
- yAxis: linearAxis
4010
+ yAxis: linearAxis,
4011
+ crosshairLine
3312
4012
  },
3313
4013
  column: {
3314
4014
  xAxis: bandAxis,
3315
- yAxis: linearAxis
4015
+ yAxis: linearAxis,
4016
+ crosshairRect,
4017
+ stackCornerRadius: [
4018
+ 4,
4019
+ 4,
4020
+ 0,
4021
+ 0
4022
+ ]
3316
4023
  },
3317
4024
  columnParallel: {
3318
4025
  xAxis: bandAxis,
3319
- yAxis: linearAxis
4026
+ yAxis: linearAxis,
4027
+ crosshairRect,
4028
+ stackCornerRadius: [
4029
+ 4,
4030
+ 4,
4031
+ 0,
4032
+ 0
4033
+ ]
3320
4034
  },
3321
4035
  columnPercent: {
3322
4036
  xAxis: bandAxis,
3323
- yAxis: linearAxis
4037
+ yAxis: linearAxis,
4038
+ crosshairRect,
4039
+ stackCornerRadius: [
4040
+ 4,
4041
+ 4,
4042
+ 0,
4043
+ 0
4044
+ ]
3324
4045
  },
3325
4046
  bar: {
3326
4047
  xAxis: linearAxis,
3327
- yAxis: barBandAxis
4048
+ yAxis: barBandAxis,
4049
+ crosshairRect,
4050
+ stackCornerRadius: [
4051
+ 0,
4052
+ 4,
4053
+ 4,
4054
+ 0
4055
+ ]
3328
4056
  },
3329
4057
  barParallel: {
3330
4058
  xAxis: linearAxis,
3331
- yAxis: barBandAxis
4059
+ yAxis: barBandAxis,
4060
+ crosshairRect,
4061
+ stackCornerRadius: [
4062
+ 0,
4063
+ 4,
4064
+ 4,
4065
+ 0
4066
+ ]
3332
4067
  },
3333
4068
  barPercent: {
3334
4069
  xAxis: linearAxis,
3335
- yAxis: barBandAxis
4070
+ yAxis: barBandAxis,
4071
+ crosshairRect,
4072
+ stackCornerRadius: [
4073
+ 0,
4074
+ 4,
4075
+ 4,
4076
+ 0
4077
+ ]
3336
4078
  },
3337
4079
  area: {
3338
4080
  xAxis: bandAxis,
3339
- yAxis: linearAxis
4081
+ yAxis: linearAxis,
4082
+ crosshairLine
3340
4083
  },
3341
4084
  areaPercent: {
3342
4085
  xAxis: bandAxis,
3343
- yAxis: linearAxis
4086
+ yAxis: linearAxis,
4087
+ crosshairLine
3344
4088
  }
3345
4089
  }
3346
4090
  };
3347
4091
  };
3348
4092
  const registerCustomTheme = (key, themeConfig)=>{
3349
- Builder._themeMap[key] = themeConfig;
4093
+ const customTheme = 'function' == typeof themeConfig ? themeConfig({
4094
+ lightTheme: lightTheme(),
4095
+ darkTheme: darkTheme()
4096
+ }) : themeConfig;
4097
+ Builder._themeMap[key] = customTheme;
3350
4098
  };
3351
4099
  const registerLightTheme = ()=>{
3352
4100
  registerCustomTheme('light', lightTheme());
@@ -3398,29 +4146,30 @@ const zDimension = z.object({
3398
4146
  ])
3399
4147
  });
3400
4148
  const zDimensions = z.array(zDimension).optional();
4149
+ const zNumFormat = z.object({
4150
+ type: z["enum"]([
4151
+ 'number',
4152
+ 'percent',
4153
+ 'permille'
4154
+ ]).default('number').optional(),
4155
+ ratio: z.number().default(1).optional(),
4156
+ symbol: z.string().default('').optional(),
4157
+ thousandSeparator: z.boolean().default(false).optional(),
4158
+ decimalPlaces: z.number().default(2).optional(),
4159
+ round: z["enum"]([
4160
+ 'round',
4161
+ 'floor',
4162
+ 'ceil'
4163
+ ]).default('round').optional(),
4164
+ prefix: z.string().default('').optional(),
4165
+ suffix: z.string().default('').optional()
4166
+ }).optional();
3401
4167
  const zMeasure = z.object({
3402
4168
  id: z.string(),
3403
4169
  alias: z.string().optional(),
3404
4170
  visible: z.boolean().default(true).optional(),
3405
4171
  autoFormat: z.boolean().default(true).optional(),
3406
- format: z.object({
3407
- type: z["enum"]([
3408
- 'number',
3409
- 'percent',
3410
- 'permille'
3411
- ]).optional().default('number'),
3412
- ratio: z.number().optional().default(1),
3413
- symbol: z.string().optional().default(''),
3414
- thousandSeparator: z.boolean().optional().default(false),
3415
- decimalPlaces: z.number().optional().default(2),
3416
- round: z["enum"]([
3417
- 'round',
3418
- 'floor',
3419
- 'ceil'
3420
- ]).optional().default('round'),
3421
- prefix: z.string().optional().default(''),
3422
- suffix: z.string().optional().default('')
3423
- }).optional()
4172
+ format: zNumFormat["default"]({}).optional()
3424
4173
  });
3425
4174
  const zMeasureGroup = z.object({
3426
4175
  id: z.string(),
@@ -3665,42 +4414,77 @@ const zXLinearAxis = z.object({
3665
4414
  }).optional()
3666
4415
  });
3667
4416
  const zYLinearAxis = zXLinearAxis;
4417
+ const zCrosshairLine = z.object({
4418
+ visible: z.boolean().optional(),
4419
+ lineColor: z.string().optional(),
4420
+ labelColor: z.string().optional(),
4421
+ labelVisible: z.boolean().optional(),
4422
+ labelBackgroundColor: z.string().optional()
4423
+ });
4424
+ const zCrosshairRect = z.object({
4425
+ visible: z.boolean().optional(),
4426
+ rectColor: z.string().optional(),
4427
+ labelColor: z.string().optional(),
4428
+ labelVisible: z.boolean().optional(),
4429
+ labelBackgroundColor: z.string().optional()
4430
+ });
4431
+ const zStackCornerRadius = z.number().or(z.array(z.number())).default([
4432
+ 3,
4433
+ 3,
4434
+ 0,
4435
+ 0
4436
+ ]);
3668
4437
  const zConfig = z.object({
3669
4438
  line: z.object({
3670
- xAxis: zXBandAxis,
3671
- yAxis: zYLinearAxis
4439
+ xAxis: zXBandAxis.optional(),
4440
+ yAxis: zYLinearAxis.optional(),
4441
+ crosshairLine: zCrosshairLine.optional()
3672
4442
  }).optional(),
3673
4443
  column: z.object({
3674
- xAxis: zXBandAxis,
3675
- yAxis: zYLinearAxis
4444
+ xAxis: zXBandAxis.optional(),
4445
+ yAxis: zYLinearAxis.optional(),
4446
+ crosshairRect: zCrosshairRect.optional(),
4447
+ stackCornerRadius: zStackCornerRadius.optional()
3676
4448
  }).optional(),
3677
4449
  columnParallel: z.object({
3678
- xAxis: zXBandAxis,
3679
- yAxis: zYLinearAxis
4450
+ xAxis: zXBandAxis.optional(),
4451
+ yAxis: zYLinearAxis.optional(),
4452
+ crosshairRect: zCrosshairRect.optional(),
4453
+ stackCornerRadius: zStackCornerRadius.optional()
3680
4454
  }).optional(),
3681
4455
  columnPercent: z.object({
3682
- xAxis: zXBandAxis,
3683
- yAxis: zYLinearAxis
4456
+ xAxis: zXBandAxis.optional(),
4457
+ yAxis: zYLinearAxis.optional(),
4458
+ crosshairRect: zCrosshairRect.optional(),
4459
+ stackCornerRadius: zStackCornerRadius.optional()
3684
4460
  }).optional(),
3685
4461
  bar: z.object({
3686
- xAxis: zXLinearAxis,
3687
- yAxis: zYBandAxis
4462
+ xAxis: zXLinearAxis.optional(),
4463
+ yAxis: zYBandAxis.optional(),
4464
+ crosshairRect: zCrosshairRect.optional(),
4465
+ stackCornerRadius: zStackCornerRadius.optional()
3688
4466
  }).optional(),
3689
4467
  barParallel: z.object({
3690
- xAxis: zXLinearAxis,
3691
- yAxis: zYBandAxis
4468
+ xAxis: zXLinearAxis.optional(),
4469
+ yAxis: zYBandAxis.optional(),
4470
+ crosshairRect: zCrosshairRect.optional(),
4471
+ stackCornerRadius: zStackCornerRadius.optional()
3692
4472
  }).optional(),
3693
4473
  barPercent: z.object({
3694
- xAxis: zXLinearAxis,
3695
- yAxis: zYBandAxis
4474
+ xAxis: zXLinearAxis.optional(),
4475
+ yAxis: zYBandAxis.optional(),
4476
+ crosshairRect: zCrosshairRect.optional(),
4477
+ stackCornerRadius: zStackCornerRadius.optional()
3696
4478
  }).optional(),
3697
4479
  area: z.object({
3698
- xAxis: zXBandAxis,
3699
- yAxis: zYLinearAxis
4480
+ xAxis: zXBandAxis.optional(),
4481
+ yAxis: zYLinearAxis.optional(),
4482
+ crosshairLine: zCrosshairLine.optional()
3700
4483
  }).optional(),
3701
4484
  areaPercent: z.object({
3702
- xAxis: zXBandAxis,
3703
- yAxis: zYLinearAxis
4485
+ xAxis: zXBandAxis.optional(),
4486
+ yAxis: zYLinearAxis.optional(),
4487
+ crosshairLine: zCrosshairLine.optional()
3704
4488
  }).optional(),
3705
4489
  pie: z.object({}).optional(),
3706
4490
  donut: z.object({}).optional(),
@@ -3709,12 +4493,6 @@ const zConfig = z.object({
3709
4493
  table: z.object({}).optional(),
3710
4494
  pivotTable: z.object({}).optional()
3711
4495
  });
3712
- const zCustomThemeConfig = z.object({
3713
- baseConfig: zBaseConfig.optional(),
3714
- config: zConfig.optional()
3715
- });
3716
- const zCustomTheme = z.record(z.string(), zCustomThemeConfig).optional();
3717
- const zTheme = z.string();
3718
4496
  const zSelector = z.union([
3719
4497
  z.string(),
3720
4498
  z.number(),
@@ -3770,28 +4548,6 @@ const zSelector = z.union([
3770
4548
  })
3771
4549
  ]);
3772
4550
  const zSelectors = z.array(zSelector);
3773
- const zBarStyle = z.object({
3774
- selector: z.union([
3775
- zSelector,
3776
- zSelectors
3777
- ]).optional(),
3778
- barColor: z.string().optional(),
3779
- barColorOpacity: z.number().optional(),
3780
- barBorderColor: z.string().optional(),
3781
- barBorderWidth: z.number().optional(),
3782
- barBorderStyle: z.union([
3783
- z.literal('solid'),
3784
- z.literal('dashed'),
3785
- z.literal('dotted')
3786
- ]).optional(),
3787
- barRadius: z.union([
3788
- z.number(),
3789
- z.array(z.number())
3790
- ]).optional()
3791
- });
3792
- const zMarkStyle = z.object({
3793
- barStyle: zBarStyle.optional()
3794
- });
3795
4551
  const zAnnotationPoint = z.object({
3796
4552
  selector: z.union([
3797
4553
  zSelector,
@@ -3972,6 +4728,82 @@ const zAnnotation = z.object({
3972
4728
  annotationHorizontalLine: zAnnotationHorizontalLine.or(z.array(zAnnotationHorizontalLine)).optional(),
3973
4729
  annotationArea: zAnnotationArea.or(z.array(zAnnotationArea)).optional()
3974
4730
  });
3975
- export { Builder, FoldMeasureId, FoldMeasureName, FoldMeasureValue, ORIGINAL_DATA, Separator, UnfoldDimensionGroup, areaAdvancedPipeline, areaPercentAdvancedPipeline, areaPercentSpecPipeline, areaSpecPipeline, barAdvancedPipeline, barParallelAdvancedPipeline, barParallelSpecPipeline, barPercentAdvancedPipeline, barPercentSpecPipeline, barSpecPipeline, columnAdvancedPipeline, columnParallelAdvancedPipeline, columnParallelSpecPipeline, columnPercentAdvancedPipeline, columnPercentSpecPipeline, columnSpecPipeline, darkTheme, dataReshapeFor1D1M, dataReshapeFor2D1M, execPipeline, foldMeasures, isPivotChart, isVChart, isVTable, lightTheme, lineAdvancedPipeline, lineSpecPipeline, pieAdvancedPipeline, pieSpecPipeline, all_registerAll as registerAll, registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerColumn, registerColumnParallel, registerColumnPercent, registerCustomTheme, registerDarkTheme, registerLightTheme, registerLine, unfoldDimensions, zAnnotation, zAnnotationArea, zAnnotationHorizontalLine, zAnnotationPoint, zAnnotationVerticalLine, zAxis, zBackgroundColor, zBarStyle, zBaseConfig, zChartType, zColor, zConfig, zCustomTheme, zCustomThemeConfig, zDataset, zDatasetReshapeInfo, zDatum, zDimension, zDimensions, zEncoding, zFoldInfo, zLabel, zLegend, zMarkStyle, zMeasure, zMeasureGroup, zMeasures, zTheme, zTooltip, zUnfoldInfo, zXBandAxis, zXLinearAxis, zYBandAxis, zYLinearAxis };
4731
+ const zBarStyle = z.object({
4732
+ selector: z.union([
4733
+ zSelector,
4734
+ zSelectors
4735
+ ]).optional(),
4736
+ barColor: z.string().optional(),
4737
+ barColorOpacity: z.number().optional(),
4738
+ barBorderColor: z.string().optional(),
4739
+ barBorderWidth: z.number().optional(),
4740
+ barBorderStyle: z.union([
4741
+ z.literal('solid'),
4742
+ z.literal('dashed'),
4743
+ z.literal('dotted')
4744
+ ]).optional(),
4745
+ barRadius: z.union([
4746
+ z.number(),
4747
+ z.array(z.number())
4748
+ ]).optional()
4749
+ });
4750
+ const zPointStyle = z.object({
4751
+ selector: z.union([
4752
+ zSelector,
4753
+ zSelectors
4754
+ ]).optional(),
4755
+ pointSize: z.number().optional(),
4756
+ pointColor: z.string().optional(),
4757
+ pointColorOpacity: z.number().optional(),
4758
+ pointBorderColor: z.string().optional(),
4759
+ pointBorderWidth: z.number().optional(),
4760
+ pointBorderStyle: z.union([
4761
+ z["enum"]([
4762
+ 'solid',
4763
+ 'dashed',
4764
+ 'dotted'
4765
+ ])
4766
+ ]).optional()
4767
+ });
4768
+ const zLineStyle = z.object({
4769
+ selector: z.union([
4770
+ zSelector,
4771
+ zSelectors
4772
+ ]).optional(),
4773
+ lineSmooth: z.boolean().default(true).optional(),
4774
+ lineColor: z.string().optional(),
4775
+ lineColorOpacity: z.number().optional(),
4776
+ lineWidth: z.number().optional(),
4777
+ lineStyle: z.union([
4778
+ z["enum"]([
4779
+ 'solid',
4780
+ 'dashed',
4781
+ 'dotted'
4782
+ ])
4783
+ ]).optional()
4784
+ });
4785
+ const zAreaStyle = z.object({
4786
+ selector: z.union([
4787
+ zSelector,
4788
+ zSelectors
4789
+ ]).optional(),
4790
+ areaColor: z.string().optional(),
4791
+ areaColorOpacity: z.number().optional()
4792
+ });
4793
+ const zMarkStyle = z.object({
4794
+ barStyle: zBarStyle.or(z.array(zBarStyle)).optional(),
4795
+ pointStyle: zPointStyle.or(z.array(zPointStyle)).optional(),
4796
+ lineStyle: zLineStyle.or(z.array(zLineStyle)).optional(),
4797
+ areaStyle: zAreaStyle.or(z.array(zAreaStyle)).optional()
4798
+ });
4799
+ const zCustomThemeConfig = z.object({
4800
+ baseConfig: zBaseConfig.optional(),
4801
+ config: zConfig.optional(),
4802
+ annotation: zAnnotation.optional(),
4803
+ markStyle: zMarkStyle.optional()
4804
+ });
4805
+ const zCustomTheme = z.record(z.string(), zCustomThemeConfig).optional();
4806
+ const zTheme = z.string();
4807
+ export { Builder, FoldMeasureId, FoldMeasureName, FoldMeasureValue, ORIGINAL_DATA, Separator, UnfoldDimensionGroup, areaAdvancedPipeline, areaPercentAdvancedPipeline, areaPercentSpecPipeline, areaSpecPipeline, autoFormatter, autoNumFormatter, barAdvancedPipeline, barParallelAdvancedPipeline, barParallelSpecPipeline, barPercentAdvancedPipeline, barPercentSpecPipeline, barSpecPipeline, columnAdvancedPipeline, columnParallelAdvancedPipeline, columnParallelSpecPipeline, columnPercentAdvancedPipeline, columnPercentSpecPipeline, columnSpecPipeline, createFormatter, createNumFormatter, darkTheme, dataReshapeFor1D1M, dataReshapeFor2D1M, execPipeline, findMeasureById, foldMeasures, i18n, intl, isPivotChart, isVChart, isVTable, lightTheme, lineAdvancedPipeline, lineSpecPipeline, pieAdvancedPipeline, pieSpecPipeline, all_registerAll as registerAll, registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerColumn, registerColumnParallel, registerColumnPercent, registerCustomTheme, registerDarkTheme, registerLightTheme, registerLine, unfoldDimensions, zAnnotation, zAnnotationArea, zAnnotationHorizontalLine, zAnnotationPoint, zAnnotationVerticalLine, zAreaStyle, zAxis, zBackgroundColor, zBarStyle, zBaseConfig, zChartType, zColor, zConfig, zCrosshairLine, zCrosshairRect, zCustomTheme, zCustomThemeConfig, zDataset, zDatasetReshapeInfo, zDatum, zDimension, zDimensions, zEncoding, zFoldInfo, zLabel, zLegend, zLineStyle, zMarkStyle, zMeasure, zMeasureGroup, zMeasures, zNumFormat, zPointStyle, zStackCornerRadius, zTheme, zTooltip, zUnfoldInfo, zXBandAxis, zXLinearAxis, zYBandAxis, zYLinearAxis };
3976
4808
 
3977
4809
  //# sourceMappingURL=index.js.map