@bino-bi/bn-template-engine 1.0.0-next.22 → 1.0.0-next.24
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/index.esm.js +1 -0
- package/dist/bn-template-engine/{p-a4ea9a79.entry.js → p-03304284.entry.js} +1 -1
- package/dist/bn-template-engine/p-0b2e1661.entry.js +1 -0
- package/dist/bn-template-engine/{p-2d3ea756.entry.js → p-0fb02c57.entry.js} +1 -1
- package/dist/bn-template-engine/p-2fbc2d50.entry.js +1 -0
- package/dist/bn-template-engine/p-36f1c5f9.entry.js +1 -0
- package/dist/bn-template-engine/{p-2fba7c99.entry.js → p-4419db8f.entry.js} +1 -1
- package/dist/bn-template-engine/p-45508f1b.entry.js +1 -0
- package/dist/bn-template-engine/p-5d7a3a77.entry.js +1 -0
- package/dist/bn-template-engine/p-62cc95b7.entry.js +1 -0
- package/dist/bn-template-engine/p-686d8e44.entry.js +1 -0
- package/dist/bn-template-engine/{p-C5uvAEKI.js → p-B5Jd_eCX.js} +1 -1
- package/dist/bn-template-engine/{p-eEfqksk-.js → p-BbmobTg0.js} +1 -1
- package/dist/bn-template-engine/p-BcLsoDrW.js +1 -0
- package/dist/bn-template-engine/p-BcaI745G.js +1 -0
- package/dist/bn-template-engine/p-C5UYpZUU.js +2 -0
- package/dist/bn-template-engine/{p-6lOdN-fB.js → p-CG_Bcm6V.js} +1 -1
- package/dist/bn-template-engine/p-CTrNbSXN.js +1 -0
- package/dist/bn-template-engine/{p-fFtEvsY-.js → p-CWWWM-XC.js} +1 -1
- package/dist/bn-template-engine/{p-D1SJ10zl.js → p-CsJ84YRk.js} +1 -1
- package/dist/bn-template-engine/{p-BgIpdpfH.js → p-D5e8I9Qe.js} +1 -1
- package/dist/bn-template-engine/p-DVrDYxlh.js +1 -0
- package/dist/bn-template-engine/p-DjPXefnq.js +1 -0
- package/dist/bn-template-engine/{p-B4JfKvVT.js → p-DtLI_CzV.js} +1 -1
- package/dist/bn-template-engine/{p-D75i_YOP.js → p-EtT29btN.js} +1 -1
- package/dist/bn-template-engine/{p-DwYUTvvI.js → p-TuLpbB5O.js} +1 -1
- package/dist/bn-template-engine/{p-c3383557.entry.js → p-a5867a4c.entry.js} +1 -1
- package/dist/bn-template-engine/p-a8eb9ca0.entry.js +1 -0
- package/dist/bn-template-engine/{p-de29986f.entry.js → p-b27009eb.entry.js} +1 -1
- package/dist/bn-template-engine/{p-28d5c266.entry.js → p-f06c3703.entry.js} +1 -1
- package/dist/bn-template-engine/{p-93eaded3.entry.js → p-fcfbb329.entry.js} +1 -1
- package/dist/bn-template-engine/{p-CYE0I1Mx.js → p-qRZrT-U3.js} +1 -1
- package/dist/cjs/{AxisConfig-D7CAyPLO.js → AxisConfig-DwiNUyYG.js} +1 -1
- package/dist/cjs/{LabelCollisionManager-DkdQ9Xdg.js → LabelCollisionManager-Bv-xkeXw.js} +7 -4
- package/dist/cjs/{Order-IPfAP0q8.js → Order-2wRydarc.js} +1 -1
- package/dist/cjs/{SVGStyle-BD8jApd4.js → SVGStyle-DoxylrEQ.js} +12 -2
- package/dist/cjs/{SVGVariancesStyleGroup-BaWzR951.js → SVGVariancesStyleGroup-CiI4GeWe.js} +1 -1
- package/dist/cjs/{VarianceMeasure-BBWTgv2e.js → VarianceMeasure-CQlSRzlp.js} +4 -4
- package/dist/cjs/{XYChartDataRow-BoR0CTfl.js → XYChartDataRow-C2FdL58s.js} +4 -4
- package/dist/cjs/bn-asset_21.cjs.entry.js +1357 -240
- package/dist/cjs/bn-chart-bubble.cjs.entry.js +33 -13
- package/dist/cjs/bn-chart-bullet.cjs.entry.js +32 -12
- package/dist/cjs/bn-chart-scatter.cjs.entry.js +32 -12
- package/dist/cjs/bn-grid.cjs.entry.js +84 -7
- 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 +80 -6
- package/dist/cjs/{context-protocol-BBhT9B52.js → context-protocol-DcTEh1rq.js} +3 -1
- package/dist/cjs/diagnostics-CTgbq_Gc.js +107 -0
- 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/index.cjs.js +15 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{scaling-B6_M_HWH.js → scaling-Dsb5_NXy.js} +3 -3
- package/dist/cjs/svgChartElements-tDA43aYj.js +400 -0
- 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-CFIc5-6s.js} +3 -3
- package/dist/cjs/{withStyled-DuwvaDMp.js → withStyled-D0jLwCib.js} +5 -5
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +60 -1
- package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.js +60 -1
- package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.js +60 -1
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.css +6 -0
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +204 -26
- package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +101 -28
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +65 -19
- package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +5 -2
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +239 -18
- package/dist/collection/components/bn-chart-time/ibcs-chart-time.css +9 -3
- package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +107 -22
- package/dist/collection/components/bn-chart-time/utils/TimeChart.js +98 -15
- package/dist/collection/components/bn-chart-time/utils/elements/Label.js +5 -2
- package/dist/collection/components/bn-context/bn-context.js +133 -1
- package/dist/collection/components/bn-grid/bn-grid.js +129 -1
- package/dist/collection/components/bn-table/bn-table.js +149 -5
- package/dist/collection/components/bn-table/ibcs-table.js +210 -40
- package/dist/collection/components/bn-table/utils/Table.js +21 -7
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +18 -32
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +4 -5
- package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +4 -0
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +89 -0
- package/dist/collection/components/bn-tree/bn-tree.js +137 -0
- package/dist/collection/context/context-protocol.js +1 -1
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/autoFit.js +63 -0
- package/dist/collection/utils/constants.js +3 -3
- package/dist/collection/utils/layoutState/diagnostics.js +17 -0
- package/dist/collection/utils/layoutState/generic.js +37 -0
- package/dist/collection/utils/layoutState/geometry.js +44 -0
- package/dist/collection/utils/layoutState/identity.js +33 -0
- package/dist/collection/utils/layoutState/index.js +6 -0
- package/dist/collection/utils/layoutState/svgChartElements.js +200 -0
- package/dist/collection/utils/layoutState/types.js +13 -0
- package/dist/collection/utils/measurementHost.js +58 -0
- package/dist/collection/utils/model/styles/FontStyle.js +10 -0
- package/dist/components/LabelCollisionManager.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-context.js +1 -1
- package/dist/components/bn-grid.js +1 -1
- package/dist/components/bn-internationalization.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/bn-tree.js +1 -1
- package/dist/components/context-protocol.js +1 -1
- package/dist/components/diagnostics.js +1 -0
- package/dist/components/geometry.js +1 -0
- package/dist/components/ibcs-chart-bubble2.js +1 -1
- package/dist/components/ibcs-chart-bullet2.js +1 -1
- package/dist/components/ibcs-chart-scatter2.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/index.js +1 -1
- package/dist/components/main.js +1 -1
- package/dist/components/svgChartElements.js +1 -0
- package/dist/components/types.js +1 -0
- package/dist/esm/{AxisConfig-ByIP5J-9.js → AxisConfig-KqzWQbML.js} +1 -1
- package/dist/esm/{LabelCollisionManager-DaNiDiM9.js → LabelCollisionManager-585bQMtP.js} +7 -4
- package/dist/esm/{Order-BQeJE_yi.js → Order-DZVWjEL_.js} +1 -1
- package/dist/esm/{SVGStyle-BwBlY3Km.js → SVGStyle-OrPkzjcb.js} +12 -2
- package/dist/esm/{SVGVariancesStyleGroup-BpGW4CvN.js → SVGVariancesStyleGroup-DO5QJfRQ.js} +1 -1
- package/dist/esm/{VarianceMeasure-CE3N8Bea.js → VarianceMeasure-DDjChp8C.js} +4 -4
- package/dist/esm/{XYChartDataRow-DeMI1JKU.js → XYChartDataRow-Dn83Tqh9.js} +4 -4
- package/dist/esm/bn-asset_21.entry.js +1350 -233
- package/dist/esm/bn-chart-bubble.entry.js +31 -11
- package/dist/esm/bn-chart-bullet.entry.js +30 -10
- package/dist/esm/bn-chart-scatter.entry.js +30 -10
- package/dist/esm/bn-grid.entry.js +84 -7
- 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 +80 -6
- package/dist/esm/{context-protocol-d8MHrEo8.js → context-protocol-B-vdGKeG.js} +2 -2
- package/dist/esm/diagnostics-CiquIw8B.js +99 -0
- 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/index.js +14 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{scaling-Bw8XyrFq.js → scaling-Dggyeqts.js} +3 -3
- package/dist/esm/svgChartElements-B3YClivG.js +395 -0
- 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-DNBSqRC0.js} +3 -3
- package/dist/esm/{withStyled-41rsCSM1.js → withStyled-DoNsbwS3.js} +5 -5
- package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +10 -0
- package/dist/types/components/bn-chart-bullet/bn-chart-bullet.d.ts +10 -0
- package/dist/types/components/bn-chart-scatter/bn-chart-scatter.d.ts +10 -0
- package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +33 -3
- package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +9 -3
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +38 -3
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +36 -0
- package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +10 -3
- package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +38 -0
- package/dist/types/components/bn-context/bn-context.d.ts +14 -0
- package/dist/types/components/bn-grid/bn-grid.d.ts +10 -0
- package/dist/types/components/bn-table/bn-table.d.ts +26 -2
- package/dist/types/components/bn-table/ibcs-table.d.ts +31 -6
- package/dist/types/components/bn-table/utils/Table.d.ts +16 -1
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +9 -1
- package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +2 -0
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +51 -0
- package/dist/types/components/bn-tree/bn-tree.d.ts +10 -0
- package/dist/types/components.d.ts +65 -4
- package/dist/types/context/context-protocol.d.ts +5 -0
- package/dist/types/index.d.ts +1 -0
- 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/layoutState/diagnostics.d.ts +7 -0
- package/dist/types/utils/layoutState/generic.d.ts +14 -0
- package/dist/types/utils/layoutState/geometry.d.ts +35 -0
- package/dist/types/utils/layoutState/identity.d.ts +22 -0
- package/dist/types/utils/layoutState/index.d.ts +6 -0
- package/dist/types/utils/layoutState/svgChartElements.d.ts +37 -0
- package/dist/types/utils/layoutState/types.d.ts +219 -0
- package/dist/types/utils/measurementHost.d.ts +9 -0
- package/dist/types/utils/model/styles/FontStyle.d.ts +7 -0
- package/package.json +1 -1
- package/dist/bn-template-engine/p-445c76cd.entry.js +0 -1
- package/dist/bn-template-engine/p-687032d5.entry.js +0 -1
- package/dist/bn-template-engine/p-7d1083f6.entry.js +0 -1
- package/dist/bn-template-engine/p-91e5dddf.entry.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-CJThzFZm.js +0 -1
- package/dist/bn-template-engine/p-Da6p_F4J.js +0 -1
- package/dist/bn-template-engine/p-a8291de2.entry.js +0 -1
- package/dist/bn-template-engine/p-cda4322a.entry.js +0 -1
- package/dist/bn-template-engine/p-e49f9170.entry.js +0 -1
- package/dist/bn-template-engine/p-f275b9fe.entry.js +0 -1
- package/dist/cjs/layoutObserver-D8leSb4j.js +0 -199
- package/dist/esm/layoutObserver-DtZb2vdM.js +0 -196
|
@@ -1,19 +1,21 @@
|
|
|
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
|
|
11
|
-
var VarianceMeasure = require('./VarianceMeasure-
|
|
12
|
-
var Order = require('./Order-
|
|
13
|
-
var
|
|
3
|
+
var index = require('./index-C1Z9vO7z.js');
|
|
4
|
+
var withHasError = require('./withHasError-BdDmiOXM.js');
|
|
5
|
+
var contextProtocol = require('./context-protocol-DcTEh1rq.js');
|
|
6
|
+
var withBodyObserver = require('./withBodyObserver-DJO98AJ-.js');
|
|
7
|
+
var withStyled = require('./withStyled-D0jLwCib.js');
|
|
8
|
+
var scaling = require('./scaling-Dsb5_NXy.js');
|
|
9
|
+
var withScalingGroup = require('./withScalingGroup-CFIc5-6s.js');
|
|
10
|
+
var svgChartElements = require('./svgChartElements-tDA43aYj.js');
|
|
11
|
+
var VarianceMeasure = require('./VarianceMeasure-CQlSRzlp.js');
|
|
12
|
+
var Order = require('./Order-2wRydarc.js');
|
|
13
|
+
var index$1 = require('./index.cjs.js');
|
|
14
|
+
var diagnostics = require('./diagnostics-CTgbq_Gc.js');
|
|
15
|
+
var SVGStyle = require('./SVGStyle-DoxylrEQ.js');
|
|
14
16
|
var sanitizeHtml = require('./sanitizeHtml-LuZr1IMd.js');
|
|
15
|
-
var LabelCollisionManager = require('./LabelCollisionManager-
|
|
16
|
-
var SVGVariancesStyleGroup = require('./SVGVariancesStyleGroup-
|
|
17
|
+
var LabelCollisionManager = require('./LabelCollisionManager-Bv-xkeXw.js');
|
|
18
|
+
var SVGVariancesStyleGroup = require('./SVGVariancesStyleGroup-CiI4GeWe.js');
|
|
17
19
|
|
|
18
20
|
const bnAssetCss = () => `:host{display:none}`;
|
|
19
21
|
|
|
@@ -101,7 +103,40 @@ const Card = class {
|
|
|
101
103
|
};
|
|
102
104
|
Card.style = bnCardCss();
|
|
103
105
|
|
|
104
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Effective font size of an element in px, resolved from computed style
|
|
108
|
+
* (which reflects `--bn-font-size` scaling). Falls back to the system
|
|
109
|
+
* default where computed style is unavailable (spec tests).
|
|
110
|
+
*/
|
|
111
|
+
function readFontSizePx(el) {
|
|
112
|
+
if (typeof getComputedStyle === "function") {
|
|
113
|
+
const parsed = parseFloat(getComputedStyle(el).fontSize);
|
|
114
|
+
if (Number.isFinite(parsed) && parsed > 0)
|
|
115
|
+
return parsed;
|
|
116
|
+
}
|
|
117
|
+
return contextProtocol.SYSTEM_STYLE_DEFAULTS.global.fontSizePx;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Layout state for a visual component without its own `getLayoutState()`:
|
|
121
|
+
* host box, identity, em context and diagnostics — no regions or elements.
|
|
122
|
+
* The caller (`bn-context`) overwrites `id` with its document-order identity.
|
|
123
|
+
*/
|
|
124
|
+
function buildGenericState(el, origins) {
|
|
125
|
+
var _a;
|
|
126
|
+
return {
|
|
127
|
+
version: index$1.LAYOUT_STATE_VERSION,
|
|
128
|
+
tag: el.localName,
|
|
129
|
+
id: diagnostics.resolveStandaloneId(el),
|
|
130
|
+
slot: (_a = el.getAttribute("slot")) !== null && _a !== void 0 ? _a : undefined,
|
|
131
|
+
rect: diagnostics.measure(el, origins),
|
|
132
|
+
em: { fontSizePx: readFontSizePx(el), appliedScaleFactor: 1 },
|
|
133
|
+
regions: [],
|
|
134
|
+
metadata: {},
|
|
135
|
+
diagnostics: diagnostics.readDiagnostics(el),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
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
140
|
|
|
106
141
|
const Chart$1 = class Chart {
|
|
107
142
|
validateScenario(newValue) {
|
|
@@ -412,7 +447,12 @@ const Chart$1 = class Chart {
|
|
|
412
447
|
* them into a bn-scaling-group.
|
|
413
448
|
*/
|
|
414
449
|
this.handleAutoScalingReport = (report) => {
|
|
415
|
-
var _a, _b;
|
|
450
|
+
var _a, _b, _c, _d, _e, _f;
|
|
451
|
+
// A report only carries the auto-resolved quantities — keep the other one.
|
|
452
|
+
this.lastAutoScalingReport = {
|
|
453
|
+
unit: (_a = report.unit) !== null && _a !== void 0 ? _a : (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.unit,
|
|
454
|
+
percentage: (_c = report.percentage) !== null && _c !== void 0 ? _c : (_d = this.lastAutoScalingReport) === null || _d === void 0 ? void 0 : _d.percentage,
|
|
455
|
+
};
|
|
416
456
|
const changed = (next, last) => last === undefined || Math.abs(next - last) > Math.abs(next) * 1e-3;
|
|
417
457
|
const effFontPx = this.getEffectiveFontPx();
|
|
418
458
|
if (report.unit !== undefined && report.unit > 0 && this.autoUnitWarningActive) {
|
|
@@ -422,7 +462,7 @@ const Chart$1 = class Chart {
|
|
|
422
462
|
this.errors.addOrReplace({
|
|
423
463
|
id: "AUTO_unitScaling",
|
|
424
464
|
type: "warning",
|
|
425
|
-
message: `unit-scaling: ${Chart$1.describeScalingInput(String((
|
|
465
|
+
message: `unit-scaling: ${Chart$1.describeScalingInput(String((_e = this.unitScaling) !== null && _e !== void 0 ? _e : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(unitsPerEm)} units.`,
|
|
426
466
|
});
|
|
427
467
|
}
|
|
428
468
|
}
|
|
@@ -433,7 +473,7 @@ const Chart$1 = class Chart {
|
|
|
433
473
|
this.errors.addOrReplace({
|
|
434
474
|
id: "AUTO_percentageScaling",
|
|
435
475
|
type: "warning",
|
|
436
|
-
message: `percentage-scaling: ${Chart$1.describeScalingInput(String((
|
|
476
|
+
message: `percentage-scaling: ${Chart$1.describeScalingInput(String((_f = this.percentageScaling) !== null && _f !== void 0 ? _f : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(ppPerEm)} percentage points.`,
|
|
437
477
|
});
|
|
438
478
|
}
|
|
439
479
|
}
|
|
@@ -450,7 +490,7 @@ const Chart$1 = class Chart {
|
|
|
450
490
|
this.errors = withHasError.withHasError(this);
|
|
451
491
|
withScalingGroup.withScalingGroup(this);
|
|
452
492
|
this.componentStyle = withStyled.withComponentStyle(this);
|
|
453
|
-
this.ruleSetConfig =
|
|
493
|
+
this.ruleSetConfig = svgChartElements.withRuleSet(this);
|
|
454
494
|
this.t = scaling.withTranslation(this).t;
|
|
455
495
|
this.resolveInherited = scaling.withInheritedProps(this, [
|
|
456
496
|
{ propName: "scenarios", ancestorAttr: "title-scenarios" },
|
|
@@ -477,18 +517,18 @@ const Chart$1 = class Chart {
|
|
|
477
517
|
const { mode } = scaling.parseScaling(this.scale);
|
|
478
518
|
if (mode !== "auto" && mode !== "empty") {
|
|
479
519
|
this._autoScaleGuard = false;
|
|
480
|
-
this.
|
|
520
|
+
this.checkOverflow();
|
|
481
521
|
return;
|
|
482
522
|
}
|
|
483
523
|
if (this._autoScaleGuard) {
|
|
484
524
|
this._autoScaleGuard = false;
|
|
485
|
-
this.
|
|
525
|
+
this.checkOverflow();
|
|
486
526
|
return;
|
|
487
527
|
}
|
|
488
528
|
const host = this.element;
|
|
489
529
|
const { height: parentHeight } = scaling.getParentDimensions(host);
|
|
490
530
|
if (parentHeight <= 0) {
|
|
491
|
-
this.
|
|
531
|
+
this.checkOverflow();
|
|
492
532
|
return;
|
|
493
533
|
}
|
|
494
534
|
// Record height so the ResizeObserver callback can tell
|
|
@@ -506,7 +546,7 @@ const Chart$1 = class Chart {
|
|
|
506
546
|
// Content fits. Don't reset to factor 1 — the content only fits
|
|
507
547
|
// BECAUSE of the current factor. Resetting would cause oscillation.
|
|
508
548
|
this.errors.remove("AUTO_scale");
|
|
509
|
-
this.
|
|
549
|
+
this.checkOverflow();
|
|
510
550
|
return;
|
|
511
551
|
}
|
|
512
552
|
// Content overflows. Compute a new factor based on the ratio of
|
|
@@ -516,7 +556,7 @@ const Chart$1 = class Chart {
|
|
|
516
556
|
// SVG charts have non-linear scaling so we use a wider tolerance
|
|
517
557
|
// than tables to avoid oscillation from sub-pixel rounding.
|
|
518
558
|
if (Math.abs(computedFactor - currentFactor) < 0.01) {
|
|
519
|
-
this.
|
|
559
|
+
this.checkOverflow();
|
|
520
560
|
return;
|
|
521
561
|
}
|
|
522
562
|
host.style.setProperty("--bn-font-size", `${baseFontSize * computedFactor}px`);
|
|
@@ -534,7 +574,10 @@ const Chart$1 = class Chart {
|
|
|
534
574
|
index.writeTask(() => {
|
|
535
575
|
this.appliedScaleFactor = computedFactor;
|
|
536
576
|
});
|
|
537
|
-
|
|
577
|
+
// Check with the current (pre-factor) content so overflow is reported
|
|
578
|
+
// even if the scheduled re-render stalls; the follow-up render re-checks
|
|
579
|
+
// in the guard branch and clears any transiently reported overflow.
|
|
580
|
+
this.checkOverflow();
|
|
538
581
|
}
|
|
539
582
|
componentDidLoad() {
|
|
540
583
|
// Observe the parent container for size changes so auto-scaling
|
|
@@ -543,7 +586,7 @@ const Chart$1 = class Chart {
|
|
|
543
586
|
// compared to what auto-scaling last measured — this prevents the
|
|
544
587
|
// ResizeObserver's initial fire (and content-reflow noise) from
|
|
545
588
|
// creating an infinite auto-scale loop.
|
|
546
|
-
this.layoutObserver =
|
|
589
|
+
this.layoutObserver = svgChartElements.observeParentResize(this.element, () => {
|
|
547
590
|
if (this._autoScaleGuard)
|
|
548
591
|
return;
|
|
549
592
|
const { height } = scaling.getParentDimensions(this.element);
|
|
@@ -572,27 +615,74 @@ const Chart$1 = class Chart {
|
|
|
572
615
|
this.layoutObserver = null;
|
|
573
616
|
}
|
|
574
617
|
/**
|
|
575
|
-
*
|
|
576
|
-
*
|
|
618
|
+
* Content width from the rendered SVG width attributes (segments render
|
|
619
|
+
* side by side) — immune to the inner hosts' overflow:hidden clipping:
|
|
620
|
+
* flex items with hidden overflow shrink below their content size, so the
|
|
621
|
+
* host's scrollWidth cannot see the overflow. Falls back to scrollWidth
|
|
622
|
+
* before the inner charts have rendered.
|
|
577
623
|
*/
|
|
578
|
-
|
|
624
|
+
measureContentWidth() {
|
|
625
|
+
var _a;
|
|
626
|
+
const inners = (_a = this.element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll("ibcs-chart-structure");
|
|
627
|
+
let total = 0;
|
|
628
|
+
let found = false;
|
|
629
|
+
inners === null || inners === void 0 ? void 0 : inners.forEach((inner) => {
|
|
630
|
+
var _a, _b, _c;
|
|
631
|
+
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 : "");
|
|
632
|
+
if (!Number.isNaN(width)) {
|
|
633
|
+
total += width;
|
|
634
|
+
found = true;
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
// scrollWidth additionally sees non-SVG chrome, but is blind to clipped
|
|
638
|
+
// segments (see above) — take the larger of the two measurements.
|
|
639
|
+
// Floor the fractional SVG widths so borderline sub-pixel overhangs are
|
|
640
|
+
// judged with the same integer tolerance as the scroll metrics.
|
|
641
|
+
return found ? Math.max(Math.floor(total), this.element.scrollWidth) : this.element.scrollWidth;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Reports a WARN_overflow item when the rendered chart exceeds its
|
|
645
|
+
* container. Overflow attributable to a fixed scaling attribute is an
|
|
646
|
+
* error (width: unit-scaling / percentage-scaling, height: scale);
|
|
647
|
+
* overflow in fully-auto mode is a warning — auto-fit prevents it by
|
|
648
|
+
* construction, so it only fires when the content cannot fit at any scale.
|
|
649
|
+
*/
|
|
650
|
+
checkOverflow() {
|
|
579
651
|
const errId = "WARN_overflow";
|
|
580
|
-
if (scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap).kind !== "value") {
|
|
581
|
-
// Auto (explicit or fallback) fits the width by construction.
|
|
582
|
-
this.errors.remove(errId);
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
652
|
const parent = scaling.getParentDimensions(this.element);
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
else {
|
|
653
|
+
const contentWidth = this.measureContentWidth();
|
|
654
|
+
const contentHeight = this.element.scrollHeight;
|
|
655
|
+
const widthOver = parent.width > 0 && contentWidth > parent.width + 1;
|
|
656
|
+
const heightOver = parent.height > 0 && contentHeight > parent.height + 1;
|
|
657
|
+
if (!widthOver && !heightOver) {
|
|
594
658
|
this.errors.remove(errId);
|
|
659
|
+
return;
|
|
595
660
|
}
|
|
661
|
+
const hasRelativeVariance = this.prepareVariances().some((variance) => variance.startsWith("dr"));
|
|
662
|
+
const fixedUnit = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap).kind === "value";
|
|
663
|
+
const fixedPercent = hasRelativeVariance && scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap).kind === "value";
|
|
664
|
+
const { mode } = scaling.parseScaling(this.scale);
|
|
665
|
+
const fixedScale = mode !== "auto" && mode !== "empty";
|
|
666
|
+
const fixedAttrs = [];
|
|
667
|
+
if (widthOver && fixedUnit)
|
|
668
|
+
fixedAttrs.push("unit-scaling");
|
|
669
|
+
if (widthOver && fixedPercent)
|
|
670
|
+
fixedAttrs.push("percentage-scaling");
|
|
671
|
+
if (heightOver && fixedScale)
|
|
672
|
+
fixedAttrs.push("scale");
|
|
673
|
+
const dims = [];
|
|
674
|
+
if (widthOver)
|
|
675
|
+
dims.push(`width (${Math.round(contentWidth)}px > ${Math.round(parent.width)}px)`);
|
|
676
|
+
if (heightOver)
|
|
677
|
+
dims.push(`height (${Math.round(contentHeight)}px > ${Math.round(parent.height)}px)`);
|
|
678
|
+
this.errors.addOrReplace({
|
|
679
|
+
id: errId,
|
|
680
|
+
type: fixedAttrs.length > 0 ? "error" : "warning",
|
|
681
|
+
message: `Chart exceeds available ${dims.join(" and ")}. ` +
|
|
682
|
+
(fixedAttrs.length > 0
|
|
683
|
+
? `Adjust ${fixedAttrs.join(" / ")} or set to "auto".`
|
|
684
|
+
: "Content does not fit even at minimum auto scaling; enlarge the container."),
|
|
685
|
+
});
|
|
596
686
|
}
|
|
597
687
|
prepareDimension() {
|
|
598
688
|
const parent = scaling.getParentDimensions(this.element);
|
|
@@ -786,6 +876,7 @@ const Chart$1 = class Chart {
|
|
|
786
876
|
},
|
|
787
877
|
fontStyles: {
|
|
788
878
|
font: `${scaledFontSize}px ${$["global"]["fontFamily"]}`,
|
|
879
|
+
family: $["global"]["fontFamily"],
|
|
789
880
|
size: scaledFontSize,
|
|
790
881
|
color: $["global"]["fontColor"],
|
|
791
882
|
background: $["global"]["fontBackgroundColor"],
|
|
@@ -915,6 +1006,87 @@ const Chart$1 = class Chart {
|
|
|
915
1006
|
const effectiveScenarios = (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === VarianceMeasure.StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
|
|
916
1007
|
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() }));
|
|
917
1008
|
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Lazily generates this chart's layout state: host box (context- and
|
|
1011
|
+
* component-relative, CSS px), one `canvas:<segment>` region per rendered
|
|
1012
|
+
* segment (base + variances), metadata (scenarios, bar count), diagnostics
|
|
1013
|
+
* and resolved scaling. With `detail: "full"` every bar, label and axis of
|
|
1014
|
+
* every segment is listed with its geometry.
|
|
1015
|
+
*
|
|
1016
|
+
* @param options - `{ detail: "summary" | "full" }`, default `"summary"`
|
|
1017
|
+
*/
|
|
1018
|
+
async getLayoutState(options) {
|
|
1019
|
+
var _a, _b, _c, _d;
|
|
1020
|
+
const detail = (_a = options === null || options === void 0 ? void 0 : options.detail) !== null && _a !== void 0 ? _a : "summary";
|
|
1021
|
+
const origins = diagnostics.originsFor(this.element);
|
|
1022
|
+
const rawFactor = this.getEffectiveScaleFactor();
|
|
1023
|
+
// Auto-scale can be mid-measurement (or unmeasurable in tests) — report a sane factor.
|
|
1024
|
+
const factor = Number.isFinite(rawFactor) && rawFactor > 0 ? rawFactor : 1;
|
|
1025
|
+
const fontSizePx = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; }) * factor;
|
|
1026
|
+
const variances = this.prepareVariances();
|
|
1027
|
+
const layout = svgChartElements.collectChartFacadeLayout(this.element, "ibcs-chart-structure", ["base", ...variances], origins, detail);
|
|
1028
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1029
|
+
const firstInner = (_b = this.element.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector("ibcs-chart-structure");
|
|
1030
|
+
const state = {
|
|
1031
|
+
version: index$1.LAYOUT_STATE_VERSION,
|
|
1032
|
+
tag: this.element.localName,
|
|
1033
|
+
id: diagnostics.resolveStandaloneId(this.element),
|
|
1034
|
+
slot: (_c = this.element.getAttribute("slot")) !== null && _c !== void 0 ? _c : undefined,
|
|
1035
|
+
rect: diagnostics.measure(this.element, origins),
|
|
1036
|
+
em: { fontSizePx, appliedScaleFactor: factor },
|
|
1037
|
+
regions: layout.regions,
|
|
1038
|
+
metadata: {
|
|
1039
|
+
title: this.chartTitle || undefined,
|
|
1040
|
+
scenarios: (_d = firstInner === null || firstInner === void 0 ? void 0 : firstInner.scenarios) !== null && _d !== void 0 ? _d : [],
|
|
1041
|
+
variances,
|
|
1042
|
+
barCount: layout.barCount,
|
|
1043
|
+
hasNoData: layout.barCount === 0,
|
|
1044
|
+
},
|
|
1045
|
+
diagnostics: diagnostics.readDiagnostics(this.element),
|
|
1046
|
+
scaling: this.resolveScalingInfo(fontSizePx),
|
|
1047
|
+
};
|
|
1048
|
+
if (layout.elements)
|
|
1049
|
+
state.elements = layout.elements;
|
|
1050
|
+
return state;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Resolved value scaling without re-triggering validation side effects.
|
|
1054
|
+
* The inner chart's scale unit is px per unit / px per 1.0 fraction;
|
|
1055
|
+
* auto-fitted values come from the last inner report.
|
|
1056
|
+
*/
|
|
1057
|
+
resolveScalingInfo(effFontPx) {
|
|
1058
|
+
var _a, _b;
|
|
1059
|
+
const info = {};
|
|
1060
|
+
const unit = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap);
|
|
1061
|
+
if (unit.kind === "value") {
|
|
1062
|
+
info.unitMode = "fixed";
|
|
1063
|
+
info.unitsPerEm = unit.value;
|
|
1064
|
+
info.unitPxPerUnit = effFontPx / unit.value;
|
|
1065
|
+
}
|
|
1066
|
+
else {
|
|
1067
|
+
info.unitMode = "auto";
|
|
1068
|
+
const pxPerUnit = (_a = this.lastAutoScalingReport) === null || _a === void 0 ? void 0 : _a.unit;
|
|
1069
|
+
if (pxPerUnit !== undefined && pxPerUnit > 0) {
|
|
1070
|
+
info.unitPxPerUnit = pxPerUnit;
|
|
1071
|
+
info.unitsPerEm = effFontPx / pxPerUnit;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
const pct = scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap);
|
|
1075
|
+
if (pct.kind === "value") {
|
|
1076
|
+
info.percentageMode = "fixed";
|
|
1077
|
+
info.percentagePointsPerEm = pct.value;
|
|
1078
|
+
info.percentagePxPerPoint = effFontPx / pct.value;
|
|
1079
|
+
}
|
|
1080
|
+
else {
|
|
1081
|
+
info.percentageMode = "auto";
|
|
1082
|
+
const pxPerFraction = (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.percentage;
|
|
1083
|
+
if (pxPerFraction !== undefined && pxPerFraction > 0) {
|
|
1084
|
+
info.percentagePxPerPoint = pxPerFraction / 100;
|
|
1085
|
+
info.percentagePointsPerEm = (100 * effFontPx) / pxPerFraction;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
return info;
|
|
1089
|
+
}
|
|
918
1090
|
getEffectiveScaleFactor() {
|
|
919
1091
|
const { mode, factor } = scaling.parseScaling(this.scale);
|
|
920
1092
|
if (mode === "factor")
|
|
@@ -948,7 +1120,7 @@ const Chart$1 = class Chart {
|
|
|
948
1120
|
scenariosArray = [...scenariosArray, ...variancesArray];
|
|
949
1121
|
}
|
|
950
1122
|
const fontStyles = this.getFontStyles();
|
|
951
|
-
return (index.h(index.Host, { key: '
|
|
1123
|
+
return (index.h(index.Host, { key: '4039c2676dbb48bc14e30092d5f5e7a8c080bd2a', style: fontStyles }, index.h("div", { key: 'c57dbcf301b86f4b22da3142c242008f8f049268', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
952
1124
|
}
|
|
953
1125
|
get element() { return index.getElement(this); }
|
|
954
1126
|
static get watchers() { return {
|
|
@@ -1466,7 +1638,12 @@ const Chart = class {
|
|
|
1466
1638
|
* them into a bn-scaling-group.
|
|
1467
1639
|
*/
|
|
1468
1640
|
this.handleAutoScalingReport = (report) => {
|
|
1469
|
-
var _a, _b;
|
|
1641
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1642
|
+
// A report only carries the auto-resolved quantities — keep the other one.
|
|
1643
|
+
this.lastAutoScalingReport = {
|
|
1644
|
+
unit: (_a = report.unit) !== null && _a !== void 0 ? _a : (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.unit,
|
|
1645
|
+
percentage: (_c = report.percentage) !== null && _c !== void 0 ? _c : (_d = this.lastAutoScalingReport) === null || _d === void 0 ? void 0 : _d.percentage,
|
|
1646
|
+
};
|
|
1470
1647
|
const changed = (next, last) => last === undefined || Math.abs(next - last) > Math.abs(next) * 1e-3;
|
|
1471
1648
|
const effFontPx = this.getEffectiveFontPx();
|
|
1472
1649
|
if (report.unit !== undefined && report.unit > 0 && this.autoUnitWarningActive) {
|
|
@@ -1476,7 +1653,7 @@ const Chart = class {
|
|
|
1476
1653
|
this.errors.addOrReplace({
|
|
1477
1654
|
id: "AUTO_unitScaling",
|
|
1478
1655
|
type: "warning",
|
|
1479
|
-
message: `unit-scaling: ${Chart.describeScalingInput(String((
|
|
1656
|
+
message: `unit-scaling: ${Chart.describeScalingInput(String((_e = this.unitScaling) !== null && _e !== void 0 ? _e : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(unitsPerEm)} units.`,
|
|
1480
1657
|
});
|
|
1481
1658
|
}
|
|
1482
1659
|
}
|
|
@@ -1487,7 +1664,7 @@ const Chart = class {
|
|
|
1487
1664
|
this.errors.addOrReplace({
|
|
1488
1665
|
id: "AUTO_percentageScaling",
|
|
1489
1666
|
type: "warning",
|
|
1490
|
-
message: `percentage-scaling: ${Chart.describeScalingInput(String((
|
|
1667
|
+
message: `percentage-scaling: ${Chart.describeScalingInput(String((_f = this.percentageScaling) !== null && _f !== void 0 ? _f : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(ppPerEm)} percentage points.`,
|
|
1491
1668
|
});
|
|
1492
1669
|
}
|
|
1493
1670
|
}
|
|
@@ -1504,7 +1681,7 @@ const Chart = class {
|
|
|
1504
1681
|
this.errors = withHasError.withHasError(this);
|
|
1505
1682
|
withScalingGroup.withScalingGroup(this);
|
|
1506
1683
|
this.componentStyle = withStyled.withComponentStyle(this);
|
|
1507
|
-
this.ruleSetConfig =
|
|
1684
|
+
this.ruleSetConfig = svgChartElements.withRuleSet(this);
|
|
1508
1685
|
this.t = scaling.withTranslation(this).t;
|
|
1509
1686
|
this.resolveInherited = scaling.withInheritedProps(this, [
|
|
1510
1687
|
{ propName: "scenarios", ancestorAttr: "title-scenarios" },
|
|
@@ -1536,32 +1713,111 @@ const Chart = class {
|
|
|
1536
1713
|
this.validateStack(this.stack);
|
|
1537
1714
|
this.validateScaling(this.scale);
|
|
1538
1715
|
}
|
|
1716
|
+
/**
|
|
1717
|
+
* Content width from the rendered SVG width attributes (segments stack
|
|
1718
|
+
* vertically, so the widest one counts) — immune to overflow:hidden
|
|
1719
|
+
* clipping along the ancestor chain. Falls back to scrollWidth before the
|
|
1720
|
+
* inner charts have rendered.
|
|
1721
|
+
*/
|
|
1722
|
+
measureContentWidth() {
|
|
1723
|
+
var _a;
|
|
1724
|
+
const inners = (_a = this.element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll("ibcs-chart-time");
|
|
1725
|
+
let widest = 0;
|
|
1726
|
+
let found = false;
|
|
1727
|
+
inners === null || inners === void 0 ? void 0 : inners.forEach((inner) => {
|
|
1728
|
+
var _a, _b, _c;
|
|
1729
|
+
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 : "");
|
|
1730
|
+
if (!Number.isNaN(width)) {
|
|
1731
|
+
widest = Math.max(widest, width);
|
|
1732
|
+
found = true;
|
|
1733
|
+
}
|
|
1734
|
+
});
|
|
1735
|
+
// scrollWidth additionally sees non-SVG chrome, so take the larger.
|
|
1736
|
+
// Floor the fractional SVG width so borderline sub-pixel overhangs are
|
|
1737
|
+
// judged with the same integer tolerance as the scroll metrics.
|
|
1738
|
+
return found ? Math.max(Math.floor(widest), this.element.scrollWidth) : this.element.scrollWidth;
|
|
1739
|
+
}
|
|
1740
|
+
/** Content height as the sum of the vertically stacked segment SVGs. */
|
|
1741
|
+
measureContentHeight() {
|
|
1742
|
+
var _a;
|
|
1743
|
+
const inners = (_a = this.element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll("ibcs-chart-time");
|
|
1744
|
+
let total = 0;
|
|
1745
|
+
let found = false;
|
|
1746
|
+
inners === null || inners === void 0 ? void 0 : inners.forEach((inner) => {
|
|
1747
|
+
var _a, _b, _c;
|
|
1748
|
+
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 : "");
|
|
1749
|
+
if (!Number.isNaN(height)) {
|
|
1750
|
+
total += height;
|
|
1751
|
+
found = true;
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
// scrollHeight additionally sees non-SVG chrome (e.g. the footer).
|
|
1755
|
+
// Floor the fractional SVG heights so borderline sub-pixel overhangs are
|
|
1756
|
+
// judged with the same integer tolerance as the scroll metrics.
|
|
1757
|
+
return found ? Math.max(Math.floor(total), this.element.scrollHeight) : this.element.scrollHeight;
|
|
1758
|
+
}
|
|
1759
|
+
/**
|
|
1760
|
+
* Reports a WARN_overflow item when the rendered chart exceeds its
|
|
1761
|
+
* container. Overflow attributable to a fixed scaling attribute is an
|
|
1762
|
+
* error (height: unit-scaling / percentage-scaling, width: scale);
|
|
1763
|
+
* overflow in fully-auto mode is a warning — auto-fit prevents it by
|
|
1764
|
+
* construction, so it only fires when the content cannot fit at any scale.
|
|
1765
|
+
*/
|
|
1766
|
+
checkOverflow() {
|
|
1767
|
+
const errId = "WARN_overflow";
|
|
1768
|
+
const parent = scaling.getParentDimensions(this.element);
|
|
1769
|
+
const contentWidth = this.measureContentWidth();
|
|
1770
|
+
const contentHeight = this.measureContentHeight();
|
|
1771
|
+
const widthOver = parent.width > 0 && contentWidth > parent.width + 1;
|
|
1772
|
+
const heightOver = parent.height > 0 && contentHeight > parent.height + 1;
|
|
1773
|
+
if (!widthOver && !heightOver) {
|
|
1774
|
+
this.errors.remove(errId);
|
|
1775
|
+
return;
|
|
1776
|
+
}
|
|
1777
|
+
const hasRelativeVariance = this.prepareVariances().some((variance) => variance.startsWith("dr"));
|
|
1778
|
+
const fixedUnit = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap).kind === "value";
|
|
1779
|
+
const fixedPercent = hasRelativeVariance && scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap).kind === "value";
|
|
1780
|
+
const { mode } = scaling.parseScaling(this.scale);
|
|
1781
|
+
const fixedScale = mode !== "auto" && mode !== "empty";
|
|
1782
|
+
const fixedAttrs = [];
|
|
1783
|
+
if (heightOver && fixedUnit)
|
|
1784
|
+
fixedAttrs.push("unit-scaling");
|
|
1785
|
+
if (heightOver && fixedPercent)
|
|
1786
|
+
fixedAttrs.push("percentage-scaling");
|
|
1787
|
+
if (widthOver && fixedScale)
|
|
1788
|
+
fixedAttrs.push("scale");
|
|
1789
|
+
const dims = [];
|
|
1790
|
+
if (widthOver)
|
|
1791
|
+
dims.push(`width (${Math.round(contentWidth)}px > ${Math.round(parent.width)}px)`);
|
|
1792
|
+
if (heightOver)
|
|
1793
|
+
dims.push(`height (${Math.round(contentHeight)}px > ${Math.round(parent.height)}px)`);
|
|
1794
|
+
this.errors.addOrReplace({
|
|
1795
|
+
id: errId,
|
|
1796
|
+
type: fixedAttrs.length > 0 ? "error" : "warning",
|
|
1797
|
+
message: `Chart exceeds available ${dims.join(" and ")}. ` +
|
|
1798
|
+
(fixedAttrs.length > 0
|
|
1799
|
+
? `Adjust ${fixedAttrs.join(" / ")} or set to "auto".`
|
|
1800
|
+
: "Content does not fit even at minimum auto scaling; enlarge the container."),
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1539
1803
|
componentDidRender() {
|
|
1540
1804
|
const { mode } = scaling.parseScaling(this.scale);
|
|
1541
1805
|
if (mode !== "auto" && mode !== "empty") {
|
|
1542
1806
|
this._autoScaleGuard = false;
|
|
1543
|
-
|
|
1544
|
-
const errId = "WARN_overflow";
|
|
1545
|
-
if (parent.width > 0 && this.element.scrollWidth > parent.width + 1) {
|
|
1546
|
-
this.errors.addOrReplace({
|
|
1547
|
-
id: errId,
|
|
1548
|
-
type: "warning",
|
|
1549
|
-
message: "Chart exceeds available space and will be cut off. Check unit-scaling value.",
|
|
1550
|
-
});
|
|
1551
|
-
}
|
|
1552
|
-
else {
|
|
1553
|
-
this.errors.remove(errId);
|
|
1554
|
-
}
|
|
1807
|
+
this.checkOverflow();
|
|
1555
1808
|
return;
|
|
1556
1809
|
}
|
|
1557
1810
|
if (this._autoScaleGuard) {
|
|
1558
1811
|
this._autoScaleGuard = false;
|
|
1812
|
+
this.checkOverflow();
|
|
1559
1813
|
return;
|
|
1560
1814
|
}
|
|
1561
1815
|
const host = this.element;
|
|
1562
1816
|
const { width: parentWidth } = scaling.getParentDimensions(host);
|
|
1563
|
-
if (parentWidth <= 0)
|
|
1817
|
+
if (parentWidth <= 0) {
|
|
1818
|
+
this.checkOverflow();
|
|
1564
1819
|
return;
|
|
1820
|
+
}
|
|
1565
1821
|
// Keep observer tracking in sync so the observer callback does not
|
|
1566
1822
|
// trigger spurious forceUpdate calls with stale threshold values.
|
|
1567
1823
|
this._lastObservedWidth = parentWidth;
|
|
@@ -1572,6 +1828,7 @@ const Chart = class {
|
|
|
1572
1828
|
// the content only fits BECAUSE of the current factor.
|
|
1573
1829
|
if (currentWidth <= parentWidth + 1) {
|
|
1574
1830
|
this.errors.remove("AUTO_scale");
|
|
1831
|
+
this.checkOverflow();
|
|
1575
1832
|
return;
|
|
1576
1833
|
}
|
|
1577
1834
|
// Content overflows. Compute a new factor based on the ratio of
|
|
@@ -1579,6 +1836,8 @@ const Chart = class {
|
|
|
1579
1836
|
const computedFactor = Math.max(0.3, (currentFactor * (parentWidth - 1)) / currentWidth);
|
|
1580
1837
|
// Only apply if the change is significant (> 1% of current factor).
|
|
1581
1838
|
if (Math.abs(computedFactor - currentFactor) < 0.01) {
|
|
1839
|
+
// Converged (possibly at the 0.3 floor) but still overflowing — report it.
|
|
1840
|
+
this.checkOverflow();
|
|
1582
1841
|
return;
|
|
1583
1842
|
}
|
|
1584
1843
|
host.style.setProperty("--bn-font-size", `${baseFontSize * computedFactor}px`);
|
|
@@ -1596,10 +1855,14 @@ const Chart = class {
|
|
|
1596
1855
|
index.writeTask(() => {
|
|
1597
1856
|
this.appliedScaleFactor = computedFactor;
|
|
1598
1857
|
});
|
|
1858
|
+
// Check with the current (pre-factor) content so overflow is reported
|
|
1859
|
+
// even if the scheduled re-render stalls; the follow-up render re-checks
|
|
1860
|
+
// in the guard branch and clears any transiently reported overflow.
|
|
1861
|
+
this.checkOverflow();
|
|
1599
1862
|
}
|
|
1600
1863
|
componentDidLoad() {
|
|
1601
1864
|
// Watch for size changes (window resize, card relayout).
|
|
1602
|
-
this.layoutObserver =
|
|
1865
|
+
this.layoutObserver = svgChartElements.observeParentResize(this.element, () => {
|
|
1603
1866
|
if (this._autoScaleGuard)
|
|
1604
1867
|
return;
|
|
1605
1868
|
const { width } = scaling.getParentDimensions(this.element);
|
|
@@ -1669,7 +1932,13 @@ const Chart = class {
|
|
|
1669
1932
|
const variancesList = this.prepareVariances();
|
|
1670
1933
|
this.canvasWidthSegmented = parent.width / (scenariosList.length + variancesList.length || 1);
|
|
1671
1934
|
this._lastAppliedHeight = parent.height;
|
|
1672
|
-
|
|
1935
|
+
// The base chart and each variance render as vertically stacked segments
|
|
1936
|
+
// (see render()), so each one may only claim its share of the height.
|
|
1937
|
+
// The measure-scale footer (first segment only) renders below its SVG:
|
|
1938
|
+
// reserve roughly one em for it so the fitted charts leave it room.
|
|
1939
|
+
const segmentCount = 1 + variancesList.length;
|
|
1940
|
+
const footerAllowance = this.showMeasureScale === "true" ? this.getEffectiveFontPx() : 0;
|
|
1941
|
+
return { width: this.canvasWidthSegmented, height: Math.max(0, parent.height - footerAllowance) / segmentCount };
|
|
1673
1942
|
}
|
|
1674
1943
|
prepareScenarios() {
|
|
1675
1944
|
var _a, _b, _c, _d;
|
|
@@ -1861,6 +2130,7 @@ const Chart = class {
|
|
|
1861
2130
|
},
|
|
1862
2131
|
fontStyles: {
|
|
1863
2132
|
font: `${scaledFontSize}px ${$["global"]["fontFamily"]}`,
|
|
2133
|
+
family: $["global"]["fontFamily"],
|
|
1864
2134
|
size: scaledFontSize,
|
|
1865
2135
|
color: $["global"]["fontColor"],
|
|
1866
2136
|
background: $["global"]["fontBackgroundColor"],
|
|
@@ -2051,6 +2321,88 @@ const Chart = class {
|
|
|
2051
2321
|
const effectiveScenarios = (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === VarianceMeasure.StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
|
|
2052
2322
|
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() }));
|
|
2053
2323
|
}
|
|
2324
|
+
/**
|
|
2325
|
+
* Lazily generates this chart's layout state: host box (context- and
|
|
2326
|
+
* component-relative, CSS px), one `canvas:<segment>` region per rendered
|
|
2327
|
+
* segment (base + variances), metadata (scenarios, bar count), diagnostics
|
|
2328
|
+
* and resolved scaling. With `detail: "full"` every bar, label and axis of
|
|
2329
|
+
* every segment is listed with its geometry.
|
|
2330
|
+
*
|
|
2331
|
+
* @param options - `{ detail: "summary" | "full" }`, default `"summary"`
|
|
2332
|
+
*/
|
|
2333
|
+
async getLayoutState(options) {
|
|
2334
|
+
var _a, _b, _c, _d;
|
|
2335
|
+
const detail = (_a = options === null || options === void 0 ? void 0 : options.detail) !== null && _a !== void 0 ? _a : "summary";
|
|
2336
|
+
const origins = diagnostics.originsFor(this.element);
|
|
2337
|
+
const rawFactor = this.getEffectiveScaleFactor();
|
|
2338
|
+
// Auto-scale can be mid-measurement (or unmeasurable in tests) — report a sane factor.
|
|
2339
|
+
const factor = Number.isFinite(rawFactor) && rawFactor > 0 ? rawFactor : 1;
|
|
2340
|
+
const fontSizePx = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; }) * factor;
|
|
2341
|
+
const variances = this.prepareVariances();
|
|
2342
|
+
const layout = svgChartElements.collectChartFacadeLayout(this.element, "ibcs-chart-time", ["base", ...variances], origins, detail);
|
|
2343
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2344
|
+
const firstInner = (_b = this.element.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector("ibcs-chart-time");
|
|
2345
|
+
const state = {
|
|
2346
|
+
version: index$1.LAYOUT_STATE_VERSION,
|
|
2347
|
+
tag: this.element.localName,
|
|
2348
|
+
id: diagnostics.resolveStandaloneId(this.element),
|
|
2349
|
+
slot: (_c = this.element.getAttribute("slot")) !== null && _c !== void 0 ? _c : undefined,
|
|
2350
|
+
rect: diagnostics.measure(this.element, origins),
|
|
2351
|
+
em: { fontSizePx, appliedScaleFactor: factor },
|
|
2352
|
+
regions: layout.regions,
|
|
2353
|
+
metadata: {
|
|
2354
|
+
title: this.chartTitle || undefined,
|
|
2355
|
+
scenarios: (_d = firstInner === null || firstInner === void 0 ? void 0 : firstInner.scenarios) !== null && _d !== void 0 ? _d : [],
|
|
2356
|
+
variances,
|
|
2357
|
+
barCount: layout.barCount,
|
|
2358
|
+
chartMode: this.chartMode || undefined,
|
|
2359
|
+
hasNoData: layout.barCount === 0,
|
|
2360
|
+
},
|
|
2361
|
+
diagnostics: diagnostics.readDiagnostics(this.element),
|
|
2362
|
+
scaling: this.resolveScalingInfo(fontSizePx),
|
|
2363
|
+
};
|
|
2364
|
+
if (layout.elements)
|
|
2365
|
+
state.elements = layout.elements;
|
|
2366
|
+
return state;
|
|
2367
|
+
}
|
|
2368
|
+
/**
|
|
2369
|
+
* Resolved value scaling without re-triggering validation side effects.
|
|
2370
|
+
* The inner chart's scale unit is px per unit / px per 1.0 fraction;
|
|
2371
|
+
* auto-fitted values come from the last inner report.
|
|
2372
|
+
*/
|
|
2373
|
+
resolveScalingInfo(effFontPx) {
|
|
2374
|
+
var _a, _b;
|
|
2375
|
+
const info = {};
|
|
2376
|
+
const unit = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap);
|
|
2377
|
+
if (unit.kind === "value") {
|
|
2378
|
+
info.unitMode = "fixed";
|
|
2379
|
+
info.unitsPerEm = unit.value;
|
|
2380
|
+
info.unitPxPerUnit = effFontPx / unit.value;
|
|
2381
|
+
}
|
|
2382
|
+
else {
|
|
2383
|
+
info.unitMode = "auto";
|
|
2384
|
+
const pxPerUnit = (_a = this.lastAutoScalingReport) === null || _a === void 0 ? void 0 : _a.unit;
|
|
2385
|
+
if (pxPerUnit !== undefined && pxPerUnit > 0) {
|
|
2386
|
+
info.unitPxPerUnit = pxPerUnit;
|
|
2387
|
+
info.unitsPerEm = effFontPx / pxPerUnit;
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
const pct = scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap);
|
|
2391
|
+
if (pct.kind === "value") {
|
|
2392
|
+
info.percentageMode = "fixed";
|
|
2393
|
+
info.percentagePointsPerEm = pct.value;
|
|
2394
|
+
info.percentagePxPerPoint = effFontPx / pct.value;
|
|
2395
|
+
}
|
|
2396
|
+
else {
|
|
2397
|
+
info.percentageMode = "auto";
|
|
2398
|
+
const pxPerFraction = (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.percentage;
|
|
2399
|
+
if (pxPerFraction !== undefined && pxPerFraction > 0) {
|
|
2400
|
+
info.percentagePxPerPoint = pxPerFraction / 100;
|
|
2401
|
+
info.percentagePointsPerEm = (100 * effFontPx) / pxPerFraction;
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
return info;
|
|
2405
|
+
}
|
|
2054
2406
|
getEffectiveScaleFactor() {
|
|
2055
2407
|
const { mode, factor } = scaling.parseScaling(this.scale);
|
|
2056
2408
|
if (mode === "factor")
|
|
@@ -2084,7 +2436,7 @@ const Chart = class {
|
|
|
2084
2436
|
scenariosArray = [...scenariosArray, ...variancesArray];
|
|
2085
2437
|
}
|
|
2086
2438
|
const fontStyles = this.getFontStyles();
|
|
2087
|
-
return (index.h(index.Host, { key: '
|
|
2439
|
+
return (index.h(index.Host, { key: '93a5778cad09ee33f54df92f3b3e32d030a734d6', style: fontStyles }, index.h("div", { key: 'b431ad76c90bc3c6e5f6820ba03df574155b0038', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
2088
2440
|
}
|
|
2089
2441
|
get element() { return index.getElement(this); }
|
|
2090
2442
|
static get watchers() { return {
|
|
@@ -2191,6 +2543,11 @@ ComponentStyle.style = bnComponentStyleCss();
|
|
|
2191
2543
|
|
|
2192
2544
|
const bnContextCss = () => `:host{display:block}`;
|
|
2193
2545
|
|
|
2546
|
+
/** Every visual bn-* component; non-visual producers (bn-dataset, ...) are excluded. */
|
|
2547
|
+
const VISUAL_SELECTOR = "bn-body, bn-card, bn-chart-bubble, bn-chart-bullet, bn-chart-scatter, " +
|
|
2548
|
+
"bn-chart-structure, bn-chart-time, bn-footer, bn-grid, bn-image, " +
|
|
2549
|
+
"bn-layout-card, bn-layout-page, bn-message, bn-page, bn-table, " +
|
|
2550
|
+
"bn-template, bn-text, bn-title, bn-tree";
|
|
2194
2551
|
const Context = class {
|
|
2195
2552
|
constructor(hostRef) {
|
|
2196
2553
|
index.registerInstance(this, hostRef);
|
|
@@ -2229,6 +2586,72 @@ const Context = class {
|
|
|
2229
2586
|
clearTimeout(this.currentPageUpdate);
|
|
2230
2587
|
}
|
|
2231
2588
|
}
|
|
2589
|
+
/**
|
|
2590
|
+
* Lazily generates a JSON-serializable snapshot of the rendered report:
|
|
2591
|
+
* every visual descendant with its position and size (context- and
|
|
2592
|
+
* component-relative, CSS px), render metadata, diagnostics and — with
|
|
2593
|
+
* `detail: "full"` — per-element geometry (bars, labels, axes, cells).
|
|
2594
|
+
*
|
|
2595
|
+
* Nothing is tracked during rendering; each call measures the DOM at that
|
|
2596
|
+
* moment. Call it after the report has settled (e.g. when
|
|
2597
|
+
* `window.componentRegisterIsRenderedResult` is true) for final geometry.
|
|
2598
|
+
*
|
|
2599
|
+
* @param options - `{ detail: "summary" | "full" }`, default `"summary"`
|
|
2600
|
+
*/
|
|
2601
|
+
async getLayoutState(options) {
|
|
2602
|
+
var _a, _b;
|
|
2603
|
+
const detail = (_a = options === null || options === void 0 ? void 0 : options.detail) !== null && _a !== void 0 ? _a : "summary";
|
|
2604
|
+
const hosts = Array.from(this.element.querySelectorAll(VISUAL_SELECTOR));
|
|
2605
|
+
await Promise.all(hosts.map((el) => { var _a, _b, _c; return (_c = (_b = (_a = el).componentOnReady) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : Promise.resolve(); }));
|
|
2606
|
+
const contextRect = this.element.getBoundingClientRect();
|
|
2607
|
+
const contextOrigin = { x: contextRect.left, y: contextRect.top };
|
|
2608
|
+
const components = await Promise.all(hosts.map(async (el) => {
|
|
2609
|
+
const hostRect = el.getBoundingClientRect();
|
|
2610
|
+
const origins = { context: contextOrigin, component: { x: hostRect.left, y: hostRect.top } };
|
|
2611
|
+
try {
|
|
2612
|
+
const rich = el;
|
|
2613
|
+
if (typeof rich.getLayoutState === "function") {
|
|
2614
|
+
return await rich.getLayoutState({ detail });
|
|
2615
|
+
}
|
|
2616
|
+
return buildGenericState(el, origins);
|
|
2617
|
+
}
|
|
2618
|
+
catch (e) {
|
|
2619
|
+
let fallback;
|
|
2620
|
+
try {
|
|
2621
|
+
fallback = buildGenericState(el, origins);
|
|
2622
|
+
}
|
|
2623
|
+
catch (_a) {
|
|
2624
|
+
const zero = { x: 0, y: 0, width: 0, height: 0 };
|
|
2625
|
+
fallback = {
|
|
2626
|
+
version: index$1.LAYOUT_STATE_VERSION,
|
|
2627
|
+
tag: el.localName,
|
|
2628
|
+
id: el.localName,
|
|
2629
|
+
rect: { context: Object.assign({}, zero), component: Object.assign({}, zero) },
|
|
2630
|
+
em: { fontSizePx: 0, appliedScaleFactor: 1 },
|
|
2631
|
+
regions: [],
|
|
2632
|
+
metadata: {},
|
|
2633
|
+
diagnostics: [],
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
fallback.error = String(e instanceof Error ? e.message : e);
|
|
2637
|
+
return fallback;
|
|
2638
|
+
}
|
|
2639
|
+
}));
|
|
2640
|
+
const ids = diagnostics.assignIds(hosts.map((el) => ({ tag: el.localName, explicitId: diagnostics.resolveOwnIdentity(el) })));
|
|
2641
|
+
components.forEach((state, index) => {
|
|
2642
|
+
state.id = ids[index];
|
|
2643
|
+
});
|
|
2644
|
+
return {
|
|
2645
|
+
version: index$1.LAYOUT_STATE_VERSION,
|
|
2646
|
+
generatedAt: new Date().toISOString(),
|
|
2647
|
+
detail,
|
|
2648
|
+
context: {
|
|
2649
|
+
viewport: diagnostics.toLayoutRect(contextRect),
|
|
2650
|
+
locale: (_b = this.stores) === null || _b === void 0 ? void 0 : _b.context.state.locale,
|
|
2651
|
+
},
|
|
2652
|
+
components,
|
|
2653
|
+
};
|
|
2654
|
+
}
|
|
2232
2655
|
componentWillLoad() {
|
|
2233
2656
|
// stencil needs one componenet implementing all lifecycle steps to get mixing working
|
|
2234
2657
|
}
|
|
@@ -2239,7 +2662,7 @@ const Context = class {
|
|
|
2239
2662
|
componentWillUpdate() { }
|
|
2240
2663
|
componentDidUpdate() { }
|
|
2241
2664
|
render() {
|
|
2242
|
-
return (index.h(index.Host, { key: '
|
|
2665
|
+
return (index.h(index.Host, { key: '005c68f320adbbd5d5269d3fe6f2da6a8096ed98' }, index.h("slot", { key: '7d9fbf3e7a253fe24414cd26274fdffb03b2d5f6' })));
|
|
2243
2666
|
}
|
|
2244
2667
|
get element() { return index.getElement(this); }
|
|
2245
2668
|
static get watchers() { return {
|
|
@@ -4383,7 +4806,10 @@ const Table$1 = class Table {
|
|
|
4383
4806
|
*/
|
|
4384
4807
|
this.measureUnit = "";
|
|
4385
4808
|
/**
|
|
4386
|
-
* Set width of bar chart columns
|
|
4809
|
+
* Set the total width of bar chart columns, in em of the table font — the same
|
|
4810
|
+
* unit and vocabulary as ```categoryWidth```, so ```bar-column-width="w15"```
|
|
4811
|
+
* renders exactly as wide as ```category-width="w15"```. The bar/pin drawing
|
|
4812
|
+
* area is that width minus the value-label gutters.
|
|
4387
4813
|
* <br /><br />
|
|
4388
4814
|
* values:<br />
|
|
4389
4815
|
* ``` w5 // w10 // w15 // w20 // w25 // w30 // w40 // w60 // w80 // w100 ```
|
|
@@ -4576,10 +5002,13 @@ const Table$1 = class Table {
|
|
|
4576
5002
|
*/
|
|
4577
5003
|
this.dataFormatDigitsPercent = 2;
|
|
4578
5004
|
/**
|
|
4579
|
-
* Set width of category column. <br />
|
|
5005
|
+
* Set width of category column, in em of the table font. <br />
|
|
4580
5006
|
* If INF is selected the columns scaling to the min space they need
|
|
4581
5007
|
* seperatly.
|
|
4582
5008
|
* <br /><br />
|
|
5009
|
+
* The column is fixed at this width; a category label too long to fit is
|
|
5010
|
+
* truncated with an ellipsis.
|
|
5011
|
+
* <br /><br />
|
|
4583
5012
|
* values:<br />
|
|
4584
5013
|
* ``` w5 // w10 // w15 // w20 // w25 // w50 // inf ```
|
|
4585
5014
|
*/
|
|
@@ -4631,6 +5060,12 @@ const Table$1 = class Table {
|
|
|
4631
5060
|
* can copy them into a bn-scaling-group.
|
|
4632
5061
|
*/
|
|
4633
5062
|
this.handleAutoScalingReport = (report) => {
|
|
5063
|
+
var _a, _b, _c, _d;
|
|
5064
|
+
// A report only carries the auto-resolved quantities — keep the other one.
|
|
5065
|
+
this.lastAutoScalingReport = {
|
|
5066
|
+
unit: (_a = report.unit) !== null && _a !== void 0 ? _a : (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.unit,
|
|
5067
|
+
percentage: (_c = report.percentage) !== null && _c !== void 0 ? _c : (_d = this.lastAutoScalingReport) === null || _d === void 0 ? void 0 : _d.percentage,
|
|
5068
|
+
};
|
|
4634
5069
|
const changed = (next, last) => last === undefined || Math.abs(next - last) > Math.abs(next) * 1e-3;
|
|
4635
5070
|
if (report.unit !== undefined && report.unit > 0 && this.autoUnitWarningActive) {
|
|
4636
5071
|
const unitsPerEm = 1 / report.unit;
|
|
@@ -4660,7 +5095,7 @@ const Table$1 = class Table {
|
|
|
4660
5095
|
this.errors = withHasError.withHasError(this);
|
|
4661
5096
|
withScalingGroup.withScalingGroup(this);
|
|
4662
5097
|
this.componentStyle = withStyled.withComponentStyle(this);
|
|
4663
|
-
this.ruleSetConfig =
|
|
5098
|
+
this.ruleSetConfig = svgChartElements.withRuleSet(this);
|
|
4664
5099
|
scaling.withDataset(this, (name, data) => {
|
|
4665
5100
|
// Helpers query the shared alasql database directly by name; we just
|
|
4666
5101
|
// record the active dataset and bump a version counter so Stencil
|
|
@@ -5051,7 +5486,7 @@ const Table$1 = class Table {
|
|
|
5051
5486
|
componentDidLoad() {
|
|
5052
5487
|
// Observe the parent container for size changes so auto-scaling
|
|
5053
5488
|
// reacts to genuine container resizes (window resize, card relayout).
|
|
5054
|
-
this.layoutObserver =
|
|
5489
|
+
this.layoutObserver = svgChartElements.observeParentResize(this.element, () => {
|
|
5055
5490
|
if (this._autoScaleGuard)
|
|
5056
5491
|
return;
|
|
5057
5492
|
const { width } = scaling.getParentDimensions(this.element);
|
|
@@ -5479,6 +5914,91 @@ const Table$1 = class Table {
|
|
|
5479
5914
|
};
|
|
5480
5915
|
return dataSetStructure;
|
|
5481
5916
|
}
|
|
5917
|
+
/**
|
|
5918
|
+
* Lazily generates this table's layout state: host box (context- and
|
|
5919
|
+
* component-relative, CSS px), header/body regions, row/column/cell counts,
|
|
5920
|
+
* diagnostics and resolved scaling. With `detail: "full"` every cell is
|
|
5921
|
+
* listed with its geometry, model value, column key and in-cell bar chart.
|
|
5922
|
+
*
|
|
5923
|
+
* @param options - `{ detail: "summary" | "full" }`, default `"summary"`
|
|
5924
|
+
*/
|
|
5925
|
+
async getLayoutState(options) {
|
|
5926
|
+
var _a, _b, _c, _d;
|
|
5927
|
+
const detail = (_a = options === null || options === void 0 ? void 0 : options.detail) !== null && _a !== void 0 ? _a : "summary";
|
|
5928
|
+
const origins = diagnostics.originsFor(this.element);
|
|
5929
|
+
const rawFactor = this.getEffectiveScaleFactor();
|
|
5930
|
+
// Auto-scale can be mid-measurement (or unmeasurable in tests) — report a sane factor.
|
|
5931
|
+
const effectiveFactor = Number.isFinite(rawFactor) && rawFactor > 0 ? rawFactor : 1;
|
|
5932
|
+
const fontSizePx = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; }) * effectiveFactor;
|
|
5933
|
+
const state = {
|
|
5934
|
+
version: index$1.LAYOUT_STATE_VERSION,
|
|
5935
|
+
tag: this.element.localName,
|
|
5936
|
+
id: diagnostics.resolveStandaloneId(this.element),
|
|
5937
|
+
slot: (_b = this.element.getAttribute("slot")) !== null && _b !== void 0 ? _b : undefined,
|
|
5938
|
+
rect: diagnostics.measure(this.element, origins),
|
|
5939
|
+
em: { fontSizePx, appliedScaleFactor: effectiveFactor },
|
|
5940
|
+
regions: [],
|
|
5941
|
+
metadata: {},
|
|
5942
|
+
diagnostics: diagnostics.readDiagnostics(this.element),
|
|
5943
|
+
scaling: this.resolveScalingInfo(fontSizePx),
|
|
5944
|
+
};
|
|
5945
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5946
|
+
const inner = (_c = this.element.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector("ibcs-table");
|
|
5947
|
+
if (inner) {
|
|
5948
|
+
const scenarios = (_d = inner.scenarios) !== null && _d !== void 0 ? _d : [];
|
|
5949
|
+
state.metadata.scenarios = scenarios.filter((name) => !name.startsWith("d"));
|
|
5950
|
+
state.metadata.variances = scenarios.filter((name) => name.startsWith("d"));
|
|
5951
|
+
if (typeof inner.getLayoutDetail === "function") {
|
|
5952
|
+
const layoutDetail = await inner.getLayoutDetail(origins, detail);
|
|
5953
|
+
state.regions = layoutDetail.regions;
|
|
5954
|
+
state.metadata = Object.assign(Object.assign({}, state.metadata), layoutDetail.metadata);
|
|
5955
|
+
state.diagnostics = [...state.diagnostics, ...layoutDetail.diagnostics];
|
|
5956
|
+
if (layoutDetail.elements)
|
|
5957
|
+
state.elements = layoutDetail.elements;
|
|
5958
|
+
if (layoutDetail.table)
|
|
5959
|
+
state.table = layoutDetail.table;
|
|
5960
|
+
}
|
|
5961
|
+
}
|
|
5962
|
+
return state;
|
|
5963
|
+
}
|
|
5964
|
+
/**
|
|
5965
|
+
* Resolved value scaling without re-triggering validation side effects.
|
|
5966
|
+
* The table's internal scale unit is em per unit / em per percentage point;
|
|
5967
|
+
* auto-fitted values come from the last inner report.
|
|
5968
|
+
*/
|
|
5969
|
+
resolveScalingInfo(emPx) {
|
|
5970
|
+
var _a, _b;
|
|
5971
|
+
const info = {};
|
|
5972
|
+
const unit = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap);
|
|
5973
|
+
if (unit.kind === "value") {
|
|
5974
|
+
info.unitMode = "fixed";
|
|
5975
|
+
info.unitsPerEm = unit.value;
|
|
5976
|
+
info.unitPxPerUnit = emPx / unit.value;
|
|
5977
|
+
}
|
|
5978
|
+
else {
|
|
5979
|
+
info.unitMode = "auto";
|
|
5980
|
+
const emPerUnit = (_a = this.lastAutoScalingReport) === null || _a === void 0 ? void 0 : _a.unit;
|
|
5981
|
+
if (emPerUnit !== undefined && emPerUnit > 0) {
|
|
5982
|
+
info.unitsPerEm = 1 / emPerUnit;
|
|
5983
|
+
info.unitPxPerUnit = emPerUnit * emPx;
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5986
|
+
const pct = scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap);
|
|
5987
|
+
if (pct.kind === "value") {
|
|
5988
|
+
info.percentageMode = "fixed";
|
|
5989
|
+
info.percentagePointsPerEm = pct.value;
|
|
5990
|
+
info.percentagePxPerPoint = emPx / pct.value;
|
|
5991
|
+
}
|
|
5992
|
+
else {
|
|
5993
|
+
info.percentageMode = "auto";
|
|
5994
|
+
const emPerPoint = (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.percentage;
|
|
5995
|
+
if (emPerPoint !== undefined && emPerPoint > 0) {
|
|
5996
|
+
info.percentagePointsPerEm = 1 / emPerPoint;
|
|
5997
|
+
info.percentagePxPerPoint = emPerPoint * emPx;
|
|
5998
|
+
}
|
|
5999
|
+
}
|
|
6000
|
+
return info;
|
|
6001
|
+
}
|
|
5482
6002
|
getEffectiveScaleFactor() {
|
|
5483
6003
|
const { mode, factor } = scaling.parseScaling(this.scale);
|
|
5484
6004
|
if (mode === "factor")
|
|
@@ -5503,7 +6023,7 @@ const Table$1 = class Table {
|
|
|
5503
6023
|
render() {
|
|
5504
6024
|
const fontStyles = this.getFontStyles();
|
|
5505
6025
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
5506
|
-
return (index.h(index.Host, { key: '
|
|
6026
|
+
return (index.h(index.Host, { key: '0581f45b1d4af5a611e295afa924b3564ad4e916', style: fontStyles }, index.h("div", { key: '461dfbb4bbaf75c3aa5df8aad21056dfb01be26c' }, index.h("ibcs-table", { key: 'c17a4104687aee9002144e2800b23b8c99c811a7', 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 }))));
|
|
5507
6027
|
}
|
|
5508
6028
|
get element() { return index.getElement(this); }
|
|
5509
6029
|
static get watchers() { return {
|
|
@@ -5650,7 +6170,7 @@ const Title$1 = class Title {
|
|
|
5650
6170
|
this.t = scaling.withTranslation(this).t;
|
|
5651
6171
|
this.errors = withHasError.withHasError(this);
|
|
5652
6172
|
this.componentStyle = withStyled.withComponentStyle(this);
|
|
5653
|
-
this.ruleSetConfig =
|
|
6173
|
+
this.ruleSetConfig = svgChartElements.withRuleSet(this);
|
|
5654
6174
|
}
|
|
5655
6175
|
validateScenario(newValue) {
|
|
5656
6176
|
const errId = "ERR_scenarios";
|
|
@@ -7031,8 +7551,11 @@ class Label {
|
|
|
7031
7551
|
// @ts-ignore
|
|
7032
7552
|
const text = label.text(prefix + valueStr);
|
|
7033
7553
|
text.move(this.x, this.y);
|
|
7034
|
-
|
|
7035
|
-
|
|
7554
|
+
// One bbox() per label, not two: svg.js caches nothing, and on a detached
|
|
7555
|
+
// tree each call clones the subtree into the document to measure it.
|
|
7556
|
+
const box = text.bbox();
|
|
7557
|
+
const boxWidth = box.w;
|
|
7558
|
+
const boxHeight = box.h;
|
|
7036
7559
|
if (this.maxWidth != null && boxWidth > this.maxWidth) {
|
|
7037
7560
|
(_a = this.group) === null || _a === void 0 ? void 0 : _a.remove();
|
|
7038
7561
|
this.group = null;
|
|
@@ -7871,6 +8394,70 @@ let ScenarioFactory$1 = class ScenarioFactory {
|
|
|
7871
8394
|
}
|
|
7872
8395
|
};
|
|
7873
8396
|
|
|
8397
|
+
/**
|
|
8398
|
+
* Pure math for the chart auto-fit loops (ibcs-chart-structure fits width,
|
|
8399
|
+
* ibcs-chart-time fits height). Kept free of chart/svg.js imports so it can
|
|
8400
|
+
* be unit-tested under mock-doc (which lacks getBBox).
|
|
8401
|
+
*
|
|
8402
|
+
* Model: a chart's size along its fit axis is affine in the pixel scales,
|
|
8403
|
+
* measured = fixed + unitExtent * pixelPerUnit + pctExtent * pixelPerPercentage
|
|
8404
|
+
* where the extents are the total bar lengths in data units (positive plus
|
|
8405
|
+
* negative side of the axis). The chart classes report their extents via
|
|
8406
|
+
* getUnitBarExtent()/getPercentBarExtent(); {@link solveAutoFitStep} solves
|
|
8407
|
+
* the model for the target size against a fresh measurement, so repeated
|
|
8408
|
+
* steps converge even when clamped label widths flip between passes.
|
|
8409
|
+
*/
|
|
8410
|
+
/** Lower bound for auto-fitted pixelPerUnit / pixelPerPercentage values. */
|
|
8411
|
+
const MIN_PIXEL_SCALE = 0.001;
|
|
8412
|
+
/**
|
|
8413
|
+
* Total bar extent (in data units) that scales linearly with pixelPerUnit.
|
|
8414
|
+
* Counts BOTH sides of the axis — a chart with values -13..+12 spans 25
|
|
8415
|
+
* units, not 12 (fitting only the positive side is how charts used to
|
|
8416
|
+
* overshoot their container).
|
|
8417
|
+
*/
|
|
8418
|
+
function computeUnitBarExtent(inputs) {
|
|
8419
|
+
if (inputs.fixedDomain != null) {
|
|
8420
|
+
return Math.max(0, inputs.fixedDomain);
|
|
8421
|
+
}
|
|
8422
|
+
if (inputs.relativeVariance) {
|
|
8423
|
+
return 0; // relative variance bars scale with pixelPerPercentage instead
|
|
8424
|
+
}
|
|
8425
|
+
return Math.max(0, inputs.maxPositive) + Math.abs(Math.min(0, inputs.minNegative));
|
|
8426
|
+
}
|
|
8427
|
+
/**
|
|
8428
|
+
* Total bar extent (in fraction units) that scales linearly with
|
|
8429
|
+
* pixelPerPercentage. Only relative variances use it; each side is clamped
|
|
8430
|
+
* because extreme pins render as fixed-size arrows instead of longer bars.
|
|
8431
|
+
*/
|
|
8432
|
+
function computePercentBarExtent(inputs) {
|
|
8433
|
+
var _a;
|
|
8434
|
+
if (!inputs.relativeVariance) {
|
|
8435
|
+
return 0;
|
|
8436
|
+
}
|
|
8437
|
+
const clamp = (_a = inputs.sideClamp) !== null && _a !== void 0 ? _a : 1.45;
|
|
8438
|
+
const positive = Math.min(clamp, Math.max(0, inputs.maxPositive));
|
|
8439
|
+
const negative = Math.min(clamp, Math.abs(Math.min(0, inputs.minNegative)));
|
|
8440
|
+
return positive + negative;
|
|
8441
|
+
}
|
|
8442
|
+
/**
|
|
8443
|
+
* Solves the affine size model for the target and returns corrected scale
|
|
8444
|
+
* values (floored at {@link MIN_PIXEL_SCALE}). Returns an empty object when
|
|
8445
|
+
* nothing scales with the solved values (both extents 0) — callers fall back
|
|
8446
|
+
* to a ratio heuristic. Only the quantities whose extent is > 0 are returned.
|
|
8447
|
+
*/
|
|
8448
|
+
function solveAutoFitStep(inputs) {
|
|
8449
|
+
const divisor = inputs.unitExtent + inputs.pctExtent;
|
|
8450
|
+
if (divisor <= 0) {
|
|
8451
|
+
return {};
|
|
8452
|
+
}
|
|
8453
|
+
const fixed = inputs.measured - inputs.unitExtent * inputs.currentPpu - inputs.pctExtent * inputs.currentPpp;
|
|
8454
|
+
const solved = Math.max(MIN_PIXEL_SCALE, (inputs.target - fixed) / divisor);
|
|
8455
|
+
return {
|
|
8456
|
+
ppu: inputs.unitExtent > 0 ? solved : undefined,
|
|
8457
|
+
ppp: inputs.pctExtent > 0 ? solved : undefined,
|
|
8458
|
+
};
|
|
8459
|
+
}
|
|
8460
|
+
|
|
7874
8461
|
/**
|
|
7875
8462
|
* Orchestrates the full rendering pipeline for an IBCS structure (categorical) chart.
|
|
7876
8463
|
*
|
|
@@ -8071,28 +8658,38 @@ class StructureChart {
|
|
|
8071
8658
|
}
|
|
8072
8659
|
}
|
|
8073
8660
|
/**
|
|
8074
|
-
*
|
|
8075
|
-
*
|
|
8661
|
+
* Total bar extent (data units) proportional to pixelPerUnit, covering
|
|
8662
|
+
* BOTH sides of the axis (left side scales with negative values, right
|
|
8663
|
+
* side with positive ones). Used by autoFitScaling to separate fixed
|
|
8664
|
+
* from variable width components.
|
|
8076
8665
|
*/
|
|
8077
|
-
|
|
8666
|
+
getUnitBarExtent() {
|
|
8078
8667
|
var _a, _b;
|
|
8079
|
-
|
|
8080
|
-
if (this.stackConfig != null && this.highestStackedTotal > 0) {
|
|
8081
|
-
if (this.stackConfig.mode === VarianceMeasure.StackMode.RELATIVE) {
|
|
8082
|
-
return 1;
|
|
8083
|
-
}
|
|
8084
|
-
return this.highestStackedTotal;
|
|
8085
|
-
}
|
|
8086
|
-
// Non-stacked: bar extent = highestDataPointValue * ppu
|
|
8668
|
+
const stacked = this.stackConfig != null && this.highestStackedTotal > 0;
|
|
8087
8669
|
const vt = this.getVarianceType();
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8670
|
+
const isVariance = vt !== VarianceType$1.NONE;
|
|
8671
|
+
const highest = isVariance ? this.highestVarianceDataPointValue : this.highestDataPointValue;
|
|
8672
|
+
const smallest = isVariance ? this.smallestVarianceDataPointValue : this.smallestDataPointValue;
|
|
8673
|
+
return computeUnitBarExtent({
|
|
8674
|
+
// Relative stacks span exactly 1 * ppu; absolute stacks the max row total
|
|
8675
|
+
fixedDomain: stacked ? (this.stackConfig.mode === VarianceMeasure.StackMode.RELATIVE ? 1 : this.highestStackedTotal) : undefined,
|
|
8676
|
+
relativeVariance: vt === VarianceType$1.RELATIVE,
|
|
8677
|
+
maxPositive: (_a = highest === null || highest === void 0 ? void 0 : highest.value) !== null && _a !== void 0 ? _a : 0,
|
|
8678
|
+
minNegative: (_b = smallest === null || smallest === void 0 ? void 0 : smallest.value) !== null && _b !== void 0 ? _b : 0,
|
|
8679
|
+
});
|
|
8680
|
+
}
|
|
8681
|
+
/**
|
|
8682
|
+
* Total bar extent (fraction units) proportional to pixelPerPercentage.
|
|
8683
|
+
* Only relative variances scale with it; each side clamps at +/-145%
|
|
8684
|
+
* because clipped needles render as fixed-size arrows.
|
|
8685
|
+
*/
|
|
8686
|
+
getPercentBarExtent() {
|
|
8687
|
+
var _a, _b, _c, _d;
|
|
8688
|
+
return computePercentBarExtent({
|
|
8689
|
+
relativeVariance: this.getVarianceType() === VarianceType$1.RELATIVE,
|
|
8690
|
+
maxPositive: (_b = (_a = this.highestVarianceDataPointValue) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0,
|
|
8691
|
+
minNegative: (_d = (_c = this.smallestVarianceDataPointValue) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 0,
|
|
8692
|
+
});
|
|
8096
8693
|
}
|
|
8097
8694
|
getAllocatedCanvasWidth() {
|
|
8098
8695
|
//let columnLabelWidth = this.calculateCategoryWidth();
|
|
@@ -8117,6 +8714,17 @@ class StructureChart {
|
|
|
8117
8714
|
patternToString() {
|
|
8118
8715
|
return "<svg></svg>";
|
|
8119
8716
|
}
|
|
8717
|
+
/**
|
|
8718
|
+
* Runs `draw()` purely for its side effects — it is what finalizes the
|
|
8719
|
+
* positions that `getAllocatedCanvas*()` read.
|
|
8720
|
+
*
|
|
8721
|
+
* The auto-fit solver measures the chart once per iteration and only needs
|
|
8722
|
+
* those numbers, so it calls this instead of {@link toString}: the XML
|
|
8723
|
+
* serialization of a tree that is immediately discarded is pure overhead.
|
|
8724
|
+
*/
|
|
8725
|
+
layout() {
|
|
8726
|
+
this.draw(new SVGStyle.Svg());
|
|
8727
|
+
}
|
|
8120
8728
|
toString() {
|
|
8121
8729
|
const container = new SVGStyle.Svg();
|
|
8122
8730
|
this.draw(container);
|
|
@@ -8125,8 +8733,32 @@ class StructureChart {
|
|
|
8125
8733
|
container.height(this.getAllocatedCanvasHeight());
|
|
8126
8734
|
return container.svg();
|
|
8127
8735
|
}
|
|
8736
|
+
/**
|
|
8737
|
+
* Writes the chart's font onto the SVG root as presentation attributes.
|
|
8738
|
+
*
|
|
8739
|
+
* `font-size` and `font-family` are inherited, so a `<text>` with neither of
|
|
8740
|
+
* its own takes whatever its ancestor chain supplies. That chain is not stable
|
|
8741
|
+
* across the places this SVG gets measured: drawn detached, svg.js's `bbox()`
|
|
8742
|
+
* clones the element into a sandbox under `document.body`, where it inherits
|
|
8743
|
+
* the document default — 16px Times — instead of the chart's real font. Every
|
|
8744
|
+
* label was measured ~9% too wide as a result, which over-allocated label
|
|
8745
|
+
* space and pushed labels past the `maxWidth` threshold in {@link Label} that
|
|
8746
|
+
* drops them entirely.
|
|
8747
|
+
*
|
|
8748
|
+
* Setting the font here makes a measurement independent of where it happens.
|
|
8749
|
+
* Stylesheet rules still win over presentation attributes, so this changes
|
|
8750
|
+
* nothing about how the chart renders in place — the CSS and this attribute
|
|
8751
|
+
* resolve to the same value, both being `fontSizePx * effectiveScaleFactor`.
|
|
8752
|
+
*/
|
|
8753
|
+
applyFontToContainer(svgContainer) {
|
|
8754
|
+
svgContainer.attr({
|
|
8755
|
+
"font-size": this.styles.fontStyles.size,
|
|
8756
|
+
"font-family": this.styles.fontStyles.family,
|
|
8757
|
+
});
|
|
8758
|
+
}
|
|
8128
8759
|
draw(svgContainer) {
|
|
8129
8760
|
this.cleanSVGforRedraw(svgContainer);
|
|
8761
|
+
this.applyFontToContainer(svgContainer);
|
|
8130
8762
|
if (this.state === FactoryState$2.DIRTY) {
|
|
8131
8763
|
this.state = FactoryState$2.UP_TO_DATE;
|
|
8132
8764
|
}
|
|
@@ -8983,7 +9615,7 @@ class DataFormatDigitsAdapter {
|
|
|
8983
9615
|
}
|
|
8984
9616
|
}
|
|
8985
9617
|
|
|
8986
|
-
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}`;
|
|
9618
|
+
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}`;
|
|
8987
9619
|
|
|
8988
9620
|
const IbcsChartStructure = class {
|
|
8989
9621
|
constructor(hostRef) {
|
|
@@ -9036,8 +9668,14 @@ const IbcsChartStructure = class {
|
|
|
9036
9668
|
const styles = this.prepareStyle();
|
|
9037
9669
|
this.chart = new StructureChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), db, this.tableName, config, styles);
|
|
9038
9670
|
this.chart.setI18n(this.i18n);
|
|
9671
|
+
// The broken-bar overdrive exists to absorb MANUAL scaling overflow.
|
|
9672
|
+
// autoFitScaling mutates config.pixelPerUnit to the solved value, so
|
|
9673
|
+
// remember auto mode beforehand and skip the overdrive for it — the
|
|
9674
|
+
// fitted chart fits by construction, and the overdrive's rough overhead
|
|
9675
|
+
// estimate would falsely re-engage on it.
|
|
9676
|
+
const unitWasAuto = config.pixelPerUnit <= 0;
|
|
9039
9677
|
this.autoFitScaling(config, styles);
|
|
9040
|
-
this.chart.setAvailableWidth(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width) || 0);
|
|
9678
|
+
this.chart.setAvailableWidth(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width) || 0);
|
|
9041
9679
|
this.pattern = new CustomPattern$1(this.chart.styles);
|
|
9042
9680
|
this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
|
|
9043
9681
|
}
|
|
@@ -9052,16 +9690,24 @@ const IbcsChartStructure = class {
|
|
|
9052
9690
|
this.chart.setStyles(styles);
|
|
9053
9691
|
this.chart.setRuleSet(new SVGStyle.IBCSRuleSet(this.ruleSetConfig));
|
|
9054
9692
|
this.chart.setConfig(config);
|
|
9693
|
+
// See componentWillLoad: no broken-bar overdrive for auto-fitted scaling
|
|
9694
|
+
const unitWasAuto = config.pixelPerUnit <= 0;
|
|
9055
9695
|
this.autoFitScaling(config, styles);
|
|
9056
|
-
this.chart.setAvailableWidth(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width) || 0);
|
|
9696
|
+
this.chart.setAvailableWidth(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width) || 0);
|
|
9057
9697
|
this.pattern = new CustomPattern$1(this.chart.styles);
|
|
9058
9698
|
this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
|
|
9059
9699
|
}
|
|
9060
9700
|
/**
|
|
9061
|
-
*
|
|
9062
|
-
* When either is 0 (auto mode), renders a measurement pass at 1,
|
|
9063
|
-
* computes the ratio to fit the available width, and rebuilds.
|
|
9701
|
+
* Auto-fit for pixelPerUnit and/or pixelPerPercentage (0 = auto mode).
|
|
9064
9702
|
* Structure charts grow horizontally, so we fit to width.
|
|
9703
|
+
*
|
|
9704
|
+
* The chart width is affine in the pixel scales (width = fixed labels +
|
|
9705
|
+
* bar extent × scale), but label clamps flip between passes, so a single
|
|
9706
|
+
* analytic solve is not enough: measure at 1, solve, then verify against
|
|
9707
|
+
* fresh measurements and re-solve until the chart fits. The loop never
|
|
9708
|
+
* ends on an overshoot — the last fitting values are restored, or when
|
|
9709
|
+
* even the minimum scale cannot fit (labels alone exceed the container)
|
|
9710
|
+
* the values are floored and the wrapper reports the overflow.
|
|
9065
9711
|
* Explicit (> 0) values are never overridden.
|
|
9066
9712
|
*/
|
|
9067
9713
|
autoFitScaling(config, styles) {
|
|
@@ -9080,49 +9726,107 @@ const IbcsChartStructure = class {
|
|
|
9080
9726
|
};
|
|
9081
9727
|
const targetWidth = (_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width;
|
|
9082
9728
|
const db = this.getDb();
|
|
9729
|
+
const rebuild = () => {
|
|
9730
|
+
this.chart = new StructureChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), db, this.tableName, config, styles);
|
|
9731
|
+
this.chart.setI18n(this.i18n);
|
|
9732
|
+
};
|
|
9733
|
+
// layout() runs draw(), which finalizes positions — an undrawn chart
|
|
9734
|
+
// reports a stale allocated width.
|
|
9735
|
+
const measure = () => {
|
|
9736
|
+
this.chart.layout();
|
|
9737
|
+
return this.chart.getAllocatedCanvasWidth();
|
|
9738
|
+
};
|
|
9083
9739
|
if (!targetWidth || targetWidth <= 0) {
|
|
9084
9740
|
if (autoUnit)
|
|
9085
9741
|
config.pixelPerUnit = 1;
|
|
9086
9742
|
if (autoPercent)
|
|
9087
9743
|
config.pixelPerPercentage = 50;
|
|
9088
|
-
|
|
9089
|
-
this.chart.setI18n(this.i18n);
|
|
9744
|
+
rebuild();
|
|
9090
9745
|
reportResolved();
|
|
9091
9746
|
return;
|
|
9092
9747
|
}
|
|
9093
|
-
//
|
|
9748
|
+
// Measurement pass: render the auto quantities at 1
|
|
9094
9749
|
if (autoUnit)
|
|
9095
9750
|
config.pixelPerUnit = 1;
|
|
9096
9751
|
if (autoPercent)
|
|
9097
9752
|
config.pixelPerPercentage = 1;
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
const svgWidth = this.chart.getAllocatedCanvasWidth();
|
|
9102
|
-
if (svgWidth <= 0) {
|
|
9753
|
+
rebuild();
|
|
9754
|
+
let width = measure();
|
|
9755
|
+
if (width <= 0) {
|
|
9103
9756
|
reportResolved();
|
|
9104
9757
|
return;
|
|
9105
9758
|
}
|
|
9106
|
-
//
|
|
9107
|
-
//
|
|
9108
|
-
|
|
9109
|
-
const
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9759
|
+
// Fallback for auto quantities nothing scales with (no bar extent):
|
|
9760
|
+
// plain ratio against the measurement pass, as before.
|
|
9761
|
+
const ratioFallback = Math.max(MIN_PIXEL_SCALE, (targetWidth * 0.9) / width);
|
|
9762
|
+
const EPS = 0.5;
|
|
9763
|
+
const MAX_CORRECTIONS = 3;
|
|
9764
|
+
let solvedUnit = false;
|
|
9765
|
+
let solvedPercent = false;
|
|
9766
|
+
let fitting = null;
|
|
9767
|
+
for (let iteration = 0; iteration <= MAX_CORRECTIONS; iteration++) {
|
|
9768
|
+
const step = solveAutoFitStep({
|
|
9769
|
+
target: targetWidth,
|
|
9770
|
+
measured: width,
|
|
9771
|
+
unitExtent: autoUnit ? this.chart.getUnitBarExtent() : 0,
|
|
9772
|
+
pctExtent: autoPercent ? this.chart.getPercentBarExtent() : 0,
|
|
9773
|
+
currentPpu: config.pixelPerUnit,
|
|
9774
|
+
currentPpp: config.pixelPerPercentage,
|
|
9775
|
+
});
|
|
9776
|
+
if (step.ppu === undefined && step.ppp === undefined) {
|
|
9777
|
+
break; // nothing scales with the auto values — fallback below
|
|
9778
|
+
}
|
|
9779
|
+
if (autoUnit && step.ppu !== undefined) {
|
|
9780
|
+
config.pixelPerUnit = step.ppu;
|
|
9781
|
+
solvedUnit = true;
|
|
9782
|
+
}
|
|
9783
|
+
if (autoPercent && step.ppp !== undefined) {
|
|
9784
|
+
config.pixelPerPercentage = step.ppp;
|
|
9785
|
+
solvedPercent = true;
|
|
9786
|
+
}
|
|
9787
|
+
rebuild();
|
|
9788
|
+
width = measure();
|
|
9789
|
+
if (width <= targetWidth + EPS) {
|
|
9790
|
+
fitting = { ppu: config.pixelPerUnit, ppp: config.pixelPerPercentage };
|
|
9791
|
+
if (width >= targetWidth * 0.98) {
|
|
9792
|
+
break; // fits and tight — done
|
|
9793
|
+
}
|
|
9794
|
+
// else a released label clamp left slack — loop once more to grow into it
|
|
9795
|
+
}
|
|
9796
|
+
}
|
|
9797
|
+
// Auto quantities the solver never touched get the ratio fallback
|
|
9798
|
+
let needsRebuild = false;
|
|
9799
|
+
if (autoUnit && !solvedUnit) {
|
|
9800
|
+
config.pixelPerUnit = ratioFallback;
|
|
9801
|
+
needsRebuild = true;
|
|
9802
|
+
}
|
|
9803
|
+
if (autoPercent && !solvedPercent) {
|
|
9804
|
+
config.pixelPerPercentage = ratioFallback;
|
|
9805
|
+
needsRebuild = true;
|
|
9806
|
+
}
|
|
9807
|
+
// Never end on an overshoot
|
|
9808
|
+
if (width > targetWidth + EPS) {
|
|
9809
|
+
if (fitting) {
|
|
9810
|
+
// Restore the last values that fit (fallback quantities have no extent)
|
|
9811
|
+
if (solvedUnit)
|
|
9812
|
+
config.pixelPerUnit = fitting.ppu;
|
|
9813
|
+
if (solvedPercent)
|
|
9814
|
+
config.pixelPerPercentage = fitting.ppp;
|
|
9114
9815
|
}
|
|
9115
9816
|
else {
|
|
9116
|
-
|
|
9817
|
+
// Even the solved minimum overshoots (labels alone exceed the
|
|
9818
|
+
// container) — shrink proportionally; the wrapper reports this.
|
|
9819
|
+
const shrink = targetWidth / width;
|
|
9820
|
+
if (autoUnit)
|
|
9821
|
+
config.pixelPerUnit = Math.max(MIN_PIXEL_SCALE, config.pixelPerUnit * shrink);
|
|
9822
|
+
if (autoPercent)
|
|
9823
|
+
config.pixelPerPercentage = Math.max(MIN_PIXEL_SCALE, config.pixelPerPercentage * shrink);
|
|
9117
9824
|
}
|
|
9825
|
+
needsRebuild = true;
|
|
9118
9826
|
}
|
|
9119
|
-
if (
|
|
9120
|
-
|
|
9121
|
-
config.pixelPerPercentage = (targetWidth * 0.9) / svgWidth;
|
|
9827
|
+
if (needsRebuild) {
|
|
9828
|
+
rebuild();
|
|
9122
9829
|
}
|
|
9123
|
-
// Second pass with the corrected scaling
|
|
9124
|
-
this.chart = new StructureChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), db, this.tableName, config, styles);
|
|
9125
|
-
this.chart.setI18n(this.i18n);
|
|
9126
9830
|
reportResolved();
|
|
9127
9831
|
}
|
|
9128
9832
|
async componentWillRender() {
|
|
@@ -11253,6 +11957,65 @@ class ScenarioFactory {
|
|
|
11253
11957
|
}
|
|
11254
11958
|
}
|
|
11255
11959
|
|
|
11960
|
+
/**
|
|
11961
|
+
* Keeps a working SVG attached to the document while it is being drawn, so
|
|
11962
|
+
* svg.js can measure it in place.
|
|
11963
|
+
*
|
|
11964
|
+
* svg.js's `bbox()` calls `getBBox()` on the node; on a **detached** tree that
|
|
11965
|
+
* returns a nulled box, so it falls back to a retry path that deep-clones the
|
|
11966
|
+
* subtree, appends the clone to a hidden sandbox in `document.body`, measures
|
|
11967
|
+
* *that*, and removes it again. Charts are drawn detached and measure heavily
|
|
11968
|
+
* (every label reads its own box), so the retry dominates render cost: one
|
|
11969
|
+
* logical measurement costs two `getBBox()` calls plus a full subtree clone and
|
|
11970
|
+
* two DOM mutations.
|
|
11971
|
+
*
|
|
11972
|
+
* Drawing inside a host that is already in the document makes the first
|
|
11973
|
+
* `getBBox()` succeed, which skips the clone entirely.
|
|
11974
|
+
*
|
|
11975
|
+
* The host is styled exactly like svg.js's own parser sandbox (see
|
|
11976
|
+
* `parser()` in @svgdotjs/svg.js) so the measurement context — and therefore
|
|
11977
|
+
* every measured value — is identical to what the retry path produced.
|
|
11978
|
+
*/
|
|
11979
|
+
const HOST_ID = "bn-measurement-host";
|
|
11980
|
+
const HOST_CSS = "opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden";
|
|
11981
|
+
function getHost() {
|
|
11982
|
+
if (typeof document === "undefined" || !document.body) {
|
|
11983
|
+
return null;
|
|
11984
|
+
}
|
|
11985
|
+
let host = document.getElementById(HOST_ID);
|
|
11986
|
+
if (!host) {
|
|
11987
|
+
host = document.createElement("div");
|
|
11988
|
+
host.id = HOST_ID;
|
|
11989
|
+
host.style.cssText = HOST_CSS;
|
|
11990
|
+
host.setAttribute("aria-hidden", "true");
|
|
11991
|
+
document.body.appendChild(host);
|
|
11992
|
+
}
|
|
11993
|
+
return host;
|
|
11994
|
+
}
|
|
11995
|
+
/**
|
|
11996
|
+
* Runs `drawFn` with `container` temporarily attached to the hidden
|
|
11997
|
+
* measurement host, then detaches it again.
|
|
11998
|
+
*
|
|
11999
|
+
* Falls back to drawing detached when there is no live document (spec runs
|
|
12000
|
+
* under mock-doc), so callers need no environment check of their own.
|
|
12001
|
+
*/
|
|
12002
|
+
function drawAttached(container, drawFn) {
|
|
12003
|
+
const host = getHost();
|
|
12004
|
+
if (!host) {
|
|
12005
|
+
drawFn();
|
|
12006
|
+
return;
|
|
12007
|
+
}
|
|
12008
|
+
host.appendChild(container.node);
|
|
12009
|
+
try {
|
|
12010
|
+
drawFn();
|
|
12011
|
+
}
|
|
12012
|
+
finally {
|
|
12013
|
+
if (container.node.parentNode === host) {
|
|
12014
|
+
host.removeChild(container.node);
|
|
12015
|
+
}
|
|
12016
|
+
}
|
|
12017
|
+
}
|
|
12018
|
+
|
|
11256
12019
|
/** Tracks whether the internal data model needs to be regenerated. */
|
|
11257
12020
|
var FactoryState$1;
|
|
11258
12021
|
(function (FactoryState) {
|
|
@@ -11546,17 +12309,87 @@ class TimeChart {
|
|
|
11546
12309
|
: this.scenariosArea.height;
|
|
11547
12310
|
return Math.max(analyticalHeight, bboxHeight);
|
|
11548
12311
|
}
|
|
12312
|
+
/**
|
|
12313
|
+
* Total column extent (data units) proportional to pixelPerUnit, covering
|
|
12314
|
+
* both sides of the axis (negative columns extend below it). Mirrors the
|
|
12315
|
+
* DataPoints getAllocatedCanvasHeight allocates with; used by autoFitScaling
|
|
12316
|
+
* to separate fixed from variable height components.
|
|
12317
|
+
*/
|
|
12318
|
+
getUnitBarExtent() {
|
|
12319
|
+
var _a, _b, _c;
|
|
12320
|
+
const isRelative = this.isVarianceChart() &&
|
|
12321
|
+
this.variancesDataModel.some((e) => e.type === VarianceType.RELATIVE);
|
|
12322
|
+
const usesVariance = this.isVarianceChart();
|
|
12323
|
+
const highest = usesVariance ? this.highestVarianceDataPointValue : this.highestDataPointValue;
|
|
12324
|
+
const smallest = usesVariance ? this.smallestVarianceDataPointValue : this.smallestDataPointValue;
|
|
12325
|
+
return computeUnitBarExtent({
|
|
12326
|
+
// Relative stacks span exactly RELATIVE_STACK_UNITS * ppu
|
|
12327
|
+
fixedDomain: ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) === VarianceMeasure.StackMode.RELATIVE ? VarianceMeasure.RELATIVE_STACK_UNITS : undefined,
|
|
12328
|
+
relativeVariance: isRelative,
|
|
12329
|
+
maxPositive: (_b = highest === null || highest === void 0 ? void 0 : highest.value) !== null && _b !== void 0 ? _b : 0,
|
|
12330
|
+
minNegative: this.isOnSameAxisSide() ? 0 : ((_c = smallest === null || smallest === void 0 ? void 0 : smallest.value) !== null && _c !== void 0 ? _c : 0),
|
|
12331
|
+
});
|
|
12332
|
+
}
|
|
12333
|
+
/**
|
|
12334
|
+
* Total column extent (fraction units) proportional to pixelPerPercentage.
|
|
12335
|
+
* Only relative variances scale with it; each side clamps at +/-145%.
|
|
12336
|
+
*/
|
|
12337
|
+
getPercentBarExtent() {
|
|
12338
|
+
var _a, _b, _c, _d;
|
|
12339
|
+
const isRelative = this.isVarianceChart() &&
|
|
12340
|
+
this.variancesDataModel.some((e) => e.type === VarianceType.RELATIVE);
|
|
12341
|
+
return computePercentBarExtent({
|
|
12342
|
+
relativeVariance: isRelative,
|
|
12343
|
+
maxPositive: (_b = (_a = this.highestVarianceDataPointValue) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0,
|
|
12344
|
+
minNegative: this.isOnSameAxisSide() ? 0 : ((_d = (_c = this.smallestVarianceDataPointValue) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 0),
|
|
12345
|
+
});
|
|
12346
|
+
}
|
|
12347
|
+
/**
|
|
12348
|
+
* Runs `draw()` purely for its side effects — it is what finalizes the
|
|
12349
|
+
* positions and the allocated-area fields that `getAllocatedCanvas*()` read.
|
|
12350
|
+
*
|
|
12351
|
+
* The auto-fit solver measures the chart once per iteration and only needs
|
|
12352
|
+
* those numbers, so it calls this instead of {@link toString}: the XML
|
|
12353
|
+
* serialization of a tree that is immediately discarded is pure overhead.
|
|
12354
|
+
*/
|
|
12355
|
+
layout() {
|
|
12356
|
+
const container = new SVGStyle.Svg();
|
|
12357
|
+
drawAttached(container, () => this.draw(container));
|
|
12358
|
+
}
|
|
11549
12359
|
toString() {
|
|
11550
12360
|
const container = new SVGStyle.Svg();
|
|
11551
|
-
this.draw(container);
|
|
12361
|
+
drawAttached(container, () => this.draw(container));
|
|
11552
12362
|
container.id("drawCanvas");
|
|
11553
12363
|
container.width(this.getAllocatedCanvasWidth());
|
|
11554
12364
|
container.height(this.getAllocatedCanvasHeight());
|
|
11555
12365
|
container.attr("overflow", "visible");
|
|
11556
12366
|
return container.svg();
|
|
11557
12367
|
}
|
|
12368
|
+
/**
|
|
12369
|
+
* Writes the chart's font onto the SVG root as presentation attributes.
|
|
12370
|
+
*
|
|
12371
|
+
* `font-size` and `font-family` are inherited, so a `<text>` with neither of
|
|
12372
|
+
* its own takes whatever its ancestor chain supplies. That chain is not stable
|
|
12373
|
+
* across the places this SVG gets measured: drawn detached, svg.js's `bbox()`
|
|
12374
|
+
* clones the element into a sandbox under `document.body`, where it inherits
|
|
12375
|
+
* the document default — 16px Times — instead of the chart's real font. Every
|
|
12376
|
+
* label was measured ~9% too wide as a result, which over-allocated label
|
|
12377
|
+
* space and pushed labels past the `maxWidth` threshold that drops them.
|
|
12378
|
+
*
|
|
12379
|
+
* Setting the font here makes a measurement independent of where it happens.
|
|
12380
|
+
* Stylesheet rules still win over presentation attributes, so this changes
|
|
12381
|
+
* nothing about how the chart renders in place — the CSS and this attribute
|
|
12382
|
+
* resolve to the same value, both being `fontSizePx * effectiveScaleFactor`.
|
|
12383
|
+
*/
|
|
12384
|
+
applyFontToContainer(svgContainer) {
|
|
12385
|
+
svgContainer.attr({
|
|
12386
|
+
"font-size": this.styles.fontStyles.size,
|
|
12387
|
+
"font-family": this.styles.fontStyles.family,
|
|
12388
|
+
});
|
|
12389
|
+
}
|
|
11558
12390
|
draw(svgContainer) {
|
|
11559
12391
|
this.cleanSVGforRedraw(svgContainer);
|
|
12392
|
+
this.applyFontToContainer(svgContainer);
|
|
11560
12393
|
if (this.state === FactoryState$1.DIRTY) {
|
|
11561
12394
|
this.state = FactoryState$1.UP_TO_DATE;
|
|
11562
12395
|
}
|
|
@@ -12059,9 +12892,12 @@ class TimeChart {
|
|
|
12059
12892
|
labelText: this.title,
|
|
12060
12893
|
isRelative: isRelative,
|
|
12061
12894
|
}, this.position, axisLabelGroup).draw();
|
|
12895
|
+
// svg.js's width()/height() getters each default to their own bbox() call,
|
|
12896
|
+
// so reading both measures the group twice. Measure once.
|
|
12897
|
+
const axisBox = axisLabelGroup.bbox();
|
|
12062
12898
|
this.axisCategoryArea = {
|
|
12063
|
-
height:
|
|
12064
|
-
width:
|
|
12899
|
+
height: axisBox.height,
|
|
12900
|
+
width: axisBox.width,
|
|
12065
12901
|
};
|
|
12066
12902
|
}
|
|
12067
12903
|
drawScenarios(dataModel, svgContainer) {
|
|
@@ -12087,9 +12923,10 @@ class TimeChart {
|
|
|
12087
12923
|
heightOffset = this.position.dataLabelHeight * 2;
|
|
12088
12924
|
}
|
|
12089
12925
|
}
|
|
12926
|
+
const columnBox = columnGroup.bbox();
|
|
12090
12927
|
this.scenariosArea = {
|
|
12091
|
-
height:
|
|
12092
|
-
width:
|
|
12928
|
+
height: columnBox.height + this.styles.padding.top + this.styles.padding.bottom + heightOffset,
|
|
12929
|
+
width: columnBox.width + this.position.spacings.columnWidth,
|
|
12093
12930
|
};
|
|
12094
12931
|
}
|
|
12095
12932
|
drawLineScenarios(dataModel, svgContainer) {
|
|
@@ -12154,9 +12991,10 @@ class TimeChart {
|
|
|
12154
12991
|
// Use getColumnPositionY() (the axis baseline) as the minimum height
|
|
12155
12992
|
// so that axis date labels drawn below are not cut off.
|
|
12156
12993
|
const axisY = this.position.getColumnPositionY();
|
|
12994
|
+
const lineBox = lineGroup.bbox();
|
|
12157
12995
|
this.scenariosArea = {
|
|
12158
|
-
height: Math.max(
|
|
12159
|
-
width:
|
|
12996
|
+
height: Math.max(lineBox.height + this.styles.padding.top, axisY) + this.styles.padding.bottom,
|
|
12997
|
+
width: lineBox.width + this.position.spacings.columnWidth,
|
|
12160
12998
|
};
|
|
12161
12999
|
}
|
|
12162
13000
|
drawAxisAndLabelsForLineChart(dataModel, svgContainer) {
|
|
@@ -12207,9 +13045,12 @@ class TimeChart {
|
|
|
12207
13045
|
labelText: this.title,
|
|
12208
13046
|
isRelative: isRelative,
|
|
12209
13047
|
}, this.position, axisLabelGroup).draw();
|
|
13048
|
+
// svg.js's width()/height() getters each default to their own bbox() call,
|
|
13049
|
+
// so reading both measures the group twice. Measure once.
|
|
13050
|
+
const axisBox = axisLabelGroup.bbox();
|
|
12210
13051
|
this.axisCategoryArea = {
|
|
12211
|
-
height:
|
|
12212
|
-
width:
|
|
13052
|
+
height: axisBox.height,
|
|
13053
|
+
width: axisBox.width,
|
|
12213
13054
|
};
|
|
12214
13055
|
}
|
|
12215
13056
|
shouldShowLineChartAxisLabel(dataModel, index) {
|
|
@@ -12267,9 +13108,10 @@ class TimeChart {
|
|
|
12267
13108
|
scenarioFactory.createVarianceBar(elements["scenario1"], index).draw(this.dataFormatDigits, this.measureScale);
|
|
12268
13109
|
}
|
|
12269
13110
|
});
|
|
13111
|
+
const varianceBox = columnGroup.bbox();
|
|
12270
13112
|
this.scenariosArea = {
|
|
12271
|
-
height:
|
|
12272
|
-
width:
|
|
13113
|
+
height: varianceBox.height + this.styles.padding.top + this.styles.padding.bottom,
|
|
13114
|
+
width: varianceBox.width + this.position.spacings.columnWidth,
|
|
12273
13115
|
};
|
|
12274
13116
|
return columnGroup;
|
|
12275
13117
|
}
|
|
@@ -12377,9 +13219,10 @@ class TimeChart {
|
|
|
12377
13219
|
}
|
|
12378
13220
|
}
|
|
12379
13221
|
});
|
|
13222
|
+
const stackBox = stackGroup.bbox();
|
|
12380
13223
|
this.scenariosArea = {
|
|
12381
|
-
height:
|
|
12382
|
-
width:
|
|
13224
|
+
height: stackBox.height + this.styles.padding.top + this.styles.padding.bottom,
|
|
13225
|
+
width: stackBox.width + this.position.spacings.columnWidth,
|
|
12383
13226
|
};
|
|
12384
13227
|
}
|
|
12385
13228
|
/**
|
|
@@ -12559,9 +13402,10 @@ class TimeChart {
|
|
|
12559
13402
|
areaFill.draw();
|
|
12560
13403
|
areaFill.drawBoundaryLine();
|
|
12561
13404
|
}
|
|
13405
|
+
const areaBox = areaGroup.bbox();
|
|
12562
13406
|
this.scenariosArea = {
|
|
12563
|
-
height:
|
|
12564
|
-
width:
|
|
13407
|
+
height: areaBox.height + this.styles.padding.top + this.styles.padding.bottom,
|
|
13408
|
+
width: areaBox.width + this.position.spacings.columnWidth,
|
|
12565
13409
|
};
|
|
12566
13410
|
}
|
|
12567
13411
|
drawOverlayLayer(dataModel, svgContainer) {
|
|
@@ -12850,7 +13694,7 @@ class TimeChartComponentConfigAdapter {
|
|
|
12850
13694
|
}
|
|
12851
13695
|
}
|
|
12852
13696
|
|
|
12853
|
-
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{
|
|
13697
|
+
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}`;
|
|
12854
13698
|
|
|
12855
13699
|
const IbcsChartTime = class {
|
|
12856
13700
|
constructor(hostRef) {
|
|
@@ -12912,8 +13756,14 @@ const IbcsChartTime = class {
|
|
|
12912
13756
|
const availableWidth = this.containerWidth || 0;
|
|
12913
13757
|
this.chart = new TimeChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), this.getDb(), this.tableName, config, styles, availableWidth);
|
|
12914
13758
|
this.chart.setI18n(this.i18n);
|
|
13759
|
+
// The broken-bar overdrive exists to absorb MANUAL scaling overflow.
|
|
13760
|
+
// autoFitScaling mutates config.pixelPerUnit to the solved value, so
|
|
13761
|
+
// remember auto mode beforehand and skip the overdrive for it — the
|
|
13762
|
+
// fitted chart fits by construction, and the overdrive's rough overhead
|
|
13763
|
+
// estimate would falsely re-engage on it.
|
|
13764
|
+
const unitWasAuto = config.pixelPerUnit <= 0;
|
|
12915
13765
|
this.autoFitScaling(config, styles);
|
|
12916
|
-
this.chart.setAvailableHeight(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
|
|
13766
|
+
this.chart.setAvailableHeight(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
|
|
12917
13767
|
this.pattern = new CustomPattern(this.chart.styles);
|
|
12918
13768
|
this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
|
|
12919
13769
|
}
|
|
@@ -12929,15 +13779,24 @@ const IbcsChartTime = class {
|
|
|
12929
13779
|
this.chart.setAvailableWidth(this.containerWidth || 0);
|
|
12930
13780
|
this.chart.setRuleSet(new SVGStyle.IBCSRuleSet(this.ruleSetConfig));
|
|
12931
13781
|
this.chart.setConfig(config);
|
|
13782
|
+
// See componentWillLoad: no broken-bar overdrive for auto-fitted scaling
|
|
13783
|
+
const unitWasAuto = config.pixelPerUnit <= 0;
|
|
12932
13784
|
this.autoFitScaling(config, styles);
|
|
12933
|
-
this.chart.setAvailableHeight(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
|
|
13785
|
+
this.chart.setAvailableHeight(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
|
|
12934
13786
|
this.pattern = new CustomPattern(this.chart.styles);
|
|
12935
13787
|
this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
|
|
12936
13788
|
}
|
|
12937
13789
|
/**
|
|
12938
|
-
*
|
|
12939
|
-
*
|
|
12940
|
-
*
|
|
13790
|
+
* Auto-fit for pixelPerUnit and/or pixelPerPercentage (0 = auto mode).
|
|
13791
|
+
* Time charts grow vertically, so we fit to height.
|
|
13792
|
+
*
|
|
13793
|
+
* The chart height is affine in the pixel scales (height = fixed labels +
|
|
13794
|
+
* column extent × scale), but label allocations shift between passes, so a
|
|
13795
|
+
* single analytic solve is not enough: measure at 1, solve, then verify
|
|
13796
|
+
* against fresh measurements and re-solve until the chart fits. The loop
|
|
13797
|
+
* never ends on an overshoot — the last fitting values are restored, or
|
|
13798
|
+
* when even the minimum scale cannot fit (labels alone exceed the
|
|
13799
|
+
* container) the values are floored and the wrapper reports the overflow.
|
|
12941
13800
|
* Explicit (> 0) values are never overridden.
|
|
12942
13801
|
*/
|
|
12943
13802
|
autoFitScaling(config, styles) {
|
|
@@ -12956,38 +13815,107 @@ const IbcsChartTime = class {
|
|
|
12956
13815
|
};
|
|
12957
13816
|
const targetHeight = (_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height;
|
|
12958
13817
|
const availableWidth = this.containerWidth || 0;
|
|
13818
|
+
const rebuild = () => {
|
|
13819
|
+
this.chart = new TimeChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), this.getDb(), this.tableName, config, styles, availableWidth);
|
|
13820
|
+
this.chart.setI18n(this.i18n);
|
|
13821
|
+
};
|
|
13822
|
+
// layout() runs draw(), which finalizes positions — an undrawn chart
|
|
13823
|
+
// reports a stale allocated height.
|
|
13824
|
+
const measure = () => {
|
|
13825
|
+
this.chart.layout();
|
|
13826
|
+
return this.chart.getAllocatedCanvasHeight();
|
|
13827
|
+
};
|
|
12959
13828
|
if (!targetHeight || targetHeight <= 0) {
|
|
12960
13829
|
if (autoUnit)
|
|
12961
13830
|
config.pixelPerUnit = 1;
|
|
12962
13831
|
if (autoPercent)
|
|
12963
13832
|
config.pixelPerPercentage = 50;
|
|
12964
|
-
|
|
12965
|
-
this.chart.setI18n(this.i18n);
|
|
13833
|
+
rebuild();
|
|
12966
13834
|
reportResolved();
|
|
12967
13835
|
return;
|
|
12968
13836
|
}
|
|
12969
|
-
//
|
|
13837
|
+
// Measurement pass: render the auto quantities at 1
|
|
12970
13838
|
if (autoUnit)
|
|
12971
13839
|
config.pixelPerUnit = 1;
|
|
12972
13840
|
if (autoPercent)
|
|
12973
13841
|
config.pixelPerPercentage = 1;
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
const svgHeight = this.chart.getAllocatedCanvasHeight();
|
|
12978
|
-
if (svgHeight <= 0) {
|
|
13842
|
+
rebuild();
|
|
13843
|
+
let height = measure();
|
|
13844
|
+
if (height <= 0) {
|
|
12979
13845
|
reportResolved();
|
|
12980
13846
|
return;
|
|
12981
13847
|
}
|
|
12982
|
-
//
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
13848
|
+
// Fallback for auto quantities nothing scales with (no column extent):
|
|
13849
|
+
// plain ratio against the measurement pass, as before.
|
|
13850
|
+
const ratioFallback = Math.max(MIN_PIXEL_SCALE, (targetHeight * 0.9) / height);
|
|
13851
|
+
const EPS = 0.5;
|
|
13852
|
+
const MAX_CORRECTIONS = 3;
|
|
13853
|
+
let solvedUnit = false;
|
|
13854
|
+
let solvedPercent = false;
|
|
13855
|
+
let fitting = null;
|
|
13856
|
+
for (let iteration = 0; iteration <= MAX_CORRECTIONS; iteration++) {
|
|
13857
|
+
const step = solveAutoFitStep({
|
|
13858
|
+
target: targetHeight,
|
|
13859
|
+
measured: height,
|
|
13860
|
+
unitExtent: autoUnit ? this.chart.getUnitBarExtent() : 0,
|
|
13861
|
+
pctExtent: autoPercent ? this.chart.getPercentBarExtent() : 0,
|
|
13862
|
+
currentPpu: config.pixelPerUnit,
|
|
13863
|
+
currentPpp: config.pixelPerPercentage,
|
|
13864
|
+
});
|
|
13865
|
+
if (step.ppu === undefined && step.ppp === undefined) {
|
|
13866
|
+
break; // nothing scales with the auto values — fallback below
|
|
13867
|
+
}
|
|
13868
|
+
if (autoUnit && step.ppu !== undefined) {
|
|
13869
|
+
config.pixelPerUnit = step.ppu;
|
|
13870
|
+
solvedUnit = true;
|
|
13871
|
+
}
|
|
13872
|
+
if (autoPercent && step.ppp !== undefined) {
|
|
13873
|
+
config.pixelPerPercentage = step.ppp;
|
|
13874
|
+
solvedPercent = true;
|
|
13875
|
+
}
|
|
13876
|
+
rebuild();
|
|
13877
|
+
height = measure();
|
|
13878
|
+
if (height <= targetHeight + EPS) {
|
|
13879
|
+
fitting = { ppu: config.pixelPerUnit, ppp: config.pixelPerPercentage };
|
|
13880
|
+
if (height >= targetHeight * 0.98) {
|
|
13881
|
+
break; // fits and tight — done
|
|
13882
|
+
}
|
|
13883
|
+
// else the label allocation left slack — loop once more to grow into it
|
|
13884
|
+
}
|
|
13885
|
+
}
|
|
13886
|
+
// Auto quantities the solver never touched get the ratio fallback
|
|
13887
|
+
let needsRebuild = false;
|
|
13888
|
+
if (autoUnit && !solvedUnit) {
|
|
13889
|
+
config.pixelPerUnit = ratioFallback;
|
|
13890
|
+
needsRebuild = true;
|
|
13891
|
+
}
|
|
13892
|
+
if (autoPercent && !solvedPercent) {
|
|
13893
|
+
config.pixelPerPercentage = ratioFallback;
|
|
13894
|
+
needsRebuild = true;
|
|
13895
|
+
}
|
|
13896
|
+
// Never end on an overshoot
|
|
13897
|
+
if (height > targetHeight + EPS) {
|
|
13898
|
+
if (fitting) {
|
|
13899
|
+
// Restore the last values that fit (fallback quantities have no extent)
|
|
13900
|
+
if (solvedUnit)
|
|
13901
|
+
config.pixelPerUnit = fitting.ppu;
|
|
13902
|
+
if (solvedPercent)
|
|
13903
|
+
config.pixelPerPercentage = fitting.ppp;
|
|
13904
|
+
}
|
|
13905
|
+
else {
|
|
13906
|
+
// Even the solved minimum overshoots (labels alone exceed the
|
|
13907
|
+
// container) — shrink proportionally; the wrapper reports this.
|
|
13908
|
+
const shrink = targetHeight / height;
|
|
13909
|
+
if (autoUnit)
|
|
13910
|
+
config.pixelPerUnit = Math.max(MIN_PIXEL_SCALE, config.pixelPerUnit * shrink);
|
|
13911
|
+
if (autoPercent)
|
|
13912
|
+
config.pixelPerPercentage = Math.max(MIN_PIXEL_SCALE, config.pixelPerPercentage * shrink);
|
|
13913
|
+
}
|
|
13914
|
+
needsRebuild = true;
|
|
13915
|
+
}
|
|
13916
|
+
if (needsRebuild) {
|
|
13917
|
+
rebuild();
|
|
13918
|
+
}
|
|
12991
13919
|
reportResolved();
|
|
12992
13920
|
}
|
|
12993
13921
|
async componentWillRender() {
|
|
@@ -13205,6 +14133,98 @@ class TableRow {
|
|
|
13205
14133
|
}
|
|
13206
14134
|
}
|
|
13207
14135
|
|
|
14136
|
+
/**
|
|
14137
|
+
* Column geometry for the inline bar / pin / waterfall charts of bn-table.
|
|
14138
|
+
*
|
|
14139
|
+
* `bar-column-width="wN"` and `category-width="wN"` both mean "N em of the table font",
|
|
14140
|
+
* so both columns render at the same width for the same N. The em used here is the TRUE
|
|
14141
|
+
* table em (`--bn-font-size`, i.e. `global.fontSizePx × scaleFactor`) — deliberately NOT
|
|
14142
|
+
* `CellBarChartStyles.fontSize`, which is 0.85 of it and doubles as the unitScaling /
|
|
14143
|
+
* percentageScaling basis.
|
|
14144
|
+
*
|
|
14145
|
+
* Every quantity is returned in px so the SVG renderers stay in one coordinate space.
|
|
14146
|
+
*/
|
|
14147
|
+
/**
|
|
14148
|
+
* SVG label font size relative to the table em. Also the multiplier in the
|
|
14149
|
+
* unitScaling / percentageScaling math, so changing it rescales every user-set value.
|
|
14150
|
+
*/
|
|
14151
|
+
const BAR_LABEL_FONT_RATIO = 0.85;
|
|
14152
|
+
/**
|
|
14153
|
+
* Horizontal padding of a bar cell, in table em:
|
|
14154
|
+
* `td:has(.cell-bar-chart) { padding: 0 0.25em }` (ibcs-table.scss:320).
|
|
14155
|
+
* With `box-sizing: border-box` the SVG has to be that much narrower than the requested
|
|
14156
|
+
* column width, so the cell's border box lands on exactly N em — the same box
|
|
14157
|
+
* `.category-wN` (ibcs-table.scss:50-83) produces.
|
|
14158
|
+
*/
|
|
14159
|
+
const BAR_CELL_PADDING_EM = 0.5;
|
|
14160
|
+
/** Value-label gutter beside a bar, in em (was a hardcoded 38 px at the 13.3333 px em). */
|
|
14161
|
+
const BAR_LABEL_EM = 2.85;
|
|
14162
|
+
/** Value-label gutter beside a pin, in em (was 45 px). */
|
|
14163
|
+
const PIN_LABEL_EM = 3.375;
|
|
14164
|
+
/** Gap between the axis and the start of a pin's reserved side, in em (was 5 px). */
|
|
14165
|
+
const PIN_PADDING_EM = 0.375;
|
|
14166
|
+
/** Zigzag break gap of an overdrive bar, in em (was 4 px). */
|
|
14167
|
+
const BREAK_GAP_EM = 0.3;
|
|
14168
|
+
/** Gap between a bar/pin end and its value label, in em (was 4 px). */
|
|
14169
|
+
const LABEL_GAP_EM = 0.3;
|
|
14170
|
+
/** Share of the per-side bar extent reserved for the overdrive stub. */
|
|
14171
|
+
const OVERDRIVE_FRACTION = 0.15;
|
|
14172
|
+
/** The SVG fills the cell's content box: the requested column width minus the cell padding. */
|
|
14173
|
+
function contentWidth(widthEm, emPx) {
|
|
14174
|
+
return Math.max(0, (widthEm - BAR_CELL_PADDING_EM) * emPx);
|
|
14175
|
+
}
|
|
14176
|
+
/** Sides the axis serves. Clamped to 1 so a hypothetical all-zero column never divides by 0. */
|
|
14177
|
+
function sideCount(hasNeg, hasPos) {
|
|
14178
|
+
return Math.max(1, (hasNeg ? 1 : 0) + (hasPos ? 1 : 0));
|
|
14179
|
+
}
|
|
14180
|
+
function absoluteBarGeometry(widthEm, emPx, hasNeg, hasPos) {
|
|
14181
|
+
const totalWidth = contentWidth(widthEm, emPx);
|
|
14182
|
+
const sides = sideCount(hasNeg, hasPos);
|
|
14183
|
+
// Narrow columns shrink the gutters rather than the total, so wN stays wN.
|
|
14184
|
+
const labelAreaWidth = Math.min(BAR_LABEL_EM * emPx, totalWidth / (2 * sides));
|
|
14185
|
+
const maxBarWidth = (totalWidth - labelAreaWidth * sides) / sides;
|
|
14186
|
+
const breakGap = Math.min(BREAK_GAP_EM * emPx, maxBarWidth * 0.2);
|
|
14187
|
+
const overdriveZoneWidth = maxBarWidth * OVERDRIVE_FRACTION;
|
|
14188
|
+
return {
|
|
14189
|
+
totalWidth,
|
|
14190
|
+
labelAreaWidth,
|
|
14191
|
+
maxBarWidth,
|
|
14192
|
+
axisX: hasNeg ? labelAreaWidth + maxBarWidth : 0,
|
|
14193
|
+
breakGap,
|
|
14194
|
+
overdriveZoneWidth,
|
|
14195
|
+
cutWidth: Math.max(0, maxBarWidth - breakGap - overdriveZoneWidth),
|
|
14196
|
+
labelGap: LABEL_GAP_EM * emPx,
|
|
14197
|
+
};
|
|
14198
|
+
}
|
|
14199
|
+
function relativePinGeometry(widthEm, emPx, hasNeg, hasPos) {
|
|
14200
|
+
const totalWidth = contentWidth(widthEm, emPx);
|
|
14201
|
+
const sides = sideCount(hasNeg, hasPos);
|
|
14202
|
+
const labelAreaWidth = Math.min(PIN_LABEL_EM * emPx, totalWidth / 2);
|
|
14203
|
+
const pinAreaWidth = totalWidth - labelAreaWidth;
|
|
14204
|
+
const sideWidth = pinAreaWidth / sides;
|
|
14205
|
+
const pinPadding = Math.min(PIN_PADDING_EM * emPx, sideWidth * 0.2);
|
|
14206
|
+
return {
|
|
14207
|
+
totalWidth,
|
|
14208
|
+
labelAreaWidth,
|
|
14209
|
+
maxPinLength: Math.max(0, sideWidth - pinPadding),
|
|
14210
|
+
pinPadding,
|
|
14211
|
+
axisX: hasNeg ? sideWidth : 0,
|
|
14212
|
+
labelX: pinAreaWidth + LABEL_GAP_EM * emPx,
|
|
14213
|
+
};
|
|
14214
|
+
}
|
|
14215
|
+
function waterfallGeometry(widthEm, emPx) {
|
|
14216
|
+
const totalWidth = contentWidth(widthEm, emPx);
|
|
14217
|
+
const labelAreaWidth = Math.min(BAR_LABEL_EM * emPx, totalWidth / 4);
|
|
14218
|
+
return {
|
|
14219
|
+
totalWidth,
|
|
14220
|
+
labelAreaWidth,
|
|
14221
|
+
barAreaWidth: totalWidth - labelAreaWidth * 2,
|
|
14222
|
+
labelGap: LABEL_GAP_EM * emPx,
|
|
14223
|
+
};
|
|
14224
|
+
}
|
|
14225
|
+
|
|
14226
|
+
/** Matches SYSTEM_STYLE_DEFAULTS.global.fontSizePx; only used when `styles` is omitted. */
|
|
14227
|
+
const DEFAULT_EM_PX = 13.3333;
|
|
13208
14228
|
// Default fallback colors (should come from componentStyle)
|
|
13209
14229
|
const DEFAULT_STYLES = {
|
|
13210
14230
|
positive: { stroke: "#008f96", fill: "#008f96", fillpattern: "solid" },
|
|
@@ -13217,7 +14237,8 @@ const DEFAULT_STYLES = {
|
|
|
13217
14237
|
pl: { stroke: "#404040", fill: "#ffffff", fillpattern: "outlined" },
|
|
13218
14238
|
},
|
|
13219
14239
|
fontColor: "#000000",
|
|
13220
|
-
fontSize:
|
|
14240
|
+
fontSize: DEFAULT_EM_PX * BAR_LABEL_FONT_RATIO,
|
|
14241
|
+
emPx: DEFAULT_EM_PX,
|
|
13221
14242
|
fontFamily: "'Noto Sans', sans-serif",
|
|
13222
14243
|
unitScaling: 0.01, // Default: 100 units per em of bar
|
|
13223
14244
|
percentageScaling: 0.5, // Default: 2 percentage points per em of pin
|
|
@@ -13392,21 +14413,20 @@ function renderZigzagBreak(breakX, breakGap, yTop, barHeight, s) {
|
|
|
13392
14413
|
/**
|
|
13393
14414
|
* Renders an absolute variance bar chart (d_ prefix).
|
|
13394
14415
|
* Horizontal bar with centered axis, green for positive, red for negative.
|
|
13395
|
-
* When a bar exceeds
|
|
14416
|
+
* When a bar exceeds the geometry's cut width it is drawn as an overdrive bar:
|
|
13396
14417
|
* base segment + zigzag break + proportional overdrive stub (like structure chart).
|
|
13397
14418
|
*
|
|
13398
|
-
* Layout: [left label area][bar area with axis][right label area]
|
|
14419
|
+
* Layout: [left label area][bar area with axis][right label area], summing to
|
|
14420
|
+
* exactly `columnWidthEm` em — see barColumnGeometry.ts.
|
|
13399
14421
|
*/
|
|
13400
14422
|
const AbsoluteVarianceBar = (props) => {
|
|
13401
|
-
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale,
|
|
14423
|
+
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, columnWidthEm = 10, styles = DEFAULT_STYLES, } = props;
|
|
13402
14424
|
const s = styles.scaleFactor;
|
|
13403
14425
|
const fs = styles.fontSize;
|
|
13404
|
-
|
|
13405
|
-
const
|
|
13406
|
-
|
|
13407
|
-
const breakGap =
|
|
13408
|
-
const overdriveZoneWidth = maxBarWidth * 0.15;
|
|
13409
|
-
const cutWidth = maxBarWidth - breakGap - overdriveZoneWidth;
|
|
14426
|
+
// Adaptive axis placement based on data range
|
|
14427
|
+
const hasNeg = columnStats.min < 0;
|
|
14428
|
+
const hasPos = columnStats.max > 0;
|
|
14429
|
+
const { totalWidth, axisX, breakGap, overdriveZoneWidth, cutWidth, labelGap } = absoluteBarGeometry(columnWidthEm, styles.emPx, hasNeg, hasPos);
|
|
13410
14430
|
// Direct unit scaling via fontSize
|
|
13411
14431
|
const scaledWidth = Math.abs(value) * styles.unitScaling * fs;
|
|
13412
14432
|
const isExtreme = scaledWidth > cutWidth;
|
|
@@ -13415,16 +14435,8 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
13415
14435
|
const maxOverflow = Math.max(0, maxScaledWidth - cutWidth);
|
|
13416
14436
|
const overflowAmount = Math.max(0, scaledWidth - cutWidth);
|
|
13417
14437
|
const overdriveWidth = maxOverflow > 0 ? (overflowAmount / maxOverflow) * overdriveZoneWidth : 0;
|
|
13418
|
-
// Adaptive axis placement based on data range
|
|
13419
|
-
const hasNeg = columnStats.min < 0;
|
|
13420
|
-
const hasPos = columnStats.max > 0;
|
|
13421
|
-
const negBarWidth = hasNeg ? maxBarWidth : 0;
|
|
13422
|
-
const posBarWidth = hasPos ? maxBarWidth : 0;
|
|
13423
|
-
const barAreaWidth = negBarWidth + posBarWidth;
|
|
13424
|
-
const totalWidth = (hasNeg ? labelAreaWidth : 0) + barAreaWidth + (hasPos ? labelAreaWidth : 0);
|
|
13425
14438
|
const padding = 2 * s;
|
|
13426
14439
|
const barHeight = height - padding * 2;
|
|
13427
|
-
const axisX = (hasNeg ? labelAreaWidth : 0) + negBarWidth;
|
|
13428
14440
|
const barY = padding;
|
|
13429
14441
|
const isPositive = value >= 0;
|
|
13430
14442
|
// Get style based on column type (scenario vs variance)
|
|
@@ -13445,7 +14457,7 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
13445
14457
|
const baseBarWidth = isExtreme ? cutWidth : scaledWidth;
|
|
13446
14458
|
// Label position accounts for overdrive
|
|
13447
14459
|
const totalVisualWidth = isExtreme ? cutWidth + breakGap + overdriveWidth : scaledWidth;
|
|
13448
|
-
const labelX = isPositive ? axisX + totalVisualWidth +
|
|
14460
|
+
const labelX = isPositive ? axisX + totalVisualWidth + labelGap : axisX - totalVisualWidth - labelGap;
|
|
13449
14461
|
const labelAnchor = isPositive ? "start" : "end";
|
|
13450
14462
|
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 &&
|
|
13451
14463
|
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)));
|
|
@@ -13454,25 +14466,18 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
13454
14466
|
* Renders a relative variance pin chart (dr_ prefix).
|
|
13455
14467
|
* Thin horizontal line from axis with dot at end and value label.
|
|
13456
14468
|
*
|
|
13457
|
-
* Layout: [pin area with axis][label area on right]
|
|
14469
|
+
* Layout: [pin area with axis][label area on right], summing to exactly
|
|
14470
|
+
* `columnWidthEm` em — see barColumnGeometry.ts.
|
|
13458
14471
|
* Uses percentageScaling to determine pin length (pixels per percentage point).
|
|
13459
14472
|
*/
|
|
13460
14473
|
const RelativeVariancePin = (props) => {
|
|
13461
|
-
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale,
|
|
14474
|
+
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, columnWidthEm = 10, styles = DEFAULT_STYLES, } = props;
|
|
13462
14475
|
const s = styles.scaleFactor;
|
|
13463
14476
|
const fs = styles.fontSize;
|
|
13464
|
-
// Pin length is ~2/3 of bar width for visual balance
|
|
13465
|
-
const maxPinLength = Math.round(maxBarWidthEm * 0.67 * fs);
|
|
13466
|
-
const pinPadding = 5 * s;
|
|
13467
14477
|
// Adaptive axis placement based on data range
|
|
13468
14478
|
const hasNeg = columnStats.min < 0;
|
|
13469
14479
|
const hasPos = columnStats.max > 0;
|
|
13470
|
-
const
|
|
13471
|
-
const posPinWidth = hasPos ? maxPinLength + pinPadding : 0;
|
|
13472
|
-
const pinAreaWidth = negPinWidth + posPinWidth;
|
|
13473
|
-
const labelAreaWidth = 45 * s;
|
|
13474
|
-
const totalWidth = pinAreaWidth + labelAreaWidth;
|
|
13475
|
-
const axisX = negPinWidth;
|
|
14480
|
+
const { totalWidth, maxPinLength, axisX, labelX } = relativePinGeometry(columnWidthEm, styles.emPx, hasNeg, hasPos);
|
|
13476
14481
|
const centerY = height / 2;
|
|
13477
14482
|
// Direct unit scaling via fontSize
|
|
13478
14483
|
const percentValue = Math.abs(value) * 100;
|
|
@@ -13485,8 +14490,6 @@ const RelativeVariancePin = (props) => {
|
|
|
13485
14490
|
const barStyle = getBarStyle(scenario, value, isPositiveGood, styles);
|
|
13486
14491
|
const dotRadius = 3 * s;
|
|
13487
14492
|
const displayValue = formattedValue || formatValue(value, true, measureScale);
|
|
13488
|
-
// Label always on the right side after the pin area
|
|
13489
|
-
const labelX = pinAreaWidth + 4 * s;
|
|
13490
14493
|
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)));
|
|
13491
14494
|
};
|
|
13492
14495
|
/**
|
|
@@ -13524,16 +14527,14 @@ const CellBarChart = (props) => {
|
|
|
13524
14527
|
* guides marking their parent bar's extent.
|
|
13525
14528
|
*/
|
|
13526
14529
|
const WaterfallBar = (props) => {
|
|
13527
|
-
const { value, scenario, height, measureScale,
|
|
14530
|
+
const { value, scenario, height, measureScale, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall } = props;
|
|
13528
14531
|
const s = styles.scaleFactor;
|
|
13529
14532
|
const fs = styles.fontSize;
|
|
13530
14533
|
const range = waterfall.max - waterfall.min;
|
|
13531
14534
|
if (value === null || value === undefined || isNaN(value) || range <= 0) {
|
|
13532
14535
|
return (index.h("span", { class: "bar-chart-empty", style: { color: styles.fontColor, fontStyle: "italic" } }, "-"));
|
|
13533
14536
|
}
|
|
13534
|
-
const labelAreaWidth =
|
|
13535
|
-
const barAreaWidth = maxBarWidthEm * fs;
|
|
13536
|
-
const totalWidth = labelAreaWidth + barAreaWidth + labelAreaWidth;
|
|
14537
|
+
const { totalWidth, labelAreaWidth, barAreaWidth, labelGap } = waterfallGeometry(columnWidthEm, styles.emPx);
|
|
13537
14538
|
const pxPerUnit = barAreaWidth / range;
|
|
13538
14539
|
const xOf = (coordinate) => labelAreaWidth + (coordinate - waterfall.min) * pxPerUnit;
|
|
13539
14540
|
const padding = 2 * s;
|
|
@@ -13550,7 +14551,7 @@ const WaterfallBar = (props) => {
|
|
|
13550
14551
|
// Scenario values carry no variance sentiment — labels are unsigned per IBCS
|
|
13551
14552
|
const displayValue = formatValue(value, waterfall.kind === "partof", measureScale).replace(/^\+/, "");
|
|
13552
14553
|
const pointsLeft = endX < startX;
|
|
13553
|
-
const labelX = pointsLeft ? barX -
|
|
14554
|
+
const labelX = pointsLeft ? barX - labelGap : barX + barWidth + labelGap;
|
|
13554
14555
|
const labelAnchor = pointsLeft ? "end" : "start";
|
|
13555
14556
|
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)));
|
|
13556
14557
|
};
|
|
@@ -14845,6 +15846,10 @@ class TableDataSetFactory {
|
|
|
14845
15846
|
this.normalizedHeader = [];
|
|
14846
15847
|
this.attributesByAlias = new Map();
|
|
14847
15848
|
}
|
|
15849
|
+
/** Effective column list (category/operation + attributes + scenarios × buckets), set by createHeader(). */
|
|
15850
|
+
getNormalizedHeader() {
|
|
15851
|
+
return this.normalizedHeader;
|
|
15852
|
+
}
|
|
14848
15853
|
/**
|
|
14849
15854
|
* Creates Tableheader based on the configured scenarios (in config)
|
|
14850
15855
|
* the created header is stored in the dataset json
|
|
@@ -15338,7 +16343,6 @@ class Table {
|
|
|
15338
16343
|
this.config = this.initConfig(config);
|
|
15339
16344
|
this.i18n = this.initI18n(new Map());
|
|
15340
16345
|
this.setSource(tableName, config.filter);
|
|
15341
|
-
this.state = FactoryState$3.DIRTY;
|
|
15342
16346
|
}
|
|
15343
16347
|
/**
|
|
15344
16348
|
* Init load of translation dictionary map
|
|
@@ -15413,8 +16417,22 @@ class Table {
|
|
|
15413
16417
|
setConfig(config) {
|
|
15414
16418
|
this.config = this.initConfig(config);
|
|
15415
16419
|
}
|
|
16420
|
+
/**
|
|
16421
|
+
* Resolves the dataset (a table or view in the shared alasql database),
|
|
16422
|
+
* caches its row count, and marks the rows stale.
|
|
16423
|
+
*
|
|
16424
|
+
* Deliberately does NOT build header/body rows. The constructor runs before
|
|
16425
|
+
* the component calls {@link setI18n}, so rows built here would carry the
|
|
16426
|
+
* built-in fallback labels and be thrown away by the first `update()` — the
|
|
16427
|
+
* whole N+1 query pass, run twice per render, for a result that was wrong.
|
|
16428
|
+
*
|
|
16429
|
+
* `fromExpr` and `rowCount` must stay eager: `hasNoData()` reads `rowCount`
|
|
16430
|
+
* and the component consults it before any `getHeader()`/`getBody()` call
|
|
16431
|
+
* would trigger the deferred update.
|
|
16432
|
+
*/
|
|
15416
16433
|
setSource(tableName, filter) {
|
|
15417
16434
|
var _a, _b;
|
|
16435
|
+
this.state = FactoryState$3.DIRTY;
|
|
15418
16436
|
if (!tableName) {
|
|
15419
16437
|
this.fromExpr = "";
|
|
15420
16438
|
this.rowCount = 0;
|
|
@@ -15429,12 +16447,6 @@ class Table {
|
|
|
15429
16447
|
// Table may not exist yet (e.g. datasource hasn't loaded). Treat as empty.
|
|
15430
16448
|
this.rowCount = 0;
|
|
15431
16449
|
}
|
|
15432
|
-
this.prepareIntervalBuckets();
|
|
15433
|
-
const normalizedScenarios = this.normalizeScenarios(this.config.scenarios, this.config.categoryThereOf, this.config.sortOrder, this.intervalBuckets);
|
|
15434
|
-
this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale, this.config.attributes);
|
|
15435
|
-
this.bodyRows =
|
|
15436
|
-
this.rowCount === 0 ? [] : this.dataSetFactory.createBodyRows(this.config, this.i18n, this.db, this.fromExpr);
|
|
15437
|
-
this.state = FactoryState$3.UP_TO_DATE;
|
|
15438
16450
|
}
|
|
15439
16451
|
update() {
|
|
15440
16452
|
this.prepareIntervalBuckets();
|
|
@@ -15458,6 +16470,13 @@ class Table {
|
|
|
15458
16470
|
}
|
|
15459
16471
|
return this.bodyRows;
|
|
15460
16472
|
}
|
|
16473
|
+
/** Effective column definitions: category/operation + attributes + scenarios × interval buckets. */
|
|
16474
|
+
getColumns() {
|
|
16475
|
+
if (this.state === FactoryState$3.DIRTY) {
|
|
16476
|
+
this.update();
|
|
16477
|
+
}
|
|
16478
|
+
return this.dataSetFactory.getNormalizedHeader();
|
|
16479
|
+
}
|
|
15461
16480
|
/**
|
|
15462
16481
|
* Resolves the interval configuration into the concrete bucket list.
|
|
15463
16482
|
* `auto` is narrowed to a concrete granularity (written back to the config so
|
|
@@ -15761,6 +16780,10 @@ const IbcsTable = class {
|
|
|
15761
16780
|
this.filter = "";
|
|
15762
16781
|
this.barColumns = [];
|
|
15763
16782
|
this.interval = "none";
|
|
16783
|
+
/**
|
|
16784
|
+
* Total width of a bar chart column, in em of the table font — the same unit
|
|
16785
|
+
* `categoryWidth` uses, so the two render at the same width for the same value.
|
|
16786
|
+
*/
|
|
15764
16787
|
this.barColumnMaxWidth = 30;
|
|
15765
16788
|
this.unitScaling = 0.01;
|
|
15766
16789
|
this.percentageScaling = 0.5;
|
|
@@ -15768,6 +16791,99 @@ const IbcsTable = class {
|
|
|
15768
16791
|
this.componentDataFormatDigits = new DataFormatDigits();
|
|
15769
16792
|
this.componentStyle = withStyled.withComponentStyle(this);
|
|
15770
16793
|
}
|
|
16794
|
+
/**
|
|
16795
|
+
* Collects the table's layout-state contribution: header/body regions,
|
|
16796
|
+
* counts, and — with `detail: "full"` — per-cell geometry paired with the
|
|
16797
|
+
* table model (values, column keys, in-cell bar charts). Called by the
|
|
16798
|
+
* outer `bn-table`; not for end users.
|
|
16799
|
+
*/
|
|
16800
|
+
async getLayoutDetail(origins, detail) {
|
|
16801
|
+
var _a, _b, _c;
|
|
16802
|
+
const result = { regions: [], metadata: {}, diagnostics: [] };
|
|
16803
|
+
const tableEl = (_a = this.element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("table");
|
|
16804
|
+
result.metadata.hasNoData = (_c = (_b = this.table) === null || _b === void 0 ? void 0 : _b.hasNoData()) !== null && _c !== void 0 ? _c : true;
|
|
16805
|
+
if (!this.table || !tableEl) {
|
|
16806
|
+
return result;
|
|
16807
|
+
}
|
|
16808
|
+
const thead = tableEl.querySelector("thead");
|
|
16809
|
+
const tbody = tableEl.querySelector("tbody");
|
|
16810
|
+
if (thead)
|
|
16811
|
+
result.regions.push({ id: "header", rect: diagnostics.measure(thead, origins) });
|
|
16812
|
+
if (tbody)
|
|
16813
|
+
result.regions.push({ id: "body", rect: diagnostics.measure(tbody, origins) });
|
|
16814
|
+
const headerRows = this.table.getHeader();
|
|
16815
|
+
const bodyRows = this.table.getBody();
|
|
16816
|
+
const columns = this.table.getColumns();
|
|
16817
|
+
result.metadata.headerRowCount = headerRows.length;
|
|
16818
|
+
result.metadata.rowCount = bodyRows.length;
|
|
16819
|
+
result.metadata.columnCount = columns.length;
|
|
16820
|
+
result.metadata.cellCount = bodyRows.reduce((count, row) => count + row.getCells().length, 0);
|
|
16821
|
+
if (detail !== "full") {
|
|
16822
|
+
return result;
|
|
16823
|
+
}
|
|
16824
|
+
const rows = [];
|
|
16825
|
+
const elements = [];
|
|
16826
|
+
const walk = (section, modelRows, container) => {
|
|
16827
|
+
const domRows = container ? Array.from(container.children).filter((child) => child.localName === "tr") : [];
|
|
16828
|
+
modelRows.forEach((row, rowIndex) => {
|
|
16829
|
+
const tr = domRows[rowIndex];
|
|
16830
|
+
if (!tr)
|
|
16831
|
+
return;
|
|
16832
|
+
rows.push({ section, index: rowIndex, type: row.type, rect: diagnostics.measure(tr, origins) });
|
|
16833
|
+
const cells = row.getCells();
|
|
16834
|
+
const domCells = Array.from(tr.children);
|
|
16835
|
+
if (cells.length !== domCells.length) {
|
|
16836
|
+
result.diagnostics.push({
|
|
16837
|
+
id: `LAYOUT_cellPairing_${section}_${rowIndex}`,
|
|
16838
|
+
type: "warning",
|
|
16839
|
+
message: `layout-state: model/DOM cell count mismatch in ${section} row ${rowIndex} (${cells.length} vs ${domCells.length}); cell details skipped for this row.`,
|
|
16840
|
+
});
|
|
16841
|
+
return;
|
|
16842
|
+
}
|
|
16843
|
+
cells.forEach((cell, cellIndex) => {
|
|
16844
|
+
var _a, _b;
|
|
16845
|
+
const domCell = domCells[cellIndex];
|
|
16846
|
+
const entry = {
|
|
16847
|
+
kind: section === "header" ? "headerCell" : "cell",
|
|
16848
|
+
row: rowIndex,
|
|
16849
|
+
column: cell.index,
|
|
16850
|
+
key: cell.key || undefined,
|
|
16851
|
+
colSpan: cell.colSpan,
|
|
16852
|
+
value: (_a = cell.value) !== null && _a !== void 0 ? _a : undefined,
|
|
16853
|
+
text: ((_b = domCell.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
|
|
16854
|
+
type: cell.type || undefined,
|
|
16855
|
+
rect: diagnostics.measure(domCell, origins),
|
|
16856
|
+
};
|
|
16857
|
+
const barSvg = domCell.querySelector("svg.cell-bar-chart");
|
|
16858
|
+
if (barSvg) {
|
|
16859
|
+
entry.bar = {
|
|
16860
|
+
variant: barSvg.classList.contains("waterfall-bar")
|
|
16861
|
+
? "waterfall"
|
|
16862
|
+
: barSvg.classList.contains("relative-variance")
|
|
16863
|
+
? "relative"
|
|
16864
|
+
: "absolute",
|
|
16865
|
+
rect: diagnostics.measure(barSvg, origins),
|
|
16866
|
+
};
|
|
16867
|
+
}
|
|
16868
|
+
elements.push(entry);
|
|
16869
|
+
});
|
|
16870
|
+
});
|
|
16871
|
+
};
|
|
16872
|
+
walk("header", headerRows, thead);
|
|
16873
|
+
walk("body", bodyRows, tbody);
|
|
16874
|
+
result.elements = elements;
|
|
16875
|
+
result.table = {
|
|
16876
|
+
rows,
|
|
16877
|
+
columns: columns.map((column, index) => ({
|
|
16878
|
+
index,
|
|
16879
|
+
key: column.name,
|
|
16880
|
+
group: column.group,
|
|
16881
|
+
type: column.type,
|
|
16882
|
+
bucket: column.bucket,
|
|
16883
|
+
})),
|
|
16884
|
+
};
|
|
16885
|
+
return result;
|
|
16886
|
+
}
|
|
15771
16887
|
render() {
|
|
15772
16888
|
const helper = () => {
|
|
15773
16889
|
if (this.table === undefined) {
|
|
@@ -15779,7 +16895,7 @@ const IbcsTable = class {
|
|
|
15779
16895
|
}
|
|
15780
16896
|
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 &&
|
|
15781
16897
|
cell.columnStats &&
|
|
15782
|
-
(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,
|
|
16898
|
+
(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)))))))))));
|
|
15783
16899
|
};
|
|
15784
16900
|
return index.h(index.Host, null, helper());
|
|
15785
16901
|
}
|
|
@@ -15845,7 +16961,7 @@ const IbcsTable = class {
|
|
|
15845
16961
|
});
|
|
15846
16962
|
}
|
|
15847
16963
|
return this.componentStyle(($) => {
|
|
15848
|
-
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;
|
|
16964
|
+
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;
|
|
15849
16965
|
const varianceStyles = (_a = $["bn-chart-time"]) === null || _a === void 0 ? void 0 : _a["varianceStyles"];
|
|
15850
16966
|
const barStyles = (_b = $["bn-chart-time"]) === null || _b === void 0 ? void 0 : _b["barStyles"];
|
|
15851
16967
|
// Default variance styles with fillpattern
|
|
@@ -15898,26 +17014,32 @@ const IbcsTable = class {
|
|
|
15898
17014
|
},
|
|
15899
17015
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
15900
17016
|
fontColor: ((_z = $["global"]) === null || _z === void 0 ? void 0 : _z["fontColor"]) || "#000000",
|
|
15901
|
-
fontSize: (((_0 = $["global"]) === null || _0 === void 0 ? void 0 : _0["fontSizePx"]) || 13.3333) *
|
|
15902
|
-
|
|
17017
|
+
fontSize: (((_0 = $["global"]) === null || _0 === void 0 ? void 0 : _0["fontSizePx"]) || 13.3333) * BAR_LABEL_FONT_RATIO * this.scaleFactor,
|
|
17018
|
+
emPx: (((_1 = $["global"]) === null || _1 === void 0 ? void 0 : _1["fontSizePx"]) || 13.3333) * this.scaleFactor,
|
|
17019
|
+
fontFamily: ((_2 = $["global"]) === null || _2 === void 0 ? void 0 : _2["fontFamily"]) || "'Noto Sans', sans-serif",
|
|
15903
17020
|
unitScaling: resolvedUnit,
|
|
15904
17021
|
percentageScaling: resolvedPercent,
|
|
15905
17022
|
scaleFactor: this.scaleFactor,
|
|
15906
17023
|
};
|
|
15907
17024
|
});
|
|
15908
17025
|
}
|
|
17026
|
+
/** The table's true em in px — the unit `.category-wN` and the bar columns share. */
|
|
17027
|
+
emPx() {
|
|
17028
|
+
return this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; }) * this.scaleFactor;
|
|
17029
|
+
}
|
|
15909
17030
|
/**
|
|
15910
17031
|
* Auto-calculate unitScaling so the largest absolute variance bar
|
|
15911
|
-
* fills ~80% of the bar
|
|
17032
|
+
* fills ~80% of its side of the bar area, without tripping the overdrive break.
|
|
15912
17033
|
*/
|
|
15913
17034
|
autoUnitScaling() {
|
|
15914
|
-
const
|
|
15915
|
-
const
|
|
15916
|
-
const
|
|
15917
|
-
const absMax = this.getMaxAbsValue();
|
|
17035
|
+
const emPx = this.emPx();
|
|
17036
|
+
const fs = emPx * BAR_LABEL_FONT_RATIO;
|
|
17037
|
+
const { absMax, hasNeg, hasPos } = this.getAbsBarColumnStats();
|
|
15918
17038
|
if (absMax <= 0 || fs <= 0) {
|
|
15919
17039
|
return 0.01;
|
|
15920
17040
|
}
|
|
17041
|
+
const { maxBarWidth, cutWidth } = absoluteBarGeometry(this.barColumnMaxWidth, emPx, hasNeg, hasPos);
|
|
17042
|
+
const targetWidth = Math.min(maxBarWidth * 0.8, cutWidth);
|
|
15921
17043
|
return targetWidth / (absMax * fs);
|
|
15922
17044
|
}
|
|
15923
17045
|
/**
|
|
@@ -15925,52 +17047,47 @@ const IbcsTable = class {
|
|
|
15925
17047
|
* fills ~80% of the pin area.
|
|
15926
17048
|
*/
|
|
15927
17049
|
autoPercentageScaling() {
|
|
15928
|
-
const
|
|
15929
|
-
const
|
|
15930
|
-
const
|
|
15931
|
-
const maxPct = this.getMaxRelativeValue();
|
|
17050
|
+
const emPx = this.emPx();
|
|
17051
|
+
const fs = emPx * BAR_LABEL_FONT_RATIO;
|
|
17052
|
+
const { absMax: maxPct, hasNeg, hasPos } = this.getRelativeBarColumnStats();
|
|
15932
17053
|
if (maxPct <= 0 || fs <= 0) {
|
|
15933
17054
|
return 0.5;
|
|
15934
17055
|
}
|
|
15935
|
-
|
|
17056
|
+
const { maxPinLength } = relativePinGeometry(this.barColumnMaxWidth, emPx, hasNeg, hasPos);
|
|
17057
|
+
return (maxPinLength * 0.8) / (maxPct * fs);
|
|
15936
17058
|
}
|
|
15937
17059
|
/**
|
|
15938
|
-
*
|
|
17060
|
+
* Maximum value and sign coverage across all absolute variance columns (d_*) in the table body.
|
|
17061
|
+
* Sign coverage decides how much of the column the bar area gets (see barColumnGeometry.ts);
|
|
17062
|
+
* OR-ing it across columns keeps the single shared scaling inside the narrowest bar area.
|
|
15939
17063
|
*/
|
|
15940
|
-
|
|
15941
|
-
|
|
15942
|
-
|
|
15943
|
-
let max = 0;
|
|
15944
|
-
for (const row of this.table.getBody()) {
|
|
15945
|
-
if (row.type === TableRowType.SUM)
|
|
15946
|
-
continue;
|
|
15947
|
-
for (const cell of row.getCells()) {
|
|
15948
|
-
// waterfall cells scale independently and must not skew variance auto-scaling
|
|
15949
|
-
if (cell.isBarChart && cell.columnStats && !cell.key.startsWith("dr") && !cell.waterfall) {
|
|
15950
|
-
max = Math.max(max, cell.columnStats.absMax);
|
|
15951
|
-
}
|
|
15952
|
-
}
|
|
15953
|
-
}
|
|
15954
|
-
return max;
|
|
17064
|
+
getAbsBarColumnStats() {
|
|
17065
|
+
// waterfall cells scale independently and must not skew variance auto-scaling
|
|
17066
|
+
return this.collectBarColumnStats((cell) => !cell.key.startsWith("dr") && !cell.waterfall, 1);
|
|
15955
17067
|
}
|
|
15956
17068
|
/**
|
|
15957
|
-
*
|
|
15958
|
-
*
|
|
17069
|
+
* Same for the relative variance columns (dr_*). Values are stored as decimals
|
|
17070
|
+
* (e.g. 0.2 = 20%), returned as percentage (20).
|
|
15959
17071
|
*/
|
|
15960
|
-
|
|
17072
|
+
getRelativeBarColumnStats() {
|
|
17073
|
+
return this.collectBarColumnStats((cell) => cell.key.startsWith("dr"), 100);
|
|
17074
|
+
}
|
|
17075
|
+
collectBarColumnStats(accept, valueFactor) {
|
|
17076
|
+
const stats = { absMax: 0, hasNeg: false, hasPos: false };
|
|
15961
17077
|
if (!this.table)
|
|
15962
|
-
return
|
|
15963
|
-
let max = 0;
|
|
17078
|
+
return stats;
|
|
15964
17079
|
for (const row of this.table.getBody()) {
|
|
15965
17080
|
if (row.type === TableRowType.SUM)
|
|
15966
17081
|
continue;
|
|
15967
17082
|
for (const cell of row.getCells()) {
|
|
15968
|
-
if (cell.isBarChart
|
|
15969
|
-
|
|
15970
|
-
|
|
17083
|
+
if (!cell.isBarChart || !cell.columnStats || !accept(cell))
|
|
17084
|
+
continue;
|
|
17085
|
+
stats.absMax = Math.max(stats.absMax, cell.columnStats.absMax * valueFactor);
|
|
17086
|
+
stats.hasNeg = stats.hasNeg || cell.columnStats.min < 0;
|
|
17087
|
+
stats.hasPos = stats.hasPos || cell.columnStats.max > 0;
|
|
15971
17088
|
}
|
|
15972
17089
|
}
|
|
15973
|
-
return
|
|
17090
|
+
return stats;
|
|
15974
17091
|
}
|
|
15975
17092
|
get element() { return index.getElement(this); }
|
|
15976
17093
|
};
|