@bino-bi/bn-template-engine 1.0.0-next.21 → 1.0.0-next.23

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 (164) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/{p-28d5c266.entry.js → p-0a49cf00.entry.js} +1 -1
  3. package/dist/bn-template-engine/{p-b9e94127.entry.js → p-22b8d044.entry.js} +1 -1
  4. package/dist/bn-template-engine/{p-6c7f0076.entry.js → p-251bb53d.entry.js} +1 -1
  5. package/dist/bn-template-engine/p-2aed639e.entry.js +1 -0
  6. package/dist/bn-template-engine/{p-7e9dbc93.entry.js → p-4616b879.entry.js} +1 -1
  7. package/dist/bn-template-engine/{p-99477a27.entry.js → p-629edcca.entry.js} +1 -1
  8. package/dist/bn-template-engine/p-686d8e44.entry.js +1 -0
  9. package/dist/bn-template-engine/{p-a4ea9a79.entry.js → p-68aa61cc.entry.js} +1 -1
  10. package/dist/bn-template-engine/{p-DwYUTvvI.js → p-B5x8M8OC.js} +1 -1
  11. package/dist/bn-template-engine/{p-fFtEvsY-.js → p-BGrnfif3.js} +1 -1
  12. package/dist/bn-template-engine/{p-6lOdN-fB.js → p-BVfLus3u.js} +1 -1
  13. package/dist/bn-template-engine/{p-CJThzFZm.js → p-BcZ5GQZ8.js} +1 -1
  14. package/dist/bn-template-engine/{p-CYE0I1Mx.js → p-Bca5V28_.js} +1 -1
  15. package/dist/bn-template-engine/p-C5UYpZUU.js +2 -0
  16. package/dist/bn-template-engine/{p-BgIpdpfH.js → p-C7T4DAAW.js} +1 -1
  17. package/dist/bn-template-engine/p-CDo04UEU.js +1 -0
  18. package/dist/bn-template-engine/p-CTrNbSXN.js +1 -0
  19. package/dist/bn-template-engine/{p-C5uvAEKI.js → p-CbciPY-M.js} +1 -1
  20. package/dist/bn-template-engine/{p-BpWWgN6k.js → p-CuR4S456.js} +1 -1
  21. package/dist/bn-template-engine/p-DWtTjg0f.js +1 -0
  22. package/dist/bn-template-engine/{p-eEfqksk-.js → p-DdqXNsKP.js} +1 -1
  23. package/dist/bn-template-engine/{p-B4JfKvVT.js → p-DtLI_CzV.js} +1 -1
  24. package/dist/bn-template-engine/p-UtNHLX1j.js +1 -0
  25. package/dist/bn-template-engine/{p-ba912130.entry.js → p-aecb5de3.entry.js} +1 -1
  26. package/dist/bn-template-engine/{p-687032d5.entry.js → p-ba43d46e.entry.js} +1 -1
  27. package/dist/bn-template-engine/{p-6077155f.entry.js → p-c476e7bb.entry.js} +1 -1
  28. package/dist/bn-template-engine/{p-2d3ea756.entry.js → p-d7c670ec.entry.js} +1 -1
  29. package/dist/bn-template-engine/{p-a1380d7c.entry.js → p-e4a584a8.entry.js} +1 -1
  30. package/dist/bn-template-engine/{p-de29986f.entry.js → p-f12fb09b.entry.js} +1 -1
  31. package/dist/bn-template-engine/p-f9a721bb.entry.js +1 -0
  32. package/dist/cjs/{AxisConfig-D7CAyPLO.js → AxisConfig-DmP4U3JM.js} +1 -1
  33. package/dist/cjs/{LabelCollisionManager-DkdQ9Xdg.js → LabelCollisionManager-Cet3WPm0.js} +2 -2
  34. package/dist/cjs/{Order-IPfAP0q8.js → Order-DlKLywO_.js} +1 -1
  35. package/dist/cjs/{SVGStyle-BD8jApd4.js → SVGStyle-D78RaNnj.js} +2 -2
  36. package/dist/cjs/{SVGVariancesStyleGroup-BaWzR951.js → SVGVariancesStyleGroup-XvNAnYYA.js} +1 -1
  37. package/dist/cjs/{VarianceMeasure-BBWTgv2e.js → VarianceMeasure-BfZLlICl.js} +4 -4
  38. package/dist/cjs/{XYChartDataRow-BoR0CTfl.js → XYChartDataRow-B0NNOqxB.js} +4 -4
  39. package/dist/cjs/bn-asset_21.cjs.entry.js +1052 -314
  40. package/dist/cjs/bn-chart-bubble.cjs.entry.js +25 -15
  41. package/dist/cjs/bn-chart-bullet.cjs.entry.js +9 -9
  42. package/dist/cjs/bn-chart-scatter.cjs.entry.js +9 -9
  43. package/dist/cjs/bn-grid.cjs.entry.js +6 -6
  44. package/dist/cjs/bn-image.cjs.entry.js +6 -6
  45. package/dist/cjs/bn-internationalization.cjs.entry.js +4 -4
  46. package/dist/cjs/bn-ruleset.cjs.entry.js +4 -4
  47. package/dist/cjs/bn-template-engine.cjs.js +3 -3
  48. package/dist/cjs/bn-template.cjs.entry.js +2 -2
  49. package/dist/cjs/bn-text.cjs.entry.js +7 -7
  50. package/dist/cjs/bn-tree.cjs.entry.js +6 -6
  51. package/dist/cjs/{context-protocol-BBhT9B52.js → context-protocol-DeLmu5s2.js} +1 -1
  52. package/dist/cjs/editor-companion.cjs.entry.js +2 -2
  53. package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +6 -6
  54. package/dist/cjs/ibcs-chart-bullet.cjs.entry.js +6 -6
  55. package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +6 -6
  56. package/dist/cjs/{index-CDKG4xmO.js → index-C1Z9vO7z.js} +61 -19
  57. package/dist/cjs/{layoutObserver-DUYYkDMQ.js → layoutObserver-CrzQQGpv.js} +5 -5
  58. package/dist/cjs/loader.cjs.js +2 -2
  59. package/dist/cjs/{scaling-BIJQ2NV1.js → scaling-JAU6IJnR.js} +85 -3
  60. package/dist/cjs/{withBodyObserver-BKUE_ypL.js → withBodyObserver-DJO98AJ-.js} +2 -2
  61. package/dist/cjs/{withHasError-Cl2gTQzA.js → withHasError-BdDmiOXM.js} +1 -1
  62. package/dist/cjs/{withScalingGroup-D5clRvRe.js → withScalingGroup-Bu5gatHT.js} +3 -3
  63. package/dist/cjs/{withStyled-Cm9dWQhu.js → withStyled-50UepUwV.js} +8 -8
  64. package/dist/collection/collection-manifest.json +1 -1
  65. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +15 -5
  66. package/dist/collection/components/bn-chart-structure/bn-chart-structure.css +6 -0
  67. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +149 -57
  68. package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +135 -28
  69. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +30 -19
  70. package/dist/collection/components/bn-chart-time/bn-chart-time.js +186 -49
  71. package/dist/collection/components/bn-chart-time/ibcs-chart-time.css +9 -3
  72. package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +141 -22
  73. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +36 -0
  74. package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +76 -19
  75. package/dist/collection/components/bn-table/bn-table.js +121 -49
  76. package/dist/collection/components/bn-table/ibcs-table.js +83 -42
  77. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +20 -34
  78. package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +4 -5
  79. package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +89 -0
  80. package/dist/collection/utils/autoFit.js +63 -0
  81. package/dist/collection/utils/constants.js +3 -3
  82. package/dist/collection/utils/dataAnalyzer.js +17 -8
  83. package/dist/collection/utils/scaling.js +79 -0
  84. package/dist/collection/utils/validate.js +3 -3
  85. package/dist/components/DataFormatDigits.js +1 -1
  86. package/dist/components/autoFit.js +1 -0
  87. package/dist/components/bn-chart-bubble.js +1 -1
  88. package/dist/components/bn-chart-bullet.js +1 -1
  89. package/dist/components/bn-chart-scatter.js +1 -1
  90. package/dist/components/bn-chart-structure.js +1 -1
  91. package/dist/components/bn-chart-time.js +1 -1
  92. package/dist/components/bn-grid.js +1 -1
  93. package/dist/components/bn-scaling-group.js +1 -1
  94. package/dist/components/bn-table.js +1 -1
  95. package/dist/components/bn-text.js +1 -1
  96. package/dist/components/bn-tree.js +1 -1
  97. package/dist/components/ibcs-chart-structure2.js +1 -1
  98. package/dist/components/ibcs-chart-time2.js +1 -1
  99. package/dist/components/ibcs-table2.js +1 -1
  100. package/dist/components/scaling.js +1 -0
  101. package/dist/components/validate.js +1 -1
  102. package/dist/components/withDataset.js +1 -1
  103. package/dist/components/withStyled.js +1 -1
  104. package/dist/esm/{AxisConfig-ByIP5J-9.js → AxisConfig-Cjy_RANi.js} +1 -1
  105. package/dist/esm/{LabelCollisionManager-DaNiDiM9.js → LabelCollisionManager-B_NUM9yq.js} +2 -2
  106. package/dist/esm/{Order-BQeJE_yi.js → Order-B-aF6Rwn.js} +1 -1
  107. package/dist/esm/{SVGStyle-BwBlY3Km.js → SVGStyle-8FfAtUF-.js} +2 -2
  108. package/dist/esm/{SVGVariancesStyleGroup-BpGW4CvN.js → SVGVariancesStyleGroup-DD4mIOjT.js} +1 -1
  109. package/dist/esm/{VarianceMeasure-CE3N8Bea.js → VarianceMeasure-DLOuIIJ7.js} +4 -4
  110. package/dist/esm/{XYChartDataRow-DeMI1JKU.js → XYChartDataRow-CKfILBFG.js} +4 -4
  111. package/dist/esm/bn-asset_21.entry.js +1052 -314
  112. package/dist/esm/bn-chart-bubble.entry.js +25 -15
  113. package/dist/esm/bn-chart-bullet.entry.js +9 -9
  114. package/dist/esm/bn-chart-scatter.entry.js +9 -9
  115. package/dist/esm/bn-grid.entry.js +6 -6
  116. package/dist/esm/bn-image.entry.js +6 -6
  117. package/dist/esm/bn-internationalization.entry.js +4 -4
  118. package/dist/esm/bn-ruleset.entry.js +4 -4
  119. package/dist/esm/bn-template-engine.js +4 -4
  120. package/dist/esm/bn-template.entry.js +2 -2
  121. package/dist/esm/bn-text.entry.js +7 -7
  122. package/dist/esm/bn-tree.entry.js +6 -6
  123. package/dist/esm/{context-protocol-d8MHrEo8.js → context-protocol-BoEL0caI.js} +1 -1
  124. package/dist/esm/editor-companion.entry.js +2 -2
  125. package/dist/esm/ibcs-chart-bubble.entry.js +6 -6
  126. package/dist/esm/ibcs-chart-bullet.entry.js +6 -6
  127. package/dist/esm/ibcs-chart-scatter.entry.js +6 -6
  128. package/dist/esm/{index-B_d-jp99.js → index-C5UYpZUU.js} +61 -19
  129. package/dist/esm/{layoutObserver-BJBEyhNf.js → layoutObserver-cgIXg2sg.js} +5 -5
  130. package/dist/esm/loader.js +3 -3
  131. package/dist/esm/{scaling-BGnpSN1j.js → scaling-CxyNpMQM.js} +83 -4
  132. package/dist/esm/{withBodyObserver-IokS6fHD.js → withBodyObserver-Cb9ZC5_J.js} +2 -2
  133. package/dist/esm/{withHasError-DW_vMDUp.js → withHasError-Bh1Viz52.js} +1 -1
  134. package/dist/esm/{withScalingGroup-CC3UcvC5.js → withScalingGroup-Yv9nGGe1.js} +3 -3
  135. package/dist/esm/{withStyled-2l5Tx3cf.js → withStyled-By9Jd-Oy.js} +8 -8
  136. package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +5 -2
  137. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +47 -19
  138. package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +17 -3
  139. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +11 -3
  140. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +52 -18
  141. package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +18 -3
  142. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +12 -0
  143. package/dist/types/components/bn-scaling-group/bn-scaling-group.d.ts +28 -8
  144. package/dist/types/components/bn-table/bn-table.d.ts +45 -19
  145. package/dist/types/components/bn-table/ibcs-table.d.ts +23 -6
  146. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +9 -1
  147. package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +51 -0
  148. package/dist/types/components.d.ts +91 -55
  149. package/dist/types/stencil-public-runtime.d.ts +1 -0
  150. package/dist/types/utils/autoFit.d.ts +79 -0
  151. package/dist/types/utils/constants.d.ts +3 -3
  152. package/dist/types/utils/dataAnalyzer.d.ts +5 -1
  153. package/dist/types/utils/scaling.d.ts +63 -0
  154. package/dist/types/utils/validate.d.ts +2 -2
  155. package/package.json +1 -1
  156. package/readme.md +2 -0
  157. package/dist/bn-template-engine/p-2fba7c99.entry.js +0 -1
  158. package/dist/bn-template-engine/p-A8xyE4b1.js +0 -1
  159. package/dist/bn-template-engine/p-B_d-jp99.js +0 -2
  160. package/dist/bn-template-engine/p-BjBz5cSL.js +0 -1
  161. package/dist/bn-template-engine/p-C8Q0lsaU.js +0 -1
  162. package/dist/bn-template-engine/p-C9i1Xsib.js +0 -1
  163. package/dist/bn-template-engine/p-a8291de2.entry.js +0 -1
  164. package/dist/bn-template-engine/p-b5274369.entry.js +0 -1
