@bino-bi/bn-template-engine 1.0.0-next.20 → 1.0.0-next.22

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 (84) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/{p-99477a27.entry.js → p-445c76cd.entry.js} +1 -1
  3. package/dist/bn-template-engine/p-7d1083f6.entry.js +1 -0
  4. package/dist/bn-template-engine/{p-7e9dbc93.entry.js → p-91e5dddf.entry.js} +1 -1
  5. package/dist/bn-template-engine/{p-b9e94127.entry.js → p-93eaded3.entry.js} +1 -1
  6. package/dist/bn-template-engine/{p-BpWWgN6k.js → p-D1SJ10zl.js} +1 -1
  7. package/dist/bn-template-engine/p-D75i_YOP.js +1 -0
  8. package/dist/bn-template-engine/{p-A8xyE4b1.js → p-Da6p_F4J.js} +1 -1
  9. package/dist/bn-template-engine/{p-a1380d7c.entry.js → p-c3383557.entry.js} +1 -1
  10. package/dist/bn-template-engine/{p-ba912130.entry.js → p-cda4322a.entry.js} +1 -1
  11. package/dist/bn-template-engine/{p-6c7f0076.entry.js → p-e49f9170.entry.js} +1 -1
  12. package/dist/bn-template-engine/{p-6077155f.entry.js → p-f275b9fe.entry.js} +1 -1
  13. package/dist/cjs/bn-asset_21.cjs.entry.js +369 -122
  14. package/dist/cjs/bn-chart-bubble.cjs.entry.js +18 -8
  15. package/dist/cjs/bn-chart-bullet.cjs.entry.js +3 -3
  16. package/dist/cjs/bn-chart-scatter.cjs.entry.js +3 -3
  17. package/dist/cjs/bn-grid.cjs.entry.js +1 -1
  18. package/dist/cjs/bn-image.cjs.entry.js +1 -1
  19. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  20. package/dist/cjs/bn-text.cjs.entry.js +2 -2
  21. package/dist/cjs/bn-tree.cjs.entry.js +1 -1
  22. package/dist/cjs/{layoutObserver-DUYYkDMQ.js → layoutObserver-D8leSb4j.js} +1 -1
  23. package/dist/cjs/loader.cjs.js +1 -1
  24. package/dist/cjs/{scaling-BIJQ2NV1.js → scaling-B6_M_HWH.js} +82 -0
  25. package/dist/cjs/{withStyled-Cm9dWQhu.js → withStyled-DuwvaDMp.js} +3 -3
  26. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +15 -5
  27. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +81 -39
  28. package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +34 -0
  29. package/dist/collection/components/bn-chart-time/bn-chart-time.js +80 -35
  30. package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +34 -0
  31. package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +76 -19
  32. package/dist/collection/components/bn-table/bn-table.js +111 -45
  33. package/dist/collection/components/bn-table/ibcs-table.js +37 -2
  34. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +2 -2
  35. package/dist/collection/utils/dataAnalyzer.js +17 -8
  36. package/dist/collection/utils/scaling.js +79 -0
  37. package/dist/collection/utils/validate.js +3 -3
  38. package/dist/components/DataFormatDigits.js +1 -1
  39. package/dist/components/bn-chart-bubble.js +1 -1
  40. package/dist/components/bn-chart-bullet.js +1 -1
  41. package/dist/components/bn-chart-scatter.js +1 -1
  42. package/dist/components/bn-chart-structure.js +1 -1
  43. package/dist/components/bn-chart-time.js +1 -1
  44. package/dist/components/bn-grid.js +1 -1
  45. package/dist/components/bn-scaling-group.js +1 -1
  46. package/dist/components/bn-table.js +1 -1
  47. package/dist/components/bn-text.js +1 -1
  48. package/dist/components/bn-tree.js +1 -1
  49. package/dist/components/ibcs-chart-structure2.js +1 -1
  50. package/dist/components/ibcs-chart-time2.js +1 -1
  51. package/dist/components/ibcs-table2.js +1 -1
  52. package/dist/components/scaling.js +1 -0
  53. package/dist/components/validate.js +1 -1
  54. package/dist/components/withDataset.js +1 -1
  55. package/dist/components/withStyled.js +1 -1
  56. package/dist/esm/bn-asset_21.entry.js +369 -122
  57. package/dist/esm/bn-chart-bubble.entry.js +18 -8
  58. package/dist/esm/bn-chart-bullet.entry.js +3 -3
  59. package/dist/esm/bn-chart-scatter.entry.js +3 -3
  60. package/dist/esm/bn-grid.entry.js +1 -1
  61. package/dist/esm/bn-image.entry.js +1 -1
  62. package/dist/esm/bn-template-engine.js +1 -1
  63. package/dist/esm/bn-text.entry.js +2 -2
  64. package/dist/esm/bn-tree.entry.js +1 -1
  65. package/dist/esm/{layoutObserver-BJBEyhNf.js → layoutObserver-DtZb2vdM.js} +1 -1
  66. package/dist/esm/loader.js +1 -1
  67. package/dist/esm/{scaling-BGnpSN1j.js → scaling-Bw8XyrFq.js} +80 -1
  68. package/dist/esm/{withStyled-2l5Tx3cf.js → withStyled-41rsCSM1.js} +3 -3
  69. package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +5 -2
  70. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +33 -16
  71. package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +8 -0
  72. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +35 -18
  73. package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +8 -0
  74. package/dist/types/components/bn-scaling-group/bn-scaling-group.d.ts +28 -8
  75. package/dist/types/components/bn-table/bn-table.d.ts +37 -17
  76. package/dist/types/components/bn-table/ibcs-table.d.ts +8 -0
  77. package/dist/types/components.d.ts +85 -51
  78. package/dist/types/utils/dataAnalyzer.d.ts +5 -1
  79. package/dist/types/utils/scaling.d.ts +63 -0
  80. package/dist/types/utils/validate.d.ts +2 -2
  81. package/package.json +1 -1
  82. package/readme.md +2 -0
  83. package/dist/bn-template-engine/p-C9i1Xsib.js +0 -1
  84. package/dist/bn-template-engine/p-b5274369.entry.js +0 -1
