@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.
- package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/{p-28d5c266.entry.js → p-0a49cf00.entry.js} +1 -1
- package/dist/bn-template-engine/{p-b9e94127.entry.js → p-22b8d044.entry.js} +1 -1
- package/dist/bn-template-engine/{p-6c7f0076.entry.js → p-251bb53d.entry.js} +1 -1
- package/dist/bn-template-engine/p-2aed639e.entry.js +1 -0
- package/dist/bn-template-engine/{p-7e9dbc93.entry.js → p-4616b879.entry.js} +1 -1
- package/dist/bn-template-engine/{p-99477a27.entry.js → p-629edcca.entry.js} +1 -1
- package/dist/bn-template-engine/p-686d8e44.entry.js +1 -0
- package/dist/bn-template-engine/{p-a4ea9a79.entry.js → p-68aa61cc.entry.js} +1 -1
- package/dist/bn-template-engine/{p-DwYUTvvI.js → p-B5x8M8OC.js} +1 -1
- package/dist/bn-template-engine/{p-fFtEvsY-.js → p-BGrnfif3.js} +1 -1
- package/dist/bn-template-engine/{p-6lOdN-fB.js → p-BVfLus3u.js} +1 -1
- package/dist/bn-template-engine/{p-CJThzFZm.js → p-BcZ5GQZ8.js} +1 -1
- package/dist/bn-template-engine/{p-CYE0I1Mx.js → p-Bca5V28_.js} +1 -1
- package/dist/bn-template-engine/p-C5UYpZUU.js +2 -0
- package/dist/bn-template-engine/{p-BgIpdpfH.js → p-C7T4DAAW.js} +1 -1
- package/dist/bn-template-engine/p-CDo04UEU.js +1 -0
- package/dist/bn-template-engine/p-CTrNbSXN.js +1 -0
- package/dist/bn-template-engine/{p-C5uvAEKI.js → p-CbciPY-M.js} +1 -1
- package/dist/bn-template-engine/{p-BpWWgN6k.js → p-CuR4S456.js} +1 -1
- package/dist/bn-template-engine/p-DWtTjg0f.js +1 -0
- package/dist/bn-template-engine/{p-eEfqksk-.js → p-DdqXNsKP.js} +1 -1
- package/dist/bn-template-engine/{p-B4JfKvVT.js → p-DtLI_CzV.js} +1 -1
- package/dist/bn-template-engine/p-UtNHLX1j.js +1 -0
- package/dist/bn-template-engine/{p-ba912130.entry.js → p-aecb5de3.entry.js} +1 -1
- package/dist/bn-template-engine/{p-687032d5.entry.js → p-ba43d46e.entry.js} +1 -1
- package/dist/bn-template-engine/{p-6077155f.entry.js → p-c476e7bb.entry.js} +1 -1
- package/dist/bn-template-engine/{p-2d3ea756.entry.js → p-d7c670ec.entry.js} +1 -1
- package/dist/bn-template-engine/{p-a1380d7c.entry.js → p-e4a584a8.entry.js} +1 -1
- package/dist/bn-template-engine/{p-de29986f.entry.js → p-f12fb09b.entry.js} +1 -1
- package/dist/bn-template-engine/p-f9a721bb.entry.js +1 -0
- package/dist/cjs/{AxisConfig-D7CAyPLO.js → AxisConfig-DmP4U3JM.js} +1 -1
- package/dist/cjs/{LabelCollisionManager-DkdQ9Xdg.js → LabelCollisionManager-Cet3WPm0.js} +2 -2
- package/dist/cjs/{Order-IPfAP0q8.js → Order-DlKLywO_.js} +1 -1
- package/dist/cjs/{SVGStyle-BD8jApd4.js → SVGStyle-D78RaNnj.js} +2 -2
- package/dist/cjs/{SVGVariancesStyleGroup-BaWzR951.js → SVGVariancesStyleGroup-XvNAnYYA.js} +1 -1
- package/dist/cjs/{VarianceMeasure-BBWTgv2e.js → VarianceMeasure-BfZLlICl.js} +4 -4
- package/dist/cjs/{XYChartDataRow-BoR0CTfl.js → XYChartDataRow-B0NNOqxB.js} +4 -4
- package/dist/cjs/bn-asset_21.cjs.entry.js +1052 -314
- package/dist/cjs/bn-chart-bubble.cjs.entry.js +25 -15
- package/dist/cjs/bn-chart-bullet.cjs.entry.js +9 -9
- package/dist/cjs/bn-chart-scatter.cjs.entry.js +9 -9
- package/dist/cjs/bn-grid.cjs.entry.js +6 -6
- package/dist/cjs/bn-image.cjs.entry.js +6 -6
- package/dist/cjs/bn-internationalization.cjs.entry.js +4 -4
- package/dist/cjs/bn-ruleset.cjs.entry.js +4 -4
- package/dist/cjs/bn-template-engine.cjs.js +3 -3
- package/dist/cjs/bn-template.cjs.entry.js +2 -2
- package/dist/cjs/bn-text.cjs.entry.js +7 -7
- package/dist/cjs/bn-tree.cjs.entry.js +6 -6
- package/dist/cjs/{context-protocol-BBhT9B52.js → context-protocol-DeLmu5s2.js} +1 -1
- package/dist/cjs/editor-companion.cjs.entry.js +2 -2
- package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +6 -6
- package/dist/cjs/ibcs-chart-bullet.cjs.entry.js +6 -6
- package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +6 -6
- package/dist/cjs/{index-CDKG4xmO.js → index-C1Z9vO7z.js} +61 -19
- package/dist/cjs/{layoutObserver-DUYYkDMQ.js → layoutObserver-CrzQQGpv.js} +5 -5
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{scaling-BIJQ2NV1.js → scaling-JAU6IJnR.js} +85 -3
- package/dist/cjs/{withBodyObserver-BKUE_ypL.js → withBodyObserver-DJO98AJ-.js} +2 -2
- package/dist/cjs/{withHasError-Cl2gTQzA.js → withHasError-BdDmiOXM.js} +1 -1
- package/dist/cjs/{withScalingGroup-D5clRvRe.js → withScalingGroup-Bu5gatHT.js} +3 -3
- package/dist/cjs/{withStyled-Cm9dWQhu.js → withStyled-50UepUwV.js} +8 -8
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +15 -5
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.css +6 -0
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +149 -57
- package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +135 -28
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +30 -19
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +186 -49
- package/dist/collection/components/bn-chart-time/ibcs-chart-time.css +9 -3
- package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +141 -22
- package/dist/collection/components/bn-chart-time/utils/TimeChart.js +36 -0
- package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +76 -19
- package/dist/collection/components/bn-table/bn-table.js +121 -49
- package/dist/collection/components/bn-table/ibcs-table.js +83 -42
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +20 -34
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +4 -5
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +89 -0
- package/dist/collection/utils/autoFit.js +63 -0
- package/dist/collection/utils/constants.js +3 -3
- package/dist/collection/utils/dataAnalyzer.js +17 -8
- package/dist/collection/utils/scaling.js +79 -0
- package/dist/collection/utils/validate.js +3 -3
- package/dist/components/DataFormatDigits.js +1 -1
- package/dist/components/autoFit.js +1 -0
- package/dist/components/bn-chart-bubble.js +1 -1
- package/dist/components/bn-chart-bullet.js +1 -1
- package/dist/components/bn-chart-scatter.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-grid.js +1 -1
- package/dist/components/bn-scaling-group.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/bn-text.js +1 -1
- package/dist/components/bn-tree.js +1 -1
- package/dist/components/ibcs-chart-structure2.js +1 -1
- package/dist/components/ibcs-chart-time2.js +1 -1
- package/dist/components/ibcs-table2.js +1 -1
- package/dist/components/scaling.js +1 -0
- package/dist/components/validate.js +1 -1
- package/dist/components/withDataset.js +1 -1
- package/dist/components/withStyled.js +1 -1
- package/dist/esm/{AxisConfig-ByIP5J-9.js → AxisConfig-Cjy_RANi.js} +1 -1
- package/dist/esm/{LabelCollisionManager-DaNiDiM9.js → LabelCollisionManager-B_NUM9yq.js} +2 -2
- package/dist/esm/{Order-BQeJE_yi.js → Order-B-aF6Rwn.js} +1 -1
- package/dist/esm/{SVGStyle-BwBlY3Km.js → SVGStyle-8FfAtUF-.js} +2 -2
- package/dist/esm/{SVGVariancesStyleGroup-BpGW4CvN.js → SVGVariancesStyleGroup-DD4mIOjT.js} +1 -1
- package/dist/esm/{VarianceMeasure-CE3N8Bea.js → VarianceMeasure-DLOuIIJ7.js} +4 -4
- package/dist/esm/{XYChartDataRow-DeMI1JKU.js → XYChartDataRow-CKfILBFG.js} +4 -4
- package/dist/esm/bn-asset_21.entry.js +1052 -314
- package/dist/esm/bn-chart-bubble.entry.js +25 -15
- package/dist/esm/bn-chart-bullet.entry.js +9 -9
- package/dist/esm/bn-chart-scatter.entry.js +9 -9
- package/dist/esm/bn-grid.entry.js +6 -6
- package/dist/esm/bn-image.entry.js +6 -6
- package/dist/esm/bn-internationalization.entry.js +4 -4
- package/dist/esm/bn-ruleset.entry.js +4 -4
- package/dist/esm/bn-template-engine.js +4 -4
- package/dist/esm/bn-template.entry.js +2 -2
- package/dist/esm/bn-text.entry.js +7 -7
- package/dist/esm/bn-tree.entry.js +6 -6
- package/dist/esm/{context-protocol-d8MHrEo8.js → context-protocol-BoEL0caI.js} +1 -1
- package/dist/esm/editor-companion.entry.js +2 -2
- package/dist/esm/ibcs-chart-bubble.entry.js +6 -6
- package/dist/esm/ibcs-chart-bullet.entry.js +6 -6
- package/dist/esm/ibcs-chart-scatter.entry.js +6 -6
- package/dist/esm/{index-B_d-jp99.js → index-C5UYpZUU.js} +61 -19
- package/dist/esm/{layoutObserver-BJBEyhNf.js → layoutObserver-cgIXg2sg.js} +5 -5
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{scaling-BGnpSN1j.js → scaling-CxyNpMQM.js} +83 -4
- package/dist/esm/{withBodyObserver-IokS6fHD.js → withBodyObserver-Cb9ZC5_J.js} +2 -2
- package/dist/esm/{withHasError-DW_vMDUp.js → withHasError-Bh1Viz52.js} +1 -1
- package/dist/esm/{withScalingGroup-CC3UcvC5.js → withScalingGroup-Yv9nGGe1.js} +3 -3
- package/dist/esm/{withStyled-2l5Tx3cf.js → withStyled-By9Jd-Oy.js} +8 -8
- package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +5 -2
- package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +47 -19
- package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +17 -3
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +11 -3
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +52 -18
- package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +18 -3
- package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +12 -0
- package/dist/types/components/bn-scaling-group/bn-scaling-group.d.ts +28 -8
- package/dist/types/components/bn-table/bn-table.d.ts +45 -19
- package/dist/types/components/bn-table/ibcs-table.d.ts +23 -6
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +9 -1
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +51 -0
- package/dist/types/components.d.ts +91 -55
- package/dist/types/stencil-public-runtime.d.ts +1 -0
- package/dist/types/utils/autoFit.d.ts +79 -0
- package/dist/types/utils/constants.d.ts +3 -3
- package/dist/types/utils/dataAnalyzer.d.ts +5 -1
- package/dist/types/utils/scaling.d.ts +63 -0
- package/dist/types/utils/validate.d.ts +2 -2
- package/package.json +1 -1
- package/readme.md +2 -0
- package/dist/bn-template-engine/p-2fba7c99.entry.js +0 -1
- package/dist/bn-template-engine/p-A8xyE4b1.js +0 -1
- package/dist/bn-template-engine/p-B_d-jp99.js +0 -2
- package/dist/bn-template-engine/p-BjBz5cSL.js +0 -1
- package/dist/bn-template-engine/p-C8Q0lsaU.js +0 -1
- package/dist/bn-template-engine/p-C9i1Xsib.js +0 -1
- package/dist/bn-template-engine/p-a8291de2.entry.js +0 -1
- package/dist/bn-template-engine/p-b5274369.entry.js +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var withHasError = require('./withHasError-
|
|
5
|
-
var contextProtocol = require('./context-protocol-
|
|
6
|
-
var withBodyObserver = require('./withBodyObserver-
|
|
7
|
-
var withStyled = require('./withStyled-
|
|
8
|
-
var scaling = require('./scaling-
|
|
9
|
-
var withScalingGroup = require('./withScalingGroup-
|
|
10
|
-
var layoutObserver = require('./layoutObserver-
|
|
11
|
-
var VarianceMeasure = require('./VarianceMeasure-
|
|
12
|
-
var Order = require('./Order-
|
|
13
|
-
var SVGStyle = require('./SVGStyle-
|
|
3
|
+
var index = require('./index-C1Z9vO7z.js');
|
|
4
|
+
var withHasError = require('./withHasError-BdDmiOXM.js');
|
|
5
|
+
var contextProtocol = require('./context-protocol-DeLmu5s2.js');
|
|
6
|
+
var withBodyObserver = require('./withBodyObserver-DJO98AJ-.js');
|
|
7
|
+
var withStyled = require('./withStyled-50UepUwV.js');
|
|
8
|
+
var scaling = require('./scaling-JAU6IJnR.js');
|
|
9
|
+
var withScalingGroup = require('./withScalingGroup-Bu5gatHT.js');
|
|
10
|
+
var layoutObserver = require('./layoutObserver-CrzQQGpv.js');
|
|
11
|
+
var VarianceMeasure = require('./VarianceMeasure-BfZLlICl.js');
|
|
12
|
+
var Order = require('./Order-DlKLywO_.js');
|
|
13
|
+
var SVGStyle = require('./SVGStyle-D78RaNnj.js');
|
|
14
14
|
var sanitizeHtml = require('./sanitizeHtml-LuZr1IMd.js');
|
|
15
|
-
var LabelCollisionManager = require('./LabelCollisionManager-
|
|
16
|
-
var SVGVariancesStyleGroup = require('./SVGVariancesStyleGroup-
|
|
15
|
+
var LabelCollisionManager = require('./LabelCollisionManager-Cet3WPm0.js');
|
|
16
|
+
var SVGVariancesStyleGroup = require('./SVGVariancesStyleGroup-XvNAnYYA.js');
|
|
17
17
|
|
|
18
18
|
const bnAssetCss = () => `:host{display:none}`;
|
|
19
19
|
|
|
@@ -101,7 +101,7 @@ const Card = class {
|
|
|
101
101
|
};
|
|
102
102
|
Card.style = bnCardCss();
|
|
103
103
|
|
|
104
|
-
const bnChartStructureCss$1 = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
|
|
104
|
+
const bnChartStructureCss$1 = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
|
|
105
105
|
|
|
106
106
|
const Chart$1 = class Chart {
|
|
107
107
|
validateScenario(newValue) {
|
|
@@ -142,8 +142,7 @@ const Chart$1 = class Chart {
|
|
|
142
142
|
}
|
|
143
143
|
validateUnitScaling(newValue) {
|
|
144
144
|
const errId = "ERR_unitScaling";
|
|
145
|
-
|
|
146
|
-
if (!isAuto && !withStyled.isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
|
|
145
|
+
if (scaling.resolveScalingValue(newValue, this.pixelPerUnitGroupMap).kind === "invalid") {
|
|
147
146
|
this.errors.addOrReplace({
|
|
148
147
|
id: errId,
|
|
149
148
|
type: "warning",
|
|
@@ -156,8 +155,7 @@ const Chart$1 = class Chart {
|
|
|
156
155
|
}
|
|
157
156
|
validatePercentageScaling(newValue) {
|
|
158
157
|
const errId = "ERR_percentageScaling";
|
|
159
|
-
|
|
160
|
-
if (!isAuto && !withStyled.isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
|
|
158
|
+
if (scaling.resolveScalingValue(newValue, this.pixelPerUnitGroupMap).kind === "invalid") {
|
|
161
159
|
this.errors.addOrReplace({
|
|
162
160
|
id: errId,
|
|
163
161
|
type: "warning",
|
|
@@ -405,6 +403,41 @@ const Chart$1 = class Chart {
|
|
|
405
403
|
this.stack = "";
|
|
406
404
|
this.pixelPerUnitGroupMap = new Map();
|
|
407
405
|
this._autoScaleGuard = false;
|
|
406
|
+
this.autoUnitWarningActive = false;
|
|
407
|
+
this.autoPctWarningActive = false;
|
|
408
|
+
/**
|
|
409
|
+
* Receives the auto-fitted values from the inner ibcs-chart-structure (px
|
|
410
|
+
* per unit / px per 1.0 fraction) and surfaces them in the AUTO_* warnings,
|
|
411
|
+
* converted back to the attribute's units-per-em form so users can copy
|
|
412
|
+
* them into a bn-scaling-group.
|
|
413
|
+
*/
|
|
414
|
+
this.handleAutoScalingReport = (report) => {
|
|
415
|
+
var _a, _b;
|
|
416
|
+
const changed = (next, last) => last === undefined || Math.abs(next - last) > Math.abs(next) * 1e-3;
|
|
417
|
+
const effFontPx = this.getEffectiveFontPx();
|
|
418
|
+
if (report.unit !== undefined && report.unit > 0 && this.autoUnitWarningActive) {
|
|
419
|
+
const unitsPerEm = effFontPx / report.unit;
|
|
420
|
+
if (changed(unitsPerEm, this.lastReportedUnitsPerEm)) {
|
|
421
|
+
this.lastReportedUnitsPerEm = unitsPerEm;
|
|
422
|
+
this.errors.addOrReplace({
|
|
423
|
+
id: "AUTO_unitScaling",
|
|
424
|
+
type: "warning",
|
|
425
|
+
message: `unit-scaling: ${Chart$1.describeScalingInput(String((_a = this.unitScaling) !== null && _a !== void 0 ? _a : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(unitsPerEm)} units.`,
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (report.percentage !== undefined && report.percentage > 0 && this.autoPctWarningActive) {
|
|
430
|
+
const ppPerEm = (100 * effFontPx) / report.percentage;
|
|
431
|
+
if (changed(ppPerEm, this.lastReportedPpPerEm)) {
|
|
432
|
+
this.lastReportedPpPerEm = ppPerEm;
|
|
433
|
+
this.errors.addOrReplace({
|
|
434
|
+
id: "AUTO_percentageScaling",
|
|
435
|
+
type: "warning",
|
|
436
|
+
message: `percentage-scaling: ${Chart$1.describeScalingInput(String((_b = this.percentageScaling) !== null && _b !== void 0 ? _b : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(ppPerEm)} percentage points.`,
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
};
|
|
408
441
|
withStyled.withStyled(this);
|
|
409
442
|
withHasError.withComponentStatus(this);
|
|
410
443
|
scaling.withDataset(this, (name, _data) => {
|
|
@@ -444,18 +477,18 @@ const Chart$1 = class Chart {
|
|
|
444
477
|
const { mode } = scaling.parseScaling(this.scale);
|
|
445
478
|
if (mode !== "auto" && mode !== "empty") {
|
|
446
479
|
this._autoScaleGuard = false;
|
|
447
|
-
this.
|
|
480
|
+
this.checkOverflow();
|
|
448
481
|
return;
|
|
449
482
|
}
|
|
450
483
|
if (this._autoScaleGuard) {
|
|
451
484
|
this._autoScaleGuard = false;
|
|
452
|
-
this.
|
|
485
|
+
this.checkOverflow();
|
|
453
486
|
return;
|
|
454
487
|
}
|
|
455
488
|
const host = this.element;
|
|
456
489
|
const { height: parentHeight } = scaling.getParentDimensions(host);
|
|
457
490
|
if (parentHeight <= 0) {
|
|
458
|
-
this.
|
|
491
|
+
this.checkOverflow();
|
|
459
492
|
return;
|
|
460
493
|
}
|
|
461
494
|
// Record height so the ResizeObserver callback can tell
|
|
@@ -473,7 +506,7 @@ const Chart$1 = class Chart {
|
|
|
473
506
|
// Content fits. Don't reset to factor 1 — the content only fits
|
|
474
507
|
// BECAUSE of the current factor. Resetting would cause oscillation.
|
|
475
508
|
this.errors.remove("AUTO_scale");
|
|
476
|
-
this.
|
|
509
|
+
this.checkOverflow();
|
|
477
510
|
return;
|
|
478
511
|
}
|
|
479
512
|
// Content overflows. Compute a new factor based on the ratio of
|
|
@@ -483,7 +516,7 @@ const Chart$1 = class Chart {
|
|
|
483
516
|
// SVG charts have non-linear scaling so we use a wider tolerance
|
|
484
517
|
// than tables to avoid oscillation from sub-pixel rounding.
|
|
485
518
|
if (Math.abs(computedFactor - currentFactor) < 0.01) {
|
|
486
|
-
this.
|
|
519
|
+
this.checkOverflow();
|
|
487
520
|
return;
|
|
488
521
|
}
|
|
489
522
|
host.style.setProperty("--bn-font-size", `${baseFontSize * computedFactor}px`);
|
|
@@ -501,7 +534,10 @@ const Chart$1 = class Chart {
|
|
|
501
534
|
index.writeTask(() => {
|
|
502
535
|
this.appliedScaleFactor = computedFactor;
|
|
503
536
|
});
|
|
504
|
-
|
|
537
|
+
// Check with the current (pre-factor) content so overflow is reported
|
|
538
|
+
// even if the scheduled re-render stalls; the follow-up render re-checks
|
|
539
|
+
// in the guard branch and clears any transiently reported overflow.
|
|
540
|
+
this.checkOverflow();
|
|
505
541
|
}
|
|
506
542
|
componentDidLoad() {
|
|
507
543
|
// Observe the parent container for size changes so auto-scaling
|
|
@@ -539,30 +575,74 @@ const Chart$1 = class Chart {
|
|
|
539
575
|
this.layoutObserver = null;
|
|
540
576
|
}
|
|
541
577
|
/**
|
|
542
|
-
*
|
|
543
|
-
*
|
|
578
|
+
* Content width from the rendered SVG width attributes (segments render
|
|
579
|
+
* side by side) — immune to the inner hosts' overflow:hidden clipping:
|
|
580
|
+
* flex items with hidden overflow shrink below their content size, so the
|
|
581
|
+
* host's scrollWidth cannot see the overflow. Falls back to scrollWidth
|
|
582
|
+
* before the inner charts have rendered.
|
|
544
583
|
*/
|
|
545
|
-
|
|
584
|
+
measureContentWidth() {
|
|
546
585
|
var _a;
|
|
586
|
+
const inners = (_a = this.element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll("ibcs-chart-structure");
|
|
587
|
+
let total = 0;
|
|
588
|
+
let found = false;
|
|
589
|
+
inners === null || inners === void 0 ? void 0 : inners.forEach((inner) => {
|
|
590
|
+
var _a, _b, _c;
|
|
591
|
+
const width = parseFloat((_c = (_b = (_a = inner.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("svg#drawCanvas")) === null || _b === void 0 ? void 0 : _b.getAttribute("width")) !== null && _c !== void 0 ? _c : "");
|
|
592
|
+
if (!Number.isNaN(width)) {
|
|
593
|
+
total += width;
|
|
594
|
+
found = true;
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
// scrollWidth additionally sees non-SVG chrome, but is blind to clipped
|
|
598
|
+
// segments (see above) — take the larger of the two measurements.
|
|
599
|
+
// Floor the fractional SVG widths so borderline sub-pixel overhangs are
|
|
600
|
+
// judged with the same integer tolerance as the scroll metrics.
|
|
601
|
+
return found ? Math.max(Math.floor(total), this.element.scrollWidth) : this.element.scrollWidth;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Reports a WARN_overflow item when the rendered chart exceeds its
|
|
605
|
+
* container. Overflow attributable to a fixed scaling attribute is an
|
|
606
|
+
* error (width: unit-scaling / percentage-scaling, height: scale);
|
|
607
|
+
* overflow in fully-auto mode is a warning — auto-fit prevents it by
|
|
608
|
+
* construction, so it only fires when the content cannot fit at any scale.
|
|
609
|
+
*/
|
|
610
|
+
checkOverflow() {
|
|
547
611
|
const errId = "WARN_overflow";
|
|
548
|
-
const us = String((_a = this.unitScaling) !== null && _a !== void 0 ? _a : "")
|
|
549
|
-
.trim()
|
|
550
|
-
.toLowerCase();
|
|
551
|
-
if (us === "" || us === "auto") {
|
|
552
|
-
this.errors.remove(errId);
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
612
|
const parent = scaling.getParentDimensions(this.element);
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
else {
|
|
613
|
+
const contentWidth = this.measureContentWidth();
|
|
614
|
+
const contentHeight = this.element.scrollHeight;
|
|
615
|
+
const widthOver = parent.width > 0 && contentWidth > parent.width + 1;
|
|
616
|
+
const heightOver = parent.height > 0 && contentHeight > parent.height + 1;
|
|
617
|
+
if (!widthOver && !heightOver) {
|
|
564
618
|
this.errors.remove(errId);
|
|
619
|
+
return;
|
|
565
620
|
}
|
|
621
|
+
const hasRelativeVariance = this.prepareVariances().some((variance) => variance.startsWith("dr"));
|
|
622
|
+
const fixedUnit = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap).kind === "value";
|
|
623
|
+
const fixedPercent = hasRelativeVariance && scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap).kind === "value";
|
|
624
|
+
const { mode } = scaling.parseScaling(this.scale);
|
|
625
|
+
const fixedScale = mode !== "auto" && mode !== "empty";
|
|
626
|
+
const fixedAttrs = [];
|
|
627
|
+
if (widthOver && fixedUnit)
|
|
628
|
+
fixedAttrs.push("unit-scaling");
|
|
629
|
+
if (widthOver && fixedPercent)
|
|
630
|
+
fixedAttrs.push("percentage-scaling");
|
|
631
|
+
if (heightOver && fixedScale)
|
|
632
|
+
fixedAttrs.push("scale");
|
|
633
|
+
const dims = [];
|
|
634
|
+
if (widthOver)
|
|
635
|
+
dims.push(`width (${Math.round(contentWidth)}px > ${Math.round(parent.width)}px)`);
|
|
636
|
+
if (heightOver)
|
|
637
|
+
dims.push(`height (${Math.round(contentHeight)}px > ${Math.round(parent.height)}px)`);
|
|
638
|
+
this.errors.addOrReplace({
|
|
639
|
+
id: errId,
|
|
640
|
+
type: fixedAttrs.length > 0 ? "error" : "warning",
|
|
641
|
+
message: `Chart exceeds available ${dims.join(" and ")}. ` +
|
|
642
|
+
(fixedAttrs.length > 0
|
|
643
|
+
? `Adjust ${fixedAttrs.join(" / ")} or set to "auto".`
|
|
644
|
+
: "Content does not fit even at minimum auto scaling; enlarge the container."),
|
|
645
|
+
});
|
|
566
646
|
}
|
|
567
647
|
prepareDimension() {
|
|
568
648
|
const parent = scaling.getParentDimensions(this.element);
|
|
@@ -619,48 +699,56 @@ const Chart$1 = class Chart {
|
|
|
619
699
|
const i18nMapGlobal = new Map(i18nMetaLabelsGlobal.map((key) => [key, this.t("global.".concat(key))]));
|
|
620
700
|
return new Map([...i18nMapGlobal.entries(), ...i18nMapLocal.entries()]);
|
|
621
701
|
}
|
|
702
|
+
/** "not set" for blank input, `invalid value "x"` otherwise — for AUTO_* messages. */
|
|
703
|
+
static describeScalingInput(raw) {
|
|
704
|
+
return raw === "" ? "not set" : `invalid value "${raw}"`;
|
|
705
|
+
}
|
|
622
706
|
preparePixelPerUnit() {
|
|
623
|
-
|
|
624
|
-
if (
|
|
707
|
+
const resolved = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap);
|
|
708
|
+
if (resolved.kind === "value") {
|
|
625
709
|
this.errors.remove("AUTO_unitScaling");
|
|
626
|
-
|
|
710
|
+
this.autoUnitWarningActive = false;
|
|
711
|
+
this.lastReportedUnitsPerEm = undefined;
|
|
712
|
+
// The attribute is data units per em; the inner chart expects px for one data unit.
|
|
713
|
+
return this.getEffectiveFontPx() / resolved.value;
|
|
627
714
|
}
|
|
628
715
|
// Explicit 'auto' → auto-calculate silently
|
|
629
|
-
if (
|
|
716
|
+
if (resolved.kind === "auto") {
|
|
630
717
|
this.errors.remove("AUTO_unitScaling");
|
|
718
|
+
this.autoUnitWarningActive = false;
|
|
719
|
+
this.lastReportedUnitsPerEm = undefined;
|
|
631
720
|
return 0;
|
|
632
721
|
}
|
|
633
|
-
const numeric = Number(this.unitScaling);
|
|
634
|
-
if (!isNaN(numeric) && numeric > 0) {
|
|
635
|
-
this.errors.remove("AUTO_unitScaling");
|
|
636
|
-
return numeric;
|
|
637
|
-
}
|
|
638
722
|
// Not set / invalid → auto-calculate with warning
|
|
723
|
+
this.autoUnitWarningActive = true;
|
|
639
724
|
this.errors.addOrReplace({
|
|
640
725
|
id: "AUTO_unitScaling",
|
|
641
726
|
type: "warning",
|
|
642
|
-
message: `unit-scaling:
|
|
727
|
+
message: `unit-scaling: ${Chart$1.describeScalingInput(resolved.raw)}, auto-calculated to fit available space.`,
|
|
643
728
|
});
|
|
644
729
|
return 0;
|
|
645
730
|
}
|
|
646
731
|
preparePixelPerPercentage() {
|
|
647
|
-
|
|
648
|
-
if (
|
|
649
|
-
return this.pixelPerUnitGroupMap.get(this.percentageScaling);
|
|
650
|
-
}
|
|
651
|
-
if (((_a = this.percentageScaling) === null || _a === void 0 ? void 0 : _a.toString().trim().toLowerCase()) === "auto") {
|
|
732
|
+
const resolved = scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap);
|
|
733
|
+
if (resolved.kind === "value") {
|
|
652
734
|
this.errors.remove("AUTO_percentageScaling");
|
|
653
|
-
|
|
735
|
+
this.autoPctWarningActive = false;
|
|
736
|
+
this.lastReportedPpPerEm = undefined;
|
|
737
|
+
// The attribute is percentage points per em; the inner chart expects
|
|
738
|
+
// px per 1.0 fraction (= per 100 percentage points).
|
|
739
|
+
return (100 * this.getEffectiveFontPx()) / resolved.value;
|
|
654
740
|
}
|
|
655
|
-
|
|
656
|
-
if (!isNaN(numeric) && numeric > 0) {
|
|
741
|
+
if (resolved.kind === "auto") {
|
|
657
742
|
this.errors.remove("AUTO_percentageScaling");
|
|
658
|
-
|
|
743
|
+
this.autoPctWarningActive = false;
|
|
744
|
+
this.lastReportedPpPerEm = undefined;
|
|
745
|
+
return 0;
|
|
659
746
|
}
|
|
747
|
+
this.autoPctWarningActive = true;
|
|
660
748
|
this.errors.addOrReplace({
|
|
661
749
|
id: "AUTO_percentageScaling",
|
|
662
750
|
type: "warning",
|
|
663
|
-
message: `percentage-scaling:
|
|
751
|
+
message: `percentage-scaling: ${Chart$1.describeScalingInput(resolved.raw)}, auto-calculated to fit available space.`,
|
|
664
752
|
});
|
|
665
753
|
return 0;
|
|
666
754
|
}
|
|
@@ -869,14 +957,13 @@ const Chart$1 = class Chart {
|
|
|
869
957
|
return this.measureUnit;
|
|
870
958
|
}
|
|
871
959
|
chartTemplate(localScenarioString, idx) {
|
|
872
|
-
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
873
960
|
const ppu = this.preparePixelPerUnit();
|
|
874
961
|
const ppp = this.preparePixelPerPercentage();
|
|
875
962
|
const stackConfig = this.prepareStackConfig();
|
|
876
963
|
const scenarios = this.prepareScenarios();
|
|
877
964
|
// Dimension stacking uses only the first scenario
|
|
878
965
|
const effectiveScenarios = (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === VarianceMeasure.StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
|
|
879
|
-
return (index.h("ibcs-chart-structure", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideCategories: this.prepareHideCategories(idx), pixelPerUnit: ppu
|
|
966
|
+
return (index.h("ibcs-chart-structure", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideCategories: this.prepareHideCategories(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, limit: this.prepareLimit(), styles: this.prepareStyle(), i18n: this.prepareI18n(), order: this.prepareOrder(), level: this.prepareLevel(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(idx), stackConfig: stackConfig, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
|
|
880
967
|
}
|
|
881
968
|
getEffectiveScaleFactor() {
|
|
882
969
|
const { mode, factor } = scaling.parseScaling(this.scale);
|
|
@@ -886,6 +973,11 @@ const Chart$1 = class Chart {
|
|
|
886
973
|
return this.appliedScaleFactor;
|
|
887
974
|
return 1;
|
|
888
975
|
}
|
|
976
|
+
/** Effective font size in px: base font from the style store × effective scale factor. */
|
|
977
|
+
getEffectiveFontPx() {
|
|
978
|
+
const baseFontSize = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; });
|
|
979
|
+
return baseFontSize * this.getEffectiveScaleFactor();
|
|
980
|
+
}
|
|
889
981
|
getFontStyles() {
|
|
890
982
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
891
983
|
return this.componentStyle(($) => {
|
|
@@ -906,7 +998,7 @@ const Chart$1 = class Chart {
|
|
|
906
998
|
scenariosArray = [...scenariosArray, ...variancesArray];
|
|
907
999
|
}
|
|
908
1000
|
const fontStyles = this.getFontStyles();
|
|
909
|
-
return (index.h(index.Host, { key: '
|
|
1001
|
+
return (index.h(index.Host, { key: '68eb9fbcc6fb712dd06729f13a33c61c2c5c90e6', style: fontStyles }, index.h("div", { key: '9d7c49c1d5e2940dd1a4381a90e08912fef77f33', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
910
1002
|
}
|
|
911
1003
|
get element() { return index.getElement(this); }
|
|
912
1004
|
static get watchers() { return {
|
|
@@ -1029,8 +1121,7 @@ const Chart = class {
|
|
|
1029
1121
|
}
|
|
1030
1122
|
validateUnitScaling(newValue) {
|
|
1031
1123
|
const errId = "ERR_unitScaling";
|
|
1032
|
-
|
|
1033
|
-
if (!isAuto && !withStyled.isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
|
|
1124
|
+
if (scaling.resolveScalingValue(newValue, this.pixelPerUnitGroupMap).kind === "invalid") {
|
|
1034
1125
|
this.errors.addOrReplace({
|
|
1035
1126
|
id: errId,
|
|
1036
1127
|
type: "warning",
|
|
@@ -1043,8 +1134,7 @@ const Chart = class {
|
|
|
1043
1134
|
}
|
|
1044
1135
|
validatePercentageScaling(newValue) {
|
|
1045
1136
|
const errId = "ERR_percentageScaling";
|
|
1046
|
-
|
|
1047
|
-
if (!isAuto && !withStyled.isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
|
|
1137
|
+
if (scaling.resolveScalingValue(newValue, this.pixelPerUnitGroupMap).kind === "invalid") {
|
|
1048
1138
|
this.errors.addOrReplace({
|
|
1049
1139
|
id: errId,
|
|
1050
1140
|
type: "warning",
|
|
@@ -1369,7 +1459,7 @@ const Chart = class {
|
|
|
1369
1459
|
* original value.
|
|
1370
1460
|
* <br /><br />
|
|
1371
1461
|
* values: <br />
|
|
1372
|
-
* ```_ // k // M // G // T // P // E // Z // Y // m // μ // n // p //
|
|
1462
|
+
* ```_ // k // M // G // T // P // E // Z // Y // m // my (μ) // n // p // f // a // z // y // GREATEST // LEAST```
|
|
1373
1463
|
* <br /><br />
|
|
1374
1464
|
* SiPrefix overview:
|
|
1375
1465
|
* ``` "Y": 1E+24,```<br />
|
|
@@ -1382,7 +1472,7 @@ const Chart = class {
|
|
|
1382
1472
|
* ``` "k": 1000,```<br />
|
|
1383
1473
|
* <br />
|
|
1384
1474
|
* ``` "m": 0.001,```<br />
|
|
1385
|
-
* ``` "μ
|
|
1475
|
+
* ``` "my" (μ): 0.000001,```<br />
|
|
1386
1476
|
* ``` "n": 0.000000001,```<br />
|
|
1387
1477
|
* ``` "p": 0.000000000001,```<br />
|
|
1388
1478
|
* ``` "f": 0.000000000000001,```<br />
|
|
@@ -1417,6 +1507,41 @@ const Chart = class {
|
|
|
1417
1507
|
this._lastObservedWidth = 0;
|
|
1418
1508
|
this._settleTimer = null;
|
|
1419
1509
|
this._lastAppliedHeight = 0;
|
|
1510
|
+
this.autoUnitWarningActive = false;
|
|
1511
|
+
this.autoPctWarningActive = false;
|
|
1512
|
+
/**
|
|
1513
|
+
* Receives the auto-fitted values from the inner ibcs-chart-time (px per
|
|
1514
|
+
* unit / px per 1.0 fraction) and surfaces them in the AUTO_* warnings,
|
|
1515
|
+
* converted back to the attribute's units-per-em form so users can copy
|
|
1516
|
+
* them into a bn-scaling-group.
|
|
1517
|
+
*/
|
|
1518
|
+
this.handleAutoScalingReport = (report) => {
|
|
1519
|
+
var _a, _b;
|
|
1520
|
+
const changed = (next, last) => last === undefined || Math.abs(next - last) > Math.abs(next) * 1e-3;
|
|
1521
|
+
const effFontPx = this.getEffectiveFontPx();
|
|
1522
|
+
if (report.unit !== undefined && report.unit > 0 && this.autoUnitWarningActive) {
|
|
1523
|
+
const unitsPerEm = effFontPx / report.unit;
|
|
1524
|
+
if (changed(unitsPerEm, this.lastReportedUnitsPerEm)) {
|
|
1525
|
+
this.lastReportedUnitsPerEm = unitsPerEm;
|
|
1526
|
+
this.errors.addOrReplace({
|
|
1527
|
+
id: "AUTO_unitScaling",
|
|
1528
|
+
type: "warning",
|
|
1529
|
+
message: `unit-scaling: ${Chart.describeScalingInput(String((_a = this.unitScaling) !== null && _a !== void 0 ? _a : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(unitsPerEm)} units.`,
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
if (report.percentage !== undefined && report.percentage > 0 && this.autoPctWarningActive) {
|
|
1534
|
+
const ppPerEm = (100 * effFontPx) / report.percentage;
|
|
1535
|
+
if (changed(ppPerEm, this.lastReportedPpPerEm)) {
|
|
1536
|
+
this.lastReportedPpPerEm = ppPerEm;
|
|
1537
|
+
this.errors.addOrReplace({
|
|
1538
|
+
id: "AUTO_percentageScaling",
|
|
1539
|
+
type: "warning",
|
|
1540
|
+
message: `percentage-scaling: ${Chart.describeScalingInput(String((_b = this.percentageScaling) !== null && _b !== void 0 ? _b : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(ppPerEm)} percentage points.`,
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1420
1545
|
withStyled.withStyled(this);
|
|
1421
1546
|
withHasError.withComponentStatus(this);
|
|
1422
1547
|
scaling.withDataset(this, (name, _data) => {
|
|
@@ -1461,32 +1586,111 @@ const Chart = class {
|
|
|
1461
1586
|
this.validateStack(this.stack);
|
|
1462
1587
|
this.validateScaling(this.scale);
|
|
1463
1588
|
}
|
|
1589
|
+
/**
|
|
1590
|
+
* Content width from the rendered SVG width attributes (segments stack
|
|
1591
|
+
* vertically, so the widest one counts) — immune to overflow:hidden
|
|
1592
|
+
* clipping along the ancestor chain. Falls back to scrollWidth before the
|
|
1593
|
+
* inner charts have rendered.
|
|
1594
|
+
*/
|
|
1595
|
+
measureContentWidth() {
|
|
1596
|
+
var _a;
|
|
1597
|
+
const inners = (_a = this.element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll("ibcs-chart-time");
|
|
1598
|
+
let widest = 0;
|
|
1599
|
+
let found = false;
|
|
1600
|
+
inners === null || inners === void 0 ? void 0 : inners.forEach((inner) => {
|
|
1601
|
+
var _a, _b, _c;
|
|
1602
|
+
const width = parseFloat((_c = (_b = (_a = inner.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("svg#drawCanvas")) === null || _b === void 0 ? void 0 : _b.getAttribute("width")) !== null && _c !== void 0 ? _c : "");
|
|
1603
|
+
if (!Number.isNaN(width)) {
|
|
1604
|
+
widest = Math.max(widest, width);
|
|
1605
|
+
found = true;
|
|
1606
|
+
}
|
|
1607
|
+
});
|
|
1608
|
+
// scrollWidth additionally sees non-SVG chrome, so take the larger.
|
|
1609
|
+
// Floor the fractional SVG width so borderline sub-pixel overhangs are
|
|
1610
|
+
// judged with the same integer tolerance as the scroll metrics.
|
|
1611
|
+
return found ? Math.max(Math.floor(widest), this.element.scrollWidth) : this.element.scrollWidth;
|
|
1612
|
+
}
|
|
1613
|
+
/** Content height as the sum of the vertically stacked segment SVGs. */
|
|
1614
|
+
measureContentHeight() {
|
|
1615
|
+
var _a;
|
|
1616
|
+
const inners = (_a = this.element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll("ibcs-chart-time");
|
|
1617
|
+
let total = 0;
|
|
1618
|
+
let found = false;
|
|
1619
|
+
inners === null || inners === void 0 ? void 0 : inners.forEach((inner) => {
|
|
1620
|
+
var _a, _b, _c;
|
|
1621
|
+
const height = parseFloat((_c = (_b = (_a = inner.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("svg#drawCanvas")) === null || _b === void 0 ? void 0 : _b.getAttribute("height")) !== null && _c !== void 0 ? _c : "");
|
|
1622
|
+
if (!Number.isNaN(height)) {
|
|
1623
|
+
total += height;
|
|
1624
|
+
found = true;
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
// scrollHeight additionally sees non-SVG chrome (e.g. the footer).
|
|
1628
|
+
// Floor the fractional SVG heights so borderline sub-pixel overhangs are
|
|
1629
|
+
// judged with the same integer tolerance as the scroll metrics.
|
|
1630
|
+
return found ? Math.max(Math.floor(total), this.element.scrollHeight) : this.element.scrollHeight;
|
|
1631
|
+
}
|
|
1632
|
+
/**
|
|
1633
|
+
* Reports a WARN_overflow item when the rendered chart exceeds its
|
|
1634
|
+
* container. Overflow attributable to a fixed scaling attribute is an
|
|
1635
|
+
* error (height: unit-scaling / percentage-scaling, width: scale);
|
|
1636
|
+
* overflow in fully-auto mode is a warning — auto-fit prevents it by
|
|
1637
|
+
* construction, so it only fires when the content cannot fit at any scale.
|
|
1638
|
+
*/
|
|
1639
|
+
checkOverflow() {
|
|
1640
|
+
const errId = "WARN_overflow";
|
|
1641
|
+
const parent = scaling.getParentDimensions(this.element);
|
|
1642
|
+
const contentWidth = this.measureContentWidth();
|
|
1643
|
+
const contentHeight = this.measureContentHeight();
|
|
1644
|
+
const widthOver = parent.width > 0 && contentWidth > parent.width + 1;
|
|
1645
|
+
const heightOver = parent.height > 0 && contentHeight > parent.height + 1;
|
|
1646
|
+
if (!widthOver && !heightOver) {
|
|
1647
|
+
this.errors.remove(errId);
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1650
|
+
const hasRelativeVariance = this.prepareVariances().some((variance) => variance.startsWith("dr"));
|
|
1651
|
+
const fixedUnit = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap).kind === "value";
|
|
1652
|
+
const fixedPercent = hasRelativeVariance && scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap).kind === "value";
|
|
1653
|
+
const { mode } = scaling.parseScaling(this.scale);
|
|
1654
|
+
const fixedScale = mode !== "auto" && mode !== "empty";
|
|
1655
|
+
const fixedAttrs = [];
|
|
1656
|
+
if (heightOver && fixedUnit)
|
|
1657
|
+
fixedAttrs.push("unit-scaling");
|
|
1658
|
+
if (heightOver && fixedPercent)
|
|
1659
|
+
fixedAttrs.push("percentage-scaling");
|
|
1660
|
+
if (widthOver && fixedScale)
|
|
1661
|
+
fixedAttrs.push("scale");
|
|
1662
|
+
const dims = [];
|
|
1663
|
+
if (widthOver)
|
|
1664
|
+
dims.push(`width (${Math.round(contentWidth)}px > ${Math.round(parent.width)}px)`);
|
|
1665
|
+
if (heightOver)
|
|
1666
|
+
dims.push(`height (${Math.round(contentHeight)}px > ${Math.round(parent.height)}px)`);
|
|
1667
|
+
this.errors.addOrReplace({
|
|
1668
|
+
id: errId,
|
|
1669
|
+
type: fixedAttrs.length > 0 ? "error" : "warning",
|
|
1670
|
+
message: `Chart exceeds available ${dims.join(" and ")}. ` +
|
|
1671
|
+
(fixedAttrs.length > 0
|
|
1672
|
+
? `Adjust ${fixedAttrs.join(" / ")} or set to "auto".`
|
|
1673
|
+
: "Content does not fit even at minimum auto scaling; enlarge the container."),
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1464
1676
|
componentDidRender() {
|
|
1465
1677
|
const { mode } = scaling.parseScaling(this.scale);
|
|
1466
1678
|
if (mode !== "auto" && mode !== "empty") {
|
|
1467
1679
|
this._autoScaleGuard = false;
|
|
1468
|
-
|
|
1469
|
-
const errId = "WARN_overflow";
|
|
1470
|
-
if (parent.width > 0 && this.element.scrollWidth > parent.width + 1) {
|
|
1471
|
-
this.errors.addOrReplace({
|
|
1472
|
-
id: errId,
|
|
1473
|
-
type: "warning",
|
|
1474
|
-
message: "Chart exceeds available space and will be cut off. Check unit-scaling value.",
|
|
1475
|
-
});
|
|
1476
|
-
}
|
|
1477
|
-
else {
|
|
1478
|
-
this.errors.remove(errId);
|
|
1479
|
-
}
|
|
1680
|
+
this.checkOverflow();
|
|
1480
1681
|
return;
|
|
1481
1682
|
}
|
|
1482
1683
|
if (this._autoScaleGuard) {
|
|
1483
1684
|
this._autoScaleGuard = false;
|
|
1685
|
+
this.checkOverflow();
|
|
1484
1686
|
return;
|
|
1485
1687
|
}
|
|
1486
1688
|
const host = this.element;
|
|
1487
1689
|
const { width: parentWidth } = scaling.getParentDimensions(host);
|
|
1488
|
-
if (parentWidth <= 0)
|
|
1690
|
+
if (parentWidth <= 0) {
|
|
1691
|
+
this.checkOverflow();
|
|
1489
1692
|
return;
|
|
1693
|
+
}
|
|
1490
1694
|
// Keep observer tracking in sync so the observer callback does not
|
|
1491
1695
|
// trigger spurious forceUpdate calls with stale threshold values.
|
|
1492
1696
|
this._lastObservedWidth = parentWidth;
|
|
@@ -1497,6 +1701,7 @@ const Chart = class {
|
|
|
1497
1701
|
// the content only fits BECAUSE of the current factor.
|
|
1498
1702
|
if (currentWidth <= parentWidth + 1) {
|
|
1499
1703
|
this.errors.remove("AUTO_scale");
|
|
1704
|
+
this.checkOverflow();
|
|
1500
1705
|
return;
|
|
1501
1706
|
}
|
|
1502
1707
|
// Content overflows. Compute a new factor based on the ratio of
|
|
@@ -1504,6 +1709,8 @@ const Chart = class {
|
|
|
1504
1709
|
const computedFactor = Math.max(0.3, (currentFactor * (parentWidth - 1)) / currentWidth);
|
|
1505
1710
|
// Only apply if the change is significant (> 1% of current factor).
|
|
1506
1711
|
if (Math.abs(computedFactor - currentFactor) < 0.01) {
|
|
1712
|
+
// Converged (possibly at the 0.3 floor) but still overflowing — report it.
|
|
1713
|
+
this.checkOverflow();
|
|
1507
1714
|
return;
|
|
1508
1715
|
}
|
|
1509
1716
|
host.style.setProperty("--bn-font-size", `${baseFontSize * computedFactor}px`);
|
|
@@ -1521,6 +1728,10 @@ const Chart = class {
|
|
|
1521
1728
|
index.writeTask(() => {
|
|
1522
1729
|
this.appliedScaleFactor = computedFactor;
|
|
1523
1730
|
});
|
|
1731
|
+
// Check with the current (pre-factor) content so overflow is reported
|
|
1732
|
+
// even if the scheduled re-render stalls; the follow-up render re-checks
|
|
1733
|
+
// in the guard branch and clears any transiently reported overflow.
|
|
1734
|
+
this.checkOverflow();
|
|
1524
1735
|
}
|
|
1525
1736
|
componentDidLoad() {
|
|
1526
1737
|
// Watch for size changes (window resize, card relayout).
|
|
@@ -1594,7 +1805,13 @@ const Chart = class {
|
|
|
1594
1805
|
const variancesList = this.prepareVariances();
|
|
1595
1806
|
this.canvasWidthSegmented = parent.width / (scenariosList.length + variancesList.length || 1);
|
|
1596
1807
|
this._lastAppliedHeight = parent.height;
|
|
1597
|
-
|
|
1808
|
+
// The base chart and each variance render as vertically stacked segments
|
|
1809
|
+
// (see render()), so each one may only claim its share of the height.
|
|
1810
|
+
// The measure-scale footer (first segment only) renders below its SVG:
|
|
1811
|
+
// reserve roughly one em for it so the fitted charts leave it room.
|
|
1812
|
+
const segmentCount = 1 + variancesList.length;
|
|
1813
|
+
const footerAllowance = this.showMeasureScale === "true" ? this.getEffectiveFontPx() : 0;
|
|
1814
|
+
return { width: this.canvasWidthSegmented, height: Math.max(0, parent.height - footerAllowance) / segmentCount };
|
|
1598
1815
|
}
|
|
1599
1816
|
prepareScenarios() {
|
|
1600
1817
|
var _a, _b, _c, _d;
|
|
@@ -1650,48 +1867,56 @@ const Chart = class {
|
|
|
1650
1867
|
const i18nMapGlobal = new Map(i18nMetaLabelsGlobal.map((key) => [key, this.t("global.".concat(key))]));
|
|
1651
1868
|
return new Map([...i18nMapGlobal.entries(), ...i18nMapLocal.entries()]);
|
|
1652
1869
|
}
|
|
1870
|
+
/** "not set" for blank input, `invalid value "x"` otherwise — for AUTO_* messages. */
|
|
1871
|
+
static describeScalingInput(raw) {
|
|
1872
|
+
return raw === "" ? "not set" : `invalid value "${raw}"`;
|
|
1873
|
+
}
|
|
1653
1874
|
preparePixelPerUnit() {
|
|
1654
|
-
|
|
1655
|
-
if (
|
|
1875
|
+
const resolved = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap);
|
|
1876
|
+
if (resolved.kind === "value") {
|
|
1656
1877
|
this.errors.remove("AUTO_unitScaling");
|
|
1657
|
-
|
|
1878
|
+
this.autoUnitWarningActive = false;
|
|
1879
|
+
this.lastReportedUnitsPerEm = undefined;
|
|
1880
|
+
// The attribute is data units per em; the inner chart expects px for one data unit.
|
|
1881
|
+
return this.getEffectiveFontPx() / resolved.value;
|
|
1658
1882
|
}
|
|
1659
1883
|
// Explicit 'auto' → auto-calculate silently
|
|
1660
|
-
if (
|
|
1884
|
+
if (resolved.kind === "auto") {
|
|
1661
1885
|
this.errors.remove("AUTO_unitScaling");
|
|
1886
|
+
this.autoUnitWarningActive = false;
|
|
1887
|
+
this.lastReportedUnitsPerEm = undefined;
|
|
1662
1888
|
return 0;
|
|
1663
1889
|
}
|
|
1664
|
-
const numeric = Number(this.unitScaling);
|
|
1665
|
-
if (!isNaN(numeric) && numeric > 0) {
|
|
1666
|
-
this.errors.remove("AUTO_unitScaling");
|
|
1667
|
-
return numeric;
|
|
1668
|
-
}
|
|
1669
1890
|
// Not set / invalid → auto-calculate with warning
|
|
1891
|
+
this.autoUnitWarningActive = true;
|
|
1670
1892
|
this.errors.addOrReplace({
|
|
1671
1893
|
id: "AUTO_unitScaling",
|
|
1672
1894
|
type: "warning",
|
|
1673
|
-
message: `unit-scaling:
|
|
1895
|
+
message: `unit-scaling: ${Chart.describeScalingInput(resolved.raw)}, auto-calculated to fit available space.`,
|
|
1674
1896
|
});
|
|
1675
1897
|
return 0;
|
|
1676
1898
|
}
|
|
1677
1899
|
preparePixelPerPercentage() {
|
|
1678
|
-
|
|
1679
|
-
if (
|
|
1680
|
-
return this.pixelPerUnitGroupMap.get(this.percentageScaling);
|
|
1681
|
-
}
|
|
1682
|
-
if (((_a = this.percentageScaling) === null || _a === void 0 ? void 0 : _a.toString().trim().toLowerCase()) === "auto") {
|
|
1900
|
+
const resolved = scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap);
|
|
1901
|
+
if (resolved.kind === "value") {
|
|
1683
1902
|
this.errors.remove("AUTO_percentageScaling");
|
|
1684
|
-
|
|
1903
|
+
this.autoPctWarningActive = false;
|
|
1904
|
+
this.lastReportedPpPerEm = undefined;
|
|
1905
|
+
// The attribute is percentage points per em; the inner chart expects
|
|
1906
|
+
// px per 1.0 fraction (= per 100 percentage points).
|
|
1907
|
+
return (100 * this.getEffectiveFontPx()) / resolved.value;
|
|
1685
1908
|
}
|
|
1686
|
-
|
|
1687
|
-
if (!isNaN(numeric) && numeric > 0) {
|
|
1909
|
+
if (resolved.kind === "auto") {
|
|
1688
1910
|
this.errors.remove("AUTO_percentageScaling");
|
|
1689
|
-
|
|
1911
|
+
this.autoPctWarningActive = false;
|
|
1912
|
+
this.lastReportedPpPerEm = undefined;
|
|
1913
|
+
return 0;
|
|
1690
1914
|
}
|
|
1915
|
+
this.autoPctWarningActive = true;
|
|
1691
1916
|
this.errors.addOrReplace({
|
|
1692
1917
|
id: "AUTO_percentageScaling",
|
|
1693
1918
|
type: "warning",
|
|
1694
|
-
message: `percentage-scaling:
|
|
1919
|
+
message: `percentage-scaling: ${Chart.describeScalingInput(resolved.raw)}, auto-calculated to fit available space.`,
|
|
1695
1920
|
});
|
|
1696
1921
|
return 0;
|
|
1697
1922
|
}
|
|
@@ -1961,13 +2186,12 @@ const Chart = class {
|
|
|
1961
2186
|
const preparedI18n = this.prepareI18n();
|
|
1962
2187
|
const preparedStyle = this.prepareStyle();
|
|
1963
2188
|
const fullParentWidth = scaling.getParentDimensions(this.element).width;
|
|
1964
|
-
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
1965
2189
|
const ppu = this.preparePixelPerUnit();
|
|
1966
2190
|
const ppp = this.preparePixelPerPercentage();
|
|
1967
2191
|
const stackConfig = this.prepareStackConfig();
|
|
1968
2192
|
const scenarios = this.prepareScenarios();
|
|
1969
2193
|
const effectiveScenarios = (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === VarianceMeasure.StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
|
|
1970
|
-
return (index.h("ibcs-chart-time", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideAxisLabels: this.prepareHideAxisLabels(idx), pixelPerUnit: ppu
|
|
2194
|
+
return (index.h("ibcs-chart-time", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideAxisLabels: this.prepareHideAxisLabels(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, limit: this.prepareLimit(), leftSideOffsetForHorizontalSync: this.prepareLeftSideOffset(preparedI18n, preparedStyle), styles: preparedStyle, i18n: preparedI18n, order: this.prepareOrder(), level: this.prepareLevel(), dateInterval: this.prepareDateInterval(), intervalSpanLimit: this.prepareIntervalSpanLimit(), axisLabelsMode: this.prepareAxisLabelsMode(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showOverlayAvg: this.prepareAvg(), showOverlayMedian: this.prepareMedian(), showMeasureScale: this.prepareShowMeasureScale(idx), chartMode: this.prepareChartMode(), maxBars: this.prepareMaxBars(), stackConfig: stackConfig, lineFullWidth: this.prepareLineFullWidth(), containerWidth: fullParentWidth, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
|
|
1971
2195
|
}
|
|
1972
2196
|
getEffectiveScaleFactor() {
|
|
1973
2197
|
const { mode, factor } = scaling.parseScaling(this.scale);
|
|
@@ -1977,6 +2201,11 @@ const Chart = class {
|
|
|
1977
2201
|
return this.appliedScaleFactor;
|
|
1978
2202
|
return 1;
|
|
1979
2203
|
}
|
|
2204
|
+
/** Effective font size in px: base font from the style store × effective scale factor. */
|
|
2205
|
+
getEffectiveFontPx() {
|
|
2206
|
+
const baseFontSize = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; });
|
|
2207
|
+
return baseFontSize * this.getEffectiveScaleFactor();
|
|
2208
|
+
}
|
|
1980
2209
|
getFontStyles() {
|
|
1981
2210
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
1982
2211
|
return this.componentStyle(($) => {
|
|
@@ -1997,7 +2226,7 @@ const Chart = class {
|
|
|
1997
2226
|
scenariosArray = [...scenariosArray, ...variancesArray];
|
|
1998
2227
|
}
|
|
1999
2228
|
const fontStyles = this.getFontStyles();
|
|
2000
|
-
return (index.h(index.Host, { key: '
|
|
2229
|
+
return (index.h(index.Host, { key: 'aff5ffed56838af70ca1525204497a708194012e', style: fontStyles }, index.h("div", { key: 'a9e0699c0fdbff19efe787e438ddf2921fac35a4', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
2001
2230
|
}
|
|
2002
2231
|
get element() { return index.getElement(this); }
|
|
2003
2232
|
static get watchers() { return {
|
|
@@ -3937,28 +4166,44 @@ const ScalingGroup = class {
|
|
|
3937
4166
|
this.stores = contextProtocol.getStores(this.element);
|
|
3938
4167
|
this.pushToStore();
|
|
3939
4168
|
}
|
|
4169
|
+
disconnectedCallback() {
|
|
4170
|
+
this.removeEntryIfOurs(this.storedName);
|
|
4171
|
+
}
|
|
3940
4172
|
onNameChange(newName, oldName) {
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
const current = this.stores.scalingGroups.state[oldName];
|
|
3945
|
-
if (current === this.value) {
|
|
3946
|
-
// @ts-ignore – dynamic key
|
|
3947
|
-
this.stores.scalingGroups.set(oldName, undefined);
|
|
3948
|
-
}
|
|
4173
|
+
const trimmedOld = oldName === null || oldName === void 0 ? void 0 : oldName.toString().trim();
|
|
4174
|
+
if (trimmedOld && trimmedOld !== (newName === null || newName === void 0 ? void 0 : newName.toString().trim())) {
|
|
4175
|
+
this.removeEntryIfOurs(trimmedOld);
|
|
3949
4176
|
}
|
|
3950
4177
|
this.pushToStore();
|
|
3951
4178
|
}
|
|
3952
4179
|
onValueChange() {
|
|
3953
4180
|
this.pushToStore();
|
|
3954
4181
|
}
|
|
4182
|
+
/**
|
|
4183
|
+
* Removes the store entry for `name` — but only if it still holds the value
|
|
4184
|
+
* this element wrote (another bn-scaling-group with the same name may have
|
|
4185
|
+
* overwritten it).
|
|
4186
|
+
*/
|
|
4187
|
+
removeEntryIfOurs(name) {
|
|
4188
|
+
if (!name || !this.stores)
|
|
4189
|
+
return;
|
|
4190
|
+
if (this.storedName === name && this.stores.scalingGroups.state[name] === this.storedValue) {
|
|
4191
|
+
// @ts-ignore – dynamic key
|
|
4192
|
+
this.stores.scalingGroups.set(name, undefined);
|
|
4193
|
+
}
|
|
4194
|
+
if (this.storedName === name) {
|
|
4195
|
+
this.storedName = undefined;
|
|
4196
|
+
this.storedValue = undefined;
|
|
4197
|
+
}
|
|
4198
|
+
}
|
|
3955
4199
|
pushToStore() {
|
|
3956
4200
|
var _a;
|
|
3957
4201
|
if (!this.stores)
|
|
3958
4202
|
return;
|
|
3959
4203
|
const trimmedName = (_a = this.name) === null || _a === void 0 ? void 0 : _a.toString().trim();
|
|
4204
|
+
const nameParse = scaling.parseScalingValue(trimmedName);
|
|
3960
4205
|
// Validate: "auto" is reserved
|
|
3961
|
-
if (
|
|
4206
|
+
if (nameParse.kind === "auto") {
|
|
3962
4207
|
this.errors.addOrReplace({
|
|
3963
4208
|
id: "ERR_reserved_name",
|
|
3964
4209
|
type: "warning",
|
|
@@ -3976,11 +4221,49 @@ const ScalingGroup = class {
|
|
|
3976
4221
|
return;
|
|
3977
4222
|
}
|
|
3978
4223
|
this.errors.remove("ERR_empty_name");
|
|
4224
|
+
// Validate: a name that parses as a number/SI value would be ambiguous
|
|
4225
|
+
// with a literal scaling value at the referencing component.
|
|
4226
|
+
if (nameParse.kind === "number") {
|
|
4227
|
+
this.errors.addOrReplace({
|
|
4228
|
+
id: "ERR_numeric_name",
|
|
4229
|
+
type: "warning",
|
|
4230
|
+
message: `bn-scaling-group: name "${trimmedName}" is not allowed — it would be ambiguous with a numeric scaling value.`,
|
|
4231
|
+
});
|
|
4232
|
+
return;
|
|
4233
|
+
}
|
|
4234
|
+
this.errors.remove("ERR_numeric_name");
|
|
4235
|
+
const parsedValue = scaling.parseScalingValue(this.value);
|
|
4236
|
+
if (parsedValue.kind !== "number") {
|
|
4237
|
+
this.errors.addOrReplace({
|
|
4238
|
+
id: "ERR_invalid_value",
|
|
4239
|
+
type: "warning",
|
|
4240
|
+
message: `bn-scaling-group: invalid value "${this.value}" — must be a positive number, optionally with k/M/G/T suffix.`,
|
|
4241
|
+
});
|
|
4242
|
+
return;
|
|
4243
|
+
}
|
|
4244
|
+
this.errors.remove("ERR_invalid_value");
|
|
4245
|
+
const existing = this.stores.scalingGroups.state[trimmedName];
|
|
4246
|
+
const wroteExisting = this.storedName === trimmedName && this.storedValue === existing;
|
|
4247
|
+
if (existing !== undefined && existing !== parsedValue.value && !wroteExisting) {
|
|
4248
|
+
this.errors.addOrReplace({
|
|
4249
|
+
id: "WARN_duplicate_group",
|
|
4250
|
+
type: "warning",
|
|
4251
|
+
message: `bn-scaling-group: "${trimmedName}" is already registered with a different value (${scaling.formatScalingValue(existing)}); overwriting.`,
|
|
4252
|
+
});
|
|
4253
|
+
}
|
|
4254
|
+
else {
|
|
4255
|
+
this.errors.remove("WARN_duplicate_group");
|
|
4256
|
+
}
|
|
4257
|
+
if (this.storedName && this.storedName !== trimmedName) {
|
|
4258
|
+
this.removeEntryIfOurs(this.storedName);
|
|
4259
|
+
}
|
|
3979
4260
|
// @ts-ignore – dynamic key
|
|
3980
|
-
this.stores.scalingGroups.set(trimmedName,
|
|
4261
|
+
this.stores.scalingGroups.set(trimmedName, parsedValue.value);
|
|
4262
|
+
this.storedName = trimmedName;
|
|
4263
|
+
this.storedValue = parsedValue.value;
|
|
3981
4264
|
}
|
|
3982
4265
|
render() {
|
|
3983
|
-
return index.h(index.Host, { key: '
|
|
4266
|
+
return index.h(index.Host, { key: '7b125b03953f91d15c6c9df7ca178c9f33b054cc' });
|
|
3984
4267
|
}
|
|
3985
4268
|
get element() { return index.getElement(this); }
|
|
3986
4269
|
static get watchers() { return {
|
|
@@ -4242,38 +4525,50 @@ const Table$1 = class Table {
|
|
|
4242
4525
|
*/
|
|
4243
4526
|
this.measureUnit = "";
|
|
4244
4527
|
/**
|
|
4245
|
-
* Set width of bar chart columns
|
|
4528
|
+
* Set the total width of bar chart columns, in em of the table font — the same
|
|
4529
|
+
* unit and vocabulary as ```categoryWidth```, so ```bar-column-width="w15"```
|
|
4530
|
+
* renders exactly as wide as ```category-width="w15"```. The bar/pin drawing
|
|
4531
|
+
* area is that width minus the value-label gutters.
|
|
4246
4532
|
* <br /><br />
|
|
4247
4533
|
* values:<br />
|
|
4248
4534
|
* ``` w5 // w10 // w15 // w20 // w25 // w30 // w40 // w60 // w80 // w100 ```
|
|
4249
4535
|
*/
|
|
4250
4536
|
this.barColumnWidth = "w10";
|
|
4251
4537
|
/**
|
|
4252
|
-
*
|
|
4253
|
-
*
|
|
4538
|
+
* Data units displayed per 1 em of bar length for absolute variance bar
|
|
4539
|
+
* charts (ΔPY) — map-scale semantics: a larger value means smaller bars.
|
|
4254
4540
|
* Bars exceeding barColumnWidth are shown with an arrow indicator.
|
|
4255
|
-
* <br /><br />
|
|
4256
|
-
* Accepts a number, `"auto"`, or a `<bn-scaling-group>` name for synchronized scaling.
|
|
4257
|
-
* <br /><br />
|
|
4258
|
-
* Default: 0.01
|
|
4259
4541
|
*
|
|
4260
|
-
*
|
|
4542
|
+
* | Value | Behavior |
|
|
4543
|
+
* |------------------|----------------------------------------------------------------|
|
|
4544
|
+
* | `"auto"` | Auto-fit the largest bar to the bar column width |
|
|
4545
|
+
* | `"250000"`, `"1M"` | Units per em; optional SI suffix `k`/`K`/`M`/`G`/`T` |
|
|
4546
|
+
* | group name | References a `<bn-scaling-group>` for synchronized scaling |
|
|
4547
|
+
* | invalid / unknown | Auto-fit + `AUTO_unitScaling` warning |
|
|
4548
|
+
*
|
|
4549
|
+
* Default: `"100"` (1 em of bar represents 100 units)
|
|
4550
|
+
*
|
|
4551
|
+
* @example unit-scaling="1M"
|
|
4261
4552
|
* @example unit-scaling="revenue-scale"
|
|
4262
4553
|
*/
|
|
4263
|
-
this.unitScaling =
|
|
4554
|
+
this.unitScaling = "100";
|
|
4264
4555
|
/**
|
|
4265
|
-
*
|
|
4266
|
-
*
|
|
4267
|
-
*
|
|
4268
|
-
*
|
|
4269
|
-
*
|
|
4270
|
-
*
|
|
4271
|
-
*
|
|
4556
|
+
* Percentage points displayed per 1 em of pin length for relative variance
|
|
4557
|
+
* pin charts (ΔPY%) — a larger value means shorter pins.
|
|
4558
|
+
*
|
|
4559
|
+
* | Value | Behavior |
|
|
4560
|
+
* |------------------|----------------------------------------------------------------|
|
|
4561
|
+
* | `"auto"` | Auto-fit the largest pin to the pin area |
|
|
4562
|
+
* | `"10"`, `"2.5"` | Percentage points per em; optional SI suffix `k`/`K`/`M`/`G`/`T` |
|
|
4563
|
+
* | group name | References a `<bn-scaling-group>` for synchronized scaling |
|
|
4564
|
+
* | invalid / unknown | Auto-fit + `AUTO_percentageScaling` warning |
|
|
4565
|
+
*
|
|
4566
|
+
* Default: `"2"` (a +2 % variance pin is 1 em long)
|
|
4272
4567
|
*
|
|
4273
|
-
* @example percentage-scaling="
|
|
4568
|
+
* @example percentage-scaling="10"
|
|
4274
4569
|
* @example percentage-scaling="pct-scale"
|
|
4275
4570
|
*/
|
|
4276
|
-
this.percentageScaling =
|
|
4571
|
+
this.percentageScaling = "2";
|
|
4277
4572
|
// Global scaling groups map - can be populated externally for shared scaling across components
|
|
4278
4573
|
this.pixelPerUnitGroupMap = new Map();
|
|
4279
4574
|
/**
|
|
@@ -4387,7 +4682,7 @@ const Table$1 = class Table {
|
|
|
4387
4682
|
* original value.
|
|
4388
4683
|
* <br /><br />
|
|
4389
4684
|
* values: <br />
|
|
4390
|
-
* ```_ // k // M // G // T // P // E // Z // Y // m // μ // n // p //
|
|
4685
|
+
* ```_ // k // M // G // T // P // E // Z // Y // m // my (μ) // n // p // f // a // z // y // GREATEST // LEAST```
|
|
4391
4686
|
* <br /><br />
|
|
4392
4687
|
* SiPrefix overview:
|
|
4393
4688
|
* ``` "Y": 1E+24,```<br />
|
|
@@ -4400,7 +4695,7 @@ const Table$1 = class Table {
|
|
|
4400
4695
|
* ``` "k": 1000,```<br />
|
|
4401
4696
|
* <br />
|
|
4402
4697
|
* ``` "m": 0.001,```<br />
|
|
4403
|
-
* ``` "μ
|
|
4698
|
+
* ``` "my" (μ): 0.000001,```<br />
|
|
4404
4699
|
* ``` "n": 0.000000001,```<br />
|
|
4405
4700
|
* ``` "p": 0.000000000001,```<br />
|
|
4406
4701
|
* ``` "f": 0.000000000000001,```<br />
|
|
@@ -4426,10 +4721,13 @@ const Table$1 = class Table {
|
|
|
4426
4721
|
*/
|
|
4427
4722
|
this.dataFormatDigitsPercent = 2;
|
|
4428
4723
|
/**
|
|
4429
|
-
* Set width of category column. <br />
|
|
4724
|
+
* Set width of category column, in em of the table font. <br />
|
|
4430
4725
|
* If INF is selected the columns scaling to the min space they need
|
|
4431
4726
|
* seperatly.
|
|
4432
4727
|
* <br /><br />
|
|
4728
|
+
* The column is fixed at this width; a category label too long to fit is
|
|
4729
|
+
* truncated with an ellipsis.
|
|
4730
|
+
* <br /><br />
|
|
4433
4731
|
* values:<br />
|
|
4434
4732
|
* ``` w5 // w10 // w15 // w20 // w25 // w50 // inf ```
|
|
4435
4733
|
*/
|
|
@@ -4472,6 +4770,39 @@ const Table$1 = class Table {
|
|
|
4472
4770
|
*/
|
|
4473
4771
|
this.tableAttributes = "";
|
|
4474
4772
|
this._autoScaleGuard = false;
|
|
4773
|
+
this.autoUnitWarningActive = false;
|
|
4774
|
+
this.autoPctWarningActive = false;
|
|
4775
|
+
/**
|
|
4776
|
+
* Receives the auto-fitted scaling values from the inner ibcs-table
|
|
4777
|
+
* (em per unit / em per percentage point) and surfaces them in the AUTO_*
|
|
4778
|
+
* warnings, converted back to the attribute's units-per-em form so users
|
|
4779
|
+
* can copy them into a bn-scaling-group.
|
|
4780
|
+
*/
|
|
4781
|
+
this.handleAutoScalingReport = (report) => {
|
|
4782
|
+
const changed = (next, last) => last === undefined || Math.abs(next - last) > Math.abs(next) * 1e-3;
|
|
4783
|
+
if (report.unit !== undefined && report.unit > 0 && this.autoUnitWarningActive) {
|
|
4784
|
+
const unitsPerEm = 1 / report.unit;
|
|
4785
|
+
if (changed(unitsPerEm, this.lastReportedUnitsPerEm)) {
|
|
4786
|
+
this.lastReportedUnitsPerEm = unitsPerEm;
|
|
4787
|
+
this.errors.addOrReplace({
|
|
4788
|
+
id: "AUTO_unitScaling",
|
|
4789
|
+
type: "warning",
|
|
4790
|
+
message: `unit-scaling: invalid value "${this.unitScaling}" — auto-fitted to 1 em ≈ ${scaling.formatScalingValue(unitsPerEm)} units.`,
|
|
4791
|
+
});
|
|
4792
|
+
}
|
|
4793
|
+
}
|
|
4794
|
+
if (report.percentage !== undefined && report.percentage > 0 && this.autoPctWarningActive) {
|
|
4795
|
+
const ppPerEm = 1 / report.percentage;
|
|
4796
|
+
if (changed(ppPerEm, this.lastReportedPpPerEm)) {
|
|
4797
|
+
this.lastReportedPpPerEm = ppPerEm;
|
|
4798
|
+
this.errors.addOrReplace({
|
|
4799
|
+
id: "AUTO_percentageScaling",
|
|
4800
|
+
type: "warning",
|
|
4801
|
+
message: `percentage-scaling: invalid value "${this.percentageScaling}" — auto-fitted to 1 em ≈ ${scaling.formatScalingValue(ppPerEm)} percentage points.`,
|
|
4802
|
+
});
|
|
4803
|
+
}
|
|
4804
|
+
}
|
|
4805
|
+
};
|
|
4475
4806
|
withStyled.withStyled(this);
|
|
4476
4807
|
withHasError.withComponentStatus(this);
|
|
4477
4808
|
this.errors = withHasError.withHasError(this);
|
|
@@ -4566,8 +4897,7 @@ const Table$1 = class Table {
|
|
|
4566
4897
|
}
|
|
4567
4898
|
validateUnitScaling(newValue) {
|
|
4568
4899
|
const errId = "ERR_unitScaling";
|
|
4569
|
-
|
|
4570
|
-
if (!isAuto && !withStyled.isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
|
|
4900
|
+
if (scaling.resolveScalingValue(newValue, this.pixelPerUnitGroupMap).kind === "invalid") {
|
|
4571
4901
|
this.errors.addOrReplace({
|
|
4572
4902
|
id: errId,
|
|
4573
4903
|
type: "warning",
|
|
@@ -4580,8 +4910,7 @@ const Table$1 = class Table {
|
|
|
4580
4910
|
}
|
|
4581
4911
|
validatePercentageScaling(newValue) {
|
|
4582
4912
|
const errId = "ERR_percentageScaling";
|
|
4583
|
-
|
|
4584
|
-
if (!isAuto && !withStyled.isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
|
|
4913
|
+
if (scaling.resolveScalingValue(newValue, this.pixelPerUnitGroupMap).kind === "invalid") {
|
|
4585
4914
|
this.errors.addOrReplace({
|
|
4586
4915
|
id: errId,
|
|
4587
4916
|
type: "warning",
|
|
@@ -5216,24 +5545,50 @@ const Table$1 = class Table {
|
|
|
5216
5545
|
return this.barColumns.split(",").map((col) => col.trim());
|
|
5217
5546
|
}
|
|
5218
5547
|
prepareUnitScaling() {
|
|
5219
|
-
|
|
5220
|
-
if (
|
|
5221
|
-
|
|
5548
|
+
const resolved = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap);
|
|
5549
|
+
if (resolved.kind === "value") {
|
|
5550
|
+
this.errors.remove("AUTO_unitScaling");
|
|
5551
|
+
this.autoUnitWarningActive = false;
|
|
5552
|
+
this.lastReportedUnitsPerEm = undefined;
|
|
5553
|
+
// Inner ibcs-table expects em per unit; the attribute is units per em.
|
|
5554
|
+
return 1 / resolved.value;
|
|
5222
5555
|
}
|
|
5223
|
-
if (
|
|
5556
|
+
if (resolved.kind === "auto") {
|
|
5557
|
+
this.errors.remove("AUTO_unitScaling");
|
|
5558
|
+
this.autoUnitWarningActive = false;
|
|
5559
|
+
this.lastReportedUnitsPerEm = undefined;
|
|
5224
5560
|
return 0;
|
|
5225
5561
|
}
|
|
5226
|
-
|
|
5562
|
+
this.autoUnitWarningActive = true;
|
|
5563
|
+
this.errors.addOrReplace({
|
|
5564
|
+
id: "AUTO_unitScaling",
|
|
5565
|
+
type: "warning",
|
|
5566
|
+
message: `unit-scaling: invalid value "${resolved.raw}" — auto-fitting to the bar column width.`,
|
|
5567
|
+
});
|
|
5568
|
+
return 0;
|
|
5227
5569
|
}
|
|
5228
5570
|
preparePercentageScaling() {
|
|
5229
|
-
|
|
5230
|
-
if (
|
|
5231
|
-
|
|
5571
|
+
const resolved = scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap);
|
|
5572
|
+
if (resolved.kind === "value") {
|
|
5573
|
+
this.errors.remove("AUTO_percentageScaling");
|
|
5574
|
+
this.autoPctWarningActive = false;
|
|
5575
|
+
this.lastReportedPpPerEm = undefined;
|
|
5576
|
+
// Inner ibcs-table expects em per percentage point.
|
|
5577
|
+
return 1 / resolved.value;
|
|
5232
5578
|
}
|
|
5233
|
-
if (
|
|
5579
|
+
if (resolved.kind === "auto") {
|
|
5580
|
+
this.errors.remove("AUTO_percentageScaling");
|
|
5581
|
+
this.autoPctWarningActive = false;
|
|
5582
|
+
this.lastReportedPpPerEm = undefined;
|
|
5234
5583
|
return 0;
|
|
5235
5584
|
}
|
|
5236
|
-
|
|
5585
|
+
this.autoPctWarningActive = true;
|
|
5586
|
+
this.errors.addOrReplace({
|
|
5587
|
+
id: "AUTO_percentageScaling",
|
|
5588
|
+
type: "warning",
|
|
5589
|
+
message: `percentage-scaling: invalid value "${resolved.raw}" — auto-fitting to the pin area.`,
|
|
5590
|
+
});
|
|
5591
|
+
return 0;
|
|
5237
5592
|
}
|
|
5238
5593
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5239
5594
|
getDataStructure() {
|
|
@@ -5296,7 +5651,7 @@ const Table$1 = class Table {
|
|
|
5296
5651
|
render() {
|
|
5297
5652
|
const fontStyles = this.getFontStyles();
|
|
5298
5653
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
5299
|
-
return (index.h(index.Host, { key: '
|
|
5654
|
+
return (index.h(index.Host, { key: '7960f554ac93c0fb6a09cf47f886827fff1aea84', style: fontStyles }, index.h("div", { key: 'e9f328144ab89bbde8c47111f7ce7de7a6c882db' }, index.h("ibcs-table", { key: 'a06695fad28dc30967784006c151abd47d2efd77', 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 }))));
|
|
5300
5655
|
}
|
|
5301
5656
|
get element() { return index.getElement(this); }
|
|
5302
5657
|
static get watchers() { return {
|
|
@@ -6115,6 +6470,10 @@ class DataAnalyzer {
|
|
|
6115
6470
|
if (mode === "_") {
|
|
6116
6471
|
return new LabelCollisionManager.SiPrefix();
|
|
6117
6472
|
}
|
|
6473
|
+
// Accept the Unicode micro sign as an alias for the ASCII "my" key.
|
|
6474
|
+
if (mode === "μ") {
|
|
6475
|
+
mode = "my";
|
|
6476
|
+
}
|
|
6118
6477
|
if (mode != null) {
|
|
6119
6478
|
if ([...this.unitsLeast, ...this.unitsGreat].includes(mode)) {
|
|
6120
6479
|
return this.lookupPrefix(mode);
|
|
@@ -6149,17 +6508,22 @@ class DataAnalyzer {
|
|
|
6149
6508
|
}
|
|
6150
6509
|
return this.determinePrefix(Math.abs(num));
|
|
6151
6510
|
}
|
|
6152
|
-
/**
|
|
6511
|
+
/**
|
|
6512
|
+
* Maps an absolute numeric value to the best-fitting SI prefix based on
|
|
6513
|
+
* its decimal magnitude. Values in (0.001, 1000) keep the identity prefix.
|
|
6514
|
+
* Magnitudes beyond the covered SI range clamp to the outermost prefix.
|
|
6515
|
+
*/
|
|
6153
6516
|
static determinePrefix(num) {
|
|
6517
|
+
if (!Number.isFinite(num) || num <= 0) {
|
|
6518
|
+
return new LabelCollisionManager.SiPrefix();
|
|
6519
|
+
}
|
|
6154
6520
|
if (num >= 1000) {
|
|
6155
|
-
const
|
|
6156
|
-
|
|
6157
|
-
return new LabelCollisionManager.SiPrefix(this.unitsGreat[floor - 1], value);
|
|
6521
|
+
const idx = Math.min(Math.floor(Math.log10(num) / 3), this.unitsGreat.length) - 1;
|
|
6522
|
+
return new LabelCollisionManager.SiPrefix(this.unitsGreat[idx], Math.pow(1000, idx + 1));
|
|
6158
6523
|
}
|
|
6159
6524
|
if (num <= 0.001) {
|
|
6160
|
-
const
|
|
6161
|
-
|
|
6162
|
-
return new LabelCollisionManager.SiPrefix(this.unitsLeast[floor - 1], value);
|
|
6525
|
+
const idx = Math.min(-Math.floor(Math.log10(num) / 3), this.unitsLeast.length) - 1;
|
|
6526
|
+
return new LabelCollisionManager.SiPrefix(this.unitsLeast[idx], Math.pow(1000, -(idx + 1)));
|
|
6163
6527
|
}
|
|
6164
6528
|
return new LabelCollisionManager.SiPrefix();
|
|
6165
6529
|
}
|
|
@@ -6171,7 +6535,7 @@ class DataAnalyzer {
|
|
|
6171
6535
|
/** SI prefixes for large numbers, ordered by magnitude (k=10^3 .. Y=10^24). */
|
|
6172
6536
|
DataAnalyzer.unitsGreat = ["k", "M", "G", "T", "P", "E", "Z", "Y"];
|
|
6173
6537
|
/** SI prefixes for small numbers, ordered by magnitude (m=10^-3 .. y=10^-24). */
|
|
6174
|
-
DataAnalyzer.unitsLeast = ["m", "my", "n", "p", "
|
|
6538
|
+
DataAnalyzer.unitsLeast = ["m", "my", "n", "p", "f", "a", "z", "y"];
|
|
6175
6539
|
|
|
6176
6540
|
class StringAdapter {
|
|
6177
6541
|
adapt(data) {
|
|
@@ -7655,6 +8019,70 @@ let ScenarioFactory$1 = class ScenarioFactory {
|
|
|
7655
8019
|
}
|
|
7656
8020
|
};
|
|
7657
8021
|
|
|
8022
|
+
/**
|
|
8023
|
+
* Pure math for the chart auto-fit loops (ibcs-chart-structure fits width,
|
|
8024
|
+
* ibcs-chart-time fits height). Kept free of chart/svg.js imports so it can
|
|
8025
|
+
* be unit-tested under mock-doc (which lacks getBBox).
|
|
8026
|
+
*
|
|
8027
|
+
* Model: a chart's size along its fit axis is affine in the pixel scales,
|
|
8028
|
+
* measured = fixed + unitExtent * pixelPerUnit + pctExtent * pixelPerPercentage
|
|
8029
|
+
* where the extents are the total bar lengths in data units (positive plus
|
|
8030
|
+
* negative side of the axis). The chart classes report their extents via
|
|
8031
|
+
* getUnitBarExtent()/getPercentBarExtent(); {@link solveAutoFitStep} solves
|
|
8032
|
+
* the model for the target size against a fresh measurement, so repeated
|
|
8033
|
+
* steps converge even when clamped label widths flip between passes.
|
|
8034
|
+
*/
|
|
8035
|
+
/** Lower bound for auto-fitted pixelPerUnit / pixelPerPercentage values. */
|
|
8036
|
+
const MIN_PIXEL_SCALE = 0.001;
|
|
8037
|
+
/**
|
|
8038
|
+
* Total bar extent (in data units) that scales linearly with pixelPerUnit.
|
|
8039
|
+
* Counts BOTH sides of the axis — a chart with values -13..+12 spans 25
|
|
8040
|
+
* units, not 12 (fitting only the positive side is how charts used to
|
|
8041
|
+
* overshoot their container).
|
|
8042
|
+
*/
|
|
8043
|
+
function computeUnitBarExtent(inputs) {
|
|
8044
|
+
if (inputs.fixedDomain != null) {
|
|
8045
|
+
return Math.max(0, inputs.fixedDomain);
|
|
8046
|
+
}
|
|
8047
|
+
if (inputs.relativeVariance) {
|
|
8048
|
+
return 0; // relative variance bars scale with pixelPerPercentage instead
|
|
8049
|
+
}
|
|
8050
|
+
return Math.max(0, inputs.maxPositive) + Math.abs(Math.min(0, inputs.minNegative));
|
|
8051
|
+
}
|
|
8052
|
+
/**
|
|
8053
|
+
* Total bar extent (in fraction units) that scales linearly with
|
|
8054
|
+
* pixelPerPercentage. Only relative variances use it; each side is clamped
|
|
8055
|
+
* because extreme pins render as fixed-size arrows instead of longer bars.
|
|
8056
|
+
*/
|
|
8057
|
+
function computePercentBarExtent(inputs) {
|
|
8058
|
+
var _a;
|
|
8059
|
+
if (!inputs.relativeVariance) {
|
|
8060
|
+
return 0;
|
|
8061
|
+
}
|
|
8062
|
+
const clamp = (_a = inputs.sideClamp) !== null && _a !== void 0 ? _a : 1.45;
|
|
8063
|
+
const positive = Math.min(clamp, Math.max(0, inputs.maxPositive));
|
|
8064
|
+
const negative = Math.min(clamp, Math.abs(Math.min(0, inputs.minNegative)));
|
|
8065
|
+
return positive + negative;
|
|
8066
|
+
}
|
|
8067
|
+
/**
|
|
8068
|
+
* Solves the affine size model for the target and returns corrected scale
|
|
8069
|
+
* values (floored at {@link MIN_PIXEL_SCALE}). Returns an empty object when
|
|
8070
|
+
* nothing scales with the solved values (both extents 0) — callers fall back
|
|
8071
|
+
* to a ratio heuristic. Only the quantities whose extent is > 0 are returned.
|
|
8072
|
+
*/
|
|
8073
|
+
function solveAutoFitStep(inputs) {
|
|
8074
|
+
const divisor = inputs.unitExtent + inputs.pctExtent;
|
|
8075
|
+
if (divisor <= 0) {
|
|
8076
|
+
return {};
|
|
8077
|
+
}
|
|
8078
|
+
const fixed = inputs.measured - inputs.unitExtent * inputs.currentPpu - inputs.pctExtent * inputs.currentPpp;
|
|
8079
|
+
const solved = Math.max(MIN_PIXEL_SCALE, (inputs.target - fixed) / divisor);
|
|
8080
|
+
return {
|
|
8081
|
+
ppu: inputs.unitExtent > 0 ? solved : undefined,
|
|
8082
|
+
ppp: inputs.pctExtent > 0 ? solved : undefined,
|
|
8083
|
+
};
|
|
8084
|
+
}
|
|
8085
|
+
|
|
7658
8086
|
/**
|
|
7659
8087
|
* Orchestrates the full rendering pipeline for an IBCS structure (categorical) chart.
|
|
7660
8088
|
*
|
|
@@ -7855,28 +8283,38 @@ class StructureChart {
|
|
|
7855
8283
|
}
|
|
7856
8284
|
}
|
|
7857
8285
|
/**
|
|
7858
|
-
*
|
|
7859
|
-
*
|
|
8286
|
+
* Total bar extent (data units) proportional to pixelPerUnit, covering
|
|
8287
|
+
* BOTH sides of the axis (left side scales with negative values, right
|
|
8288
|
+
* side with positive ones). Used by autoFitScaling to separate fixed
|
|
8289
|
+
* from variable width components.
|
|
7860
8290
|
*/
|
|
7861
|
-
|
|
8291
|
+
getUnitBarExtent() {
|
|
7862
8292
|
var _a, _b;
|
|
7863
|
-
|
|
7864
|
-
if (this.stackConfig != null && this.highestStackedTotal > 0) {
|
|
7865
|
-
if (this.stackConfig.mode === VarianceMeasure.StackMode.RELATIVE) {
|
|
7866
|
-
return 1;
|
|
7867
|
-
}
|
|
7868
|
-
return this.highestStackedTotal;
|
|
7869
|
-
}
|
|
7870
|
-
// Non-stacked: bar extent = highestDataPointValue * ppu
|
|
8293
|
+
const stacked = this.stackConfig != null && this.highestStackedTotal > 0;
|
|
7871
8294
|
const vt = this.getVarianceType();
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
8295
|
+
const isVariance = vt !== VarianceType$1.NONE;
|
|
8296
|
+
const highest = isVariance ? this.highestVarianceDataPointValue : this.highestDataPointValue;
|
|
8297
|
+
const smallest = isVariance ? this.smallestVarianceDataPointValue : this.smallestDataPointValue;
|
|
8298
|
+
return computeUnitBarExtent({
|
|
8299
|
+
// Relative stacks span exactly 1 * ppu; absolute stacks the max row total
|
|
8300
|
+
fixedDomain: stacked ? (this.stackConfig.mode === VarianceMeasure.StackMode.RELATIVE ? 1 : this.highestStackedTotal) : undefined,
|
|
8301
|
+
relativeVariance: vt === VarianceType$1.RELATIVE,
|
|
8302
|
+
maxPositive: (_a = highest === null || highest === void 0 ? void 0 : highest.value) !== null && _a !== void 0 ? _a : 0,
|
|
8303
|
+
minNegative: (_b = smallest === null || smallest === void 0 ? void 0 : smallest.value) !== null && _b !== void 0 ? _b : 0,
|
|
8304
|
+
});
|
|
8305
|
+
}
|
|
8306
|
+
/**
|
|
8307
|
+
* Total bar extent (fraction units) proportional to pixelPerPercentage.
|
|
8308
|
+
* Only relative variances scale with it; each side clamps at +/-145%
|
|
8309
|
+
* because clipped needles render as fixed-size arrows.
|
|
8310
|
+
*/
|
|
8311
|
+
getPercentBarExtent() {
|
|
8312
|
+
var _a, _b, _c, _d;
|
|
8313
|
+
return computePercentBarExtent({
|
|
8314
|
+
relativeVariance: this.getVarianceType() === VarianceType$1.RELATIVE,
|
|
8315
|
+
maxPositive: (_b = (_a = this.highestVarianceDataPointValue) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0,
|
|
8316
|
+
minNegative: (_d = (_c = this.smallestVarianceDataPointValue) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 0,
|
|
8317
|
+
});
|
|
7880
8318
|
}
|
|
7881
8319
|
getAllocatedCanvasWidth() {
|
|
7882
8320
|
//let columnLabelWidth = this.calculateCategoryWidth();
|
|
@@ -8767,7 +9205,7 @@ class DataFormatDigitsAdapter {
|
|
|
8767
9205
|
}
|
|
8768
9206
|
}
|
|
8769
9207
|
|
|
8770
|
-
const bnChartStructureCss = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
|
|
9208
|
+
const bnChartStructureCss = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
|
|
8771
9209
|
|
|
8772
9210
|
const IbcsChartStructure = class {
|
|
8773
9211
|
constructor(hostRef) {
|
|
@@ -8820,8 +9258,14 @@ const IbcsChartStructure = class {
|
|
|
8820
9258
|
const styles = this.prepareStyle();
|
|
8821
9259
|
this.chart = new StructureChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), db, this.tableName, config, styles);
|
|
8822
9260
|
this.chart.setI18n(this.i18n);
|
|
9261
|
+
// The broken-bar overdrive exists to absorb MANUAL scaling overflow.
|
|
9262
|
+
// autoFitScaling mutates config.pixelPerUnit to the solved value, so
|
|
9263
|
+
// remember auto mode beforehand and skip the overdrive for it — the
|
|
9264
|
+
// fitted chart fits by construction, and the overdrive's rough overhead
|
|
9265
|
+
// estimate would falsely re-engage on it.
|
|
9266
|
+
const unitWasAuto = config.pixelPerUnit <= 0;
|
|
8823
9267
|
this.autoFitScaling(config, styles);
|
|
8824
|
-
this.chart.setAvailableWidth(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width) || 0);
|
|
9268
|
+
this.chart.setAvailableWidth(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width) || 0);
|
|
8825
9269
|
this.pattern = new CustomPattern$1(this.chart.styles);
|
|
8826
9270
|
this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
|
|
8827
9271
|
}
|
|
@@ -8836,16 +9280,24 @@ const IbcsChartStructure = class {
|
|
|
8836
9280
|
this.chart.setStyles(styles);
|
|
8837
9281
|
this.chart.setRuleSet(new SVGStyle.IBCSRuleSet(this.ruleSetConfig));
|
|
8838
9282
|
this.chart.setConfig(config);
|
|
9283
|
+
// See componentWillLoad: no broken-bar overdrive for auto-fitted scaling
|
|
9284
|
+
const unitWasAuto = config.pixelPerUnit <= 0;
|
|
8839
9285
|
this.autoFitScaling(config, styles);
|
|
8840
|
-
this.chart.setAvailableWidth(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width) || 0);
|
|
9286
|
+
this.chart.setAvailableWidth(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width) || 0);
|
|
8841
9287
|
this.pattern = new CustomPattern$1(this.chart.styles);
|
|
8842
9288
|
this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
|
|
8843
9289
|
}
|
|
8844
9290
|
/**
|
|
8845
|
-
*
|
|
8846
|
-
* When either is 0 (auto mode), renders a measurement pass at 1,
|
|
8847
|
-
* computes the ratio to fit the available width, and rebuilds.
|
|
9291
|
+
* Auto-fit for pixelPerUnit and/or pixelPerPercentage (0 = auto mode).
|
|
8848
9292
|
* Structure charts grow horizontally, so we fit to width.
|
|
9293
|
+
*
|
|
9294
|
+
* The chart width is affine in the pixel scales (width = fixed labels +
|
|
9295
|
+
* bar extent × scale), but label clamps flip between passes, so a single
|
|
9296
|
+
* analytic solve is not enough: measure at 1, solve, then verify against
|
|
9297
|
+
* fresh measurements and re-solve until the chart fits. The loop never
|
|
9298
|
+
* ends on an overshoot — the last fitting values are restored, or when
|
|
9299
|
+
* even the minimum scale cannot fit (labels alone exceed the container)
|
|
9300
|
+
* the values are floored and the wrapper reports the overflow.
|
|
8849
9301
|
* Explicit (> 0) values are never overridden.
|
|
8850
9302
|
*/
|
|
8851
9303
|
autoFitScaling(config, styles) {
|
|
@@ -8855,49 +9307,117 @@ const IbcsChartStructure = class {
|
|
|
8855
9307
|
if (!autoUnit && !autoPercent) {
|
|
8856
9308
|
return; // Both explicit — nothing to auto-fit
|
|
8857
9309
|
}
|
|
9310
|
+
const reportResolved = () => {
|
|
9311
|
+
var _a;
|
|
9312
|
+
(_a = this.reportAutoScaling) === null || _a === void 0 ? void 0 : _a.call(this, {
|
|
9313
|
+
unit: autoUnit ? config.pixelPerUnit : undefined,
|
|
9314
|
+
percentage: autoPercent ? config.pixelPerPercentage : undefined,
|
|
9315
|
+
});
|
|
9316
|
+
};
|
|
8858
9317
|
const targetWidth = (_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width;
|
|
8859
9318
|
const db = this.getDb();
|
|
9319
|
+
const rebuild = () => {
|
|
9320
|
+
this.chart = new StructureChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), db, this.tableName, config, styles);
|
|
9321
|
+
this.chart.setI18n(this.i18n);
|
|
9322
|
+
};
|
|
9323
|
+
// toString() runs draw(), which finalizes positions — an undrawn chart
|
|
9324
|
+
// reports a stale allocated width.
|
|
9325
|
+
const measure = () => {
|
|
9326
|
+
this.chart.toString();
|
|
9327
|
+
return this.chart.getAllocatedCanvasWidth();
|
|
9328
|
+
};
|
|
8860
9329
|
if (!targetWidth || targetWidth <= 0) {
|
|
8861
9330
|
if (autoUnit)
|
|
8862
9331
|
config.pixelPerUnit = 1;
|
|
8863
9332
|
if (autoPercent)
|
|
8864
9333
|
config.pixelPerPercentage = 50;
|
|
8865
|
-
|
|
8866
|
-
|
|
9334
|
+
rebuild();
|
|
9335
|
+
reportResolved();
|
|
8867
9336
|
return;
|
|
8868
9337
|
}
|
|
8869
|
-
//
|
|
9338
|
+
// Measurement pass: render the auto quantities at 1
|
|
8870
9339
|
if (autoUnit)
|
|
8871
9340
|
config.pixelPerUnit = 1;
|
|
8872
9341
|
if (autoPercent)
|
|
8873
9342
|
config.pixelPerPercentage = 1;
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
if (svgWidth <= 0) {
|
|
9343
|
+
rebuild();
|
|
9344
|
+
let width = measure();
|
|
9345
|
+
if (width <= 0) {
|
|
9346
|
+
reportResolved();
|
|
8879
9347
|
return;
|
|
8880
9348
|
}
|
|
8881
|
-
//
|
|
8882
|
-
//
|
|
8883
|
-
|
|
8884
|
-
const
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
9349
|
+
// Fallback for auto quantities nothing scales with (no bar extent):
|
|
9350
|
+
// plain ratio against the measurement pass, as before.
|
|
9351
|
+
const ratioFallback = Math.max(MIN_PIXEL_SCALE, (targetWidth * 0.9) / width);
|
|
9352
|
+
const EPS = 0.5;
|
|
9353
|
+
const MAX_CORRECTIONS = 3;
|
|
9354
|
+
let solvedUnit = false;
|
|
9355
|
+
let solvedPercent = false;
|
|
9356
|
+
let fitting = null;
|
|
9357
|
+
for (let iteration = 0; iteration <= MAX_CORRECTIONS; iteration++) {
|
|
9358
|
+
const step = solveAutoFitStep({
|
|
9359
|
+
target: targetWidth,
|
|
9360
|
+
measured: width,
|
|
9361
|
+
unitExtent: autoUnit ? this.chart.getUnitBarExtent() : 0,
|
|
9362
|
+
pctExtent: autoPercent ? this.chart.getPercentBarExtent() : 0,
|
|
9363
|
+
currentPpu: config.pixelPerUnit,
|
|
9364
|
+
currentPpp: config.pixelPerPercentage,
|
|
9365
|
+
});
|
|
9366
|
+
if (step.ppu === undefined && step.ppp === undefined) {
|
|
9367
|
+
break; // nothing scales with the auto values — fallback below
|
|
9368
|
+
}
|
|
9369
|
+
if (autoUnit && step.ppu !== undefined) {
|
|
9370
|
+
config.pixelPerUnit = step.ppu;
|
|
9371
|
+
solvedUnit = true;
|
|
9372
|
+
}
|
|
9373
|
+
if (autoPercent && step.ppp !== undefined) {
|
|
9374
|
+
config.pixelPerPercentage = step.ppp;
|
|
9375
|
+
solvedPercent = true;
|
|
9376
|
+
}
|
|
9377
|
+
rebuild();
|
|
9378
|
+
width = measure();
|
|
9379
|
+
if (width <= targetWidth + EPS) {
|
|
9380
|
+
fitting = { ppu: config.pixelPerUnit, ppp: config.pixelPerPercentage };
|
|
9381
|
+
if (width >= targetWidth * 0.98) {
|
|
9382
|
+
break; // fits and tight — done
|
|
9383
|
+
}
|
|
9384
|
+
// else a released label clamp left slack — loop once more to grow into it
|
|
9385
|
+
}
|
|
9386
|
+
}
|
|
9387
|
+
// Auto quantities the solver never touched get the ratio fallback
|
|
9388
|
+
let needsRebuild = false;
|
|
9389
|
+
if (autoUnit && !solvedUnit) {
|
|
9390
|
+
config.pixelPerUnit = ratioFallback;
|
|
9391
|
+
needsRebuild = true;
|
|
9392
|
+
}
|
|
9393
|
+
if (autoPercent && !solvedPercent) {
|
|
9394
|
+
config.pixelPerPercentage = ratioFallback;
|
|
9395
|
+
needsRebuild = true;
|
|
9396
|
+
}
|
|
9397
|
+
// Never end on an overshoot
|
|
9398
|
+
if (width > targetWidth + EPS) {
|
|
9399
|
+
if (fitting) {
|
|
9400
|
+
// Restore the last values that fit (fallback quantities have no extent)
|
|
9401
|
+
if (solvedUnit)
|
|
9402
|
+
config.pixelPerUnit = fitting.ppu;
|
|
9403
|
+
if (solvedPercent)
|
|
9404
|
+
config.pixelPerPercentage = fitting.ppp;
|
|
8889
9405
|
}
|
|
8890
9406
|
else {
|
|
8891
|
-
|
|
9407
|
+
// Even the solved minimum overshoots (labels alone exceed the
|
|
9408
|
+
// container) — shrink proportionally; the wrapper reports this.
|
|
9409
|
+
const shrink = targetWidth / width;
|
|
9410
|
+
if (autoUnit)
|
|
9411
|
+
config.pixelPerUnit = Math.max(MIN_PIXEL_SCALE, config.pixelPerUnit * shrink);
|
|
9412
|
+
if (autoPercent)
|
|
9413
|
+
config.pixelPerPercentage = Math.max(MIN_PIXEL_SCALE, config.pixelPerPercentage * shrink);
|
|
8892
9414
|
}
|
|
9415
|
+
needsRebuild = true;
|
|
8893
9416
|
}
|
|
8894
|
-
if (
|
|
8895
|
-
|
|
8896
|
-
config.pixelPerPercentage = (targetWidth * 0.9) / svgWidth;
|
|
9417
|
+
if (needsRebuild) {
|
|
9418
|
+
rebuild();
|
|
8897
9419
|
}
|
|
8898
|
-
|
|
8899
|
-
this.chart = new StructureChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), db, this.tableName, config, styles);
|
|
8900
|
-
this.chart.setI18n(this.i18n);
|
|
9420
|
+
reportResolved();
|
|
8901
9421
|
}
|
|
8902
9422
|
async componentWillRender() {
|
|
8903
9423
|
// return await (async () => {
|
|
@@ -11320,6 +11840,41 @@ class TimeChart {
|
|
|
11320
11840
|
: this.scenariosArea.height;
|
|
11321
11841
|
return Math.max(analyticalHeight, bboxHeight);
|
|
11322
11842
|
}
|
|
11843
|
+
/**
|
|
11844
|
+
* Total column extent (data units) proportional to pixelPerUnit, covering
|
|
11845
|
+
* both sides of the axis (negative columns extend below it). Mirrors the
|
|
11846
|
+
* DataPoints getAllocatedCanvasHeight allocates with; used by autoFitScaling
|
|
11847
|
+
* to separate fixed from variable height components.
|
|
11848
|
+
*/
|
|
11849
|
+
getUnitBarExtent() {
|
|
11850
|
+
var _a, _b, _c;
|
|
11851
|
+
const isRelative = this.isVarianceChart() &&
|
|
11852
|
+
this.variancesDataModel.some((e) => e.type === VarianceType.RELATIVE);
|
|
11853
|
+
const usesVariance = this.isVarianceChart();
|
|
11854
|
+
const highest = usesVariance ? this.highestVarianceDataPointValue : this.highestDataPointValue;
|
|
11855
|
+
const smallest = usesVariance ? this.smallestVarianceDataPointValue : this.smallestDataPointValue;
|
|
11856
|
+
return computeUnitBarExtent({
|
|
11857
|
+
// Relative stacks span exactly RELATIVE_STACK_UNITS * ppu
|
|
11858
|
+
fixedDomain: ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) === VarianceMeasure.StackMode.RELATIVE ? VarianceMeasure.RELATIVE_STACK_UNITS : undefined,
|
|
11859
|
+
relativeVariance: isRelative,
|
|
11860
|
+
maxPositive: (_b = highest === null || highest === void 0 ? void 0 : highest.value) !== null && _b !== void 0 ? _b : 0,
|
|
11861
|
+
minNegative: this.isOnSameAxisSide() ? 0 : ((_c = smallest === null || smallest === void 0 ? void 0 : smallest.value) !== null && _c !== void 0 ? _c : 0),
|
|
11862
|
+
});
|
|
11863
|
+
}
|
|
11864
|
+
/**
|
|
11865
|
+
* Total column extent (fraction units) proportional to pixelPerPercentage.
|
|
11866
|
+
* Only relative variances scale with it; each side clamps at +/-145%.
|
|
11867
|
+
*/
|
|
11868
|
+
getPercentBarExtent() {
|
|
11869
|
+
var _a, _b, _c, _d;
|
|
11870
|
+
const isRelative = this.isVarianceChart() &&
|
|
11871
|
+
this.variancesDataModel.some((e) => e.type === VarianceType.RELATIVE);
|
|
11872
|
+
return computePercentBarExtent({
|
|
11873
|
+
relativeVariance: isRelative,
|
|
11874
|
+
maxPositive: (_b = (_a = this.highestVarianceDataPointValue) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0,
|
|
11875
|
+
minNegative: this.isOnSameAxisSide() ? 0 : ((_d = (_c = this.smallestVarianceDataPointValue) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 0),
|
|
11876
|
+
});
|
|
11877
|
+
}
|
|
11323
11878
|
toString() {
|
|
11324
11879
|
const container = new SVGStyle.Svg();
|
|
11325
11880
|
this.draw(container);
|
|
@@ -12624,7 +13179,7 @@ class TimeChartComponentConfigAdapter {
|
|
|
12624
13179
|
}
|
|
12625
13180
|
}
|
|
12626
13181
|
|
|
12627
|
-
const ibcsChartTimeCss = () => `:host{position:relative;display:inline-block}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-default{stroke:black;stroke-width:0.1em}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.hide{opacity:0}.footer{margin:0.2em;font-size:0.6em}.footer-hide{
|
|
13182
|
+
const ibcsChartTimeCss = () => `:host{position:relative;display:inline-block}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-default{stroke:black;stroke-width:0.1em}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.hide{opacity:0}.footer{margin:0.2em;font-size:0.6em}.footer-hide{display:none}svg#drawCanvas{display:block}`;
|
|
12628
13183
|
|
|
12629
13184
|
const IbcsChartTime = class {
|
|
12630
13185
|
constructor(hostRef) {
|
|
@@ -12686,8 +13241,14 @@ const IbcsChartTime = class {
|
|
|
12686
13241
|
const availableWidth = this.containerWidth || 0;
|
|
12687
13242
|
this.chart = new TimeChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), this.getDb(), this.tableName, config, styles, availableWidth);
|
|
12688
13243
|
this.chart.setI18n(this.i18n);
|
|
13244
|
+
// The broken-bar overdrive exists to absorb MANUAL scaling overflow.
|
|
13245
|
+
// autoFitScaling mutates config.pixelPerUnit to the solved value, so
|
|
13246
|
+
// remember auto mode beforehand and skip the overdrive for it — the
|
|
13247
|
+
// fitted chart fits by construction, and the overdrive's rough overhead
|
|
13248
|
+
// estimate would falsely re-engage on it.
|
|
13249
|
+
const unitWasAuto = config.pixelPerUnit <= 0;
|
|
12689
13250
|
this.autoFitScaling(config, styles);
|
|
12690
|
-
this.chart.setAvailableHeight(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
|
|
13251
|
+
this.chart.setAvailableHeight(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
|
|
12691
13252
|
this.pattern = new CustomPattern(this.chart.styles);
|
|
12692
13253
|
this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
|
|
12693
13254
|
}
|
|
@@ -12703,15 +13264,24 @@ const IbcsChartTime = class {
|
|
|
12703
13264
|
this.chart.setAvailableWidth(this.containerWidth || 0);
|
|
12704
13265
|
this.chart.setRuleSet(new SVGStyle.IBCSRuleSet(this.ruleSetConfig));
|
|
12705
13266
|
this.chart.setConfig(config);
|
|
13267
|
+
// See componentWillLoad: no broken-bar overdrive for auto-fitted scaling
|
|
13268
|
+
const unitWasAuto = config.pixelPerUnit <= 0;
|
|
12706
13269
|
this.autoFitScaling(config, styles);
|
|
12707
|
-
this.chart.setAvailableHeight(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
|
|
13270
|
+
this.chart.setAvailableHeight(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
|
|
12708
13271
|
this.pattern = new CustomPattern(this.chart.styles);
|
|
12709
13272
|
this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
|
|
12710
13273
|
}
|
|
12711
13274
|
/**
|
|
12712
|
-
*
|
|
12713
|
-
*
|
|
12714
|
-
*
|
|
13275
|
+
* Auto-fit for pixelPerUnit and/or pixelPerPercentage (0 = auto mode).
|
|
13276
|
+
* Time charts grow vertically, so we fit to height.
|
|
13277
|
+
*
|
|
13278
|
+
* The chart height is affine in the pixel scales (height = fixed labels +
|
|
13279
|
+
* column extent × scale), but label allocations shift between passes, so a
|
|
13280
|
+
* single analytic solve is not enough: measure at 1, solve, then verify
|
|
13281
|
+
* against fresh measurements and re-solve until the chart fits. The loop
|
|
13282
|
+
* never ends on an overshoot — the last fitting values are restored, or
|
|
13283
|
+
* when even the minimum scale cannot fit (labels alone exceed the
|
|
13284
|
+
* container) the values are floored and the wrapper reports the overflow.
|
|
12715
13285
|
* Explicit (> 0) values are never overridden.
|
|
12716
13286
|
*/
|
|
12717
13287
|
autoFitScaling(config, styles) {
|
|
@@ -12721,38 +13291,117 @@ const IbcsChartTime = class {
|
|
|
12721
13291
|
if (!autoUnit && !autoPercent) {
|
|
12722
13292
|
return; // Both explicit — nothing to auto-fit
|
|
12723
13293
|
}
|
|
13294
|
+
const reportResolved = () => {
|
|
13295
|
+
var _a;
|
|
13296
|
+
(_a = this.reportAutoScaling) === null || _a === void 0 ? void 0 : _a.call(this, {
|
|
13297
|
+
unit: autoUnit ? config.pixelPerUnit : undefined,
|
|
13298
|
+
percentage: autoPercent ? config.pixelPerPercentage : undefined,
|
|
13299
|
+
});
|
|
13300
|
+
};
|
|
12724
13301
|
const targetHeight = (_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height;
|
|
12725
13302
|
const availableWidth = this.containerWidth || 0;
|
|
13303
|
+
const rebuild = () => {
|
|
13304
|
+
this.chart = new TimeChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), this.getDb(), this.tableName, config, styles, availableWidth);
|
|
13305
|
+
this.chart.setI18n(this.i18n);
|
|
13306
|
+
};
|
|
13307
|
+
// toString() runs draw(), which finalizes positions — an undrawn chart
|
|
13308
|
+
// reports a stale allocated height.
|
|
13309
|
+
const measure = () => {
|
|
13310
|
+
this.chart.toString();
|
|
13311
|
+
return this.chart.getAllocatedCanvasHeight();
|
|
13312
|
+
};
|
|
12726
13313
|
if (!targetHeight || targetHeight <= 0) {
|
|
12727
13314
|
if (autoUnit)
|
|
12728
13315
|
config.pixelPerUnit = 1;
|
|
12729
13316
|
if (autoPercent)
|
|
12730
13317
|
config.pixelPerPercentage = 50;
|
|
12731
|
-
|
|
12732
|
-
|
|
13318
|
+
rebuild();
|
|
13319
|
+
reportResolved();
|
|
12733
13320
|
return;
|
|
12734
13321
|
}
|
|
12735
|
-
//
|
|
13322
|
+
// Measurement pass: render the auto quantities at 1
|
|
12736
13323
|
if (autoUnit)
|
|
12737
13324
|
config.pixelPerUnit = 1;
|
|
12738
13325
|
if (autoPercent)
|
|
12739
13326
|
config.pixelPerPercentage = 1;
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
|
-
if (svgHeight <= 0) {
|
|
13327
|
+
rebuild();
|
|
13328
|
+
let height = measure();
|
|
13329
|
+
if (height <= 0) {
|
|
13330
|
+
reportResolved();
|
|
12745
13331
|
return;
|
|
12746
13332
|
}
|
|
12747
|
-
//
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
13333
|
+
// Fallback for auto quantities nothing scales with (no column extent):
|
|
13334
|
+
// plain ratio against the measurement pass, as before.
|
|
13335
|
+
const ratioFallback = Math.max(MIN_PIXEL_SCALE, (targetHeight * 0.9) / height);
|
|
13336
|
+
const EPS = 0.5;
|
|
13337
|
+
const MAX_CORRECTIONS = 3;
|
|
13338
|
+
let solvedUnit = false;
|
|
13339
|
+
let solvedPercent = false;
|
|
13340
|
+
let fitting = null;
|
|
13341
|
+
for (let iteration = 0; iteration <= MAX_CORRECTIONS; iteration++) {
|
|
13342
|
+
const step = solveAutoFitStep({
|
|
13343
|
+
target: targetHeight,
|
|
13344
|
+
measured: height,
|
|
13345
|
+
unitExtent: autoUnit ? this.chart.getUnitBarExtent() : 0,
|
|
13346
|
+
pctExtent: autoPercent ? this.chart.getPercentBarExtent() : 0,
|
|
13347
|
+
currentPpu: config.pixelPerUnit,
|
|
13348
|
+
currentPpp: config.pixelPerPercentage,
|
|
13349
|
+
});
|
|
13350
|
+
if (step.ppu === undefined && step.ppp === undefined) {
|
|
13351
|
+
break; // nothing scales with the auto values — fallback below
|
|
13352
|
+
}
|
|
13353
|
+
if (autoUnit && step.ppu !== undefined) {
|
|
13354
|
+
config.pixelPerUnit = step.ppu;
|
|
13355
|
+
solvedUnit = true;
|
|
13356
|
+
}
|
|
13357
|
+
if (autoPercent && step.ppp !== undefined) {
|
|
13358
|
+
config.pixelPerPercentage = step.ppp;
|
|
13359
|
+
solvedPercent = true;
|
|
13360
|
+
}
|
|
13361
|
+
rebuild();
|
|
13362
|
+
height = measure();
|
|
13363
|
+
if (height <= targetHeight + EPS) {
|
|
13364
|
+
fitting = { ppu: config.pixelPerUnit, ppp: config.pixelPerPercentage };
|
|
13365
|
+
if (height >= targetHeight * 0.98) {
|
|
13366
|
+
break; // fits and tight — done
|
|
13367
|
+
}
|
|
13368
|
+
// else the label allocation left slack — loop once more to grow into it
|
|
13369
|
+
}
|
|
13370
|
+
}
|
|
13371
|
+
// Auto quantities the solver never touched get the ratio fallback
|
|
13372
|
+
let needsRebuild = false;
|
|
13373
|
+
if (autoUnit && !solvedUnit) {
|
|
13374
|
+
config.pixelPerUnit = ratioFallback;
|
|
13375
|
+
needsRebuild = true;
|
|
13376
|
+
}
|
|
13377
|
+
if (autoPercent && !solvedPercent) {
|
|
13378
|
+
config.pixelPerPercentage = ratioFallback;
|
|
13379
|
+
needsRebuild = true;
|
|
13380
|
+
}
|
|
13381
|
+
// Never end on an overshoot
|
|
13382
|
+
if (height > targetHeight + EPS) {
|
|
13383
|
+
if (fitting) {
|
|
13384
|
+
// Restore the last values that fit (fallback quantities have no extent)
|
|
13385
|
+
if (solvedUnit)
|
|
13386
|
+
config.pixelPerUnit = fitting.ppu;
|
|
13387
|
+
if (solvedPercent)
|
|
13388
|
+
config.pixelPerPercentage = fitting.ppp;
|
|
13389
|
+
}
|
|
13390
|
+
else {
|
|
13391
|
+
// Even the solved minimum overshoots (labels alone exceed the
|
|
13392
|
+
// container) — shrink proportionally; the wrapper reports this.
|
|
13393
|
+
const shrink = targetHeight / height;
|
|
13394
|
+
if (autoUnit)
|
|
13395
|
+
config.pixelPerUnit = Math.max(MIN_PIXEL_SCALE, config.pixelPerUnit * shrink);
|
|
13396
|
+
if (autoPercent)
|
|
13397
|
+
config.pixelPerPercentage = Math.max(MIN_PIXEL_SCALE, config.pixelPerPercentage * shrink);
|
|
13398
|
+
}
|
|
13399
|
+
needsRebuild = true;
|
|
13400
|
+
}
|
|
13401
|
+
if (needsRebuild) {
|
|
13402
|
+
rebuild();
|
|
13403
|
+
}
|
|
13404
|
+
reportResolved();
|
|
12756
13405
|
}
|
|
12757
13406
|
async componentWillRender() {
|
|
12758
13407
|
// return await (async () => {
|
|
@@ -12969,6 +13618,98 @@ class TableRow {
|
|
|
12969
13618
|
}
|
|
12970
13619
|
}
|
|
12971
13620
|
|
|
13621
|
+
/**
|
|
13622
|
+
* Column geometry for the inline bar / pin / waterfall charts of bn-table.
|
|
13623
|
+
*
|
|
13624
|
+
* `bar-column-width="wN"` and `category-width="wN"` both mean "N em of the table font",
|
|
13625
|
+
* so both columns render at the same width for the same N. The em used here is the TRUE
|
|
13626
|
+
* table em (`--bn-font-size`, i.e. `global.fontSizePx × scaleFactor`) — deliberately NOT
|
|
13627
|
+
* `CellBarChartStyles.fontSize`, which is 0.85 of it and doubles as the unitScaling /
|
|
13628
|
+
* percentageScaling basis.
|
|
13629
|
+
*
|
|
13630
|
+
* Every quantity is returned in px so the SVG renderers stay in one coordinate space.
|
|
13631
|
+
*/
|
|
13632
|
+
/**
|
|
13633
|
+
* SVG label font size relative to the table em. Also the multiplier in the
|
|
13634
|
+
* unitScaling / percentageScaling math, so changing it rescales every user-set value.
|
|
13635
|
+
*/
|
|
13636
|
+
const BAR_LABEL_FONT_RATIO = 0.85;
|
|
13637
|
+
/**
|
|
13638
|
+
* Horizontal padding of a bar cell, in table em:
|
|
13639
|
+
* `td:has(.cell-bar-chart) { padding: 0 0.25em }` (ibcs-table.scss:320).
|
|
13640
|
+
* With `box-sizing: border-box` the SVG has to be that much narrower than the requested
|
|
13641
|
+
* column width, so the cell's border box lands on exactly N em — the same box
|
|
13642
|
+
* `.category-wN` (ibcs-table.scss:50-83) produces.
|
|
13643
|
+
*/
|
|
13644
|
+
const BAR_CELL_PADDING_EM = 0.5;
|
|
13645
|
+
/** Value-label gutter beside a bar, in em (was a hardcoded 38 px at the 13.3333 px em). */
|
|
13646
|
+
const BAR_LABEL_EM = 2.85;
|
|
13647
|
+
/** Value-label gutter beside a pin, in em (was 45 px). */
|
|
13648
|
+
const PIN_LABEL_EM = 3.375;
|
|
13649
|
+
/** Gap between the axis and the start of a pin's reserved side, in em (was 5 px). */
|
|
13650
|
+
const PIN_PADDING_EM = 0.375;
|
|
13651
|
+
/** Zigzag break gap of an overdrive bar, in em (was 4 px). */
|
|
13652
|
+
const BREAK_GAP_EM = 0.3;
|
|
13653
|
+
/** Gap between a bar/pin end and its value label, in em (was 4 px). */
|
|
13654
|
+
const LABEL_GAP_EM = 0.3;
|
|
13655
|
+
/** Share of the per-side bar extent reserved for the overdrive stub. */
|
|
13656
|
+
const OVERDRIVE_FRACTION = 0.15;
|
|
13657
|
+
/** The SVG fills the cell's content box: the requested column width minus the cell padding. */
|
|
13658
|
+
function contentWidth(widthEm, emPx) {
|
|
13659
|
+
return Math.max(0, (widthEm - BAR_CELL_PADDING_EM) * emPx);
|
|
13660
|
+
}
|
|
13661
|
+
/** Sides the axis serves. Clamped to 1 so a hypothetical all-zero column never divides by 0. */
|
|
13662
|
+
function sideCount(hasNeg, hasPos) {
|
|
13663
|
+
return Math.max(1, (hasNeg ? 1 : 0) + (hasPos ? 1 : 0));
|
|
13664
|
+
}
|
|
13665
|
+
function absoluteBarGeometry(widthEm, emPx, hasNeg, hasPos) {
|
|
13666
|
+
const totalWidth = contentWidth(widthEm, emPx);
|
|
13667
|
+
const sides = sideCount(hasNeg, hasPos);
|
|
13668
|
+
// Narrow columns shrink the gutters rather than the total, so wN stays wN.
|
|
13669
|
+
const labelAreaWidth = Math.min(BAR_LABEL_EM * emPx, totalWidth / (2 * sides));
|
|
13670
|
+
const maxBarWidth = (totalWidth - labelAreaWidth * sides) / sides;
|
|
13671
|
+
const breakGap = Math.min(BREAK_GAP_EM * emPx, maxBarWidth * 0.2);
|
|
13672
|
+
const overdriveZoneWidth = maxBarWidth * OVERDRIVE_FRACTION;
|
|
13673
|
+
return {
|
|
13674
|
+
totalWidth,
|
|
13675
|
+
labelAreaWidth,
|
|
13676
|
+
maxBarWidth,
|
|
13677
|
+
axisX: hasNeg ? labelAreaWidth + maxBarWidth : 0,
|
|
13678
|
+
breakGap,
|
|
13679
|
+
overdriveZoneWidth,
|
|
13680
|
+
cutWidth: Math.max(0, maxBarWidth - breakGap - overdriveZoneWidth),
|
|
13681
|
+
labelGap: LABEL_GAP_EM * emPx,
|
|
13682
|
+
};
|
|
13683
|
+
}
|
|
13684
|
+
function relativePinGeometry(widthEm, emPx, hasNeg, hasPos) {
|
|
13685
|
+
const totalWidth = contentWidth(widthEm, emPx);
|
|
13686
|
+
const sides = sideCount(hasNeg, hasPos);
|
|
13687
|
+
const labelAreaWidth = Math.min(PIN_LABEL_EM * emPx, totalWidth / 2);
|
|
13688
|
+
const pinAreaWidth = totalWidth - labelAreaWidth;
|
|
13689
|
+
const sideWidth = pinAreaWidth / sides;
|
|
13690
|
+
const pinPadding = Math.min(PIN_PADDING_EM * emPx, sideWidth * 0.2);
|
|
13691
|
+
return {
|
|
13692
|
+
totalWidth,
|
|
13693
|
+
labelAreaWidth,
|
|
13694
|
+
maxPinLength: Math.max(0, sideWidth - pinPadding),
|
|
13695
|
+
pinPadding,
|
|
13696
|
+
axisX: hasNeg ? sideWidth : 0,
|
|
13697
|
+
labelX: pinAreaWidth + LABEL_GAP_EM * emPx,
|
|
13698
|
+
};
|
|
13699
|
+
}
|
|
13700
|
+
function waterfallGeometry(widthEm, emPx) {
|
|
13701
|
+
const totalWidth = contentWidth(widthEm, emPx);
|
|
13702
|
+
const labelAreaWidth = Math.min(BAR_LABEL_EM * emPx, totalWidth / 4);
|
|
13703
|
+
return {
|
|
13704
|
+
totalWidth,
|
|
13705
|
+
labelAreaWidth,
|
|
13706
|
+
barAreaWidth: totalWidth - labelAreaWidth * 2,
|
|
13707
|
+
labelGap: LABEL_GAP_EM * emPx,
|
|
13708
|
+
};
|
|
13709
|
+
}
|
|
13710
|
+
|
|
13711
|
+
/** Matches SYSTEM_STYLE_DEFAULTS.global.fontSizePx; only used when `styles` is omitted. */
|
|
13712
|
+
const DEFAULT_EM_PX = 13.3333;
|
|
12972
13713
|
// Default fallback colors (should come from componentStyle)
|
|
12973
13714
|
const DEFAULT_STYLES = {
|
|
12974
13715
|
positive: { stroke: "#008f96", fill: "#008f96", fillpattern: "solid" },
|
|
@@ -12981,10 +13722,11 @@ const DEFAULT_STYLES = {
|
|
|
12981
13722
|
pl: { stroke: "#404040", fill: "#ffffff", fillpattern: "outlined" },
|
|
12982
13723
|
},
|
|
12983
13724
|
fontColor: "#000000",
|
|
12984
|
-
fontSize:
|
|
13725
|
+
fontSize: DEFAULT_EM_PX * BAR_LABEL_FONT_RATIO,
|
|
13726
|
+
emPx: DEFAULT_EM_PX,
|
|
12985
13727
|
fontFamily: "'Noto Sans', sans-serif",
|
|
12986
|
-
unitScaling: 0.01, // Default:
|
|
12987
|
-
percentageScaling: 0.5, // Default:
|
|
13728
|
+
unitScaling: 0.01, // Default: 100 units per em of bar
|
|
13729
|
+
percentageScaling: 0.5, // Default: 2 percentage points per em of pin
|
|
12988
13730
|
scaleFactor: 1,
|
|
12989
13731
|
};
|
|
12990
13732
|
const AXIS_COLOR = "#666666";
|
|
@@ -13156,21 +13898,20 @@ function renderZigzagBreak(breakX, breakGap, yTop, barHeight, s) {
|
|
|
13156
13898
|
/**
|
|
13157
13899
|
* Renders an absolute variance bar chart (d_ prefix).
|
|
13158
13900
|
* Horizontal bar with centered axis, green for positive, red for negative.
|
|
13159
|
-
* When a bar exceeds
|
|
13901
|
+
* When a bar exceeds the geometry's cut width it is drawn as an overdrive bar:
|
|
13160
13902
|
* base segment + zigzag break + proportional overdrive stub (like structure chart).
|
|
13161
13903
|
*
|
|
13162
|
-
* Layout: [left label area][bar area with axis][right label area]
|
|
13904
|
+
* Layout: [left label area][bar area with axis][right label area], summing to
|
|
13905
|
+
* exactly `columnWidthEm` em — see barColumnGeometry.ts.
|
|
13163
13906
|
*/
|
|
13164
13907
|
const AbsoluteVarianceBar = (props) => {
|
|
13165
|
-
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale,
|
|
13908
|
+
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, columnWidthEm = 10, styles = DEFAULT_STYLES, } = props;
|
|
13166
13909
|
const s = styles.scaleFactor;
|
|
13167
13910
|
const fs = styles.fontSize;
|
|
13168
|
-
|
|
13169
|
-
const
|
|
13170
|
-
|
|
13171
|
-
const breakGap =
|
|
13172
|
-
const overdriveZoneWidth = maxBarWidth * 0.15;
|
|
13173
|
-
const cutWidth = maxBarWidth - breakGap - overdriveZoneWidth;
|
|
13911
|
+
// Adaptive axis placement based on data range
|
|
13912
|
+
const hasNeg = columnStats.min < 0;
|
|
13913
|
+
const hasPos = columnStats.max > 0;
|
|
13914
|
+
const { totalWidth, axisX, breakGap, overdriveZoneWidth, cutWidth, labelGap } = absoluteBarGeometry(columnWidthEm, styles.emPx, hasNeg, hasPos);
|
|
13174
13915
|
// Direct unit scaling via fontSize
|
|
13175
13916
|
const scaledWidth = Math.abs(value) * styles.unitScaling * fs;
|
|
13176
13917
|
const isExtreme = scaledWidth > cutWidth;
|
|
@@ -13179,16 +13920,8 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
13179
13920
|
const maxOverflow = Math.max(0, maxScaledWidth - cutWidth);
|
|
13180
13921
|
const overflowAmount = Math.max(0, scaledWidth - cutWidth);
|
|
13181
13922
|
const overdriveWidth = maxOverflow > 0 ? (overflowAmount / maxOverflow) * overdriveZoneWidth : 0;
|
|
13182
|
-
// Adaptive axis placement based on data range
|
|
13183
|
-
const hasNeg = columnStats.min < 0;
|
|
13184
|
-
const hasPos = columnStats.max > 0;
|
|
13185
|
-
const negBarWidth = hasNeg ? maxBarWidth : 0;
|
|
13186
|
-
const posBarWidth = hasPos ? maxBarWidth : 0;
|
|
13187
|
-
const barAreaWidth = negBarWidth + posBarWidth;
|
|
13188
|
-
const totalWidth = (hasNeg ? labelAreaWidth : 0) + barAreaWidth + (hasPos ? labelAreaWidth : 0);
|
|
13189
13923
|
const padding = 2 * s;
|
|
13190
13924
|
const barHeight = height - padding * 2;
|
|
13191
|
-
const axisX = (hasNeg ? labelAreaWidth : 0) + negBarWidth;
|
|
13192
13925
|
const barY = padding;
|
|
13193
13926
|
const isPositive = value >= 0;
|
|
13194
13927
|
// Get style based on column type (scenario vs variance)
|
|
@@ -13209,7 +13942,7 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
13209
13942
|
const baseBarWidth = isExtreme ? cutWidth : scaledWidth;
|
|
13210
13943
|
// Label position accounts for overdrive
|
|
13211
13944
|
const totalVisualWidth = isExtreme ? cutWidth + breakGap + overdriveWidth : scaledWidth;
|
|
13212
|
-
const labelX = isPositive ? axisX + totalVisualWidth +
|
|
13945
|
+
const labelX = isPositive ? axisX + totalVisualWidth + labelGap : axisX - totalVisualWidth - labelGap;
|
|
13213
13946
|
const labelAnchor = isPositive ? "start" : "end";
|
|
13214
13947
|
return (index.h("svg", { width: totalWidth, height: height, class: "cell-bar-chart absolute-variance", style: { overflow: "visible" } }, index.h(PatternDefs, { styles: styles }), index.h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s }), baseBarWidth > 0 && (index.h("rect", { x: isPositive ? axisX : axisX - baseBarWidth, y: barY, width: baseBarWidth, height: barHeight, fill: fillValue, stroke: barStroke, "stroke-width": barStrokeWidth * s })), isExtreme && overdriveWidth > 0 && (index.h("rect", { x: isPositive ? axisX + cutWidth + breakGap : axisX - cutWidth - breakGap - overdriveWidth, y: barY, width: overdriveWidth, height: barHeight, fill: fillValue, stroke: barStroke, "stroke-width": barStrokeWidth * s })), isExtreme &&
|
|
13215
13948
|
renderZigzagBreak(isPositive ? axisX + cutWidth : axisX - cutWidth - breakGap, breakGap, barY, barHeight, s), index.h("text", { x: labelX, y: height / 2, dy: "0.35em", "text-anchor": labelAnchor, fill: styles.fontColor, "font-size": fs, "font-family": styles.fontFamily }, displayValue)));
|
|
@@ -13218,25 +13951,18 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
13218
13951
|
* Renders a relative variance pin chart (dr_ prefix).
|
|
13219
13952
|
* Thin horizontal line from axis with dot at end and value label.
|
|
13220
13953
|
*
|
|
13221
|
-
* Layout: [pin area with axis][label area on right]
|
|
13954
|
+
* Layout: [pin area with axis][label area on right], summing to exactly
|
|
13955
|
+
* `columnWidthEm` em — see barColumnGeometry.ts.
|
|
13222
13956
|
* Uses percentageScaling to determine pin length (pixels per percentage point).
|
|
13223
13957
|
*/
|
|
13224
13958
|
const RelativeVariancePin = (props) => {
|
|
13225
|
-
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale,
|
|
13959
|
+
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, columnWidthEm = 10, styles = DEFAULT_STYLES, } = props;
|
|
13226
13960
|
const s = styles.scaleFactor;
|
|
13227
13961
|
const fs = styles.fontSize;
|
|
13228
|
-
// Pin length is ~2/3 of bar width for visual balance
|
|
13229
|
-
const maxPinLength = Math.round(maxBarWidthEm * 0.67 * fs);
|
|
13230
|
-
const pinPadding = 5 * s;
|
|
13231
13962
|
// Adaptive axis placement based on data range
|
|
13232
13963
|
const hasNeg = columnStats.min < 0;
|
|
13233
13964
|
const hasPos = columnStats.max > 0;
|
|
13234
|
-
const
|
|
13235
|
-
const posPinWidth = hasPos ? maxPinLength + pinPadding : 0;
|
|
13236
|
-
const pinAreaWidth = negPinWidth + posPinWidth;
|
|
13237
|
-
const labelAreaWidth = 45 * s;
|
|
13238
|
-
const totalWidth = pinAreaWidth + labelAreaWidth;
|
|
13239
|
-
const axisX = negPinWidth;
|
|
13965
|
+
const { totalWidth, maxPinLength, axisX, labelX } = relativePinGeometry(columnWidthEm, styles.emPx, hasNeg, hasPos);
|
|
13240
13966
|
const centerY = height / 2;
|
|
13241
13967
|
// Direct unit scaling via fontSize
|
|
13242
13968
|
const percentValue = Math.abs(value) * 100;
|
|
@@ -13249,8 +13975,6 @@ const RelativeVariancePin = (props) => {
|
|
|
13249
13975
|
const barStyle = getBarStyle(scenario, value, isPositiveGood, styles);
|
|
13250
13976
|
const dotRadius = 3 * s;
|
|
13251
13977
|
const displayValue = formattedValue || formatValue(value, true, measureScale);
|
|
13252
|
-
// Label always on the right side after the pin area
|
|
13253
|
-
const labelX = pinAreaWidth + 4 * s;
|
|
13254
13978
|
return (index.h("svg", { width: totalWidth, height: height, class: "cell-bar-chart relative-variance", style: { overflow: "visible" } }, index.h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s }), !isExtreme && index.h("circle", { cx: pinEndX, cy: centerY, r: dotRadius, fill: styles.fontColor }), index.h("line", { x1: axisX, y1: centerY, x2: pinEndX, y2: centerY, stroke: barStyle.fill, "stroke-width": 2 * s }), isExtreme && isPositive && (index.h("polygon", { points: `${axisX + maxPinLength},${centerY} ${axisX + maxPinLength - 6 * s},${centerY - 3 * s} ${axisX + maxPinLength - 6 * s},${centerY + 3 * s}`, fill: barStyle.fill })), isExtreme && !isPositive && (index.h("polygon", { points: `${axisX - maxPinLength},${centerY} ${axisX - maxPinLength + 6 * s},${centerY - 3 * s} ${axisX - maxPinLength + 6 * s},${centerY + 3 * s}`, fill: barStyle.fill })), index.h("text", { x: labelX, y: height / 2, dy: "0.35em", "text-anchor": "start", fill: styles.fontColor, "font-size": fs, "font-style": "italic", "font-family": styles.fontFamily }, displayValue)));
|
|
13255
13979
|
};
|
|
13256
13980
|
/**
|
|
@@ -13288,16 +14012,14 @@ const CellBarChart = (props) => {
|
|
|
13288
14012
|
* guides marking their parent bar's extent.
|
|
13289
14013
|
*/
|
|
13290
14014
|
const WaterfallBar = (props) => {
|
|
13291
|
-
const { value, scenario, height, measureScale,
|
|
14015
|
+
const { value, scenario, height, measureScale, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall } = props;
|
|
13292
14016
|
const s = styles.scaleFactor;
|
|
13293
14017
|
const fs = styles.fontSize;
|
|
13294
14018
|
const range = waterfall.max - waterfall.min;
|
|
13295
14019
|
if (value === null || value === undefined || isNaN(value) || range <= 0) {
|
|
13296
14020
|
return (index.h("span", { class: "bar-chart-empty", style: { color: styles.fontColor, fontStyle: "italic" } }, "-"));
|
|
13297
14021
|
}
|
|
13298
|
-
const labelAreaWidth =
|
|
13299
|
-
const barAreaWidth = maxBarWidthEm * fs;
|
|
13300
|
-
const totalWidth = labelAreaWidth + barAreaWidth + labelAreaWidth;
|
|
14022
|
+
const { totalWidth, labelAreaWidth, barAreaWidth, labelGap } = waterfallGeometry(columnWidthEm, styles.emPx);
|
|
13301
14023
|
const pxPerUnit = barAreaWidth / range;
|
|
13302
14024
|
const xOf = (coordinate) => labelAreaWidth + (coordinate - waterfall.min) * pxPerUnit;
|
|
13303
14025
|
const padding = 2 * s;
|
|
@@ -13314,7 +14036,7 @@ const WaterfallBar = (props) => {
|
|
|
13314
14036
|
// Scenario values carry no variance sentiment — labels are unsigned per IBCS
|
|
13315
14037
|
const displayValue = formatValue(value, waterfall.kind === "partof", measureScale).replace(/^\+/, "");
|
|
13316
14038
|
const pointsLeft = endX < startX;
|
|
13317
|
-
const labelX = pointsLeft ? barX -
|
|
14039
|
+
const labelX = pointsLeft ? barX - labelGap : barX + barWidth + labelGap;
|
|
13318
14040
|
const labelAnchor = pointsLeft ? "end" : "start";
|
|
13319
14041
|
return (index.h("svg", { width: totalWidth, height: height, class: "cell-bar-chart waterfall-bar", style: { overflow: "visible" } }, index.h(PatternDefs, { styles: styles }), index.h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s }), waterfall.parentStart !== undefined && waterfall.parentEnd !== undefined && (index.h("line", { x1: xOf(waterfall.parentStart), y1: 0, x2: xOf(waterfall.parentStart), y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s, "stroke-dasharray": `${2 * s},${2 * s}` })), waterfall.parentStart !== undefined && waterfall.parentEnd !== undefined && (index.h("line", { x1: xOf(waterfall.parentEnd), y1: 0, x2: xOf(waterfall.parentEnd), y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s, "stroke-dasharray": `${2 * s},${2 * s}` })), barWidth > 0 && (index.h("rect", { x: barX, y: barY, width: barWidth, height: barHeight, fill: fillValue, stroke: barStroke, "stroke-width": barStrokeWidth * s })), index.h("text", { x: labelX, y: height / 2, dy: "0.35em", "text-anchor": labelAnchor, fill: styles.fontColor, "font-size": fs, "font-family": styles.fontFamily }, displayValue)));
|
|
13320
14042
|
};
|
|
@@ -15525,6 +16247,10 @@ const IbcsTable = class {
|
|
|
15525
16247
|
this.filter = "";
|
|
15526
16248
|
this.barColumns = [];
|
|
15527
16249
|
this.interval = "none";
|
|
16250
|
+
/**
|
|
16251
|
+
* Total width of a bar chart column, in em of the table font — the same unit
|
|
16252
|
+
* `categoryWidth` uses, so the two render at the same width for the same value.
|
|
16253
|
+
*/
|
|
15528
16254
|
this.barColumnMaxWidth = 30;
|
|
15529
16255
|
this.unitScaling = 0.01;
|
|
15530
16256
|
this.percentageScaling = 0.5;
|
|
@@ -15543,7 +16269,7 @@ const IbcsTable = class {
|
|
|
15543
16269
|
}
|
|
15544
16270
|
return (index.h("table", null, index.h("thead", null, this.table.getHeader().map((row) => (index.h("tr", { class: row.cssStyle }, row.getCells().map((cell) => (index.h("th", { colSpan: cell.colSpan, class: cell.cssStyle }, cell.getAsHeaderList().map((line, i, arr) => (index.h("span", null, i === arr.length - 1 ? (index.h("span", { class: line === " " ? "table-footer" : "" }, line, cell.drawPrefix(), " ")) : (index.h("span", null, line, cell.drawPrefix(), index.h("br", null))))))))))))), index.h("tbody", null, this.table.getBody().map((row) => (index.h("tr", { class: row.cssStyle }, row === null || row === void 0 ? void 0 : row.getCells().map((cell) => (index.h("td", { colSpan: cell.colSpan, class: cell.type ? `${cell.cssStyle} ${cell.type}` : cell.cssStyle }, cell.prefix != null ? (index.h("span", { class: cell.cssStyle + " " + cell.prefixStyle }, cell.drawPrefix())) : (""), cell.isBarChart &&
|
|
15545
16271
|
cell.columnStats &&
|
|
15546
|
-
(cell.waterfall !== undefined || row.type !== TableRowType.SUM) ? (cell.waterfall !== undefined ? (index.h(WaterfallBar, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: false, isPositiveGood: cell.key.endsWith("_pos"), measureScale: cell.measureScale,
|
|
16272
|
+
(cell.waterfall !== undefined || row.type !== TableRowType.SUM) ? (cell.waterfall !== undefined ? (index.h(WaterfallBar, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: false, isPositiveGood: cell.key.endsWith("_pos"), measureScale: cell.measureScale, columnWidthEm: this.barColumnMaxWidth, styles: this.barChartStyles, waterfall: cell.waterfall })) : (index.h(CellBarChart, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: cell.key.startsWith("dr"), isPositiveGood: cell.key.endsWith("_pos"), measureScale: cell.measureScale, columnWidthEm: this.barColumnMaxWidth, styles: this.barChartStyles }))) : (cell.draw(this.componentDataFormatDigits)))))))))));
|
|
15547
16273
|
};
|
|
15548
16274
|
return index.h(index.Host, null, helper());
|
|
15549
16275
|
}
|
|
@@ -15597,8 +16323,19 @@ const IbcsTable = class {
|
|
|
15597
16323
|
* Scenario styles (ac, pp, fc, pl) use barStyles for IBCS-compliant grayscale coloring.
|
|
15598
16324
|
*/
|
|
15599
16325
|
prepareBarChartStyles() {
|
|
16326
|
+
var _a;
|
|
16327
|
+
const autoUnit = !(this.unitScaling > 0);
|
|
16328
|
+
const autoPercent = !(this.percentageScaling > 0);
|
|
16329
|
+
const resolvedUnit = autoUnit ? this.autoUnitScaling() : this.unitScaling;
|
|
16330
|
+
const resolvedPercent = autoPercent ? this.autoPercentageScaling() : this.percentageScaling;
|
|
16331
|
+
if (autoUnit || autoPercent) {
|
|
16332
|
+
(_a = this.reportAutoScaling) === null || _a === void 0 ? void 0 : _a.call(this, {
|
|
16333
|
+
unit: autoUnit ? resolvedUnit : undefined,
|
|
16334
|
+
percentage: autoPercent ? resolvedPercent : undefined,
|
|
16335
|
+
});
|
|
16336
|
+
}
|
|
15600
16337
|
return this.componentStyle(($) => {
|
|
15601
|
-
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;
|
|
16338
|
+
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, _2;
|
|
15602
16339
|
const varianceStyles = (_a = $["bn-chart-time"]) === null || _a === void 0 ? void 0 : _a["varianceStyles"];
|
|
15603
16340
|
const barStyles = (_b = $["bn-chart-time"]) === null || _b === void 0 ? void 0 : _b["barStyles"];
|
|
15604
16341
|
// Default variance styles with fillpattern
|
|
@@ -15651,26 +16388,32 @@ const IbcsTable = class {
|
|
|
15651
16388
|
},
|
|
15652
16389
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
15653
16390
|
fontColor: ((_z = $["global"]) === null || _z === void 0 ? void 0 : _z["fontColor"]) || "#000000",
|
|
15654
|
-
fontSize: (((_0 = $["global"]) === null || _0 === void 0 ? void 0 : _0["fontSizePx"]) || 13.3333) *
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
16391
|
+
fontSize: (((_0 = $["global"]) === null || _0 === void 0 ? void 0 : _0["fontSizePx"]) || 13.3333) * BAR_LABEL_FONT_RATIO * this.scaleFactor,
|
|
16392
|
+
emPx: (((_1 = $["global"]) === null || _1 === void 0 ? void 0 : _1["fontSizePx"]) || 13.3333) * this.scaleFactor,
|
|
16393
|
+
fontFamily: ((_2 = $["global"]) === null || _2 === void 0 ? void 0 : _2["fontFamily"]) || "'Noto Sans', sans-serif",
|
|
16394
|
+
unitScaling: resolvedUnit,
|
|
16395
|
+
percentageScaling: resolvedPercent,
|
|
15658
16396
|
scaleFactor: this.scaleFactor,
|
|
15659
16397
|
};
|
|
15660
16398
|
});
|
|
15661
16399
|
}
|
|
16400
|
+
/** The table's true em in px — the unit `.category-wN` and the bar columns share. */
|
|
16401
|
+
emPx() {
|
|
16402
|
+
return this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; }) * this.scaleFactor;
|
|
16403
|
+
}
|
|
15662
16404
|
/**
|
|
15663
16405
|
* Auto-calculate unitScaling so the largest absolute variance bar
|
|
15664
|
-
* fills ~80% of the bar
|
|
16406
|
+
* fills ~80% of its side of the bar area, without tripping the overdrive break.
|
|
15665
16407
|
*/
|
|
15666
16408
|
autoUnitScaling() {
|
|
15667
|
-
const
|
|
15668
|
-
const
|
|
15669
|
-
const
|
|
15670
|
-
const absMax = this.getMaxAbsValue();
|
|
16409
|
+
const emPx = this.emPx();
|
|
16410
|
+
const fs = emPx * BAR_LABEL_FONT_RATIO;
|
|
16411
|
+
const { absMax, hasNeg, hasPos } = this.getAbsBarColumnStats();
|
|
15671
16412
|
if (absMax <= 0 || fs <= 0) {
|
|
15672
16413
|
return 0.01;
|
|
15673
16414
|
}
|
|
16415
|
+
const { maxBarWidth, cutWidth } = absoluteBarGeometry(this.barColumnMaxWidth, emPx, hasNeg, hasPos);
|
|
16416
|
+
const targetWidth = Math.min(maxBarWidth * 0.8, cutWidth);
|
|
15674
16417
|
return targetWidth / (absMax * fs);
|
|
15675
16418
|
}
|
|
15676
16419
|
/**
|
|
@@ -15678,52 +16421,47 @@ const IbcsTable = class {
|
|
|
15678
16421
|
* fills ~80% of the pin area.
|
|
15679
16422
|
*/
|
|
15680
16423
|
autoPercentageScaling() {
|
|
15681
|
-
const
|
|
15682
|
-
const
|
|
15683
|
-
const
|
|
15684
|
-
const maxPct = this.getMaxRelativeValue();
|
|
16424
|
+
const emPx = this.emPx();
|
|
16425
|
+
const fs = emPx * BAR_LABEL_FONT_RATIO;
|
|
16426
|
+
const { absMax: maxPct, hasNeg, hasPos } = this.getRelativeBarColumnStats();
|
|
15685
16427
|
if (maxPct <= 0 || fs <= 0) {
|
|
15686
16428
|
return 0.5;
|
|
15687
16429
|
}
|
|
15688
|
-
|
|
16430
|
+
const { maxPinLength } = relativePinGeometry(this.barColumnMaxWidth, emPx, hasNeg, hasPos);
|
|
16431
|
+
return (maxPinLength * 0.8) / (maxPct * fs);
|
|
15689
16432
|
}
|
|
15690
16433
|
/**
|
|
15691
|
-
*
|
|
16434
|
+
* Maximum value and sign coverage across all absolute variance columns (d_*) in the table body.
|
|
16435
|
+
* Sign coverage decides how much of the column the bar area gets (see barColumnGeometry.ts);
|
|
16436
|
+
* OR-ing it across columns keeps the single shared scaling inside the narrowest bar area.
|
|
15692
16437
|
*/
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
|
|
15696
|
-
let max = 0;
|
|
15697
|
-
for (const row of this.table.getBody()) {
|
|
15698
|
-
if (row.type === TableRowType.SUM)
|
|
15699
|
-
continue;
|
|
15700
|
-
for (const cell of row.getCells()) {
|
|
15701
|
-
// waterfall cells scale independently and must not skew variance auto-scaling
|
|
15702
|
-
if (cell.isBarChart && cell.columnStats && !cell.key.startsWith("dr") && !cell.waterfall) {
|
|
15703
|
-
max = Math.max(max, cell.columnStats.absMax);
|
|
15704
|
-
}
|
|
15705
|
-
}
|
|
15706
|
-
}
|
|
15707
|
-
return max;
|
|
16438
|
+
getAbsBarColumnStats() {
|
|
16439
|
+
// waterfall cells scale independently and must not skew variance auto-scaling
|
|
16440
|
+
return this.collectBarColumnStats((cell) => !cell.key.startsWith("dr") && !cell.waterfall, 1);
|
|
15708
16441
|
}
|
|
15709
16442
|
/**
|
|
15710
|
-
*
|
|
15711
|
-
*
|
|
16443
|
+
* Same for the relative variance columns (dr_*). Values are stored as decimals
|
|
16444
|
+
* (e.g. 0.2 = 20%), returned as percentage (20).
|
|
15712
16445
|
*/
|
|
15713
|
-
|
|
16446
|
+
getRelativeBarColumnStats() {
|
|
16447
|
+
return this.collectBarColumnStats((cell) => cell.key.startsWith("dr"), 100);
|
|
16448
|
+
}
|
|
16449
|
+
collectBarColumnStats(accept, valueFactor) {
|
|
16450
|
+
const stats = { absMax: 0, hasNeg: false, hasPos: false };
|
|
15714
16451
|
if (!this.table)
|
|
15715
|
-
return
|
|
15716
|
-
let max = 0;
|
|
16452
|
+
return stats;
|
|
15717
16453
|
for (const row of this.table.getBody()) {
|
|
15718
16454
|
if (row.type === TableRowType.SUM)
|
|
15719
16455
|
continue;
|
|
15720
16456
|
for (const cell of row.getCells()) {
|
|
15721
|
-
if (cell.isBarChart
|
|
15722
|
-
|
|
15723
|
-
|
|
16457
|
+
if (!cell.isBarChart || !cell.columnStats || !accept(cell))
|
|
16458
|
+
continue;
|
|
16459
|
+
stats.absMax = Math.max(stats.absMax, cell.columnStats.absMax * valueFactor);
|
|
16460
|
+
stats.hasNeg = stats.hasNeg || cell.columnStats.min < 0;
|
|
16461
|
+
stats.hasPos = stats.hasPos || cell.columnStats.max > 0;
|
|
15724
16462
|
}
|
|
15725
16463
|
}
|
|
15726
|
-
return
|
|
16464
|
+
return stats;
|
|
15727
16465
|
}
|
|
15728
16466
|
get element() { return index.getElement(this); }
|
|
15729
16467
|
};
|