@@ -9,6 +9,7 @@ import { TimeChartStylesAdapter } from "./utils/model/styles/TimeChartStyle";
9
9
  import { ScaleFactorsTimeChartAdapter } from "./utils/model/styles/ScaleFactorsTimeChart";
10
10
  import { DateDistance } from "../../utils/DateStringFactory";
11
11
  import { AggregationLevel, AxisLabelsMode, ChartMode } from "../../utils/constants";
12
+ import { MIN_PIXEL_SCALE, solveAutoFitStep } from "../../utils/autoFit";
12
13
  import { StringAdapter } from "../../utils/helper/StringAdapter";
13
14
  import { IBCSRuleSet } from "../../utils/ibcsRuleSet";
14
15
  import { DataFormatDigitsAdapter } from "../../utils/model/DataFormatDigits";
@@ -77,8 +78,14 @@ export class IbcsChartTime {
77
78
  const availableWidth = this.containerWidth || 0;
78
79
  this.chart = new TimeChart(new IBCSRuleSet(this.ruleSetConfig), this.getDb(), this.tableName, config, styles, availableWidth);
79
80
  this.chart.setI18n(this.i18n);
81
+ // The broken-bar overdrive exists to absorb MANUAL scaling overflow.
82
+ // autoFitScaling mutates config.pixelPerUnit to the solved value, so
83
+ // remember auto mode beforehand and skip the overdrive for it — the
84
+ // fitted chart fits by construction, and the overdrive's rough overhead
85
+ // estimate would falsely re-engage on it.
86
+ const unitWasAuto = config.pixelPerUnit <= 0;
80
87
  this.autoFitScaling(config, styles);
81
- this.chart.setAvailableHeight(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
88
+ this.chart.setAvailableHeight(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
82
89
  this.pattern = new CustomPattern(this.chart.styles);
83
90
  this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
84
91
  }
@@ -94,15 +101,24 @@ export class IbcsChartTime {
94
101
  this.chart.setAvailableWidth(this.containerWidth || 0);
95
102
  this.chart.setRuleSet(new IBCSRuleSet(this.ruleSetConfig));
96
103
  this.chart.setConfig(config);
104
+ // See componentWillLoad: no broken-bar overdrive for auto-fitted scaling
105
+ const unitWasAuto = config.pixelPerUnit <= 0;
97
106
  this.autoFitScaling(config, styles);
98
- this.chart.setAvailableHeight(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
107
+ this.chart.setAvailableHeight(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
99
108
  this.pattern = new CustomPattern(this.chart.styles);
100
109
  this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
101
110
  }
102
111
  /**
103
- * Two-pass auto-fit for pixelPerUnit and/or pixelPerPercentage.
104
- * When either is 0 (auto mode), renders a measurement pass at 1,
105
- * computes the ratio to fit ~90% of the available height, and rebuilds.
112
+ * Auto-fit for pixelPerUnit and/or pixelPerPercentage (0 = auto mode).
113
+ * Time charts grow vertically, so we fit to height.
114
+ *
115
+ * The chart height is affine in the pixel scales (height = fixed labels +
116
+ * column extent × scale), but label allocations shift between passes, so a
117
+ * single analytic solve is not enough: measure at 1, solve, then verify
118
+ * against fresh measurements and re-solve until the chart fits. The loop
119
+ * never ends on an overshoot — the last fitting values are restored, or
120
+ * when even the minimum scale cannot fit (labels alone exceed the
121
+ * container) the values are floored and the wrapper reports the overflow.
106
122
  * Explicit (> 0) values are never overridden.
107
123
  */
108
124
  autoFitScaling(config, styles) {
@@ -112,38 +128,117 @@ export class IbcsChartTime {
112
128
  if (!autoUnit && !autoPercent) {
113
129
  return; // Both explicit — nothing to auto-fit
114
130
  }
131
+ const reportResolved = () => {
132
+ var _a;
133
+ (_a = this.reportAutoScaling) === null || _a === void 0 ? void 0 : _a.call(this, {
134
+ unit: autoUnit ? config.pixelPerUnit : undefined,
135
+ percentage: autoPercent ? config.pixelPerPercentage : undefined,
136
+ });
137
+ };
115
138
  const targetHeight = (_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height;
116
139
  const availableWidth = this.containerWidth || 0;
140
+ const rebuild = () => {
141
+ this.chart = new TimeChart(new IBCSRuleSet(this.ruleSetConfig), this.getDb(), this.tableName, config, styles, availableWidth);
142
+ this.chart.setI18n(this.i18n);
143
+ };
144
+ // toString() runs draw(), which finalizes positions — an undrawn chart
145
+ // reports a stale allocated height.
146
+ const measure = () => {
147
+ this.chart.toString();
148
+ return this.chart.getAllocatedCanvasHeight();
149
+ };
117
150
  if (!targetHeight || targetHeight <= 0) {
118
151
  if (autoUnit)
119
152
  config.pixelPerUnit = 1;
120
153
  if (autoPercent)
121
154
  config.pixelPerPercentage = 50;
122
- this.chart = new TimeChart(new IBCSRuleSet(this.ruleSetConfig), this.getDb(), this.tableName, config, styles, availableWidth);
123
- this.chart.setI18n(this.i18n);
155
+ rebuild();
156
+ reportResolved();
124
157
  return;
125
158
  }
126
- // First pass: set auto values to 1 and measure SVG height
159
+ // Measurement pass: render the auto quantities at 1
127
160
  if (autoUnit)
128
161
  config.pixelPerUnit = 1;
129
162
  if (autoPercent)
130
163
  config.pixelPerPercentage = 1;
131
- this.chart = new TimeChart(new IBCSRuleSet(this.ruleSetConfig), this.getDb(), this.tableName, config, styles, availableWidth);
132
- this.chart.setI18n(this.i18n);
133
- this.chart.toString();
134
- const svgHeight = this.chart.getAllocatedCanvasHeight();
135
- if (svgHeight <= 0) {
164
+ rebuild();
165
+ let height = measure();
166
+ if (height <= 0) {
167
+ reportResolved();
136
168
  return;
137
169
  }
138
- // Scale so the chart fits in ~90% of the available height
139
- const ratio = (targetHeight * 0.9) / svgHeight;
140
- if (autoUnit)
141
- config.pixelPerUnit = ratio;
142
- if (autoPercent)
143
- config.pixelPerPercentage = ratio;
144
- // Second pass with the corrected scaling
145
- this.chart = new TimeChart(new IBCSRuleSet(this.ruleSetConfig), this.getDb(), this.tableName, config, styles, availableWidth);
146
- this.chart.setI18n(this.i18n);
170
+ // Fallback for auto quantities nothing scales with (no column extent):
171
+ // plain ratio against the measurement pass, as before.
172
+ const ratioFallback = Math.max(MIN_PIXEL_SCALE, (targetHeight * 0.9) / height);
173
+ const EPS = 0.5;
174
+ const MAX_CORRECTIONS = 3;
175
+ let solvedUnit = false;
176
+ let solvedPercent = false;
177
+ let fitting = null;
178
+ for (let iteration = 0; iteration <= MAX_CORRECTIONS; iteration++) {
179
+ const step = solveAutoFitStep({
180
+ target: targetHeight,
181
+ measured: height,
182
+ unitExtent: autoUnit ? this.chart.getUnitBarExtent() : 0,
183
+ pctExtent: autoPercent ? this.chart.getPercentBarExtent() : 0,
184
+ currentPpu: config.pixelPerUnit,
185
+ currentPpp: config.pixelPerPercentage,
186
+ });
187
+ if (step.ppu === undefined && step.ppp === undefined) {
188
+ break; // nothing scales with the auto values — fallback below
189
+ }
190
+ if (autoUnit && step.ppu !== undefined) {
191
+ config.pixelPerUnit = step.ppu;
192
+ solvedUnit = true;
193
+ }
194
+ if (autoPercent && step.ppp !== undefined) {
195
+ config.pixelPerPercentage = step.ppp;
196
+ solvedPercent = true;
197
+ }
198
+ rebuild();
199
+ height = measure();
200
+ if (height <= targetHeight + EPS) {
201
+ fitting = { ppu: config.pixelPerUnit, ppp: config.pixelPerPercentage };
202
+ if (height >= targetHeight * 0.98) {
203
+ break; // fits and tight — done
204
+ }
205
+ // else the label allocation left slack — loop once more to grow into it
206
+ }
207
+ }
208
+ // Auto quantities the solver never touched get the ratio fallback
209
+ let needsRebuild = false;
210
+ if (autoUnit && !solvedUnit) {
211
+ config.pixelPerUnit = ratioFallback;
212
+ needsRebuild = true;
213
+ }
214
+ if (autoPercent && !solvedPercent) {
215
+ config.pixelPerPercentage = ratioFallback;
216
+ needsRebuild = true;
217
+ }
218
+ // Never end on an overshoot
219
+ if (height > targetHeight + EPS) {
220
+ if (fitting) {
221
+ // Restore the last values that fit (fallback quantities have no extent)
222
+ if (solvedUnit)
223
+ config.pixelPerUnit = fitting.ppu;
224
+ if (solvedPercent)
225
+ config.pixelPerPercentage = fitting.ppp;
226
+ }
227
+ else {
228
+ // Even the solved minimum overshoots (labels alone exceed the
229
+ // container) — shrink proportionally; the wrapper reports this.
230
+ const shrink = targetHeight / height;
231
+ if (autoUnit)
232
+ config.pixelPerUnit = Math.max(MIN_PIXEL_SCALE, config.pixelPerUnit * shrink);
233
+ if (autoPercent)
234
+ config.pixelPerPercentage = Math.max(MIN_PIXEL_SCALE, config.pixelPerPercentage * shrink);
235
+ }
236
+ needsRebuild = true;
237
+ }
238
+ if (needsRebuild) {
239
+ rebuild();
240
+ }
241
+ reportResolved();
147
242
  }
148
243
  async componentWillRender() {
149
244
  // return await (async () => {
@@ -369,6 +464,30 @@ export class IbcsChartTime {
369
464
  "attribute": "pixel-per-percentage",
370
465
  "defaultValue": "50"
371
466
  },
467
+ "reportAutoScaling": {
468
+ "type": "unknown",
469
+ "mutable": false,
470
+ "complexType": {
471
+ "original": "(report: AutoScalingReport) => void",
472
+ "resolved": "(report: AutoScalingReport) => void",
473
+ "references": {
474
+ "AutoScalingReport": {
475
+ "location": "import",
476
+ "path": "../../utils/scaling",
477
+ "id": "src/utils/scaling.ts::AutoScalingReport",
478
+ "referenceLocation": "AutoScalingReport"
479
+ }
480
+ }
481
+ },
482
+ "required": false,
483
+ "optional": true,
484
+ "docs": {
485
+ "tags": [],
486
+ "text": "Internal wrapper channel: called with the auto-fitted values (px for one\ndata unit / px per 1.0 fraction) whenever one of them was auto-resolved, so\nthe outer `bn-chart-time` can surface them in its AUTO_* warnings.\nNot for end users."
487
+ },
488
+ "getter": false,
489
+ "setter": false
490
+ },
372
491
  "limit": {
373
492
  "type": "number",
374
493
  "mutable": false,
@@ -11,6 +11,7 @@ import { buildFromExpr } from "../../../context/scopedDb";
11
11
  import { DateDistance, DateStringFactory } from "../../../utils/DateStringFactory";
12
12
  import { AxisLabelsMode, ChartMode, RELATIVE_STACK_UNITS, StackBy, StackMode, } from "../../../utils/constants";
13
13
  import { getScenarioPrefix, IBCS_LAYER_ORDER } from "../../../utils/stackColors";
14
+ import { computePercentBarExtent, computeUnitBarExtent } from "../../../utils/autoFit";
14
15
  import { Formatter } from "../../../utils";
15
16
  import { IBCSRuleSet } from "../../../utils/ibcsRuleSet";
16
17
  import { VarianceScenario } from "../../../utils/model";
@@ -308,6 +309,41 @@ export class TimeChart {
308
309
  : this.scenariosArea.height;
309
310
  return Math.max(analyticalHeight, bboxHeight);
310
311
  }
312
+ /**
313
+ * Total column extent (data units) proportional to pixelPerUnit, covering
314
+ * both sides of the axis (negative columns extend below it). Mirrors the
315
+ * DataPoints getAllocatedCanvasHeight allocates with; used by autoFitScaling
316
+ * to separate fixed from variable height components.
317
+ */
318
+ getUnitBarExtent() {
319
+ var _a, _b, _c;
320
+ const isRelative = this.isVarianceChart() &&
321
+ this.variancesDataModel.some((e) => e.type === VarianceType.RELATIVE);
322
+ const usesVariance = this.isVarianceChart();
323
+ const highest = usesVariance ? this.highestVarianceDataPointValue : this.highestDataPointValue;
324
+ const smallest = usesVariance ? this.smallestVarianceDataPointValue : this.smallestDataPointValue;
325
+ return computeUnitBarExtent({
326
+ // Relative stacks span exactly RELATIVE_STACK_UNITS * ppu
327
+ fixedDomain: ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) === StackMode.RELATIVE ? RELATIVE_STACK_UNITS : undefined,
328
+ relativeVariance: isRelative,
329
+ maxPositive: (_b = highest === null || highest === void 0 ? void 0 : highest.value) !== null && _b !== void 0 ? _b : 0,
330
+ minNegative: this.isOnSameAxisSide() ? 0 : ((_c = smallest === null || smallest === void 0 ? void 0 : smallest.value) !== null && _c !== void 0 ? _c : 0),
331
+ });
332
+ }
333
+ /**
334
+ * Total column extent (fraction units) proportional to pixelPerPercentage.
335
+ * Only relative variances scale with it; each side clamps at +/-145%.
336
+ */
337
+ getPercentBarExtent() {
338
+ var _a, _b, _c, _d;
339
+ const isRelative = this.isVarianceChart() &&
340
+ this.variancesDataModel.some((e) => e.type === VarianceType.RELATIVE);
341
+ return computePercentBarExtent({
342
+ relativeVariance: isRelative,
343
+ maxPositive: (_b = (_a = this.highestVarianceDataPointValue) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0,
344
+ minNegative: this.isOnSameAxisSide() ? 0 : ((_d = (_c = this.smallestVarianceDataPointValue) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 0),
345
+ });
346
+ }
311
347
  toString() {
312
348
  const container = new Svg();
313
349
  this.draw(container);
@@ -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,