@visactor/vseed 0.4.25 → 0.4.27

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 (97) hide show
  1. package/dist/cjs/index.cjs +2 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/esm/pipeline/advanced/chart/pipes/config/column.js +1 -0
  4. package/dist/esm/pipeline/advanced/chart/pipes/config/column.js.map +1 -1
  5. package/dist/esm/pipeline/advanced/chart/pipes/config/line.js +1 -0
  6. package/dist/esm/pipeline/advanced/chart/pipes/config/line.js.map +1 -1
  7. package/dist/esm/pipeline/spec/chart/pipeline/area.js +5 -1
  8. package/dist/esm/pipeline/spec/chart/pipeline/area.js.map +1 -1
  9. package/dist/esm/pipeline/spec/chart/pipeline/areaPercent.js +3 -1
  10. package/dist/esm/pipeline/spec/chart/pipeline/areaPercent.js.map +1 -1
  11. package/dist/esm/pipeline/spec/chart/pipeline/bar.js +3 -1
  12. package/dist/esm/pipeline/spec/chart/pipeline/bar.js.map +1 -1
  13. package/dist/esm/pipeline/spec/chart/pipeline/barParallel.js +3 -1
  14. package/dist/esm/pipeline/spec/chart/pipeline/barParallel.js.map +1 -1
  15. package/dist/esm/pipeline/spec/chart/pipeline/barPercent.js +3 -1
  16. package/dist/esm/pipeline/spec/chart/pipeline/barPercent.js.map +1 -1
  17. package/dist/esm/pipeline/spec/chart/pipeline/column.js +3 -1
  18. package/dist/esm/pipeline/spec/chart/pipeline/column.js.map +1 -1
  19. package/dist/esm/pipeline/spec/chart/pipeline/columnParallel.js +3 -1
  20. package/dist/esm/pipeline/spec/chart/pipeline/columnParallel.js.map +1 -1
  21. package/dist/esm/pipeline/spec/chart/pipeline/columnPercent.js +3 -1
  22. package/dist/esm/pipeline/spec/chart/pipeline/columnPercent.js.map +1 -1
  23. package/dist/esm/pipeline/spec/chart/pipeline/line.js +5 -1
  24. package/dist/esm/pipeline/spec/chart/pipeline/line.js.map +1 -1
  25. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.js +220 -73
  26. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.js.map +1 -1
  27. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLineCommon.d.ts +21 -5
  28. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLineCommon.js +67 -14
  29. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLineCommon.js.map +1 -1
  30. package/dist/esm/pipeline/spec/chart/pipes/region/index.d.ts +1 -0
  31. package/dist/esm/pipeline/spec/chart/pipes/region/index.js +1 -0
  32. package/dist/esm/pipeline/spec/chart/pipes/region/regionPadding.d.ts +2 -0
  33. package/dist/esm/pipeline/spec/chart/pipes/region/regionPadding.js +20 -0
  34. package/dist/esm/pipeline/spec/chart/pipes/region/regionPadding.js.map +1 -0
  35. package/dist/esm/types/chartType/area/area.d.ts +11 -1
  36. package/dist/esm/types/chartType/area/zArea.d.ts +309 -0
  37. package/dist/esm/types/chartType/area/zArea.js +3 -1
  38. package/dist/esm/types/chartType/area/zArea.js.map +1 -1
  39. package/dist/esm/types/chartType/areaPercent/areaPercent.d.ts +6 -1
  40. package/dist/esm/types/chartType/areaPercent/zAreaPercent.d.ts +6 -0
  41. package/dist/esm/types/chartType/areaPercent/zAreaPercent.js +2 -1
  42. package/dist/esm/types/chartType/areaPercent/zAreaPercent.js.map +1 -1
  43. package/dist/esm/types/chartType/bar/bar.d.ts +6 -1
  44. package/dist/esm/types/chartType/bar/zBar.d.ts +6 -0
  45. package/dist/esm/types/chartType/bar/zBar.js +2 -1
  46. package/dist/esm/types/chartType/bar/zBar.js.map +1 -1
  47. package/dist/esm/types/chartType/barParallel/barParallel.d.ts +6 -1
  48. package/dist/esm/types/chartType/barParallel/zBarParallel.d.ts +6 -0
  49. package/dist/esm/types/chartType/barParallel/zBarParallel.js +2 -1
  50. package/dist/esm/types/chartType/barParallel/zBarParallel.js.map +1 -1
  51. package/dist/esm/types/chartType/barPercent/barPercent.d.ts +6 -1
  52. package/dist/esm/types/chartType/barPercent/zBarPercent.d.ts +6 -0
  53. package/dist/esm/types/chartType/barPercent/zBarPercent.js +2 -1
  54. package/dist/esm/types/chartType/barPercent/zBarPercent.js.map +1 -1
  55. package/dist/esm/types/chartType/column/column.d.ts +6 -1
  56. package/dist/esm/types/chartType/column/zColumn.d.ts +6 -0
  57. package/dist/esm/types/chartType/column/zColumn.js +2 -1
  58. package/dist/esm/types/chartType/column/zColumn.js.map +1 -1
  59. package/dist/esm/types/chartType/columnParallel/columnParallel.d.ts +6 -1
  60. package/dist/esm/types/chartType/columnParallel/zColumnParallel.d.ts +6 -0
  61. package/dist/esm/types/chartType/columnParallel/zColumnParallel.js +2 -1
  62. package/dist/esm/types/chartType/columnParallel/zColumnParallel.js.map +1 -1
  63. package/dist/esm/types/chartType/columnPercent/columnPercent.d.ts +6 -1
  64. package/dist/esm/types/chartType/columnPercent/zColumnPercent.d.ts +6 -0
  65. package/dist/esm/types/chartType/columnPercent/zColumnPercent.js +2 -1
  66. package/dist/esm/types/chartType/columnPercent/zColumnPercent.js.map +1 -1
  67. package/dist/esm/types/chartType/line/line.d.ts +11 -1
  68. package/dist/esm/types/chartType/line/zLine.d.ts +309 -0
  69. package/dist/esm/types/chartType/line/zLine.js +3 -1
  70. package/dist/esm/types/chartType/line/zLine.js.map +1 -1
  71. package/dist/esm/types/properties/config/area.d.ts +12 -0
  72. package/dist/esm/types/properties/config/area.js +2 -0
  73. package/dist/esm/types/properties/config/area.js.map +1 -1
  74. package/dist/esm/types/properties/config/bar.d.ts +18 -0
  75. package/dist/esm/types/properties/config/bar.js +2 -0
  76. package/dist/esm/types/properties/config/bar.js.map +1 -1
  77. package/dist/esm/types/properties/config/column.d.ts +18 -0
  78. package/dist/esm/types/properties/config/column.js +2 -0
  79. package/dist/esm/types/properties/config/column.js.map +1 -1
  80. package/dist/esm/types/properties/config/config.d.ts +66 -0
  81. package/dist/esm/types/properties/config/line.d.ts +6 -0
  82. package/dist/esm/types/properties/config/line.js +2 -0
  83. package/dist/esm/types/properties/config/line.js.map +1 -1
  84. package/dist/esm/types/properties/config/race.d.ts +12 -0
  85. package/dist/esm/types/properties/index.d.ts +1 -0
  86. package/dist/esm/types/properties/index.js +1 -0
  87. package/dist/esm/types/properties/regionPadding/index.d.ts +2 -0
  88. package/dist/esm/types/properties/regionPadding/index.js +1 -0
  89. package/dist/esm/types/properties/regionPadding/regionPadding.d.ts +6 -0
  90. package/dist/esm/types/properties/regionPadding/regionPadding.js +0 -0
  91. package/dist/esm/types/properties/regionPadding/zRegionPadding.d.ts +7 -0
  92. package/dist/esm/types/properties/regionPadding/zRegionPadding.js +11 -0
  93. package/dist/esm/types/properties/regionPadding/zRegionPadding.js.map +1 -0
  94. package/dist/esm/types/properties/theme/customTheme.d.ts +132 -0
  95. package/dist/umd/index.js +552 -291
  96. package/dist/umd/index.js.map +1 -1
  97. package/package.json +1 -1
package/dist/umd/index.js CHANGED
@@ -1029,6 +1029,7 @@
1029
1029
  FoldPrimaryMeasureValue: ()=>FoldPrimaryMeasureValue,
1030
1030
  donutSpecPipeline: ()=>donutSpecPipeline,
1031
1031
  registerTokenThemes: ()=>registerTokenThemes,
1032
+ zRegionPadding: ()=>zRegionPadding,
1032
1033
  zSortLegend: ()=>zSortLegend,
1033
1034
  registerTable: ()=>registerTable,
1034
1035
  zCrosshairRect: ()=>zCrosshairRect,
@@ -5578,6 +5579,7 @@ self.R = R;
5578
5579
  'color',
5579
5580
  'label',
