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