@@ -1,18 +1,21 @@
1
1
  import { h, Host } from "@stencil/core";
2
2
  import { getStores } from "../../context/context-protocol";
3
+ import { formatScalingValue, parseScalingValue } from "../../utils/scaling";
3
4
  import withComponentStatus from "../../utils/withComponentStatus";
4
5
  import withHasError from "../../utils/withHasError";
5
6
  /**
6
7
  * Defines a named scaling value that chart and table components can reference
7
- * via their `unit-scaling` or `percentage-scaling` attributes.
8
+ * via their `unit-scaling` or `percentage-scaling` attributes, or a bubble
9
+ * chart via its `size` spec's `group` key.
8
10
  *
9
11
  * Multiple components sharing the same group name will use the same scaling
10
12
  * value, allowing synchronized scaling across an entire page or section.
11
13
  *
12
- * The reserved name `"auto"` is not allowed and will be ignored with a warning.
14
+ * The reserved name `"auto"` is not allowed, and neither is a name that would
15
+ * parse as a number/SI value (e.g. `"1M"`); both are rejected with a warning.
13
16
  *
14
17
  * @example
15
- * <bn-scaling-group name="revenue" value="0.05"></bn-scaling-group>
18
+ * <bn-scaling-group name="revenue" value="250k"></bn-scaling-group>
16
19
  * <bn-chart-structure unit-scaling="revenue" ...></bn-chart-structure>
17
20
  * <bn-table unit-scaling="revenue" ...></bn-table>
18
21
  */
@@ -25,28 +28,44 @@ export class ScalingGroup {
25
28
  this.stores = getStores(this.element);
26
29
  this.pushToStore();
27
30
  }