5580
5581
  'legend',
5582
+ 'regionPadding',
5581
5583
  'tooltip',
5582
5584
  'xAxis',
5583
5585
  'yAxis',
@@ -5692,6 +5694,23 @@ self.R = R;
5692
5694
  result.animation = true;
5693
5695
  return result;
5694
5696
  };
5697
+ const regionPadding = (spec, context)=>{
5698
+ const chartConfig = context.advancedVSeed.config?.[context.vseed.chartType];
5699
+ const padding = chartConfig?.regionPadding;
5700
+ if (null == padding || !Array.isArray(spec.region)) return spec;
5701
+ const region = spec.region;
5702
+ if (0 === region.length) return spec;
5703
+ return {
5704
+ ...spec,
5705
+ region: [
5706
+ {
5707
+ ...region[0],
5708
+ padding
5709
+ },
5710
+ ...region.slice(1)
5711
+ ]
5712
+ };
5713
+ };
5695
5714
  const color_color = (spec, context)=>{
5696
5715
  const result = {
5697
5716
  ...spec
@@ -7075,7 +7094,494 @@ self.R = R;
7075
7094
  };
7076
7095
  };
7077
7096
  };
7078
- const annotationPoint_annotationPoint = generateAnnotationPointPipe({});
7097
+ const annotationPoint_annotationPoint = generateAnnotationPointPipe({});
7098
+ const STACK_END_FIELD = '__VCHART_STACK_END';
7099
+ const toArray = (value)=>{
7100
+ if (Array.isArray(value)) return value;
7101
+ return null == value ? [] : [
7102
+ value
7103
+ ];
7104
+ };
7105
+ const getDifferenceBandFields = (spec)=>toArray('horizontal' === spec.direction ? spec.yField : spec.xField);
7106
+ const getDifferenceValueField = (spec)=>{
7107
+ const valueField = toArray('horizontal' === spec.direction ? spec.xField : spec.yField)[0];
7108
+ if (!valueField) throw new Error('annotationDifferenceLine requires a value field in the target chart spec');
7109
+ return valueField;
7110
+ };
7111
+ const normalizeDifferenceValue = (value, selectorLabel, field)=>{
7112
+ const numberValue = Number(value);
7113
+ if (Number.isNaN(numberValue)) throw new Error(`annotationDifferenceLine ${selectorLabel} selector resolved to a non-numeric value on field "${field}"`);
7114
+ return numberValue;
7115
+ };
7116
+ const buildStackGroupDatum = (datum, bandFields)=>Object.fromEntries(bandFields.map((field)=>[
7117
+ field,
7118
+ datum[field]
7119
+ ]));
7120
+ const resolveBandIndex = (dataset, bandDatum)=>{
7121
+ const bandIndex = dataset.findIndex((datum)=>isSubset(bandDatum, datum));
7122
+ return bandIndex >= 0 ? bandIndex : void 0;
7123
+ };
7124
+ const buildFallbackSelectorDatum = (selectorValue)=>{
7125
+ const selectorList = Array.isArray(selectorValue) ? selectorValue : [
7126
+ selectorValue
7127
+ ];
7128
+ const fallbackDatum = {};
7129
+ for (const currentSelector of selectorList){
7130
+ if (isValueSelector(currentSelector) || isFieldSelector(currentSelector)) return;
7131
+ if (isMeasureSelector(currentSelector)) {
7132
+ const operator = currentSelector.operator || currentSelector.op;
7133
+ const selectorValues = Array.isArray(currentSelector.value) ? currentSelector.value : [
7134
+ currentSelector.value
7135
+ ];
7136
+ if (![
7137
+ '=',
7138
+ '=='
7139
+ ].includes(operator) || 1 !== selectorValues.length) return;
7140
+ fallbackDatum[currentSelector.field] = selectorValues[0];
7141
+ continue;
7142
+ }
7143
+ if (isDimensionSelector(currentSelector)) {
7144
+ const operator = currentSelector.operator || currentSelector.op;
7145
+ const selectorValues = Array.isArray(currentSelector.value) ? currentSelector.value : [
7146
+ currentSelector.value
7147
+ ];
7148
+ if ('in' !== operator || 1 !== selectorValues.length) return;
7149
+ fallbackDatum[currentSelector.field] = selectorValues[0];
7150
+ continue;
7151
+ }
7152
+ if (isPartialDatumSelector(currentSelector)) {
7153
+ Object.assign(fallbackDatum, currentSelector);
7154
+ continue;
7155
+ }
7156
+ return;
7157
+ }
7158
+ return Object.keys(fallbackDatum).length > 0 ? fallbackDatum : void 0;
7159
+ };
7160
+ const inferFallbackValue = (fallbackDatum, valueField, bandFields)=>{
7161
+ if (valueField in fallbackDatum) return fallbackDatum[valueField];
7162
+ const numericCandidateKeys = Object.keys(fallbackDatum).filter((key)=>{
7163
+ if (key === valueField || bandFields.includes(key)) return false;
7164
+ return 'number' == typeof fallbackDatum[key];
7165
+ });
7166
+ if (1 !== numericCandidateKeys.length) return;
7167
+ return fallbackDatum[numericCandidateKeys[0]];
7168
+ };
7169
+ const resolveFallbackAnchor = (options)=>{
7170
+ const { dataset, selectorLabel, selectorValue, valueField, bandFields } = options;
7171
+ const fallbackDatum = buildFallbackSelectorDatum(selectorValue);
7172
+ if (!fallbackDatum) return;
7173
+ const inferredValue = inferFallbackValue(fallbackDatum, valueField, bandFields);
7174
+ if (void 0 === inferredValue) return;
7175
+ const coordinateDatum = {
7176
+ ...fallbackDatum,
7177
+ [valueField]: inferredValue
7178
+ };
7179
+ const bandDatum = buildStackGroupDatum(coordinateDatum, bandFields);
7180
+ try {
7181
+ return {
7182
+ mode: 'element',
7183
+ selectorLabel,
7184
+ coordinateDatum,
7185
+ matchedDatum: fallbackDatum,
7186
+ bandDatum,
7187
+ bandIndex: resolveBandIndex(dataset, bandDatum),
7188
+ value: normalizeDifferenceValue(inferredValue, selectorLabel, valueField)
7189
+ };
7190
+ } catch {
7191
+ return;
7192
+ }
7193
+ };
7194
+ const hasMixedSigns = (values)=>{
7195
+ const nonZeroValues = values.filter((value)=>0 !== value);
7196
+ return nonZeroValues.some((value)=>value > 0) && nonZeroValues.some((value)=>value < 0);
7197
+ };
7198
+ const getDifferenceLineStackResolveMode = (vseed, advancedVSeed)=>{
7199
+ const hasMultipleMeasure = hasMultipleMeasureInSingleView(advancedVSeed.reshapeMeasures ?? []);
7200
+ if (!hasMultipleMeasure) return 'none';
7201
+ if ('column' === vseed.chartType) return 'auto';
7202
+ if ('bar' === vseed.chartType) return 'auto';
7203
+ return 'none';
7204
+ };
7205
+ const usesDifferenceLineElementStackEnd = (vseed, advancedVSeed)=>'area' === vseed.chartType && hasMultipleMeasureInSingleView(advancedVSeed.reshapeMeasures ?? []);
7206
+ const resolveDifferenceAnchor = (options)=>{
7207
+ const { dataset, selectorLabel, selectorValue, spec, stackResolveMode, allowSelectorFallback = true } = options;
7208
+ const matches = dataset.filter((datum)=>selector_selector(datum, selectorValue));
7209
+ const valueField = getDifferenceValueField(spec);
7210
+ const bandFields = getDifferenceBandFields(spec);
7211
+ if (0 === matches.length) return 'none' === stackResolveMode && allowSelectorFallback ? resolveFallbackAnchor({
7212
+ dataset,
7213
+ selectorLabel,
7214
+ selectorValue,
7215
+ valueField,
7216
+ bandFields
7217
+ }) : void 0;
7218
+ if ('none' === stackResolveMode || 'auto' === stackResolveMode && 1 === matches.length) {
7219
+ if (1 !== matches.length) throw new Error(`annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one datum, got ${matches.length}`);
7220
+ const bandDatum = buildStackGroupDatum(matches[0], bandFields);
7221
+ return {
7222
+ mode: 'element',
7223
+ selectorLabel,
7224
+ coordinateDatum: matches[0],
7225
+ matchedDatum: matches[0],
7226
+ bandDatum,
7227
+ bandIndex: resolveBandIndex(dataset, bandDatum),
7228
+ value: normalizeDifferenceValue(matches[0][valueField], selectorLabel, valueField)
7229
+ };
7230
+ }
7231
+ const stackGroups = new Map();
7232
+ matches.forEach((datum)=>{
7233
+ const stackGroupDatum = buildStackGroupDatum(datum, bandFields);
7234
+ stackGroups.set(JSON.stringify(stackGroupDatum), stackGroupDatum);
7235
+ });
7236
+ if (1 !== stackGroups.size) throw new Error(`annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one stack group, got ${stackGroups.size}`);
7237
+ const stackGroupDatum = Array.from(stackGroups.values())[0];
7238
+ const groupRows = dataset.filter((datum)=>isSubset(stackGroupDatum, datum));
7239
+ if ('auto' === stackResolveMode && groupRows.length !== matches.length) throw new Error(`annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one stack element or one full stack group`);
7240
+ const groupValues = groupRows.map((datum)=>normalizeDifferenceValue(datum[valueField], selectorLabel, valueField));
7241
+ if (hasMixedSigns(groupValues)) throw new Error('annotationDifferenceLine does not support mixed-sign stack totals in v1');
7242
+ return {
7243
+ mode: 'stackTotal',
7244
+ selectorLabel,
7245
+ coordinateDatum: stackGroupDatum,
7246
+ matchedDatum: matches[0],
7247
+ stackGroupDatum,
7248
+ bandDatum: stackGroupDatum,
7249
+ bandIndex: resolveBandIndex(dataset, stackGroupDatum),
7250
+ value: groupValues.reduce((sum, value)=>sum + value, 0)
7251
+ };
7252
+ };
7253
+ const getStackRuntimeTotal = (runtimeMatches)=>{
7254
+ if (0 === runtimeMatches.length) return;
7255
+ const stackEndValues = runtimeMatches.map((datum)=>Number(datum[STACK_END_FIELD]));
7256
+ if (stackEndValues.some((value)=>!Number.isFinite(value))) return;
7257
+ if (hasMixedSigns(stackEndValues)) throw new Error('annotationDifferenceLine does not support mixed-sign runtime stack totals in v1');
7258
+ return stackEndValues.some((value)=>value < 0) ? Math.min(...stackEndValues) : Math.max(...stackEndValues);
7259
+ };
7260
+ const buildDifferenceCoordinateDatum = (options)=>{
7261
+ const { anchor, seriesData, relativeSeries, useElementStackEnd = false } = options;
7262
+ if (!anchor.stackGroupDatum) {
7263
+ const runtimeMatches = anchor.matchedDatum ? seriesData.filter((datum)=>isSubset(anchor.matchedDatum, datum)) : [];
7264
+ if (!useElementStackEnd) return runtimeMatches[0] ?? anchor.coordinateDatum;
7265
+ const runtimeMatch = runtimeMatches[0];
7266
+ const runtimeStackEnd = Number(runtimeMatch?.[STACK_END_FIELD]);
7267
+ return {
7268
+ ...runtimeMatch ?? anchor.coordinateDatum,
7269
+ [relativeSeries.getStackValueField()]: Number.isFinite(runtimeStackEnd) ? runtimeStackEnd : anchor.value
7270
+ };
7271
+ }
7272
+ const runtimeMatches = seriesData.filter((datum)=>isSubset(anchor.stackGroupDatum, datum));
7273
+ const runtimeStackTotal = getStackRuntimeTotal(runtimeMatches);
7274
+ return {
7275
+ ...runtimeMatches[0] ?? anchor.coordinateDatum,
7276
+ [relativeSeries.getStackValueField()]: runtimeStackTotal ?? anchor.value
7277
+ };
7278
+ };
7279
+ const getRuntimeDifferenceValue = (options)=>{
7280
+ const { anchor, seriesData, useElementStackEnd = false } = options;
7281
+ if (anchor.stackGroupDatum) {
7282
+ const runtimeMatches = seriesData.filter((datum)=>isSubset(anchor.stackGroupDatum, datum));
7283
+ return getStackRuntimeTotal(runtimeMatches) ?? anchor.value;
7284
+ }
7285
+ if (!useElementStackEnd || !anchor.matchedDatum) return anchor.value;
7286
+ const runtimeMatch = seriesData.find((datum)=>isSubset(anchor.matchedDatum, datum));
7287
+ const runtimeStackEnd = Number(runtimeMatch?.[STACK_END_FIELD]);
7288
+ return Number.isFinite(runtimeStackEnd) ? runtimeStackEnd : anchor.value;
7289
+ };
7290
+ const getDifferenceValue = (startValue, endValue, differenceType = 'absolute')=>{
7291
+ if ('percent' === differenceType) {
7292
+ if (0 === startValue) throw new Error('annotationDifferenceLine percent difference cannot be computed because start value is 0');
7293
+ return (endValue - startValue) / startValue;
7294
+ }
7295
+ return endValue - startValue;
7296
+ };
7297
+ const buildDifferenceText = (startValue, endValue, differenceType = 'absolute', formatter)=>{
7298
+ const differenceValue = getDifferenceValue(startValue, endValue, differenceType);
7299
+ if (formatter) return formatter(differenceValue);
7300
+ if ('percent' === differenceType) return `${(100 * differenceValue).toFixed(2)}%`;
7301
+ return `${differenceValue}`;
7302
+ };
7303
+ const inferDifferenceConnectDirection = (vseed, values)=>{
7304
+ const isNegativeSide = values.every((value)=>value < 0);
7305
+ if (isBarLikeChart(vseed)) return isNegativeSide ? 'left' : 'right';
7306
+ return isNegativeSide ? 'bottom' : 'top';
7307
+ };
7308
+ const inferDifferenceBracketDirection = (start, end)=>{
7309
+ if (void 0 === start.bandIndex || void 0 === end.bandIndex) return 'right';
7310
+ return start.bandIndex <= end.bandIndex ? 'right' : 'left';
7311
+ };
7312
+ const DEFAULT_LINE_COLOR = '#BCC1CB';
7313
+ const DEFAULT_TEXT_COLOR = '#ffffff';
7314
+ const DEFAULT_TEXT_BACKGROUND_COLOR = '#BCC1CB';
7315
+ const DEFAULT_TEXT_FONT_SIZE = 12;
7316
+ const DEFAULT_EXPAND_DISTANCE = 24;
7317
+ const DEFAULT_LINE_WIDTH = 2;
7318
+ const DEFAULT_CORNER_RADIUS = 4;
7319
+ const DEFAULT_LABEL_PADDING = 4;
7320
+ const DEFAULT_END_SYMBOL_SIZE = 12;
7321
+ const DEFAULT_END_SYMBOL_REF_X = -4;
7322
+ const DEFAULT_BRACKET_EXPAND_DISTANCE = 80;
7323
+ const DEFAULT_BRACKET_LINE_DASH = [
7324
+ 2,
7325
+ 2
7326
+ ];
7327
+ const DEFAULT_PERCENT_DIFFERENCE_FORMAT = {
7328
+ type: 'percent',
7329
+ fractionDigits: 2
7330
+ };
7331
+ const getDifferenceLinePath = (index, total)=>1 === total ? 'annotationDifferenceLine' : `annotationDifferenceLine[${index}]`;
7332
+ const annotationDifferenceLine_toArray = (value)=>{
7333
+ if (Array.isArray(value)) return value;
7334
+ return null == value ? [] : [
7335
+ value
7336
+ ];
7337
+ };
7338
+ const getAxisFormatter = (spec)=>{
7339
+ const valueAxisOrient = 'horizontal' === spec.direction ? 'bottom' : 'left';
7340
+ const formatMethod = spec.axes?.find((axis)=>axis.orient === valueAxisOrient)?.label?.formatMethod;
7341
+ return 'function' == typeof formatMethod ? (value)=>String(formatMethod(value) ?? value) : void 0;
7342
+ };
7343
+ const getExplicitMeasureFormat = (measure)=>{
7344
+ if (measure?.numFormat && !chunk_VCYTMP4D_n(measure.numFormat)) return measure.numFormat;
7345
+ if (measure?.format && !chunk_VCYTMP4D_n(measure.format)) return measure.format;
7346
+ };
7347
+ const inferMeasureIdFromDatum = (anchor, measureIds)=>{
7348
+ const candidateValues = [
7349
+ anchor.matchedDatum,
7350
+ anchor.coordinateDatum
7351
+ ];
7352
+ for (const datum of candidateValues){
7353
+ if (!datum) continue;
7354
+ const candidates = measureIds.filter((measureId)=>Number(datum[measureId]) === anchor.value);
7355
+ if (1 === candidates.length) return candidates[0];
7356
+ }
7357
+ };
7358
+ const inferMeasureIdFromSelector = (selectorValue, measureIdSet)=>{
7359
+ const matchedMeasureIds = new Set();
7360
+ for (const currentSelector of annotationDifferenceLine_toArray(selectorValue)){
7361
+ if (isMeasureSelector(currentSelector)) {
7362
+ if (measureIdSet.has(currentSelector.field)) matchedMeasureIds.add(currentSelector.field);
7363
+ continue;
7364
+ }
7365
+ if (!(isFieldSelector(currentSelector) || isDimensionSelector(currentSelector))) {
7366
+ if (isPartialDatumSelector(currentSelector)) Object.keys(currentSelector).forEach((field)=>{
7367
+ if (measureIdSet.has(field)) matchedMeasureIds.add(field);
7368
+ });
7369
+ }
7370
+ }
7371
+ return 1 === matchedMeasureIds.size ? Array.from(matchedMeasureIds)[0] : void 0;
7372
+ };
7373
+ const resolveDifferenceMeasureId = (anchor, selectorValue, measureIds)=>{
7374
+ if ('element' !== anchor.mode) return;
7375
+ if (1 === measureIds.length) return measureIds[0];
7376
+ const measureIdSet = new Set(measureIds);
7377
+ return inferMeasureIdFromSelector(selectorValue, measureIdSet) ?? inferMeasureIdFromDatum(anchor, measureIds);
7378
+ };
7379
+ const assertDifferenceLineConfig = (value, path)=>{
7380
+ if ('object' != typeof value || null === value || Array.isArray(value)) throw new Error(`${path} must be an object`);
7381
+ const start = value.start;
7382
+ if ('object' != typeof start || null === start || Array.isArray(start)) throw new Error(`${path}.start is required`);
7383
+ if (null == start.selector) throw new Error(`${path}.start.selector is required`);
7384
+ const end = value.end;
7385
+ if ('object' != typeof end || null === end || Array.isArray(end)) throw new Error(`${path}.end is required`);
7386
+ if (null == end.selector) throw new Error(`${path}.end.selector is required`);
7387
+ };
7388
+ const annotationDifferenceLine_annotationDifferenceLine = (spec, context)=>{
7389
+ const { advancedVSeed, vseed } = context;
7390
+ const annotationDifferenceLine = advancedVSeed.annotation?.annotationDifferenceLine;
7391
+ if (!annotationDifferenceLine) return spec;
7392
+ const theme = advancedVSeed.config?.[vseed.chartType]?.annotation?.annotationDifferenceLine;
7393
+ const annotationDifferenceLineList = Array.isArray(annotationDifferenceLine) ? annotationDifferenceLine : [
7394
+ annotationDifferenceLine
7395
+ ];
7396
+ const dataset = advancedVSeed.dataset.flat();
7397
+ const chartSpec = spec;
7398
+ const stackResolveMode = getDifferenceLineStackResolveMode(vseed, advancedVSeed);
7399
+ const useElementStackEnd = usesDifferenceLineElementStackEnd(vseed, advancedVSeed);
7400
+ const isBracketChart = 'line' === vseed.chartType || 'area' === vseed.chartType;
7401
+ const measures = findAllMeasures(advancedVSeed.measures);
7402
+ const measureIds = measures.map((measure)=>measure.id);
7403
+ const axisFormatter = getAxisFormatter(chartSpec);
7404
+ const percentFormatter = createFormatter(DEFAULT_PERCENT_DIFFERENCE_FORMAT);
7405
+ const markLine = annotationDifferenceLineList.flatMap((annotationDifferenceLine, index)=>{
7406
+ try {
7407
+ assertDifferenceLineConfig(annotationDifferenceLine, getDifferenceLinePath(index, annotationDifferenceLineList.length));
7408
+ const start = resolveDifferenceAnchor({
7409
+ dataset,
7410
+ selectorLabel: 'start',
7411
+ selectorValue: annotationDifferenceLine.start.selector,
7412
+ spec: chartSpec,
7413
+ stackResolveMode,
7414
+ allowSelectorFallback: !useElementStackEnd
7415
+ });
7416
+ const end = resolveDifferenceAnchor({
7417
+ dataset,
7418
+ selectorLabel: 'end',
7419
+ selectorValue: annotationDifferenceLine.end.selector,
7420
+ spec: chartSpec,
7421
+ stackResolveMode,
7422
+ allowSelectorFallback: !useElementStackEnd
7423
+ });
7424
+ if (!start || !end) return [];
7425
+ if (start.mode !== end.mode) return [];
7426
+ const usesRuntimeStackEnd = useElementStackEnd || ('column' === vseed.chartType || 'bar' === vseed.chartType) && 'element' === start.mode && 'auto' === stackResolveMode;
7427
+ const useBracketStyle = isBracketChart || ('column' === vseed.chartType || 'bar' === vseed.chartType) && 'element' === start.mode && 'auto' === stackResolveMode;
7428
+ const isStackedBarElementBracket = 'bar' === vseed.chartType && 'element' === start.mode && 'auto' === stackResolveMode;
7429
+ const connectDirection = useBracketStyle ? isStackedBarElementBracket ? 'top' : inferDifferenceBracketDirection(start, end) : inferDifferenceConnectDirection(vseed, [
7430
+ start.value,
7431
+ end.value
7432
+ ]);
7433
+ const lineColor = annotationDifferenceLine.lineColor ?? theme?.lineColor ?? DEFAULT_LINE_COLOR;
7434
+ const textColor = annotationDifferenceLine.textColor ?? theme?.textColor ?? DEFAULT_TEXT_COLOR;
7435
+ const textBackgroundColor = annotationDifferenceLine.textBackgroundColor ?? theme?.textBackgroundColor ?? DEFAULT_TEXT_BACKGROUND_COLOR;
7436
+ const textFontSize = annotationDifferenceLine.textFontSize ?? theme?.textFontSize ?? DEFAULT_TEXT_FONT_SIZE;
7437
+ const differenceType = annotationDifferenceLine.differenceType ?? 'absolute';
7438
+ const startMeasureId = resolveDifferenceMeasureId(start, annotationDifferenceLine.start.selector, measureIds);
7439
+ const endMeasureId = resolveDifferenceMeasureId(end, annotationDifferenceLine.end.selector, measureIds);
7440
+ const sameMeasure = void 0 !== startMeasureId && startMeasureId === endMeasureId;
7441
+ const explicitMeasureFormat = sameMeasure ? getExplicitMeasureFormat(measures.find((measure)=>measure.id === startMeasureId)) : void 0;
7442
+ const differenceFormatter = 'percent' === differenceType ? percentFormatter : explicitMeasureFormat ? createFormatter(explicitMeasureFormat) : axisFormatter ?? autoFormatter;
7443
+ const label = usesRuntimeStackEnd ? {
7444
+ visible: true,
7445
+ position: 'middle',
7446
+ refY: 0,
7447
+ formatMethod: (_markData, seriesData)=>{
7448
+ try {
7449
+ return buildDifferenceText(getRuntimeDifferenceValue({
7450
+ anchor: start,
7451
+ seriesData,
7452
+ useElementStackEnd: usesRuntimeStackEnd
7453
+ }), getRuntimeDifferenceValue({
7454
+ anchor: end,
7455
+ seriesData,
7456
+ useElementStackEnd: usesRuntimeStackEnd
7457
+ }), differenceType, differenceFormatter);
7458
+ } catch {
7459
+ return '';
7460
+ }
7461
+ },
7462
+ style: {
7463
+ fill: textColor,
7464
+ fontSize: textFontSize
7465
+ },
7466
+ labelBackground: {
7467
+ visible: true,
7468
+ padding: DEFAULT_LABEL_PADDING,
7469
+ style: {
7470
+ fill: textBackgroundColor,
7471
+ fillOpacity: 1,
7472
+ stroke: lineColor,
7473
+ lineWidth: 1,
7474
+ cornerRadius: DEFAULT_CORNER_RADIUS
7475
+ }
7476
+ }
7477
+ } : {
7478
+ visible: true,
7479
+ position: 'middle',
7480
+ refY: 0,
7481
+ text: buildDifferenceText(start.value, end.value, differenceType, differenceFormatter),
7482
+ style: {
7483
+ fill: textColor,
7484
+ fontSize: textFontSize
7485
+ },
7486
+ labelBackground: {
7487
+ visible: true,
7488
+ padding: DEFAULT_LABEL_PADDING,
7489
+ style: {
7490
+ fill: textBackgroundColor,
7491
+ fillOpacity: 1,
7492
+ stroke: lineColor,
7493
+ lineWidth: 1,
7494
+ cornerRadius: DEFAULT_CORNER_RADIUS
7495
+ }
7496
+ }
7497
+ };
7498
+ return [
7499
+ {
7500
+ type: 'type-step',
7501
+ autoRange: true,
7502
+ zIndex: 1000,
7503
+ connectDirection,
7504
+ expandDistance: useBracketStyle ? DEFAULT_BRACKET_EXPAND_DISTANCE : DEFAULT_EXPAND_DISTANCE,
7505
+ coordinates: (seriesData, relativeSeries)=>{
7506
+ try {
7507
+ return [
7508
+ buildDifferenceCoordinateDatum({
7509
+ anchor: start,
7510
+ seriesData,
7511
+ relativeSeries,
7512
+ useElementStackEnd: usesRuntimeStackEnd
7513
+ }),
7514
+ buildDifferenceCoordinateDatum({
7515
+ anchor: end,
7516
+ seriesData,
7517
+ relativeSeries,
7518
+ useElementStackEnd: usesRuntimeStackEnd
7519
+ })
7520
+ ];
7521
+ } catch {
7522
+ return [];
7523
+ }
7524
+ },
7525
+ line: useBracketStyle ? {
7526
+ multiSegment: true,
7527
+ mainSegmentIndex: 1,
7528
+ style: [
7529
+ {
7530
+ visible: true,
7531
+ stroke: lineColor,
7532
+ lineWidth: DEFAULT_LINE_WIDTH,
7533
+ lineDash: DEFAULT_BRACKET_LINE_DASH
7534
+ },
7535
+ {
7536
+ visible: true,
7537
+ stroke: lineColor,
7538
+ lineWidth: DEFAULT_LINE_WIDTH
7539
+ },
7540
+ {
7541
+ visible: true,
7542
+ stroke: lineColor,
7543
+ lineWidth: DEFAULT_LINE_WIDTH,
7544
+ lineDash: DEFAULT_BRACKET_LINE_DASH
7545
+ }
7546
+ ]
7547
+ } : {
7548
+ style: {
7549
+ visible: true,
7550
+ stroke: lineColor,
7551
+ lineWidth: DEFAULT_LINE_WIDTH,
7552
+ lineDash: [
7553
+ 0
7554
+ ],
7555
+ cornerRadius: DEFAULT_CORNER_RADIUS
7556
+ }
7557
+ },
7558
+ label,
7559
+ startSymbol: {
7560
+ visible: false
7561
+ },
7562
+ endSymbol: {
7563
+ visible: true,
7564
+ size: DEFAULT_END_SYMBOL_SIZE,
7565
+ refX: DEFAULT_END_SYMBOL_REF_X,
7566
+ style: {
7567
+ fill: lineColor
7568
+ }
7569
+ }
7570
+ }
7571
+ ];
7572
+ } catch {
7573
+ return [];
7574
+ }
7575
+ });
7576
+ const specMarkLine = chartSpec.markLine || [];
7577
+ return {
7578
+ ...spec,
7579
+ markLine: [
7580
+ ...specMarkLine,
7581
+ ...markLine
7582
+ ]
7583
+ };
7584
+ };
7079
7585
  const annotationVerticalLine_annotationVerticalLine = (spec, context)=>{
7080
7586
  const { advancedVSeed, vseed } = context;
7081
7587
  const { annotation, config } = advancedVSeed;
@@ -8719,6 +9225,7 @@ self.R = R;
8719
9225
  const line_line = [
8720
9226
  fontFamilyTheme,
8721
9227
  initLine,
9228
+ regionPadding,
8722
9229
  colorAdapter(color_color, linearColor),
8723
9230
  background_backgroundColor,
8724
9231
  datasetXY,
@@ -8736,6 +9243,7 @@ self.R = R;
8736
9243
  titleEncoding: 'x'
8737
9244
  }),
8738
9245
  annotationPoint_annotationPoint,
9246
+ annotationDifferenceLine_annotationDifferenceLine,
8739
9247
  annotationVerticalLine_annotationVerticalLine,
8740
9248
  annotationHorizontalLine_annotationHorizontalLine,
8741
9249
  annotationArea_annotationArea,
@@ -8749,6 +9257,7 @@ self.R = R;
8749
9257
  pivotIndicators_pivotIndicators([
8750
9258
  fontFamilyTheme,
8751
9259
  initLine,
9260
+ regionPadding,
8752
9261
  colorAdapter(color_color, linearColor),
8753
9262
  background_backgroundColor,
8754
9263
  datasetXY,
@@ -8765,6 +9274,7 @@ self.R = R;
8765
9274
  titleEncoding: 'x'
8766
9275
  }),
8767
9276
  annotationPoint_annotationPoint,
9277
+ annotationDifferenceLine_annotationDifferenceLine,
8768
9278
  annotationVerticalLine_annotationVerticalLine,
8769
9279
  annotationHorizontalLine_annotationHorizontalLine,
8770
9280
  annotationArea_annotationArea,
@@ -8862,6 +9372,7 @@ self.R = R;
8862
9372
  'color',
8863
9373
  'label',
8864
9374
  'legend',