31
+ disconnectedCallback() {
32
+ this.removeEntryIfOurs(this.storedName);
33
+ }
28
34
  onNameChange(newName, oldName) {
29
- if (oldName && oldName !== newName && this.stores) {
30
- // Remove old entry — only if it still points to our value
31
- // (another bn-scaling-group with the same name may have overwritten it)
32
- const current = this.stores.scalingGroups.state[oldName];
33
- if (current === this.value) {
34
- // @ts-ignore – dynamic key
35
- this.stores.scalingGroups.set(oldName, undefined);
36
- }
35
+ const trimmedOld = oldName === null || oldName === void 0 ? void 0 : oldName.toString().trim();
36
+ if (trimmedOld && trimmedOld !== (newName === null || newName === void 0 ? void 0 : newName.toString().trim())) {
37
+ this.removeEntryIfOurs(trimmedOld);
37
38
  }
38
39
  this.pushToStore();
39
40
  }
40
41
  onValueChange() {
41
42
  this.pushToStore();
42
43
  }
44
+ /**
45
+ * Removes the store entry for `name` — but only if it still holds the value
46
+ * this element wrote (another bn-scaling-group with the same name may have
47
+ * overwritten it).
48
+ */
49
+ removeEntryIfOurs(name) {
50
+ if (!name || !this.stores)
51
+ return;
52
+ if (this.storedName === name && this.stores.scalingGroups.state[name] === this.storedValue) {
53
+ // @ts-ignore – dynamic key
54
+ this.stores.scalingGroups.set(name, undefined);
55
+ }
56
+ if (this.storedName === name) {
57
+ this.storedName = undefined;
58
+ this.storedValue = undefined;
59
+ }
60
+ }
43
61
  pushToStore() {
44
62
  var _a;
45
63
  if (!this.stores)
46
64
  return;
47
65
  const trimmedName = (_a = this.name) === null || _a === void 0 ? void 0 : _a.toString().trim();
66
+ const nameParse = parseScalingValue(trimmedName);
48
67
  // Validate: "auto" is reserved
49
- if ((trimmedName === null || trimmedName === void 0 ? void 0 : trimmedName.toLowerCase()) === "auto") {
68
+ if (nameParse.kind === "auto") {
50
69
  this.errors.addOrReplace({
51
70
  id: "ERR_reserved_name",
52
71
  type: "warning",
@@ -64,11 +83,49 @@ export class ScalingGroup {
64
83
  return;
65
84
  }
66
85
  this.errors.remove("ERR_empty_name");
86
+ // Validate: a name that parses as a number/SI value would be ambiguous
87
+ // with a literal scaling value at the referencing component.
88
+ if (nameParse.kind === "number") {
89
+ this.errors.addOrReplace({
90
+ id: "ERR_numeric_name",
91
+ type: "warning",
92
+ message: `bn-scaling-group: name "${trimmedName}" is not allowed — it would be ambiguous with a numeric scaling value.`,
93
+ });
94
+ return;
95
+ }
96
+ this.errors.remove("ERR_numeric_name");
97
+ const parsedValue = parseScalingValue(this.value);
98
+ if (parsedValue.kind !== "number") {
99
+ this.errors.addOrReplace({
100
+ id: "ERR_invalid_value",
101
+ type: "warning",
102
+ message: `bn-scaling-group: invalid value "${this.value}" — must be a positive number, optionally with k/M/G/T suffix.`,
103
+ });
104
+ return;
105
+ }
106
+ this.errors.remove("ERR_invalid_value");
107
+ const existing = this.stores.scalingGroups.state[trimmedName];
108
+ const wroteExisting = this.storedName === trimmedName && this.storedValue === existing;
109
+ if (existing !== undefined && existing !== parsedValue.value && !wroteExisting) {
110
+ this.errors.addOrReplace({
111
+ id: "WARN_duplicate_group",
112
+ type: "warning",
113
+ message: `bn-scaling-group: "${trimmedName}" is already registered with a different value (${formatScalingValue(existing)}); overwriting.`,
114
+ });
115
+ }
116
+ else {
117
+ this.errors.remove("WARN_duplicate_group");
118
+ }
119
+ if (this.storedName && this.storedName !== trimmedName) {
120
+ this.removeEntryIfOurs(this.storedName);
121
+ }
67
122
  // @ts-ignore – dynamic key
68
- this.stores.scalingGroups.set(trimmedName, this.value);
123
+ this.stores.scalingGroups.set(trimmedName, parsedValue.value);
124
+ this.storedName = trimmedName;
125
+ this.storedValue = parsedValue.value;
69
126
  }
70
127
  render() {
71
- return h(Host, { key: '56092f6e012b217bb60833dba91def0561edf06b' });
128
+ return h(Host, { key: '7b125b03953f91d15c6c9df7ca178c9f33b054cc' });
72
129
  }
73
130
  static get is() { return "bn-scaling-group"; }
74
131
  static get originalStyleUrls() {
@@ -95,7 +152,7 @@ export class ScalingGroup {
95
152
  "optional": false,
96
153
  "docs": {
97
154
  "tags": [],
98
- "text": "Unique name identifying this scaling group.\nComponents reference this name in their `unit-scaling` or `percentage-scaling` attributes.\n\nThe name `\"auto\"` is reserved and cannot be used."
155
+ "text": "Unique name identifying this scaling group.\nComponents reference this name in their `unit-scaling` or `percentage-scaling`\nattributes, or in a bubble chart's `size.group`.\n\nThe name `\"auto\"` is reserved, and names that parse as a number/SI value\n(`\"100\"`, `\"1M\"`) are rejected \u2014 they would be ambiguous with a literal\nscaling value."
99
156
  },
100
157
  "getter": false,
101
158
  "setter": false,
@@ -103,18 +160,18 @@ export class ScalingGroup {
103
160
  "attribute": "name"
104
161
  },
105
162
  "value": {
106
- "type": "number",
163
+ "type": "any",
107
164
  "mutable": false,
108
165
  "complexType": {
109
- "original": "number",
110
- "resolved": "number",
166
+ "original": "string | number",
167
+ "resolved": "number | string",
111
168
  "references": {}
112
169
  },
113
170
  "required": true,
114
171
  "optional": false,
115
172
  "docs": {
116
173
  "tags": [],
117
- "text": "The scaling value (pixels per data unit or pixels per percentage point,\ndepending on which attribute references this group)."
174
+ "text": "The scaling value: a positive number with optional SI suffix\n(`k`/`K` = 1e3, `M` = 1e6, `G` = 1e9, `T` = 1e12), e.g. `\"250k\"` or `2.5`.\n\nThe unit depends on which attribute references this group:\n- from `unit-scaling`: data units per 1 em of bar length\n- from `percentage-scaling`: percentage points per 1 em of pin length\n- from a bubble chart's `size.group`: data units per 1 em\u00B2 of bubble area"
118
175
  },
119
176
  "getter": false,
120
177
  "setter": false,
@@ -1,5 +1,5 @@
1
1
  import { forceUpdate, h, Host, writeTask } from "@stencil/core";
2
- import { isBlankInput, isTableBarColumnWidth, isTableCategoryWidth, isValidBoolean, isValidDataFormat, isValidDateFormat, isValidDirection, isValidInteger, isValidMeasureScale, isValidMeasureType, isValidNumber, isValidTableType, validateAttributesJsonStr, validateBarColumnsList, validateColumnThereOfJsonStr, validateOrderList, validatePartOfJsonStr, validateScenarioList, validateThereOfJsonStr, validateVariancesList, } from "../../utils/validate";
2
+ import { isBlankInput, isTableBarColumnWidth, isTableCategoryWidth, isValidBoolean, isValidDataFormat, isValidDateFormat, isValidDirection, isValidInteger, isValidMeasureScale, isValidMeasureType, isValidTableType, validateAttributesJsonStr, validateBarColumnsList, validateColumnThereOfJsonStr, validateOrderList, validatePartOfJsonStr, validateScenarioList, validateThereOfJsonStr, validateVariancesList, } from "../../utils/validate";
3
3
  import withDataset from "../../utils/withDataset";
4
4
  import withComponentStatus from "../../utils/withComponentStatus";
5
5
  import withScalingGroup from "../../utils/withScalingGroup";
@@ -11,7 +11,7 @@ import withRuleSet from "../../utils/withRuleSet";
11
11
  import withHasError from "../../utils/withHasError";
12
12
  import withInheritedProps, { isInheritedValue } from "../../utils/withInheritedProps";
13
13
  import { getParentDimensions } from "../../utils/parentDimensions";
14
- import { parseScaling } from "../../utils/scaling";
14
+ import { formatScalingValue, parseScaling, resolveScalingValue } from "../../utils/scaling";
15
15
  import { observeParentResize } from "../../utils/layoutObserver";
16
16
  import { BAR_COLUMN_WIDTH_EM, DataFormat, I18nMode, MeasureType, TableBarColumnWidth, TableCategoryWidth, } from "../../utils/constants";
17
17
  import { TableType } from "./utils/model";
@@ -80,31 +80,40 @@ export class Table {
80
80
  */
81
81
  this.barColumnWidth = "w10";
82
82
  /**
83
- * Pixels per unit for absolute variance bar charts (ΔPY).
84
- * Controls bar width: barWidth = value × unitScaling.
83
+ * Data units displayed per 1 em of bar length for absolute variance bar
84
+ * charts (ΔPY) — map-scale semantics: a larger value means smaller bars.
85
85
  * Bars exceeding barColumnWidth are shown with an arrow indicator.
86
- * <br /><br />
87
- * Accepts a number, `"auto"`, or a `<bn-scaling-group>` name for synchronized scaling.
88
- * <br /><br />
89
- * Default: 0.01
90
86
  *
91
- * @example unit-scaling="0.01"
87
+ * | Value | Behavior |
88
+ * |------------------|----------------------------------------------------------------|
89
+ * | `"auto"` | Auto-fit the largest bar to the bar column width |
90
+ * | `"250000"`, `"1M"` | Units per em; optional SI suffix `k`/`K`/`M`/`G`/`T` |
91
+ * | group name | References a `<bn-scaling-group>` for synchronized scaling |
92
+ * | invalid / unknown | Auto-fit + `AUTO_unitScaling` warning |
93
+ *
94
+ * Default: `"100"` (1 em of bar represents 100 units)
95
+ *
96
+ * @example unit-scaling="1M"
92
97
  * @example unit-scaling="revenue-scale"
93
98
  */
94
- this.unitScaling = 0.01;
99
+ this.unitScaling = "100";
95
100
  /**
96
- * Scaling for relative variance pin charts (ΔPY%).
97
- * <br /><br />
98
- * Accepts a number, `"auto"`, or a `<bn-scaling-group>` name for synchronized scaling.
99
- * <br /><br />
100
- * Example: 0.5 means 100% = 50 pixels width.
101
- * <br /><br />
102
- * Default: 0.5
101
+ * Percentage points displayed per 1 em of pin length for relative variance
102
+ * pin charts (ΔPY%) — a larger value means shorter pins.
103
103
  *
104
- * @example percentage-scaling="0.5"
104
+ * | Value | Behavior |
105
+ * |------------------|----------------------------------------------------------------|
106
+ * | `"auto"` | Auto-fit the largest pin to the pin area |
107
+ * | `"10"`, `"2.5"` | Percentage points per em; optional SI suffix `k`/`K`/`M`/`G`/`T` |
108
+ * | group name | References a `<bn-scaling-group>` for synchronized scaling |
109
+ * | invalid / unknown | Auto-fit + `AUTO_percentageScaling` warning |
110
+ *
111
+ * Default: `"2"` (a +2 % variance pin is 1 em long)
112
+ *
113
+ * @example percentage-scaling="10"
105
114
  * @example percentage-scaling="pct-scale"
106
115
  */
107
- this.percentageScaling = 0.5;
116
+ this.percentageScaling = "2";
108
117
  // Global scaling groups map - can be populated externally for shared scaling across components
109
118
  this.pixelPerUnitGroupMap = new Map();
110
119
  /**
@@ -218,7 +227,7 @@ export class Table {
218
227
  * original value.
219
228
  * <br /><br />
220
229
  * values: <br />
221
- * ```_ // k // M // G // T // P // E // Z // Y // m // μ // n // p // P // f // a // z // y // GREATEST // LEAST```
230
+ * ```_ // k // M // G // T // P // E // Z // Y // m // my (μ) // n // p // f // a // z // y // GREATEST // LEAST```
222
231
  * <br /><br />
223
232
  * SiPrefix overview:
224
233
  * ``` "Y": 1E+24,```<br />
@@ -231,7 +240,7 @@ export class Table {
231
240
  * ``` "k": 1000,```<br />
232
241
  * <br />
233
242
  * ``` "m": 0.001,```<br />
234
- * ``` "μ": 0.000001,```<br />
243
+ * ``` "my" (μ): 0.000001,```<br />
235
244
  * ``` "n": 0.000000001,```<br />
236
245
  * ``` "p": 0.000000000001,```<br />
237
246
  * ``` "f": 0.000000000000001,```<br />
@@ -303,6 +312,39 @@ export class Table {
303
312
  */
304
313
  this.tableAttributes = "";
305
314
  this._autoScaleGuard = false;
315
+ this.autoUnitWarningActive = false;
316
+ this.autoPctWarningActive = false;
317
+ /**
318
+ * Receives the auto-fitted scaling values from the inner ibcs-table
319
+ * (em per unit / em per percentage point) and surfaces them in the AUTO_*
320
+ * warnings, converted back to the attribute's units-per-em form so users
321
+ * can copy them into a bn-scaling-group.
322
+ */
323
+ this.handleAutoScalingReport = (report) => {
324
+ const changed = (next, last) => last === undefined || Math.abs(next - last) > Math.abs(next) * 1e-3;
325
+ if (report.unit !== undefined && report.unit > 0 && this.autoUnitWarningActive) {
326
+ const unitsPerEm = 1 / report.unit;
327
+ if (changed(unitsPerEm, this.lastReportedUnitsPerEm)) {
328
+ this.lastReportedUnitsPerEm = unitsPerEm;
329
+ this.errors.addOrReplace({
330
+ id: "AUTO_unitScaling",
331
+ type: "warning",
332
+ message: `unit-scaling: invalid value "${this.unitScaling}" — auto-fitted to 1 em ≈ ${formatScalingValue(unitsPerEm)} units.`,
333
+ });
334
+ }
335
+ }
336
+ if (report.percentage !== undefined && report.percentage > 0 && this.autoPctWarningActive) {
337
+ const ppPerEm = 1 / report.percentage;
338
+ if (changed(ppPerEm, this.lastReportedPpPerEm)) {
339
+ this.lastReportedPpPerEm = ppPerEm;
340
+ this.errors.addOrReplace({
341
+ id: "AUTO_percentageScaling",
342
+ type: "warning",
343
+ message: `percentage-scaling: invalid value "${this.percentageScaling}" — auto-fitted to 1 em ≈ ${formatScalingValue(ppPerEm)} percentage points.`,
344
+ });
345
+ }
346
+ }
347
+ };
306
348
  withStyled(this);
307
349
  withComponentStatus(this);
308
350
  this.errors = withHasError(this);
@@ -397,8 +439,7 @@ export class Table {
397
439
  }
398
440
  validateUnitScaling(newValue) {
399
441
  const errId = "ERR_unitScaling";
400
- const isAuto = (newValue === null || newValue === void 0 ? void 0 : newValue.toString().trim().toLowerCase()) === "auto";
401
- if (!isAuto && !isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
442
+ if (resolveScalingValue(newValue, this.pixelPerUnitGroupMap).kind === "invalid") {
402
443
  this.errors.addOrReplace({
403
444
  id: errId,
404
445
  type: "warning",
@@ -411,8 +452,7 @@ export class Table {
411
452
  }
412
453
  validatePercentageScaling(newValue) {
413
454
  const errId = "ERR_percentageScaling";
414
- const isAuto = (newValue === null || newValue === void 0 ? void 0 : newValue.toString().trim().toLowerCase()) === "auto";
415
- if (!isAuto && !isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
455
+ if (resolveScalingValue(newValue, this.pixelPerUnitGroupMap).kind === "invalid") {
416
456
  this.errors.addOrReplace({
417
457
  id: errId,
418
458
  type: "warning",
@@ -1047,24 +1087,50 @@ export class Table {
1047
1087
  return this.barColumns.split(",").map((col) => col.trim());
1048
1088
  }
1049
1089
  prepareUnitScaling() {
1050
- var _a;
1051
- if (this.pixelPerUnitGroupMap.has(this.unitScaling)) {
1052
- return this.pixelPerUnitGroupMap.get(this.unitScaling);
1053
- }
1054
- if (((_a = this.unitScaling) === null || _a === void 0 ? void 0 : _a.toString().trim().toLowerCase()) === "auto") {
1090
+ const resolved = resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap);
1091
+ if (resolved.kind === "value") {
1092
+ this.errors.remove("AUTO_unitScaling");
1093
+ this.autoUnitWarningActive = false;
1094
+ this.lastReportedUnitsPerEm = undefined;
1095
+ // Inner ibcs-table expects em per unit; the attribute is units per em.
1096
+ return 1 / resolved.value;
1097
+ }
1098
+ if (resolved.kind === "auto") {
1099
+ this.errors.remove("AUTO_unitScaling");
1100
+ this.autoUnitWarningActive = false;
1101
+ this.lastReportedUnitsPerEm = undefined;
1055
1102
  return 0;
1056
1103
  }
1057
- return Number(this.unitScaling);
1104
+ this.autoUnitWarningActive = true;
1105
+ this.errors.addOrReplace({
1106
+ id: "AUTO_unitScaling",
1107
+ type: "warning",
1108
+ message: `unit-scaling: invalid value "${resolved.raw}" — auto-fitting to the bar column width.`,
1109
+ });
1110
+ return 0;
1058
1111
  }
1059
1112
  preparePercentageScaling() {
1060
- var _a;
1061
- if (this.pixelPerUnitGroupMap.has(this.percentageScaling)) {
1062
- return this.pixelPerUnitGroupMap.get(this.percentageScaling);
1063
- }
1064
- if (((_a = this.percentageScaling) === null || _a === void 0 ? void 0 : _a.toString().trim().toLowerCase()) === "auto") {
1113
+ const resolved = resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap);
1114
+ if (resolved.kind === "value") {
1115
+ this.errors.remove("AUTO_percentageScaling");
1116
+ this.autoPctWarningActive = false;
1117
+ this.lastReportedPpPerEm = undefined;
1118
+ // Inner ibcs-table expects em per percentage point.
1119
+ return 1 / resolved.value;
1120
+ }
1121
+ if (resolved.kind === "auto") {
1122
+ this.errors.remove("AUTO_percentageScaling");
1123
+ this.autoPctWarningActive = false;
1124
+ this.lastReportedPpPerEm = undefined;
1065
1125
  return 0;
1066
1126
  }
1067
- return Number(this.percentageScaling);
1127
+ this.autoPctWarningActive = true;
1128
+ this.errors.addOrReplace({
1129
+ id: "AUTO_percentageScaling",
1130
+ type: "warning",
1131
+ message: `percentage-scaling: invalid value "${resolved.raw}" — auto-fitting to the pin area.`,
1132
+ });
1133
+ return 0;
1068
1134
  }
1069
1135
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1070
1136
  getDataStructure() {
@@ -1127,7 +1193,7 @@ export class Table {
1127
1193
  render() {
1128
1194
  const fontStyles = this.getFontStyles();
1129
1195
  const effectiveFactor = this.getEffectiveScaleFactor();
1130
- return (h(Host, { key: '71fe0e81888c25970edcaab0803cbdbd3b73d1fd', style: fontStyles }, h("div", { key: '5afa87ac3a8b4d5864bb34acb8a4e84de12261ea' }, h("ibcs-table", { key: '8a276ca87e342f8c3b3aac76c9915681c4b2a005', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
1196
+ return (h(Host, { key: 'de215fb339b9b38a57da35da8dce380641cd9d35', style: fontStyles }, h("div", { key: '6628fdc73598c2f9bf313184ae62703b6587c35f' }, h("ibcs-table", { key: 'f9a93bdfdfef7861604ba3a880ade5e2cafdd6dc', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
1131
1197
  }
1132
1198
  static get is() { return "bn-table"; }
1133
1199
  static get encapsulation() { return "shadow"; }
@@ -1353,18 +1419,18 @@ export class Table {
1353
1419
  "docs": {
1354
1420
  "tags": [{
1355
1421
  "name": "example",
1356
- "text": "unit-scaling=\"0.01\""
1422
+ "text": "unit-scaling=\"1M\""
1357
1423
  }, {
1358
1424
  "name": "example",
1359
1425
  "text": "unit-scaling=\"revenue-scale\""
1360
1426
  }],
1361
- "text": "Pixels per unit for absolute variance bar charts (\u0394PY).\nControls bar width: barWidth = value \u00D7 unitScaling.\nBars exceeding barColumnWidth are shown with an arrow indicator.\n<br /><br />\nAccepts a number, `\"auto\"`, or a `<bn-scaling-group>` name for synchronized scaling.\n<br /><br />\nDefault: 0.01"
1427
+ "text": "Data units displayed per 1 em of bar length for absolute variance bar\ncharts (\u0394PY) \u2014 map-scale semantics: a larger value means smaller bars.\nBars exceeding barColumnWidth are shown with an arrow indicator.\n\n| Value | Behavior |\n|------------------|----------------------------------------------------------------|\n| `\"auto\"` | Auto-fit the largest bar to the bar column width |\n| `\"250000\"`, `\"1M\"` | Units per em; optional SI suffix `k`/`K`/`M`/`G`/`T` |\n| group name | References a `<bn-scaling-group>` for synchronized scaling |\n| invalid / unknown | Auto-fit + `AUTO_unitScaling` warning |\n\nDefault: `\"100\"` (1 em of bar represents 100 units)"
1362
1428
  },
1363
1429
  "getter": false,
1364
1430
  "setter": false,
1365
1431
  "reflect": false,
1366
1432
  "attribute": "unit-scaling",
1367
- "defaultValue": "0.01"
1433
+ "defaultValue": "\"100\""
1368
1434
  },
1369
1435
  "percentageScaling": {
1370
1436
  "type": "any",
@@ -1379,18 +1445,18 @@ export class Table {
1379
1445
  "docs": {
1380
1446
  "tags": [{
1381
1447
  "name": "example",
1382
- "text": "percentage-scaling=\"0.5\""
1448
+ "text": "percentage-scaling=\"10\""
1383
1449
  }, {
1384
1450
  "name": "example",
1385
1451
  "text": "percentage-scaling=\"pct-scale\""
1386
1452
  }],
1387
- "text": "Scaling for relative variance pin charts (\u0394PY%).\n<br /><br />\nAccepts a number, `\"auto\"`, or a `<bn-scaling-group>` name for synchronized scaling.\n<br /><br />\nExample: 0.5 means 100% = 50 pixels width.\n<br /><br />\nDefault: 0.5"
1453
+ "text": "Percentage points displayed per 1 em of pin length for relative variance\npin charts (\u0394PY%) \u2014 a larger value means shorter pins.\n\n| Value | Behavior |\n|------------------|----------------------------------------------------------------|\n| `\"auto\"` | Auto-fit the largest pin to the pin area |\n| `\"10\"`, `\"2.5\"` | Percentage points per em; optional SI suffix `k`/`K`/`M`/`G`/`T` |\n| group name | References a `<bn-scaling-group>` for synchronized scaling |\n| invalid / unknown | Auto-fit + `AUTO_percentageScaling` warning |\n\nDefault: `\"2\"` (a +2 % variance pin is 1 em long)"
1388
1454
  },
1389
1455
  "getter": false,
1390
1456
  "setter": false,
1391
1457
  "reflect": false,
1392
1458
  "attribute": "percentage-scaling",
1393
- "defaultValue": "0.5"
1459
+ "defaultValue": "\"2\""
1394
1460
  },
1395
1461
  "dataFormat": {
1396
1462
  "type": "string",
@@ -1624,7 +1690,7 @@ export class Table {
1624
1690
  "optional": false,
1625
1691
  "docs": {
1626
1692
  "tags": [],
1627
- "text": "Sets the SiPrefix of the Mesaurements and converts the\noriginal value.\n<br /><br />\nvalues: <br />\n```_ // k // M // G // T // P // E // Z // Y // m // \u03BC // n // p // P // f // a // z // y // GREATEST // LEAST```\n<br /><br />\nSiPrefix overview:\n``` \"Y\": 1E+24,```<br />\n``` \"Z\": 1E+21,```<br />\n``` \"E\": 1E+18,```<br />\n``` \"P\": 1E+15,```<br />\n``` \"T\": 1E+12,```<br />\n``` \"G\": 1000000000,```<br />\n``` \"M\": 1000000,```<br />\n``` \"k\": 1000,```<br />\n<br />\n``` \"m\": 0.001,```<br />\n``` \"\u03BC\": 0.000001,```<br />\n``` \"n\": 0.000000001,```<br />\n``` \"p\": 0.000000000001,```<br />\n``` \"f\": 0.000000000000001,```<br />\n``` \"a\": 0.000000000000000001,```<br />\n``` \"z\": 0.000000000000000000001,```<br />\n``` \"y\": 0.000000000000000000000001,```<br />\n<br /><br />\nSpecial modes:\n```GREATEST``` seaches for the bigest (farest to zero) Value in the dataset and sets this value to SiPrefix<br />\n```LEAST``` searches for smallest (closest to zero) Value in the dataset and sets this value to SiPrefix<br />\n<br /><br />\n```_``` is the value for no SiPrefix the value is displayed as in the dataset stored."
1693
+ "text": "Sets the SiPrefix of the Mesaurements and converts the\noriginal value.\n<br /><br />\nvalues: <br />\n```_ // k // M // G // T // P // E // Z // Y // m // my (\u03BC) // n // p // f // a // z // y // GREATEST // LEAST```\n<br /><br />\nSiPrefix overview:\n``` \"Y\": 1E+24,```<br />\n``` \"Z\": 1E+21,```<br />\n``` \"E\": 1E+18,```<br />\n``` \"P\": 1E+15,```<br />\n``` \"T\": 1E+12,```<br />\n``` \"G\": 1000000000,```<br />\n``` \"M\": 1000000,```<br />\n``` \"k\": 1000,```<br />\n<br />\n``` \"m\": 0.001,```<br />\n``` \"my\" (\u03BC): 0.000001,```<br />\n``` \"n\": 0.000000001,```<br />\n``` \"p\": 0.000000000001,```<br />\n``` \"f\": 0.000000000000001,```<br />\n``` \"a\": 0.000000000000000001,```<br />\n``` \"z\": 0.000000000000000000001,```<br />\n``` \"y\": 0.000000000000000000000001,```<br />\n<br /><br />\nSpecial modes:\n```GREATEST``` seaches for the bigest (farest to zero) Value in the dataset and sets this value to SiPrefix<br />\n```LEAST``` searches for smallest (closest to zero) Value in the dataset and sets this value to SiPrefix<br />\n<br /><br />\n```_``` is the value for no SiPrefix the value is displayed as in the dataset stored."
1628
1694
  },
1629
1695
  "getter": false,
1630
1696
  "setter": false,
@@ -135,6 +135,17 @@ export class IbcsTable {
135
135
  * Scenario styles (ac, pp, fc, pl) use barStyles for IBCS-compliant grayscale coloring.
136
136
  */
137
137
  prepareBarChartStyles() {
138
+ var _a;
139
+ const autoUnit = !(this.unitScaling > 0);
140
+ const autoPercent = !(this.percentageScaling > 0);
141
+ const resolvedUnit = autoUnit ? this.autoUnitScaling() : this.unitScaling;
142
+ const resolvedPercent = autoPercent ? this.autoPercentageScaling() : this.percentageScaling;
143
+ if (autoUnit || autoPercent) {
144
+ (_a = this.reportAutoScaling) === null || _a === void 0 ? void 0 : _a.call(this, {
145
+ unit: autoUnit ? resolvedUnit : undefined,
146
+ percentage: autoPercent ? resolvedPercent : undefined,
147
+ });
148
+ }
138
149
  return this.componentStyle(($) => {
139
150
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
140
151
  const varianceStyles = (_a = $["bn-chart-time"]) === null || _a === void 0 ? void 0 : _a["varianceStyles"];
@@ -191,8 +202,8 @@ export class IbcsTable {
191
202
  fontColor: ((_z = $["global"]) === null || _z === void 0 ? void 0 : _z["fontColor"]) || "#000000",
192
203
  fontSize: (((_0 = $["global"]) === null || _0 === void 0 ? void 0 : _0["fontSizePx"]) || 13.3333) * 0.85 * this.scaleFactor,
193
204
  fontFamily: ((_1 = $["global"]) === null || _1 === void 0 ? void 0 : _1["fontFamily"]) || "'Noto Sans', sans-serif",
194
- unitScaling: this.unitScaling > 0 ? this.unitScaling : this.autoUnitScaling(),
195
- percentageScaling: this.percentageScaling > 0 ? this.percentageScaling : this.autoPercentageScaling(),
205
+ unitScaling: resolvedUnit,
206
+ percentageScaling: resolvedPercent,
196
207
  scaleFactor: this.scaleFactor,
197
208
  };
198
209
  });
@@ -946,6 +957,30 @@ export class IbcsTable {
946
957
  "attribute": "percentage-scaling",
947
958
  "defaultValue": "0.5"
948
959
  },
960
+ "reportAutoScaling": {
961
+ "type": "unknown",
962
+ "mutable": false,
963
+ "complexType": {
964
+ "original": "(report: AutoScalingReport) => void",
965
+ "resolved": "(report: AutoScalingReport) => void",
966
+ "references": {
967
+ "AutoScalingReport": {
968
+ "location": "import",
969
+ "path": "../../utils/scaling",
970
+ "id": "src/utils/scaling.ts::AutoScalingReport",
971
+ "referenceLocation": "AutoScalingReport"
972
+ }
973
+ }
974
+ },
975
+ "required": false,
976
+ "optional": true,
977
+ "docs": {
978
+ "tags": [],
979
+ "text": "Internal wrapper channel: called with the auto-fitted scaling values\n(em per unit / em per percentage point) whenever one of them was\nauto-resolved, so the outer `bn-table` can surface them in its AUTO_*\nwarnings. Not for end users."
980
+ },
981
+ "getter": false,
982
+ "setter": false
983
+ },
949
984
  "scaleFactor": {
950
985
  "type": "number",
951
986
  "mutable": false,
@@ -13,8 +13,8 @@ export const DEFAULT_STYLES = {
13
13
  fontColor: "#000000",
14
14
  fontSize: 11,
15
15
  fontFamily: "'Noto Sans', sans-serif",
16
- unitScaling: 0.01, // Default: 1000 units = 10 pixels
17
- percentageScaling: 0.5, // Default: 100% = 50 pixels
16
+ unitScaling: 0.01, // Default: 100 units per em of bar
17
+ percentageScaling: 0.5, // Default: 2 percentage points per em of pin
18
18
  scaleFactor: 1,
19
19
  };
20
20
  export const AXIS_COLOR = "#666666";
@@ -50,6 +50,10 @@ export class DataAnalyzer {
50
50
  if (mode === "_") {
51
51
  return new SiPrefix();
52
52
  }
53
+ // Accept the Unicode micro sign as an alias for the ASCII "my" key.
54
+ if (mode === "μ") {
55
+ mode = "my";
56
+ }
53
57
  if (mode != null) {
54
58
  if ([...this.unitsLeast, ...this.unitsGreat].includes(mode)) {
55
59
  return this.lookupPrefix(mode);
@@ -84,17 +88,22 @@ export class DataAnalyzer {
84
88
  }
85
89
  return this.determinePrefix(Math.abs(num));
86
90
  }
87
- /** Maps an absolute numeric value to the best-fitting SI prefix based on digit count. */
91
+ /**
92
+ * Maps an absolute numeric value to the best-fitting SI prefix based on
93
+ * its decimal magnitude. Values in (0.001, 1000) keep the identity prefix.
94
+ * Magnitudes beyond the covered SI range clamp to the outermost prefix.
95
+ */
88
96
  static determinePrefix(num) {
97
+ if (!Number.isFinite(num) || num <= 0) {
98
+ return new SiPrefix();
99
+ }
89
100
  if (num >= 1000) {
90
- const floor = Math.floor(Math.floor(Math.abs(num)).toString().length / 3);
91
- const value = +Math.pow(1000, floor);
92
- return new SiPrefix(this.unitsGreat[floor - 1], value);
101
+ const idx = Math.min(Math.floor(Math.log10(num) / 3), this.unitsGreat.length) - 1;
102
+ return new SiPrefix(this.unitsGreat[idx], Math.pow(1000, idx + 1));
93
103
  }
94
104
  if (num <= 0.001) {
95
- const floor = Math.floor(Math.abs(num).toString().length / 3);
96
- const value = +(1 / Math.pow(1000, floor));
97
- return new SiPrefix(this.unitsLeast[floor - 1], value);
105
+ const idx = Math.min(-Math.floor(Math.log10(num) / 3), this.unitsLeast.length) - 1;
106
+ return new SiPrefix(this.unitsLeast[idx], Math.pow(1000, -(idx + 1)));
98
107
  }
99
108
  return new SiPrefix();
100
109
  }
@@ -106,4 +115,4 @@ export class DataAnalyzer {
106
115
  /** SI prefixes for large numbers, ordered by magnitude (k=10^3 .. Y=10^24). */
107
116
  DataAnalyzer.unitsGreat = ["k", "M", "G", "T", "P", "E", "Z", "Y"];
108
117
  /** SI prefixes for small numbers, ordered by magnitude (m=10^-3 .. y=10^-24). */
109
- DataAnalyzer.unitsLeast = ["m", "my", "n", "p", "P", "f", "a", "z", "y"];
118
+ DataAnalyzer.unitsLeast = ["m", "my", "n", "p", "f", "a", "z", "y"];