9375
+ 'regionPadding',
8865
9376
  'tooltip',
8866
9377
  'xAxis',
8867
9378
  'yAxis',
@@ -9153,296 +9664,6 @@ self.R = R;
9153
9664
  };
9154
9665
  return result;
9155
9666
  };
9156
- const toArray = (value)=>{
9157
- if (Array.isArray(value)) return value;
9158
- return null == value ? [] : [
9159
- value
9160
- ];
9161
- };
9162
- const getDifferenceBandFields = (spec)=>toArray('horizontal' === spec.direction ? spec.yField : spec.xField);
9163
- const getDifferenceValueField = (spec)=>{
9164
- const valueField = toArray('horizontal' === spec.direction ? spec.xField : spec.yField)[0];
9165
- if (!valueField) throw new Error('annotationDifferenceLine requires a value field in the target chart spec');
9166
- return valueField;
9167
- };
9168
- const normalizeDifferenceValue = (value, selectorLabel, field)=>{
9169
- const numberValue = Number(value);
9170
- if (Number.isNaN(numberValue)) throw new Error(`annotationDifferenceLine ${selectorLabel} selector resolved to a non-numeric value on field "${field}"`);
9171
- return numberValue;
9172
- };
9173
- const buildStackGroupDatum = (datum, bandFields)=>Object.fromEntries(bandFields.map((field)=>[
9174
- field,
9175
- datum[field]
9176
- ]));
9177
- const buildFallbackSelectorDatum = (selectorValue)=>{
9178
- const selectorList = Array.isArray(selectorValue) ? selectorValue : [
9179
- selectorValue
9180
- ];
9181
- const fallbackDatum = {};
9182
- for (const currentSelector of selectorList){
9183
- if (isValueSelector(currentSelector) || isFieldSelector(currentSelector)) return;
9184
- if (isMeasureSelector(currentSelector)) {
9185
- const operator = currentSelector.operator || currentSelector.op;
9186
- const selectorValues = Array.isArray(currentSelector.value) ? currentSelector.value : [
9187
- currentSelector.value
9188
- ];
9189
- if (![
9190
- '=',
9191
- '=='
9192
- ].includes(operator) || 1 !== selectorValues.length) return;
9193
- fallbackDatum[currentSelector.field] = selectorValues[0];
9194
- continue;
9195
- }
9196
- if (isDimensionSelector(currentSelector)) {
9197
- const operator = currentSelector.operator || currentSelector.op;
9198
- const selectorValues = Array.isArray(currentSelector.value) ? currentSelector.value : [
9199
- currentSelector.value
9200
- ];
9201
- if ('in' !== operator || 1 !== selectorValues.length) return;
9202
- fallbackDatum[currentSelector.field] = selectorValues[0];
9203
- continue;
9204
- }
9205
- if (isPartialDatumSelector(currentSelector)) {
9206
- Object.assign(fallbackDatum, currentSelector);
9207
- continue;
9208
- }
9209
- return;
9210
- }
9211
- return Object.keys(fallbackDatum).length > 0 ? fallbackDatum : void 0;
9212
- };
9213
- const inferFallbackValue = (fallbackDatum, valueField, bandFields)=>{
9214
- if (valueField in fallbackDatum) return fallbackDatum[valueField];
9215
- const numericCandidateKeys = Object.keys(fallbackDatum).filter((key)=>{
9216
- if (key === valueField || bandFields.includes(key)) return false;
9217
- return 'number' == typeof fallbackDatum[key];
9218
- });
9219
- if (1 !== numericCandidateKeys.length) return;
9220
- return fallbackDatum[numericCandidateKeys[0]];
9221
- };
9222
- const resolveFallbackAnchor = (options)=>{
9223
- const { selectorLabel, selectorValue, valueField, bandFields } = options;
9224
- const fallbackDatum = buildFallbackSelectorDatum(selectorValue);
9225
- if (!fallbackDatum) return;
9226
- const inferredValue = inferFallbackValue(fallbackDatum, valueField, bandFields);
9227
- if (void 0 === inferredValue) return;
9228
- const coordinateDatum = {
9229
- ...fallbackDatum,
9230
- [valueField]: inferredValue
9231
- };
9232
- try {
9233
- return {
9234
- selectorLabel,
9235
- coordinateDatum,
9236
- matchedDatum: fallbackDatum,
9237
- value: normalizeDifferenceValue(inferredValue, selectorLabel, valueField)
9238
- };
9239
- } catch {
9240
- return;
9241
- }
9242
- };
9243
- const hasMixedSigns = (values)=>{
9244
- const nonZeroValues = values.filter((value)=>0 !== value);
9245
- return nonZeroValues.some((value)=>value > 0) && nonZeroValues.some((value)=>value < 0);
9246
- };
9247
- const isDifferenceLineStacked = (vseed, advancedVSeed)=>('column' === vseed.chartType || 'bar' === vseed.chartType) && hasMultipleMeasureInSingleView(advancedVSeed.reshapeMeasures ?? []);
9248
- const resolveDifferenceAnchor = (options)=>{
9249
- const { dataset, selectorLabel, selectorValue, spec, isStacked } = options;
9250
- const matches = dataset.filter((datum)=>selector_selector(datum, selectorValue));
9251
- const valueField = getDifferenceValueField(spec);
9252
- const bandFields = getDifferenceBandFields(spec);
9253
- if (0 === matches.length) return isStacked ? void 0 : resolveFallbackAnchor({
9254
- selectorLabel,
9255
- selectorValue,
9256
- valueField,
9257
- bandFields
9258
- });
9259
- if (!isStacked) {
9260
- if (1 !== matches.length) throw new Error(`annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one datum, got ${matches.length}`);
9261
- return {
9262
- selectorLabel,
9263
- coordinateDatum: matches[0],
9264
- matchedDatum: matches[0],
9265
- value: normalizeDifferenceValue(matches[0][valueField], selectorLabel, valueField)
9266
- };
9267
- }
9268
- const stackGroups = new Map();
9269
- matches.forEach((datum)=>{
9270
- const stackGroupDatum = buildStackGroupDatum(datum, bandFields);
9271
- stackGroups.set(JSON.stringify(stackGroupDatum), stackGroupDatum);
9272
- });
9273
- if (1 !== stackGroups.size) throw new Error(`annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one stack group, got ${stackGroups.size}`);
9274
- const stackGroupDatum = Array.from(stackGroups.values())[0];
9275
- const groupRows = dataset.filter((datum)=>isSubset(stackGroupDatum, datum));
9276
- const groupValues = groupRows.map((datum)=>normalizeDifferenceValue(datum[valueField], selectorLabel, valueField));
9277
- if (hasMixedSigns(groupValues)) throw new Error('annotationDifferenceLine does not support mixed-sign stack totals in v1');
9278
- return {
9279
- selectorLabel,
9280
- coordinateDatum: stackGroupDatum,
9281
- matchedDatum: matches[0],
9282
- stackGroupDatum,
9283
- value: groupValues.reduce((sum, value)=>sum + value, 0)
9284
- };
9285
- };
9286
- const getStackRuntimeTotal = (runtimeMatches)=>{
9287
- const stackEndValues = runtimeMatches.map((datum)=>Number(datum.__VCHART_STACK_END));
9288
- if (stackEndValues.some((value)=>Number.isNaN(value))) return;
9289
- if (hasMixedSigns(stackEndValues)) throw new Error('annotationDifferenceLine does not support mixed-sign runtime stack totals in v1');
9290
- return stackEndValues.some((value)=>value < 0) ? Math.min(...stackEndValues) : Math.max(...stackEndValues);
9291
- };
9292
- const buildDifferenceCoordinateDatum = (options)=>{
9293
- const { anchor, seriesData, relativeSeries } = options;
9294
- if (!anchor.stackGroupDatum) {
9295
- const runtimeMatches = anchor.matchedDatum ? seriesData.filter((datum)=>isSubset(anchor.matchedDatum, datum)) : [];
9296
- return runtimeMatches[0] ?? anchor.coordinateDatum;
9297
- }
9298
- const runtimeMatches = seriesData.filter((datum)=>isSubset(anchor.stackGroupDatum, datum));
9299
- const runtimeStackTotal = getStackRuntimeTotal(runtimeMatches);
9300
- return {
9301
- ...runtimeMatches[0] ?? anchor.coordinateDatum,
9302
- [relativeSeries.getStackValueField()]: runtimeStackTotal ?? anchor.value
9303
- };
9304
- };
9305
- const buildDifferenceText = (startValue, endValue, differenceType = 'absolute')=>{
9306
- if ('percent' === differenceType) {
9307
- if (0 === startValue) throw new Error('annotationDifferenceLine percent difference cannot be computed because start value is 0');
9308
- return `${((endValue - startValue) / startValue * 100).toFixed(0)}%`;
9309
- }
9310
- return `${endValue - startValue}`;
9311
- };
9312
- const inferDifferenceConnectDirection = (vseed, values)=>{
9313
- const isNegativeSide = values.every((value)=>value < 0);
9314
- if (isBarLikeChart(vseed)) return isNegativeSide ? 'left' : 'right';
9315
- return isNegativeSide ? 'bottom' : 'top';
9316
- };
9317
- const DEFAULT_LINE_COLOR = '#BCC1CB';
9318
- const DEFAULT_TEXT_COLOR = '#ffffff';
9319
- const DEFAULT_TEXT_BACKGROUND_COLOR = '#BCC1CB';
9320
- const DEFAULT_TEXT_FONT_SIZE = 12;
9321
- const DEFAULT_EXPAND_DISTANCE = 24;
9322
- const DEFAULT_LINE_WIDTH = 2;
9323
- const DEFAULT_CORNER_RADIUS = 4;
9324
- const DEFAULT_LABEL_PADDING = 4;
9325
- const DEFAULT_END_SYMBOL_SIZE = 12;
9326
- const DEFAULT_END_SYMBOL_REF_X = -4;
9327
- const getDifferenceLinePath = (index, total)=>1 === total ? 'annotationDifferenceLine' : `annotationDifferenceLine[${index}]`;
9328
- const assertDifferenceLineConfig = (value, path)=>{
9329
- if ('object' != typeof value || null === value || Array.isArray(value)) throw new Error(`${path} must be an object`);
9330
- const start = value.start;
9331
- if ('object' != typeof start || null === start || Array.isArray(start)) throw new Error(`${path}.start is required`);
9332
- if (null == start.selector) throw new Error(`${path}.start.selector is required`);
9333
- const end = value.end;
9334
- if ('object' != typeof end || null === end || Array.isArray(end)) throw new Error(`${path}.end is required`);
9335
- if (null == end.selector) throw new Error(`${path}.end.selector is required`);
9336
- };
9337
- const annotationDifferenceLine_annotationDifferenceLine = (spec, context)=>{
9338
- const { advancedVSeed, vseed } = context;
9339
- const annotationDifferenceLine = advancedVSeed.annotation?.annotationDifferenceLine;
9340
- if (!annotationDifferenceLine) return spec;
9341
- const theme = advancedVSeed.config?.[vseed.chartType]?.annotation?.annotationDifferenceLine;
9342
- const annotationDifferenceLineList = Array.isArray(annotationDifferenceLine) ? annotationDifferenceLine : [
9343
- annotationDifferenceLine
9344
- ];
9345
- const dataset = advancedVSeed.dataset.flat();
9346
- const barSpec = spec;
9347
- const isStacked = isDifferenceLineStacked(vseed, advancedVSeed);
9348
- const markLine = annotationDifferenceLineList.flatMap((annotationDifferenceLine, index)=>{
9349
- assertDifferenceLineConfig(annotationDifferenceLine, getDifferenceLinePath(index, annotationDifferenceLineList.length));
9350
- const start = resolveDifferenceAnchor({
9351
- dataset,
9352
- selectorLabel: 'start',
9353
- selectorValue: annotationDifferenceLine.start.selector,
9354
- spec: barSpec,
9355
- isStacked
9356
- });
9357
- const end = resolveDifferenceAnchor({
9358
- dataset,
9359
- selectorLabel: 'end',
9360
- selectorValue: annotationDifferenceLine.end.selector,
9361
- spec: barSpec,
9362
- isStacked
9363
- });
9364
- if (!start || !end) return [];
9365
- const lineColor = annotationDifferenceLine.lineColor ?? theme?.lineColor ?? DEFAULT_LINE_COLOR;
9366
- const textColor = annotationDifferenceLine.textColor ?? theme?.textColor ?? DEFAULT_TEXT_COLOR;
9367
- const textBackgroundColor = annotationDifferenceLine.textBackgroundColor ?? theme?.textBackgroundColor ?? DEFAULT_TEXT_BACKGROUND_COLOR;
9368
- const textFontSize = annotationDifferenceLine.textFontSize ?? theme?.textFontSize ?? DEFAULT_TEXT_FONT_SIZE;
9369
- return [
9370
- {
9371
- type: 'type-step',
9372
- autoRange: true,
9373
- zIndex: 1000,
9374
- connectDirection: inferDifferenceConnectDirection(vseed, [
9375
- start.value,
9376
- end.value
9377
- ]),
9378
- expandDistance: DEFAULT_EXPAND_DISTANCE,
9379
- coordinates: (seriesData, relativeSeries)=>[
9380
- buildDifferenceCoordinateDatum({
9381
- anchor: start,
9382
- seriesData,
9383
- relativeSeries
9384
- }),
9385
- buildDifferenceCoordinateDatum({
9386
- anchor: end,
9387
- seriesData,
9388
- relativeSeries
9389
- })
9390
- ],
9391
- line: {
9392
- style: {
9393
- visible: true,
9394
- stroke: lineColor,
9395
- lineWidth: DEFAULT_LINE_WIDTH,
9396
- lineDash: [
9397
- 0
9398
- ],
9399
- cornerRadius: DEFAULT_CORNER_RADIUS
9400
- }
9401
- },
9402
- label: {
9403
- confine: true,
9404
- visible: true,
9405
- position: 'middle',
9406
- text: buildDifferenceText(start.value, end.value, annotationDifferenceLine.differenceType ?? 'absolute'),
9407
- style: {
9408
- fill: textColor,
9409
- fontSize: textFontSize
9410
- },
9411
- labelBackground: {
9412
- visible: true,
9413
- padding: DEFAULT_LABEL_PADDING,
9414
- style: {
9415
- fill: textBackgroundColor,
9416
- fillOpacity: 1,
9417
- stroke: lineColor,
9418
- lineWidth: 1,
9419
- cornerRadius: DEFAULT_CORNER_RADIUS
9420
- }
9421
- }
9422
- },
9423
- startSymbol: {
9424
- visible: false
9425
- },
9426
- endSymbol: {
9427
- visible: true,
9428
- size: DEFAULT_END_SYMBOL_SIZE,
9429
- refX: DEFAULT_END_SYMBOL_REF_X,
9430
- style: {
9431
- fill: lineColor
9432
- }
9433
- }
9434
- }
9435
- ];
9436
- });
9437
- const specMarkLine = barSpec.markLine || [];
9438
- return {
9439
- ...spec,
9440
- markLine: [
9441
- ...specMarkLine,
9442
- ...markLine
9443
- ]
9444
- };
9445
- };
9446
9667
  const annotationAreaBand = (spec, context)=>{
9447
9668
  const { advancedVSeed, vseed } = context;
9448
9669
  const { annotation, config } = advancedVSeed;
@@ -10038,6 +10259,7 @@ self.R = R;
10038
10259
  const column_column = [
10039
10260
  fontFamilyTheme,
10040
10261
  initColumn,
10262
+ regionPadding,
10041
10263
  stackCornerRadius_stackCornerRadius,
10042
10264
  barMaxWidth_barMaxWidth,
10043
10265
  stackInverse,
@@ -10070,6 +10292,7 @@ self.R = R;
10070
10292
  pivotIndicators_pivotIndicators([
10071
10293
  fontFamilyTheme,
10072
10294
  initColumn,
10295
+ regionPadding,
10073
10296
  stackCornerRadius_stackCornerRadius,
10074
10297
  barMaxWidth_barMaxWidth,
10075
10298
  stackInverse,
@@ -10255,6 +10478,7 @@ self.R = R;
10255
10478
  const columnParallel = [
10256
10479
  fontFamilyTheme,
10257
10480
  initColumnParallel,
10481
+ regionPadding,
10258
10482
  stackCornerRadius_stackCornerRadius,
10259
10483
  barMaxWidth_barMaxWidth,
10260
10484
  barGapInGroup_barGapInGroup,
@@ -10286,6 +10510,7 @@ self.R = R;
10286
10510
  pivotIndicators_pivotIndicators([
10287
10511
  fontFamilyTheme,
10288
10512
  initColumnParallel,
10513
+ regionPadding,
10289
10514
  stackCornerRadius_stackCornerRadius,
10290
10515
  barMaxWidth_barMaxWidth,
10291
10516
  colorAdapter(color_color, linearColor),
@@ -10362,6 +10587,7 @@ self.R = R;
10362
10587
  const columnPercent = [
10363
10588
  fontFamilyTheme,
10364
10589
  initColumn,
10590
+ regionPadding,
10365
10591
  stackCornerRadius_stackCornerRadius,
10366
10592
  stackInverse,
10367
10593
  barMaxWidth_barMaxWidth,
@@ -10393,6 +10619,7 @@ self.R = R;
10393
10619
  pivotIndicators_pivotIndicators([
10394
10620
  fontFamilyTheme,
10395
10621
  initColumn,
10622
+ regionPadding,
10396
10623
  stackCornerRadius_stackCornerRadius,
10397
10624
  stackInverse,
10398
10625
  barMaxWidth_barMaxWidth,
@@ -10742,6 +10969,7 @@ self.R = R;
10742
10969
  const bar = [
10743
10970
  fontFamilyTheme,
10744
10971
  initBar,
10972
+ regionPadding,
10745
10973
  stackCornerRadius_stackCornerRadius,
10746
10974
  barMaxWidth_barMaxWidth,
10747
10975
  colorAdapter(color_color, linearColor),
@@ -10772,6 +11000,7 @@ self.R = R;
10772
11000
  pivotIndicators_pivotIndicators([
10773
11001
  fontFamilyTheme,
10774
11002
  initBar,
11003
+ regionPadding,
10775
11004
  stackCornerRadius_stackCornerRadius,
10776
11005
  barMaxWidth_barMaxWidth,
10777
11006
  colorAdapter(color_color, linearColor),
@@ -13493,6 +13722,7 @@ self.R = R;
13493
13722
  const barParallel = [
13494
13723
  fontFamilyTheme,
13495
13724
  initBarParallel,
13725
+ regionPadding,
13496
13726
  stackCornerRadius_stackCornerRadius,
13497
13727
  barMaxWidth_barMaxWidth,
13498
13728
  barGapInGroup_barGapInGroup,
@@ -13524,6 +13754,7 @@ self.R = R;
13524
13754
  pivotIndicators_pivotIndicators([
13525
13755
  fontFamilyTheme,
13526
13756
  initBarParallel,
13757
+ regionPadding,
13527
13758
  stackCornerRadius_stackCornerRadius,
13528
13759
  barMaxWidth_barMaxWidth,
13529
13760
  colorAdapter(color_color, linearColor),
@@ -13592,6 +13823,7 @@ self.R = R;
13592
13823
  const barPercent = [
13593
13824
  fontFamilyTheme,
13594
13825
  initBar,
13826
+ regionPadding,
13595
13827
  stackCornerRadius_stackCornerRadius,
13596
13828
  barMaxWidth_barMaxWidth,
13597
13829
  colorAdapter(color_color, linearColor),
@@ -13622,6 +13854,7 @@ self.R = R;
13622
13854
  pivotIndicators_pivotIndicators([
13623
13855
  fontFamilyTheme,
13624
13856
  initBar,
13857
+ regionPadding,
13625
13858
  stackCornerRadius_stackCornerRadius,
13626
13859
  barMaxWidth_barMaxWidth,
13627
13860
  colorAdapter(color_color, linearColor),
@@ -13779,6 +14012,7 @@ self.R = R;
13779
14012
  const area_area = [
13780
14013
  fontFamilyTheme,
13781
14014
  initArea,
14015
+ regionPadding,
13782
14016
  stackInverse,
13783
14017
  colorAdapter(color_color, linearColor),
13784
14018
  background_backgroundColor,
@@ -13798,6 +14032,7 @@ self.R = R;
13798
14032
  colorLineStyleFill(lineStyle_lineStyle),
13799
14033
  colorAreaStyleFill(areaStyle_areaStyle),
13800
14034
  annotationPoint_annotationPoint,
14035
+ annotationDifferenceLine_annotationDifferenceLine,
13801
14036
  annotationVerticalLine_annotationVerticalLine,
13802
14037
  annotationHorizontalLine_annotationHorizontalLine,
13803
14038
  annotationArea_annotationArea,
@@ -13811,6 +14046,7 @@ self.R = R;
13811
14046
  pivotIndicators_pivotIndicators([
13812
14047
  fontFamilyTheme,
13813
14048
  initArea,
14049
+ regionPadding,
13814
14050
  colorAdapter(color_color, linearColor),
13815
14051
  background_backgroundColor,
13816
14052
  stackInverse,
@@ -13829,6 +14065,7 @@ self.R = R;
13829
14065
  colorLineStyleFill(lineStyle_lineStyle),
13830
14066
  colorAreaStyleFill(areaStyle_areaStyle),
13831
14067
  annotationPoint_annotationPoint,
14068
+ annotationDifferenceLine_annotationDifferenceLine,
13832
14069
  annotationVerticalLine_annotationVerticalLine,
13833
14070
  annotationHorizontalLine_annotationHorizontalLine,
13834
14071
  annotationArea_annotationArea,
@@ -13882,6 +14119,7 @@ self.R = R;
13882
14119
  const areaPercent = [
13883
14120
  fontFamilyTheme,
13884
14121
  initArea,
14122
+ regionPadding,
13885
14123
  stackInverse,
13886
14124
  colorAdapter(color_color, linearColor),
13887
14125
  background_backgroundColor,
@@ -13914,6 +14152,7 @@ self.R = R;
13914
14152
  pivotIndicators_pivotIndicators([
13915
14153
  fontFamilyTheme,
13916
14154
  initArea,
14155
+ regionPadding,
13917
14156
  stackInverse,
13918
14157
  colorAdapter(color_color, linearColor),
13919
14158
  background_backgroundColor,
@@ -25612,6 +25851,13 @@ self.R = R;
25612
25851
  showTooltip: schemas_boolean().nullish(),
25613
25852
  showLabel: schemas_boolean().nullish()
25614
25853
  });
25854
+ const zRegionPaddingObject = schemas_object({
25855
+ top: schemas_number().nonnegative().nullish(),
25856
+ right: schemas_number().nonnegative().nullish(),
25857
+ bottom: schemas_number().nonnegative().nullish(),
25858
+ left: schemas_number().nonnegative().nullish()
25859
+ }).partial();
25860
+ const zRegionPadding = schemas_number().nonnegative().or(zRegionPaddingObject);
25615
25861
  const zBrushStyleConfig = schemas_object({
25616
25862
  opacity: schemas_number().optional(),
25617
25863
  stroke: schemas_string().optional(),
@@ -25644,6 +25890,7 @@ self.R = R;
25644
25890
  color: zColor.nullish(),
25645
25891
  tooltip: zTooltip.nullish(),
25646
25892
  legend: zLegend.nullish(),
25893
+ regionPadding: zRegionPadding.nullish(),
25647
25894
  xAxis: zXBandAxis.nullish(),
25648
25895
  yAxis: zYLinearAxis.nullish(),
25649
25896
  crosshairLine: zCrosshairLine.nullish(),
@@ -25699,6 +25946,7 @@ self.R = R;
25699
25946
  color: zColor.nullish(),
25700
25947
  tooltip: zTooltip.nullish(),
25701
25948
  legend: zLegend.nullish(),
25949
+ regionPadding: zRegionPadding.nullish(),
25702
25950
  xAxis: zXBandAxis.nullish(),
25703
25951
  yAxis: zYLinearAxis.nullish(),
25704
25952
  crosshairRect: zCrosshairRect.nullish(),
@@ -25720,6 +25968,7 @@ self.R = R;
25720
25968
  color: zColor.nullish(),
25721
25969
  tooltip: zTooltip.nullish(),
25722
25970
  legend: zLegend.nullish(),
25971
+ regionPadding: zRegionPadding.nullish(),
25723
25972
  xAxis: zXLinearAxis.nullish(),
25724
25973
  yAxis: zYBandAxis.nullish(),
25725
25974
  crosshairRect: zCrosshairRect.nullish(),
@@ -25737,6 +25986,7 @@ self.R = R;
25737
25986
  color: zColor.nullish(),
25738
25987
  tooltip: zTooltip.nullish(),
25739
25988
  legend: zLegend.nullish(),
25989
+ regionPadding: zRegionPadding.nullish(),
25740
25990
  xAxis: zXBandAxis.nullish(),
25741
25991
  yAxis: zYLinearAxis.nullish(),
25742
25992
  crosshairLine: zCrosshairLine.nullish(),
@@ -26273,6 +26523,7 @@ self.R = R;
26273
26523
  color: zColor.nullish(),
26274
26524
  label: zLabel.nullish(),
26275
26525
  legend: zLegend.nullish(),
26526
+ regionPadding: zRegionPadding.nullish(),
26276
26527
  tooltip: zTooltip.nullish(),
26277
26528
  brush: zBrush.nullish(),
26278
26529
  xAxis: zXBandAxis.nullish(),
@@ -26287,6 +26538,7 @@ self.R = R;
26287
26538
  annotationVerticalLine: schemas_array(zAnnotationVerticalLine).or(zAnnotationVerticalLine).nullish(),
26288
26539
  annotationHorizontalLine: schemas_array(zAnnotationHorizontalLine).or(zAnnotationHorizontalLine).nullish(),
26289
26540
  annotationArea: schemas_array(zAnnotationArea).or(zAnnotationArea).nullish(),
26541
+ annotationDifferenceLine: schemas_array(zAnnotationDifferenceLine).or(zAnnotationDifferenceLine).nullish(),
26290
26542
  dimensionLinkage: zDimensionLinkage.nullish(),
26291
26543
  locale: zLocale.nullish()
26292
26544
  });
@@ -26302,6 +26554,7 @@ self.R = R;
26302
26554
  color: zColor.nullish(),
26303
26555
  label: zLabel.nullish(),
26304
26556
  legend: zLegend.nullish(),
26557
+ regionPadding: zRegionPadding.nullish(),
26305
26558
  tooltip: zTooltip.nullish(),
26306
26559
  brush: zBrush.nullish(),
26307
26560
  xAxis: zXBandAxis.nullish(),
@@ -26334,6 +26587,7 @@ self.R = R;
26334
26587
  color: zColor.nullish(),
26335
26588
  label: zLabel.nullish(),
26336
26589
  legend: zLegend.nullish(),
26590
+ regionPadding: zRegionPadding.nullish(),
26337
26591
  tooltip: zTooltip.nullish(),
26338
26592
  brush: zBrush.nullish(),
26339
26593
  xAxis: zXBandAxis.nullish(),
@@ -26363,6 +26617,7 @@ self.R = R;
26363
26617
  color: zColor.nullish(),
26364
26618
  label: zLabel.nullish(),
26365
26619
  legend: zLegend.nullish(),
26620
+ regionPadding: zRegionPadding.nullish(),
26366
26621
  tooltip: zTooltip.nullish(),
26367
26622
  brush: zBrush.nullish(),
26368
26623
  xAxis: zXBandAxis.nullish(),
@@ -26390,6 +26645,7 @@ self.R = R;
26390
26645
  color: zColor.nullish(),
26391
26646
  label: zLabel.nullish(),
26392
26647
  legend: zLegend.nullish(),
26648
+ regionPadding: zRegionPadding.nullish(),
26393
26649
  tooltip: zTooltip.nullish(),
26394
26650
  brush: zBrush.nullish(),
26395
26651
  xAxis: zXLinearAxis.nullish(),
@@ -26535,6 +26791,7 @@ self.R = R;
26535
26791
  color: zColor.nullish(),
26536
26792
  label: zLabel.nullish(),
26537
26793
  legend: zLegend.nullish(),
26794
+ regionPadding: zRegionPadding.nullish(),
26538
26795
  tooltip: zTooltip.nullish(),
26539
26796
  brush: zBrush.nullish(),
26540
26797
  xAxis: zXLinearAxis.nullish(),
@@ -26565,6 +26822,7 @@ self.R = R;
26565
26822
  color: zColor.nullish(),
26566
26823
  label: zLabel.nullish(),
26567
26824
  legend: zLegend.nullish(),
26825
+ regionPadding: zRegionPadding.nullish(),
26568
26826
  tooltip: zTooltip.nullish(),
26569
26827
  brush: zBrush.nullish(),
26570
26828
  xAxis: zXLinearAxis.nullish(),
@@ -26592,6 +26850,7 @@ self.R = R;
26592
26850
  color: zColor.nullish(),
26593
26851
  label: zLabel.nullish(),
26594
26852
  legend: zLegend.nullish(),
26853
+ regionPadding: zRegionPadding.nullish(),
26595
26854
  tooltip: zTooltip.nullish(),
26596
26855
  brush: zBrush.nullish(),
26597
26856
  xAxis: zXBandAxis.nullish(),
@@ -26605,6 +26864,7 @@ self.R = R;
26605
26864
  annotationVerticalLine: schemas_array(zAnnotationVerticalLine).or(zAnnotationVerticalLine).nullish(),
26606
26865
  annotationHorizontalLine: schemas_array(zAnnotationHorizontalLine).or(zAnnotationHorizontalLine).nullish(),
26607
26866
  annotationArea: schemas_array(zAnnotationArea).or(zAnnotationArea).nullish(),
26867
+ annotationDifferenceLine: schemas_array(zAnnotationDifferenceLine).or(zAnnotationDifferenceLine).nullish(),
26608
26868
  dimensionLinkage: zDimensionLinkage.nullish(),
26609
26869
  locale: zLocale.nullish()
26610
26870
  });
@@ -26619,6 +26879,7 @@ self.R = R;
26619
26879
  color: zColor.nullish(),
26620
26880
  label: zLabel.nullish(),
26621
26881
  legend: zLegend.nullish(),
26882
+ regionPadding: zRegionPadding.nullish(),
26622
26883
  tooltip: zTooltip.nullish(),
26623
26884
  brush: zBrush.nullish(),
26624
26885
  xAxis: zXBandAxis.nullish(),