@bino-bi/bn-template-engine 1.0.0-next.26 → 1.0.0-next.28
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-5075771a.entry.js +1 -0
- package/dist/bn-template-engine/p-5d516435.entry.js +1 -0
- package/dist/bn-template-engine/p-5e90e728.entry.js +1 -0
- package/dist/bn-template-engine/p-9ef7e132.entry.js +1 -0
- package/dist/bn-template-engine/{p-f06c3703.entry.js → p-9f7a1980.entry.js} +1 -1
- package/dist/bn-template-engine/p-BeXgxHkW.js +1 -0
- package/dist/bn-template-engine/p-CH0bpt_k.js +1 -0
- package/dist/bn-template-engine/p-ClruFZD_.js +1 -0
- package/dist/bn-template-engine/{p-CTrNbSXN.js → p-DFmSrSnf.js} +1 -1
- package/dist/bn-template-engine/{p-BcLsoDrW.js → p-DI3efDSV.js} +1 -1
- package/dist/bn-template-engine/p-DXLTTILG.js +1 -0
- package/dist/bn-template-engine/p-DtP4jqG5.js +1 -0
- package/dist/bn-template-engine/p-a8281b71.entry.js +1 -0
- package/dist/bn-template-engine/p-b31277e7.entry.js +1 -0
- package/dist/bn-template-engine/p-b396ac84.entry.js +1 -0
- package/dist/cjs/{bn-asset_21.cjs.entry.js → bn-asset_28.cjs.entry.js} +21358 -6528
- package/dist/cjs/bn-grid.cjs.entry.js +4 -6
- package/dist/cjs/bn-image.cjs.entry.js +3 -5
- package/dist/cjs/bn-internationalization.cjs.entry.js +17 -6
- package/dist/cjs/bn-ruleset.cjs.entry.js +5 -5
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/bn-template.cjs.entry.js +2 -2
- package/dist/cjs/bn-text.cjs.entry.js +115 -43
- package/dist/cjs/{context-protocol-DcTEh1rq.js → context-protocol-C0rKepqu.js} +108 -22
- package/dist/cjs/{diagnostics-CTgbq_Gc.js → diagnostics-Cq-qDtXq.js} +1 -1
- package/dist/cjs/editor-companion.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/queryError-BZjnIW_w.js +16 -0
- package/dist/cjs/{scaling-Dsb5_NXy.js → sanitizeHtml-Yx1xn6i_.js} +467 -287
- package/dist/cjs/{withBodyObserver-DJO98AJ-.js → withBodyObserver-CaPUjuC5.js} +1 -1
- package/dist/cjs/withHasError-qGW_yqIv.js +426 -0
- package/dist/cjs/{withStyled-D0jLwCib.js → withStyled-vSfogp9J.js} +543 -42
- package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.css +37 -0
- package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +53 -28
- package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.css +37 -5
- package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.js +16 -7
- package/dist/collection/components/bn-chart-bubble/utils/BubbleChart.js +67 -30
- package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.css +37 -0
- package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.js +49 -29
- package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.css +37 -5
- package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.js +17 -7
- package/dist/collection/components/bn-chart-bullet/utils/BulletChart.js +34 -18
- package/dist/collection/components/bn-chart-bullet/utils/model/BulletChartStyle.js +2 -0
- package/dist/collection/components/bn-chart-bullet/utils/model/BulletConfig.js +1 -1
- package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.css +37 -0
- package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.js +52 -27
- package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.css +37 -5
- package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.js +16 -7
- package/dist/collection/components/bn-chart-scatter/utils/ScatterChart.js +52 -18
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.css +37 -5
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +74 -44
- package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +60 -19
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +218 -262
- package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +1 -1
- package/dist/collection/components/bn-chart-structure/utils/elements/Needle.js +11 -4
- package/dist/collection/components/bn-chart-structure/utils/elements/StackedBar.js +16 -25
- package/dist/collection/components/bn-chart-structure/utils/model/StructureChartComponentConfig.js +3 -2
- package/dist/collection/components/bn-chart-structure/utils/model/styles/StructureChartStyle.js +2 -0
- package/dist/collection/components/bn-chart-time/bn-chart-time.css +37 -0
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +122 -52
- package/dist/collection/components/bn-chart-time/ibcs-chart-time.css +37 -0
- package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +60 -19
- package/dist/collection/components/bn-chart-time/utils/TimeChart.js +245 -250
- package/dist/collection/components/bn-chart-time/utils/elements/AreaFill.js +1 -1
- package/dist/collection/components/bn-chart-time/utils/elements/Label.js +1 -1
- package/dist/collection/components/bn-chart-time/utils/elements/LineSeries.js +1 -1
- package/dist/collection/components/bn-chart-time/utils/elements/Needle.js +11 -4
- package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +22 -34
- package/dist/collection/components/bn-chart-time/utils/helper/LabelCollisionManager.js +3 -3
- package/dist/collection/components/bn-chart-time/utils/model/TimeChartComponentConfig.js +4 -3
- package/dist/collection/components/bn-chart-time/utils/model/TimeChartDataRow.js +2 -2
- package/dist/collection/components/bn-chart-time/utils/model/styles/TimeChartStyle.js +2 -0
- package/dist/collection/components/bn-component-style/bn-component-style.js +14 -2
- package/dist/collection/components/bn-context/bn-context.js +92 -22
- package/dist/collection/components/bn-dataset/bn-dataset.js +246 -90
- package/dist/collection/components/bn-datasource/bn-datasource.js +169 -77
- package/dist/collection/components/bn-footer/bn-footer.js +6 -6
- package/dist/collection/components/bn-internationalization/bn-internationalization.js +14 -3
- package/dist/collection/components/bn-layout-card/bn-layout-card.js +25 -74
- package/dist/collection/components/bn-layout-page/bn-layout-page.js +59 -71
- package/dist/collection/components/bn-message/bn-message.js +2 -2
- package/dist/collection/components/bn-page/bn-page.css +0 -240
- package/dist/collection/components/bn-page/bn-page.js +14 -4
- package/dist/collection/components/bn-page/pageFormats.js +69 -0
- package/dist/collection/components/bn-ruleset/bn-ruleset.js +2 -2
- package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +7 -7
- package/dist/collection/components/bn-table/bn-table.css +38 -1
- package/dist/collection/components/bn-table/bn-table.js +96 -59
- package/dist/collection/components/bn-table/ibcs-table.css +39 -1
- package/dist/collection/components/bn-table/ibcs-table.js +89 -30
- package/dist/collection/components/bn-table/utils/Table.js +12 -13
- package/dist/collection/components/bn-table/utils/elements/Cell.js +9 -3
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +38 -34
- package/dist/collection/components/bn-table/utils/elements/TableRow.js +2 -1
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +4 -4
- package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +17 -4
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +128 -98
- package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +6 -20
- package/dist/collection/components/bn-table/utils/helper/QueryGroup.js +9 -2
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +2 -2
- package/dist/collection/components/bn-table/utils/model/TableAttribute.js +2 -2
- package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +3 -2
- package/dist/collection/components/bn-template/bn-template.js +1 -1
- package/dist/collection/components/bn-text/bn-text.js +36 -39
- package/dist/collection/components/bn-text/utils/template.js +79 -0
- package/dist/collection/components/bn-title/bn-title.js +10 -4
- package/dist/collection/components/bn-title/ibcs-title/ibcs-title.js +3 -1
- package/dist/collection/components/bn-tree/bn-tree.js +119 -23
- package/dist/collection/components/bn-tree/utils/EdgeRenderer.js +59 -51
- package/dist/collection/components/bn-tree/utils/TreeLayout.js +30 -5
- package/dist/collection/components/bn-tree/utils/TreeParser.js +35 -0
- package/dist/collection/components/editor-companion/editor-companion.js +1 -1
- package/dist/collection/context/context-protocol.js +1 -1
- package/dist/collection/context/scopedDb.js +47 -4
- package/dist/collection/stores/componentStyles.js +39 -0
- package/dist/collection/stores/internationalization.js +15 -13
- package/dist/collection/utils/DateStringFactory.js +17 -15
- package/dist/collection/utils/autoFit.js +2 -2
- package/dist/collection/utils/componentRegister.js +60 -16
- package/dist/collection/utils/constants.js +2 -2
- package/dist/collection/utils/dataAnalyzer.js +9 -12
- package/dist/collection/utils/emptyState.js +21 -0
- package/dist/collection/utils/formatter.js +29 -20
- package/dist/collection/utils/layoutObserver.js +1 -1
- package/dist/collection/utils/layoutState/generic.js +1 -1
- package/dist/collection/utils/layoutState/svgChartElements.js +2 -2
- package/dist/collection/utils/layoutTemplate.js +81 -0
- package/dist/collection/utils/measurementHost.js +2 -2
- package/dist/collection/utils/model/Order.js +1 -1
- package/dist/collection/utils/model/styles/SVGStyle.js +12 -4
- package/dist/collection/utils/parentDimensions.js +35 -3
- package/dist/collection/utils/queryError.js +11 -0
- package/dist/collection/utils/relativeVariance.js +14 -0
- package/dist/collection/utils/sanitizeHtml.js +30 -16
- package/dist/collection/utils/scaling.js +2 -2
- package/dist/collection/utils/stackColors.js +27 -5
- package/dist/collection/utils/stackLayout.js +71 -0
- package/dist/collection/utils/styled/attributes.js +16 -3
- package/dist/collection/utils/styled/style-sheet.js +1 -1
- package/dist/collection/utils/styled/withStyled.js +1 -1
- package/dist/collection/utils/testing/fakeGroup.js +21 -0
- package/dist/collection/utils/testing/mutationObserver.js +44 -0
- package/dist/collection/utils/testing/structureChart.js +26 -0
- package/dist/collection/utils/testing/timeChart.js +28 -0
- package/dist/collection/utils/validate.js +1 -1
- package/dist/collection/utils/withComponentStatus.js +137 -12
- package/dist/collection/utils/withInheritedProps.js +113 -64
- package/dist/collection/utils/withRuleSet.js +10 -7
- package/dist/collection/utils/withTranslation.js +3 -3
- package/dist/collection/utils/xy/FacetGrid.js +1 -1
- package/dist/collection/utils/xy/IsoCurves.js +1 -1
- package/dist/collection/utils/xy/NumericScale.js +46 -15
- package/dist/collection/utils/xy/PointLabeler.js +2 -2
- package/dist/collection/utils/xy/RadiusScale.js +2 -2
- package/dist/collection/utils/xy/SeriesPalette.js +3 -3
- package/dist/collection/utils/xy/VarianceMeasure.js +22 -4
- package/dist/collection/utils/xy/XYFrame.js +4 -4
- package/dist/collection/utils/xy/XYLegend.js +5 -7
- package/dist/collection/utils/xy/checkXYOverflow.js +32 -0
- package/dist/collection/utils/xy/formatXYValue.js +13 -0
- package/dist/collection/utils/xy/model/XYChartDataRow.js +0 -0
- package/dist/collection/utils/xy/model/XYChartStyle.js +2 -0
- package/dist/components/DataFormatDigits.js +1 -1
- package/dist/components/DateStringFactory.js +1 -1
- package/dist/components/LabelCollisionManager.js +1 -1
- package/dist/components/NumericScale.js +1 -1
- package/dist/components/Order.js +1 -1
- package/dist/components/SVGStyle.js +1 -0
- package/dist/components/TableAttribute.js +1 -0
- package/dist/components/VarianceMeasure.js +1 -1
- package/dist/components/XYChartDataRow.js +1 -1
- package/dist/components/bn-asset.js +1 -1
- package/dist/components/bn-body2.js +1 -1
- package/dist/components/bn-card2.js +1 -1
- 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-component-style.js +1 -1
- package/dist/components/bn-context.js +1 -1
- package/dist/components/bn-dataset.js +1 -1
- package/dist/components/bn-datasource.js +1 -1
- package/dist/components/bn-footer2.js +1 -1
- package/dist/components/bn-grid.js +1 -1
- package/dist/components/bn-image.js +1 -1
- package/dist/components/bn-internationalization.js +1 -1
- package/dist/components/bn-layout-card.js +1 -1
- package/dist/components/bn-layout-page.js +1 -1
- package/dist/components/bn-message2.js +1 -1
- package/dist/components/bn-page2.js +1 -1
- package/dist/components/bn-ruleset.js +1 -1
- package/dist/components/bn-scaling-group.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/bn-template.js +1 -1
- package/dist/components/bn-text.js +1 -1
- package/dist/components/bn-title2.js +1 -1
- package/dist/components/bn-tree.js +1 -1
- package/dist/components/checkXYOverflow.js +1 -0
- package/dist/components/context-protocol.js +1 -1
- package/dist/components/editor-companion.js +1 -1
- package/dist/components/emptyState.js +1 -0
- package/dist/components/formatter.js +1 -1
- package/dist/components/ibcs-chart-bubble2.js +1 -1
- package/dist/components/ibcs-chart-bullet2.js +1 -1
- package/dist/components/ibcs-chart-scatter2.js +1 -1
- package/dist/components/ibcs-chart-structure2.js +1 -1
- package/dist/components/ibcs-chart-time2.js +1 -1
- package/dist/components/ibcs-table2.js +1 -1
- package/dist/components/ibcs-title2.js +1 -1
- package/dist/components/layoutTemplate.js +1 -0
- package/dist/components/pageFormats.js +1 -0
- package/dist/components/parentDimensions.js +1 -0
- package/dist/components/queryError.js +1 -0
- package/dist/components/relativeVariance.js +1 -0
- package/dist/components/sanitizeHtml.js +1 -1
- package/dist/components/stackColors.js +1 -1
- package/dist/components/stackLayout.js +1 -0
- package/dist/components/svg.esm.js +1 -0
- package/dist/components/validate.js +1 -1
- package/dist/components/withBodyObserver.js +1 -1
- package/dist/components/withComponentStatus.js +1 -0
- package/dist/components/withComponentStyle.js +1 -1
- package/dist/components/withDataset.js +1 -1
- package/dist/components/withHasError.js +1 -1
- package/dist/components/withRuleSet.js +1 -1
- package/dist/components/withScalingGroup.js +1 -1
- package/dist/components/withStyled.js +1 -1
- package/dist/components/withTranslation.js +1 -1
- package/dist/esm/{bn-asset_21.entry.js → bn-asset_28.entry.js} +20948 -6125
- package/dist/esm/bn-grid.entry.js +4 -6
- package/dist/esm/bn-image.entry.js +3 -5
- package/dist/esm/bn-internationalization.entry.js +17 -6
- package/dist/esm/bn-ruleset.entry.js +5 -5
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/bn-template.entry.js +2 -2
- package/dist/esm/bn-text.entry.js +111 -39
- package/dist/esm/{context-protocol-B-vdGKeG.js → context-protocol-CdTp19uA.js} +106 -22
- package/dist/esm/{diagnostics-CiquIw8B.js → diagnostics-vw6TKMiT.js} +1 -1
- package/dist/esm/editor-companion.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/queryError-ClruFZD_.js +13 -0
- package/dist/esm/{scaling-Dggyeqts.js → sanitizeHtml-C5bFtARM.js} +464 -287
- package/dist/esm/{withBodyObserver-Cb9ZC5_J.js → withBodyObserver-DD_-r04o.js} +1 -1
- package/dist/esm/withHasError-73WV2SP5.js +422 -0
- package/dist/esm/{withStyled-DoNsbwS3.js → withStyled-BDEyKd_H.js} +513 -27
- package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +8 -4
- package/dist/types/components/bn-chart-bubble/ibcs-chart-bubble.d.ts +2 -1
- package/dist/types/components/bn-chart-bubble/utils/BubbleChart.d.ts +14 -2
- package/dist/types/components/bn-chart-bullet/bn-chart-bullet.d.ts +12 -11
- package/dist/types/components/bn-chart-bullet/ibcs-chart-bullet.d.ts +2 -1
- package/dist/types/components/bn-chart-bullet/utils/BulletChart.d.ts +8 -5
- package/dist/types/components/bn-chart-bullet/utils/model/BulletChartStyle.d.ts +2 -0
- package/dist/types/components/bn-chart-bullet/utils/model/BulletConfig.d.ts +1 -1
- package/dist/types/components/bn-chart-scatter/bn-chart-scatter.d.ts +8 -4
- package/dist/types/components/bn-chart-scatter/ibcs-chart-scatter.d.ts +2 -1
- package/dist/types/components/bn-chart-scatter/utils/ScatterChart.d.ts +11 -1
- package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +13 -12
- package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +8 -1
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +29 -6
- package/dist/types/components/bn-chart-structure/utils/elements/StackedBar.d.ts +4 -3
- package/dist/types/components/bn-chart-structure/utils/model/DataPoint.d.ts +3 -2
- package/dist/types/components/bn-chart-structure/utils/model/StructureChartComponentConfig.d.ts +2 -1
- package/dist/types/components/bn-chart-structure/utils/model/styles/StructureChartStyle.d.ts +2 -0
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +19 -15
- package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +8 -1
- package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +63 -5
- package/dist/types/components/bn-chart-time/utils/elements/AreaFill.d.ts +1 -1
- package/dist/types/components/bn-chart-time/utils/elements/StackedColumn.d.ts +9 -8
- package/dist/types/components/bn-chart-time/utils/model/DataPoint.d.ts +3 -2
- package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +3 -2
- package/dist/types/components/bn-chart-time/utils/model/styles/TimeChartStyle.d.ts +2 -0
- package/dist/types/components/bn-context/bn-context.d.ts +15 -3
- package/dist/types/components/bn-dataset/bn-dataset.d.ts +41 -20
- package/dist/types/components/bn-datasource/bn-datasource.d.ts +34 -18
- package/dist/types/components/bn-footer/bn-footer.d.ts +2 -2
- package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +3 -10
- package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +13 -6
- package/dist/types/components/bn-message/bn-message.d.ts +2 -1
- package/dist/types/components/bn-page/bn-page.d.ts +2 -1
- package/dist/types/components/bn-page/pageFormats.d.ts +40 -0
- package/dist/types/components/bn-scaling-group/bn-scaling-group.d.ts +2 -2
- package/dist/types/components/bn-table/bn-table.d.ts +11 -10
- package/dist/types/components/bn-table/ibcs-table.d.ts +8 -5
- package/dist/types/components/bn-table/utils/Table.d.ts +3 -1
- package/dist/types/components/bn-table/utils/elements/Cell.d.ts +2 -2
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +6 -4
- package/dist/types/components/bn-table/utils/elements/WaterfallBar.d.ts +1 -1
- package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +2 -0
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +14 -5
- package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +2 -2
- package/dist/types/components/bn-table/utils/helper/QueryGroup.d.ts +6 -1
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +2 -2
- package/dist/types/components/bn-table/utils/model/TableAttribute.d.ts +2 -0
- package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +2 -1
- package/dist/types/components/bn-text/bn-text.d.ts +20 -13
- package/dist/types/components/bn-text/utils/template.d.ts +10 -0
- package/dist/types/components/bn-title/ibcs-title/ibcs-title.d.ts +1 -0
- package/dist/types/components/bn-tree/bn-tree.d.ts +8 -1
- package/dist/types/components/bn-tree/utils/EdgeRenderer.d.ts +18 -5
- package/dist/types/components/bn-tree/utils/TreeLayout.d.ts +5 -0
- package/dist/types/components.d.ts +226 -184
- package/dist/types/context/scopedDb.d.ts +20 -0
- package/dist/types/stores/componentStyles.d.ts +6 -0
- package/dist/types/utils/DateStringFactory.d.ts +3 -2
- package/dist/types/utils/autoFit.d.ts +2 -2
- package/dist/types/utils/componentRegister.d.ts +21 -5
- package/dist/types/utils/constants.d.ts +2 -2
- package/dist/types/utils/dataAnalyzer.d.ts +1 -1
- package/dist/types/utils/emptyState.d.ts +10 -0
- package/dist/types/utils/formatter.d.ts +7 -9
- package/dist/types/utils/layoutState/generic.d.ts +1 -1
- package/dist/types/utils/layoutState/svgChartElements.d.ts +2 -2
- package/dist/types/utils/layoutTemplate.d.ts +16 -0
- package/dist/types/utils/model/ChartStyles.d.ts +1 -1
- package/dist/types/utils/model/DataQueryResultRow.d.ts +2 -2
- package/dist/types/utils/model/Order.d.ts +1 -1
- package/dist/types/utils/model/styles/SVGStyle.d.ts +5 -1
- package/dist/types/utils/parentDimensions.d.ts +9 -0
- package/dist/types/utils/queryError.d.ts +5 -0
- package/dist/types/utils/relativeVariance.d.ts +9 -0
- package/dist/types/utils/sanitizeHtml.d.ts +2 -2
- package/dist/types/utils/scaling.d.ts +1 -1
- package/dist/types/utils/stackColors.d.ts +3 -2
- package/dist/types/utils/stackLayout.d.ts +49 -0
- package/dist/types/utils/testing/fakeGroup.d.ts +8 -0
- package/dist/types/utils/testing/mutationObserver.d.ts +5 -0
- package/dist/types/utils/testing/structureChart.d.ts +5 -0
- package/dist/types/utils/testing/timeChart.d.ts +5 -0
- package/dist/types/utils/validate.d.ts +1 -1
- package/dist/types/utils/withComponentStatus.d.ts +11 -3
- package/dist/types/utils/withInheritedProps.d.ts +42 -15
- package/dist/types/utils/withRuleSet.d.ts +2 -1
- package/dist/types/utils/withTranslation.d.ts +2 -2
- package/dist/types/utils/xy/FacetGrid.d.ts +1 -1
- package/dist/types/utils/xy/IsoCurves.d.ts +1 -1
- package/dist/types/utils/xy/NumericScale.d.ts +9 -4
- package/dist/types/utils/xy/PointLabeler.d.ts +2 -2
- package/dist/types/utils/xy/RadiusScale.d.ts +2 -2
- package/dist/types/utils/xy/SeriesPalette.d.ts +3 -3
- package/dist/types/utils/xy/VarianceMeasure.d.ts +10 -2
- package/dist/types/utils/xy/XYFrame.d.ts +4 -1
- package/dist/types/utils/xy/XYLegend.d.ts +3 -1
- package/dist/types/utils/xy/checkXYOverflow.d.ts +8 -0
- package/dist/types/utils/xy/formatXYValue.d.ts +7 -0
- package/dist/types/utils/xy/model/AxisConfig.d.ts +1 -1
- package/dist/types/utils/xy/model/XYChartStyle.d.ts +2 -0
- package/package.json +4 -2
- package/readme.md +11 -11
- package/dist/bn-template-engine/p-03304284.entry.js +0 -1
- package/dist/bn-template-engine/p-0fb02c57.entry.js +0 -1
- package/dist/bn-template-engine/p-4419db8f.entry.js +0 -1
- package/dist/bn-template-engine/p-45508f1b.entry.js +0 -1
- package/dist/bn-template-engine/p-461fdffa.entry.js +0 -1
- package/dist/bn-template-engine/p-5d7a3a77.entry.js +0 -1
- package/dist/bn-template-engine/p-62cc95b7.entry.js +0 -1
- package/dist/bn-template-engine/p-686d8e44.entry.js +0 -1
- package/dist/bn-template-engine/p-829212c3.entry.js +0 -1
- package/dist/bn-template-engine/p-B5Jd_eCX.js +0 -1
- package/dist/bn-template-engine/p-BA48JiHe.js +0 -1
- package/dist/bn-template-engine/p-BbmobTg0.js +0 -1
- package/dist/bn-template-engine/p-BcaI745G.js +0 -1
- package/dist/bn-template-engine/p-CG_Bcm6V.js +0 -1
- package/dist/bn-template-engine/p-CWWWM-XC.js +0 -1
- package/dist/bn-template-engine/p-CsJ84YRk.js +0 -1
- package/dist/bn-template-engine/p-D5e8I9Qe.js +0 -1
- package/dist/bn-template-engine/p-DVrDYxlh.js +0 -1
- package/dist/bn-template-engine/p-DjPXefnq.js +0 -1
- package/dist/bn-template-engine/p-DsTzlzxQ.js +0 -1
- package/dist/bn-template-engine/p-DtLI_CzV.js +0 -1
- package/dist/bn-template-engine/p-EtT29btN.js +0 -1
- package/dist/bn-template-engine/p-TuLpbB5O.js +0 -1
- package/dist/bn-template-engine/p-a5867a4c.entry.js +0 -1
- package/dist/bn-template-engine/p-b27009eb.entry.js +0 -1
- package/dist/bn-template-engine/p-bfa87b07.entry.js +0 -1
- package/dist/bn-template-engine/p-ceb80db3.entry.js +0 -1
- package/dist/bn-template-engine/p-fcfbb329.entry.js +0 -1
- package/dist/bn-template-engine/p-qRZrT-U3.js +0 -1
- package/dist/cjs/AxisConfig-DwiNUyYG.js +0 -233
- package/dist/cjs/LabelCollisionManager-Bv-xkeXw.js +0 -415
- package/dist/cjs/NumericScale-BAyYXpKL.js +0 -107
- package/dist/cjs/Order-2wRydarc.js +0 -87
- package/dist/cjs/SVGStyle-DoxylrEQ.js +0 -8219
- package/dist/cjs/SVGVariancesStyleGroup-CiI4GeWe.js +0 -50
- package/dist/cjs/VarianceMeasure-CQlSRzlp.js +0 -372
- package/dist/cjs/XYChartDataRow-C2FdL58s.js +0 -829
- package/dist/cjs/bn-chart-bubble.cjs.entry.js +0 -792
- package/dist/cjs/bn-chart-bullet.cjs.entry.js +0 -805
- package/dist/cjs/bn-chart-scatter.cjs.entry.js +0 -678
- package/dist/cjs/bn-tree.cjs.entry.js +0 -1042
- package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +0 -624
- package/dist/cjs/ibcs-chart-bullet.cjs.entry.js +0 -673
- package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +0 -667
- package/dist/cjs/sanitizeHtml-LuZr1IMd.js +0 -85
- package/dist/cjs/svgChartElements-tDA43aYj.js +0 -400
- package/dist/cjs/withHasError-BdDmiOXM.js +0 -258
- package/dist/cjs/withScalingGroup-CFIc5-6s.js +0 -73
- package/dist/components/autoFit.js +0 -1
- package/dist/components/main.js +0 -1
- package/dist/components/utils.js +0 -1
- package/dist/esm/AxisConfig-KqzWQbML.js +0 -224
- package/dist/esm/LabelCollisionManager-585bQMtP.js +0 -407
- package/dist/esm/NumericScale-DsTzlzxQ.js +0 -105
- package/dist/esm/Order-DZVWjEL_.js +0 -83
- package/dist/esm/SVGStyle-OrPkzjcb.js +0 -8209
- package/dist/esm/SVGVariancesStyleGroup-DO5QJfRQ.js +0 -48
- package/dist/esm/VarianceMeasure-DDjChp8C.js +0 -364
- package/dist/esm/XYChartDataRow-Dn83Tqh9.js +0 -820
- package/dist/esm/bn-chart-bubble.entry.js +0 -790
- package/dist/esm/bn-chart-bullet.entry.js +0 -803
- package/dist/esm/bn-chart-scatter.entry.js +0 -676
- package/dist/esm/bn-tree.entry.js +0 -1040
- package/dist/esm/ibcs-chart-bubble.entry.js +0 -622
- package/dist/esm/ibcs-chart-bullet.entry.js +0 -671
- package/dist/esm/ibcs-chart-scatter.entry.js +0 -665
- package/dist/esm/sanitizeHtml-BA48JiHe.js +0 -83
- package/dist/esm/svgChartElements-B3YClivG.js +0 -395
- package/dist/esm/withHasError-Bh1Viz52.js +0 -254
- package/dist/esm/withScalingGroup-DNBSqRC0.js +0 -71
|
@@ -7,16 +7,21 @@ import { LabelCollisionManager, SCENARIO_PRIORITY } from "./helper";
|
|
|
7
7
|
import CalculateSize from "calculate-size";
|
|
8
8
|
import { ScaleFactorsTimeChart } from "./model/styles/ScaleFactorsTimeChart";
|
|
9
9
|
import { DateTime } from "luxon";
|
|
10
|
-
import {
|
|
10
|
+
import { sourceExpr } from "../../../context/scopedDb";
|
|
11
|
+
import { errorText } from "../../../utils/queryError";
|
|
11
12
|
import { DateDistance, DateStringFactory } from "../../../utils/DateStringFactory";
|
|
12
13
|
import { AxisLabelsMode, ChartMode, RELATIVE_STACK_UNITS, StackBy, StackMode, } from "../../../utils/constants";
|
|
13
14
|
import { getScenarioPrefix, IBCS_LAYER_ORDER } from "../../../utils/stackColors";
|
|
15
|
+
import { layoutStack, stackExtent, stackLabelSide } from "../../../utils/stackLayout";
|
|
14
16
|
import { computePercentBarExtent, computeUnitBarExtent } from "../../../utils/autoFit";
|
|
15
17
|
import { drawAttached } from "../../../utils/measurementHost";
|
|
16
18
|
import { Formatter } from "../../../utils";
|
|
17
19
|
import { IBCSRuleSet } from "../../../utils/ibcsRuleSet";
|
|
20
|
+
import { relativeVariance } from "../../../utils/relativeVariance";
|
|
18
21
|
import { VarianceScenario } from "../../../utils/model";
|
|
19
22
|
import { SiPrefix } from "../../../utils/model/SiPrefix";
|
|
23
|
+
/** Above this many periods between the first and the last date, gaps are not filled with empty periods. */
|
|
24
|
+
const MAX_GAP_FILLED_PERIODS = 10000;
|
|
20
25
|
/** Tracks whether the internal data model needs to be regenerated. */
|
|
21
26
|
var FactoryState;
|
|
22
27
|
(function (FactoryState) {
|
|
@@ -205,6 +210,17 @@ export class TimeChart {
|
|
|
205
210
|
this.stackConfig = config.stackConfig;
|
|
206
211
|
this.lineFullWidth = config.lineFullWidth;
|
|
207
212
|
this.lastScenarios = scenarios;
|
|
213
|
+
if (this.stackConfig != null) {
|
|
214
|
+
// a stack is as high as its two sides, not as its largest segment: virtual data points for the layout
|
|
215
|
+
const layouts = [];
|
|
216
|
+
for (const row of this.dataModel) {
|
|
217
|
+
layouts.push(...this.stackGroups(row).map((group) => group.layout));
|
|
218
|
+
}
|
|
219
|
+
const sides = stackExtent(layouts);
|
|
220
|
+
const { scenario, variance } = this.highestDataPointValue;
|
|
221
|
+
this.highestDataPointValue = new DataPoint(sides.positive, scenario, this.pixelPerUnit, variance);
|
|
222
|
+
this.smallestDataPointValue = new DataPoint(0 - sides.negative, scenario, this.pixelPerUnit, variance);
|
|
223
|
+
}
|
|
208
224
|
this.updatePosition(scenarios);
|
|
209
225
|
}
|
|
210
226
|
getFooter() {
|
|
@@ -238,7 +254,7 @@ export class TimeChart {
|
|
|
238
254
|
setI18n(i18n) {
|
|
239
255
|
this.i18n = this.createI18n(i18n);
|
|
240
256
|
// The variance title bakes translated scenario labels in, and setI18n
|
|
241
|
-
// arrives after the constructor's setConfig
|
|
257
|
+
// arrives after the constructor's setConfig - recompute it here so the
|
|
242
258
|
// first render doesn't keep the built-in labels (e.g. ΔPY vs ΔVorjahr).
|
|
243
259
|
this.updateTitle();
|
|
244
260
|
}
|
|
@@ -249,28 +265,37 @@ export class TimeChart {
|
|
|
249
265
|
}
|
|
250
266
|
/**
|
|
251
267
|
* Resolves the dataset (a table or view in the shared alasql database) and
|
|
252
|
-
* caches its row count. Subsequent queries reference the source by name
|
|
268
|
+
* caches its row count. Subsequent queries reference the source by name -
|
|
253
269
|
* alasql doesn't have to ingest a fresh array per call.
|
|
254
270
|
*/
|
|
255
271
|
setSource(filter) {
|
|
256
272
|
var _a, _b;
|
|
257
273
|
this.state = FactoryState.DIRTY;
|
|
258
|
-
|
|
259
|
-
|
|
274
|
+
this.queryError = undefined;
|
|
275
|
+
// "" while the source is not registered yet: no data, and no error
|
|
276
|
+
this.fromExpr = sourceExpr(this.db, this.tableName, filter);
|
|
277
|
+
if (!this.fromExpr) {
|
|
260
278
|
this.rowCount = 0;
|
|
261
279
|
return;
|
|
262
280
|
}
|
|
263
|
-
this.fromExpr = buildFromExpr(this.tableName, filter);
|
|
264
281
|
try {
|
|
265
282
|
const r = this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);
|
|
266
283
|
this.rowCount = ((_b = (_a = r[0]) === null || _a === void 0 ? void 0 : _a.cnt) !== null && _b !== void 0 ? _b : 0);
|
|
267
284
|
}
|
|
268
|
-
catch (
|
|
285
|
+
catch (e) {
|
|
269
286
|
this.rowCount = 0;
|
|
287
|
+
this.failQuery(e);
|
|
270
288
|
}
|
|
271
289
|
}
|
|
290
|
+
getQueryError() {
|
|
291
|
+
return this.queryError;
|
|
292
|
+
}
|
|
293
|
+
failQuery(e) {
|
|
294
|
+
var _a;
|
|
295
|
+
(_a = this.queryError) !== null && _a !== void 0 ? _a : (this.queryError = errorText(e));
|
|
296
|
+
}
|
|
272
297
|
getAllocatedCanvasWidth() {
|
|
273
|
-
// Analytical calculation
|
|
298
|
+
// Analytical calculation - doesn't rely on text bbox (unreliable in detached SVGs)
|
|
274
299
|
const axisEnd = this.position.getAxisEndPositionX();
|
|
275
300
|
// Buffer for the last date label extending beyond axis end
|
|
276
301
|
const labelBuffer = this.styles.fontStyles.size * 3;
|
|
@@ -286,7 +311,7 @@ export class TimeChart {
|
|
|
286
311
|
this.highestDataPointValue.value == null) {
|
|
287
312
|
return 0;
|
|
288
313
|
}
|
|
289
|
-
// Analytical calculation
|
|
314
|
+
// Analytical calculation - doesn't rely on text bbox
|
|
290
315
|
const isRelative = this.isVarianceChart() &&
|
|
291
316
|
this.variancesDataModel.some((e) => e.type === VarianceType.RELATIVE);
|
|
292
317
|
const axisY = this.position.getAxisPositionY(isRelative);
|
|
@@ -294,7 +319,7 @@ export class TimeChart {
|
|
|
294
319
|
const belowAxis = this.position.spacings.labelToAxis + this.position.dataLabelHeight + this.styles.padding.bottom;
|
|
295
320
|
let analyticalHeight;
|
|
296
321
|
if (!this.isOnSameAxisSide()) {
|
|
297
|
-
// Bars extend below axis
|
|
322
|
+
// Bars extend below axis - account for negative bar + its data label
|
|
298
323
|
const min = this.isVarianceChart() ? this.smallestVarianceDataPointValue : this.smallestDataPointValue;
|
|
299
324
|
const minScaled = Math.abs(min.getScaledUnit());
|
|
300
325
|
analyticalHeight =
|
|
@@ -317,18 +342,16 @@ export class TimeChart {
|
|
|
317
342
|
* to separate fixed from variable height components.
|
|
318
343
|
*/
|
|
319
344
|
getUnitBarExtent() {
|
|
320
|
-
var _a, _b
|
|
345
|
+
var _a, _b;
|
|
321
346
|
const isRelative = this.isVarianceChart() &&
|
|
322
347
|
this.variancesDataModel.some((e) => e.type === VarianceType.RELATIVE);
|
|
323
348
|
const usesVariance = this.isVarianceChart();
|
|
324
349
|
const highest = usesVariance ? this.highestVarianceDataPointValue : this.highestDataPointValue;
|
|
325
350
|
const smallest = usesVariance ? this.smallestVarianceDataPointValue : this.smallestDataPointValue;
|
|
326
351
|
return computeUnitBarExtent({
|
|
327
|
-
// Relative stacks span exactly RELATIVE_STACK_UNITS * ppu
|
|
328
|
-
fixedDomain: ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) === StackMode.RELATIVE ? RELATIVE_STACK_UNITS : undefined,
|
|
329
352
|
relativeVariance: isRelative,
|
|
330
|
-
maxPositive: (
|
|
331
|
-
minNegative: this.isOnSameAxisSide() ? 0 : ((
|
|
353
|
+
maxPositive: (_a = highest === null || highest === void 0 ? void 0 : highest.value) !== null && _a !== void 0 ? _a : 0,
|
|
354
|
+
minNegative: this.isOnSameAxisSide() ? 0 : ((_b = smallest === null || smallest === void 0 ? void 0 : smallest.value) !== null && _b !== void 0 ? _b : 0),
|
|
332
355
|
});
|
|
333
356
|
}
|
|
334
357
|
/**
|
|
@@ -346,7 +369,7 @@ export class TimeChart {
|
|
|
346
369
|
});
|
|
347
370
|
}
|
|
348
371
|
/**
|
|
349
|
-
* Runs `draw()` purely for its side effects
|
|
372
|
+
* Runs `draw()` purely for its side effects - it is what finalizes the
|
|
350
373
|
* positions and the allocated-area fields that `getAllocatedCanvas*()` read.
|
|
351
374
|
*
|
|
352
375
|
* The auto-fit solver measures the chart once per iteration and only needs
|
|
@@ -373,13 +396,13 @@ export class TimeChart {
|
|
|
373
396
|
* its own takes whatever its ancestor chain supplies. That chain is not stable
|
|
374
397
|
* across the places this SVG gets measured: drawn detached, svg.js's `bbox()`
|
|
375
398
|
* clones the element into a sandbox under `document.body`, where it inherits
|
|
376
|
-
* the document default
|
|
399
|
+
* the document default - 16px Times - instead of the chart's real font. Every
|
|
377
400
|
* label was measured ~9% too wide as a result, which over-allocated label
|
|
378
401
|
* space and pushed labels past the `maxWidth` threshold that drops them.
|
|
379
402
|
*
|
|
380
403
|
* Setting the font here makes a measurement independent of where it happens.
|
|
381
404
|
* Stylesheet rules still win over presentation attributes, so this changes
|
|
382
|
-
* nothing about how the chart renders in place
|
|
405
|
+
* nothing about how the chart renders in place - the CSS and this attribute
|
|
383
406
|
* resolve to the same value, both being `fontSizePx * effectiveScaleFactor`.
|
|
384
407
|
*/
|
|
385
408
|
applyFontToContainer(svgContainer) {
|
|
@@ -493,7 +516,6 @@ export class TimeChart {
|
|
|
493
516
|
return new Map([...defaultI18n, ...i18n]);
|
|
494
517
|
}
|
|
495
518
|
createElementPosition(scenarios) {
|
|
496
|
-
var _a;
|
|
497
519
|
let maxLabelLengthLeft;
|
|
498
520
|
// only need scenarios written on the leftside of bar/ marker
|
|
499
521
|
const scenarioLabelLeft = CalculateSize(scenarios
|
|
@@ -529,12 +551,6 @@ export class TimeChart {
|
|
|
529
551
|
min = this.smallestDataPointValue;
|
|
530
552
|
max = this.highestDataPointValue;
|
|
531
553
|
}
|
|
532
|
-
// In relative (100%) stacking the vertical domain is 0..RELATIVE_STACK_UNITS percent,
|
|
533
|
-
// not the raw data values — use a virtual max so axis position, canvas height and
|
|
534
|
-
// auto-fit all agree on the percent domain.
|
|
535
|
-
if (((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) === StackMode.RELATIVE) {
|
|
536
|
-
max = new DataPoint(RELATIVE_STACK_UNITS, max.scenario, this.pixelPerUnit, max.variance);
|
|
537
|
-
}
|
|
538
554
|
// When overflow config is active, create a virtual max so the coordinate system
|
|
539
555
|
// allocates exactly cutHeight + breakGap + overdriveZoneHeight instead of the
|
|
540
556
|
// full (clipped) bar height.
|
|
@@ -632,46 +648,51 @@ export class TimeChart {
|
|
|
632
648
|
});
|
|
633
649
|
}
|
|
634
650
|
findDateInterval(dateInterval) {
|
|
635
|
-
var _a, _b, _c;
|
|
636
651
|
if (dateInterval !== DateDistance.AUTO) {
|
|
637
652
|
return dateInterval;
|
|
638
653
|
}
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
localDateInterval = new DateStringFactory().calculateDistanceType((_b = resultMinMax[0]) === null || _b === void 0 ? void 0 : _b.mindate, (_c = resultMinMax[0]) === null || _c === void 0 ? void 0 : _c.maxdate, this.intervalSpanLimit);
|
|
654
|
+
const dates = this.queryDates();
|
|
655
|
+
if (dates.length === 0) {
|
|
656
|
+
return DateDistance.DAY;
|
|
643
657
|
}
|
|
644
|
-
|
|
658
|
+
// a loop, not DateTime.min(...dates): a spread of some 100000 dates exceeds the argument limit
|
|
659
|
+
let first = dates[0];
|
|
660
|
+
let last = dates[0];
|
|
661
|
+
for (const date of dates) {
|
|
662
|
+
if (date < first)
|
|
663
|
+
first = date;
|
|
664
|
+
if (date > last)
|
|
665
|
+
last = date;
|
|
666
|
+
}
|
|
667
|
+
return new DateStringFactory().calculateDistanceType(first, last, this.intervalSpanLimit);
|
|
645
668
|
}
|
|
646
|
-
|
|
647
|
-
|
|
669
|
+
/** Distinct dates of the filtered rows. Min and max are taken in JS: alasql MIN/MAX skip ISO strings. */
|
|
670
|
+
queryDates() {
|
|
671
|
+
// no source, no rows, or the count query has failed already
|
|
672
|
+
if (this.rowCount === 0) {
|
|
673
|
+
return [];
|
|
674
|
+
}
|
|
648
675
|
let result;
|
|
649
676
|
try {
|
|
650
|
-
result = this.db.exec(`SELECT
|
|
677
|
+
result = this.db.exec(`SELECT DISTINCT [date] FROM ${this.fromExpr}`);
|
|
651
678
|
}
|
|
652
679
|
catch (e) {
|
|
653
|
-
|
|
654
|
-
return [
|
|
680
|
+
this.failQuery(e);
|
|
681
|
+
return [];
|
|
655
682
|
}
|
|
656
683
|
// `date` rows in the shared db are typically ISO strings (raw JSON) or millis;
|
|
657
684
|
// accept both so existing fixtures and live JSON data both work.
|
|
658
|
-
|
|
659
|
-
result[0].mindate = TimeChart.coerceDateTime(result[0].mindate);
|
|
660
|
-
}
|
|
661
|
-
if (((_b = result[0]) === null || _b === void 0 ? void 0 : _b.maxdate) != null) {
|
|
662
|
-
result[0].maxdate = TimeChart.coerceDateTime(result[0].maxdate);
|
|
663
|
-
}
|
|
664
|
-
return result;
|
|
685
|
+
return result.map((row) => TimeChart.coerceDateTime(row.date)).filter((date) => date != null);
|
|
665
686
|
}
|
|
666
687
|
static coerceDateTime(v) {
|
|
667
688
|
if (v == null)
|
|
668
689
|
return undefined;
|
|
669
690
|
if (typeof v === "string") {
|
|
670
|
-
const dt = DateTime.fromISO(v);
|
|
691
|
+
const dt = DateTime.fromISO(v, { zone: "utc" });
|
|
671
692
|
return dt.isValid ? dt : undefined;
|
|
672
693
|
}
|
|
673
694
|
if (typeof v === "number") {
|
|
674
|
-
const dt = DateTime.fromMillis(v);
|
|
695
|
+
const dt = DateTime.fromMillis(v, { zone: "utc" });
|
|
675
696
|
return dt.isValid ? dt : undefined;
|
|
676
697
|
}
|
|
677
698
|
if (typeof v.isValid === "boolean") {
|
|
@@ -730,7 +751,7 @@ export class TimeChart {
|
|
|
730
751
|
ORDER BY ${"calcdate asc"}`);
|
|
731
752
|
}
|
|
732
753
|
catch (e) {
|
|
733
|
-
|
|
754
|
+
this.failQuery(e);
|
|
734
755
|
return [];
|
|
735
756
|
}
|
|
736
757
|
return result;
|
|
@@ -822,7 +843,8 @@ export class TimeChart {
|
|
|
822
843
|
}
|
|
823
844
|
const isRelativeVariance = scenarios.type === VarianceType.RELATIVE;
|
|
824
845
|
if (isRelativeVariance) {
|
|
825
|
-
|
|
846
|
+
// NaN marks a bucket without data and stays empty; undefined is a reference of 0 and is shown as "n/a"
|
|
847
|
+
return relativeVariance(element[scenarioBase].value - element[scenarioDelta].value, element[scenarioDelta].value);
|
|
826
848
|
}
|
|
827
849
|
else {
|
|
828
850
|
return element[scenarioBase].value - element[scenarioDelta].value;
|
|
@@ -854,18 +876,45 @@ export class TimeChart {
|
|
|
854
876
|
factory.setLocale(this.locale);
|
|
855
877
|
return factory;
|
|
856
878
|
}
|
|
879
|
+
/**
|
|
880
|
+
* Side of the axis and distance from it for the date label of one period: opposite the
|
|
881
|
+
* value, and for a stack opposite its total and behind the segments on that side.
|
|
882
|
+
*/
|
|
883
|
+
dateLabelPlace(elements) {
|
|
884
|
+
let flipped = elements["scenario1"]["value"] < 0;
|
|
885
|
+
let offset = this.position.spacings.labelToAxis;
|
|
886
|
+
if (this.stackConfig != null && !this.isVarianceChart()) {
|
|
887
|
+
// a column stack prints its total behind its segments, a 100 % stack and the area print none
|
|
888
|
+
const printsTotal = this.stackConfig.mode !== StackMode.RELATIVE && this.determineEffectiveChartMode() !== ChartMode.LINE;
|
|
889
|
+
const totalLabelRoom = printsTotal
|
|
890
|
+
? (this.position.spacings.labelToColumn + this.position.dataLabelHeight) / this.pixelPerUnit
|
|
891
|
+
: 0;
|
|
892
|
+
const layouts = this.stackGroups(elements)
|
|
893
|
+
.filter((group) => group.hasValue)
|
|
894
|
+
.map((group) => group.layout);
|
|
895
|
+
let side = stackLabelSide(layouts, () => totalLabelRoom);
|
|
896
|
+
// Above the columns the layout has room for one label, below for two. A date label that
|
|
897
|
+
// would go above the total label of a back stack goes below instead, under everything there.
|
|
898
|
+
if (side.flipped && totalLabelRoom > 0 && layouts.some((layout) => layout.total >= 0)) {
|
|
899
|
+
side = {
|
|
900
|
+
flipped: false,
|
|
901
|
+
clearance: Math.max(...layouts.map((layout) => layout.negative + (layout.total < 0 ? totalLabelRoom : 0))),
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
flipped = side.flipped;
|
|
905
|
+
offset += side.clearance * this.pixelPerUnit;
|
|
906
|
+
}
|
|
907
|
+
return flipped
|
|
908
|
+
? { hookLocation: HookLocation.Bottom, offset: -offset }
|
|
909
|
+
: { hookLocation: HookLocation.Top, offset };
|
|
910
|
+
}
|
|
857
911
|
drawAxisAndLabels(dataModel, svgContainer) {
|
|
858
912
|
const dateStringFactory = this.createDateFactory();
|
|
859
913
|
const axisLabelGroup = svgContainer.group().id("AxisAndDateLables");
|
|
860
914
|
let isRelative = false;
|
|
861
915
|
if (this.hideAxisLabels === false) {
|
|
862
916
|
dataModel.forEach((elements, index) => {
|
|
863
|
-
|
|
864
|
-
let offset = this.position.spacings.labelToAxis;
|
|
865
|
-
if (elements["scenario1"]["value"] < 0) {
|
|
866
|
-
hookLocation = HookLocation.Bottom;
|
|
867
|
-
offset *= -1;
|
|
868
|
-
}
|
|
917
|
+
const { hookLocation, offset } = this.dateLabelPlace(elements);
|
|
869
918
|
if (elements["type"] === VarianceType.RELATIVE) {
|
|
870
919
|
isRelative = true;
|
|
871
920
|
}
|
|
@@ -959,7 +1008,7 @@ export class TimeChart {
|
|
|
959
1008
|
}
|
|
960
1009
|
}
|
|
961
1010
|
// Sort by z-order: lowest priority first so SVG groups are created in correct render order
|
|
962
|
-
// PL(4) → FC(3) → PP(2) → AC(1)
|
|
1011
|
+
// PL(4) → FC(3) → PP(2) → AC(1) - AC geometry on top of PP geometry
|
|
963
1012
|
scenarios.sort((a, b) => {
|
|
964
1013
|
const pa = SCENARIO_PRIORITY[a.scenarioType] || 99;
|
|
965
1014
|
const pb = SCENARIO_PRIORITY[b.scenarioType] || 99;
|
|
@@ -1009,13 +1058,8 @@ export class TimeChart {
|
|
|
1009
1058
|
if (!this.shouldShowLineChartAxisLabel(dataModel, index)) {
|
|
1010
1059
|
return;
|
|
1011
1060
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
if (elements["scenario1"]["value"] < 0) {
|
|
1015
|
-
hookLocation = HookLocation.Bottom;
|
|
1016
|
-
offset *= -1;
|
|
1017
|
-
}
|
|
1018
|
-
// Get the date label — use smart/short logic when full-width shows all labels
|
|
1061
|
+
const { hookLocation, offset } = this.dateLabelPlace(elements);
|
|
1062
|
+
// Get the date label - use smart/short logic when full-width shows all labels
|
|
1019
1063
|
let datelabel;
|
|
1020
1064
|
if (this.lineFullWidth && this.availableWidth > 0) {
|
|
1021
1065
|
if (this.axisLabelsMode === AxisLabelsMode.SMART) {
|
|
@@ -1077,6 +1121,10 @@ export class TimeChart {
|
|
|
1077
1121
|
if (!currentDate || !previousDate) {
|
|
1078
1122
|
return false;
|
|
1079
1123
|
}
|
|
1124
|
+
// a week belongs to its ISO week year, which is also what its label shows
|
|
1125
|
+
if (this.dateInterval === DateDistance.WEEK) {
|
|
1126
|
+
return currentDate.weekYear !== previousDate.weekYear;
|
|
1127
|
+
}
|
|
1080
1128
|
return currentDate.year !== previousDate.year;
|
|
1081
1129
|
}
|
|
1082
1130
|
drawYearSeparatorLine(group, index, isRelative) {
|
|
@@ -1128,97 +1176,99 @@ export class TimeChart {
|
|
|
1128
1176
|
});
|
|
1129
1177
|
}
|
|
1130
1178
|
/**
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1133
|
-
*
|
|
1134
|
-
* back-to-front per IBCS convention (PL behind, AC on top).
|
|
1179
|
+
* The stacks of one period as they are drawn. Columns: one stack per scenario family
|
|
1180
|
+
* when the period mixes several (overlay, back to front per IBCS layer order), else a
|
|
1181
|
+
* single one. Line mode: the area stacks every scenario in one stack.
|
|
1135
1182
|
*/
|
|
1136
|
-
|
|
1183
|
+
stackGroups(row) {
|
|
1137
1184
|
if (!this.stackConfig)
|
|
1138
|
-
return;
|
|
1139
|
-
const stackGroup = svgContainer.group().id("StackedScenarios");
|
|
1185
|
+
return [];
|
|
1140
1186
|
const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
this.sortSegmentsByPropOrder(segments);
|
|
1187
|
+
const isArea = this.determineEffectiveChartMode() === ChartMode.LINE;
|
|
1188
|
+
const segments = [];
|
|
1189
|
+
for (const key of isScenarioStack || isArea
|
|
1190
|
+
? ["scenario1", "scenario2", "scenario3", "scenario4"]
|
|
1191
|
+
: ["scenario1"]) {
|
|
1192
|
+
const dp = row[key];
|
|
1193
|
+
if (dp && !dp.isEmpty() && dp.value != null) {
|
|
1194
|
+
segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
|
|
1152
1195
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1196
|
+
}
|
|
1197
|
+
if (segments.length === 0)
|
|
1198
|
+
return [];
|
|
1199
|
+
const relativeSpan = this.stackConfig.mode === StackMode.RELATIVE ? RELATIVE_STACK_UNITS : 0;
|
|
1200
|
+
const toGroup = (prefix, groupSegments) => ({
|
|
1201
|
+
prefix,
|
|
1202
|
+
segments: groupSegments,
|
|
1203
|
+
layout: layoutStack(groupSegments.map((segment) => segment.value), relativeSpan),
|
|
1204
|
+
hasValue: groupSegments.some((segment) => Number.isFinite(segment.value)),
|
|
1205
|
+
});
|
|
1206
|
+
if (isScenarioStack) {
|
|
1207
|
+
this.sortSegmentsByPropOrder(segments);
|
|
1208
|
+
}
|
|
1209
|
+
if (isArea) {
|
|
1210
|
+
return [toGroup("", segments)];
|
|
1211
|
+
}
|
|
1212
|
+
if (isScenarioStack) {
|
|
1213
|
+
const groupMap = new Map();
|
|
1214
|
+
for (const seg of segments) {
|
|
1215
|
+
const prefix = getScenarioPrefix(seg.scenario);
|
|
1216
|
+
if (!groupMap.has(prefix))
|
|
1217
|
+
groupMap.set(prefix, []);
|
|
1218
|
+
groupMap.get(prefix).push(seg);
|
|
1158
1219
|
}
|
|
1159
|
-
if (
|
|
1160
|
-
|
|
1161
|
-
// Check if we have multiple scenario type groups for overlay mode
|
|
1162
|
-
const prefixes = isScenarioStack
|
|
1163
|
-
? new Set(segments.map((s) => getScenarioPrefix(s.scenario)))
|
|
1164
|
-
: new Set();
|
|
1165
|
-
if (prefixes.size > 1) {
|
|
1166
|
-
// Overlay mode: group by scenario prefix, draw each group from same baseline
|
|
1167
|
-
const groupMap = new Map();
|
|
1168
|
-
for (const seg of segments) {
|
|
1169
|
-
const prefix = getScenarioPrefix(seg.scenario);
|
|
1170
|
-
if (!groupMap.has(prefix))
|
|
1171
|
-
groupMap.set(prefix, []);
|
|
1172
|
-
groupMap.get(prefix).push(seg);
|
|
1173
|
-
}
|
|
1220
|
+
if (groupMap.size > 1) {
|
|
1221
|
+
// Sort groups by IBCS layer order (back-to-front: pl, fc, pp, ac)
|
|
1174
1222
|
const groups = [];
|
|
1175
1223
|
for (const prefix of IBCS_LAYER_ORDER) {
|
|
1176
1224
|
if (groupMap.has(prefix)) {
|
|
1177
|
-
groups.push(
|
|
1225
|
+
groups.push(toGroup(prefix, groupMap.get(prefix)));
|
|
1178
1226
|
groupMap.delete(prefix);
|
|
1179
1227
|
}
|
|
1180
1228
|
}
|
|
1181
1229
|
for (const [prefix, segs] of groupMap) {
|
|
1182
|
-
groups.push(
|
|
1230
|
+
groups.push(toGroup(prefix, segs));
|
|
1183
1231
|
}
|
|
1184
|
-
|
|
1185
|
-
groups.forEach((group, groupIdx) => {
|
|
1186
|
-
const groupTotal = group.segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
|
|
1187
|
-
const colorIndex = groups.length - 1 - groupIdx;
|
|
1188
|
-
let cumulativeValue = 0;
|
|
1189
|
-
let lastColumn = null;
|
|
1190
|
-
group.segments.forEach((seg) => {
|
|
1191
|
-
const column = new StackedColumn(this.position, this.styles, seg.dataPoint, index, cumulativeValue, seg.scenario, colorIndex, this.stackConfig.mode, groupTotal, true, stackGroup);
|
|
1192
|
-
column.draw(this.dataFormatDigits, this.measureScale);
|
|
1193
|
-
cumulativeValue += Math.abs(seg.value);
|
|
1194
|
-
lastColumn = column;
|
|
1195
|
-
});
|
|
1196
|
-
if (lastColumn) {
|
|
1197
|
-
lastColumn.drawTotalLabel(this.dataFormatDigits, this.measureScale);
|
|
1198
|
-
}
|
|
1199
|
-
});
|
|
1232
|
+
return groups;
|
|
1200
1233
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1234
|
+
}
|
|
1235
|
+
// a segment without a value sorts like 0: NaN in the comparison would leave the stack unsorted
|
|
1236
|
+
const sortValue = (segment) => (Number.isFinite(segment.value) ? segment.value : 0);
|
|
1237
|
+
if (this.stackConfig.order === "asc") {
|
|
1238
|
+
segments.sort((a, b) => sortValue(a) - sortValue(b));
|
|
1239
|
+
}
|
|
1240
|
+
else if (this.stackConfig.order === "desc") {
|
|
1241
|
+
segments.sort((a, b) => sortValue(b) - sortValue(a));
|
|
1242
|
+
}
|
|
1243
|
+
return [toGroup("", segments)];
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* Draw stacked bar columns. Supports stacking by scenario or by data dimension.
|
|
1247
|
+
* When stacking by scenario with multiple scenario types (e.g. ac+pl),
|
|
1248
|
+
* uses overlay mode: each type group is drawn from the same baseline,
|
|
1249
|
+
* back-to-front per IBCS convention (PL behind, AC on top).
|
|
1250
|
+
* Positive segments stack above the axis, negative segments below it.
|
|
1251
|
+
*/
|
|
1252
|
+
drawStackedScenarios(dataModel, svgContainer) {
|
|
1253
|
+
if (!this.stackConfig)
|
|
1254
|
+
return;
|
|
1255
|
+
const stackGroup = svgContainer.group().id("StackedScenarios");
|
|
1256
|
+
const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
|
|
1257
|
+
dataModel.forEach((elements, index) => {
|
|
1258
|
+
const groups = this.stackGroups(elements);
|
|
1259
|
+
groups.forEach((group, groupIdx) => {
|
|
1211
1260
|
let lastColumn = null;
|
|
1212
|
-
segments.forEach((seg, segIdx) => {
|
|
1213
|
-
const column = new StackedColumn(this.position, this.styles, seg.dataPoint, index,
|
|
1261
|
+
group.segments.forEach((seg, segIdx) => {
|
|
1262
|
+
const column = new StackedColumn(this.position, this.styles, seg.dataPoint, index, group.layout.segments[segIdx], seg.scenario,
|
|
1263
|
+
// overlay: one colour per group, back=lighter, front=darker
|
|
1264
|
+
groups.length > 1 ? groups.length - 1 - groupIdx : segIdx, this.stackConfig.mode, group.layout, isScenarioStack, stackGroup);
|
|
1214
1265
|
column.draw(this.dataFormatDigits, this.measureScale);
|
|
1215
|
-
cumulativeValue += Math.abs(seg.value);
|
|
1216
1266
|
lastColumn = column;
|
|
1217
1267
|
});
|
|
1218
|
-
if (lastColumn) {
|
|
1268
|
+
if (lastColumn && group.hasValue) {
|
|
1219
1269
|
lastColumn.drawTotalLabel(this.dataFormatDigits, this.measureScale);
|
|
1220
1270
|
}
|
|
1221
|
-
}
|
|
1271
|
+
});
|
|
1222
1272
|
});
|
|
1223
1273
|
const stackBox = stackGroup.bbox();
|
|
1224
1274
|
this.scenariosArea = {
|
|
@@ -1230,6 +1280,7 @@ export class TimeChart {
|
|
|
1230
1280
|
* Draw column headers next to stacked columns showing what each group/segment represents.
|
|
1231
1281
|
* For overlay mode (multiple scenario types): shows one header per group.
|
|
1232
1282
|
* For single-group: shows individual segment headers.
|
|
1283
|
+
* The headers take their place from the first period.
|
|
1233
1284
|
*/
|
|
1234
1285
|
drawStackedHeaders(dataModel, svgContainer) {
|
|
1235
1286
|
if (!this.stackConfig || dataModel.length === 0)
|
|
@@ -1238,81 +1289,36 @@ export class TimeChart {
|
|
|
1238
1289
|
if (!isScenarioStack)
|
|
1239
1290
|
return;
|
|
1240
1291
|
const headerGroup = svgContainer.group().id("StackedHeaders");
|
|
1241
|
-
const
|
|
1242
|
-
|
|
1243
|
-
const segments = [];
|
|
1244
|
-
for (const key of scenarioKeys) {
|
|
1245
|
-
const dp = firstRow[key];
|
|
1246
|
-
if (dp && !dp.isEmpty() && dp.value != null) {
|
|
1247
|
-
segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
if (segments.length === 0)
|
|
1292
|
+
const groups = this.stackGroups(dataModel[0]);
|
|
1293
|
+
if (groups.length === 0)
|
|
1251
1294
|
return;
|
|
1252
|
-
this.sortSegmentsByPropOrder(segments);
|
|
1253
|
-
const prefixes = new Set(segments.map((s) => getScenarioPrefix(s.scenario)));
|
|
1254
1295
|
const axisY = this.position.getColumnPositionY();
|
|
1255
1296
|
const xBase = this.position.getColumnCenterPositionX(0) - this.position.getColumnWidth() / 2;
|
|
1256
1297
|
const labelX = xBase - this.position.spacings.labelToColumn;
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
const prefix = getScenarioPrefix(seg.scenario);
|
|
1263
|
-
if (!groupMap.has(prefix))
|
|
1264
|
-
groupMap.set(prefix, []);
|
|
1265
|
-
groupMap.get(prefix).push(seg);
|
|
1266
|
-
}
|
|
1267
|
-
const groups = [];
|
|
1268
|
-
for (const prefix of IBCS_LAYER_ORDER) {
|
|
1269
|
-
if (groupMap.has(prefix)) {
|
|
1270
|
-
groups.push({ prefix, segments: groupMap.get(prefix) });
|
|
1271
|
-
groupMap.delete(prefix);
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
for (const [prefix, segs] of groupMap) {
|
|
1275
|
-
groups.push({ prefix, segments: segs });
|
|
1276
|
-
}
|
|
1298
|
+
const drawHeader = (centerY, labelText) => {
|
|
1299
|
+
new Label(headerGroup, labelX, centerY, "STACK_HEADER", labelText, this.styles, HookLocation.Center, HookLocation.Right).forceStringTypeDraw();
|
|
1300
|
+
};
|
|
1301
|
+
if (groups.length > 1) {
|
|
1302
|
+
// Overlay mode: one header per group
|
|
1277
1303
|
groups.forEach((group, groupIdx) => {
|
|
1278
|
-
const
|
|
1304
|
+
const { positive, negative, total } = group.layout;
|
|
1279
1305
|
const pixelPerUnit = group.segments[0].dataPoint.pixelPerUnit;
|
|
1280
|
-
const groupPixelHeight = this.stackConfig.mode === StackMode.RELATIVE
|
|
1281
|
-
? RELATIVE_STACK_UNITS * pixelPerUnit
|
|
1282
|
-
: groupTotal * pixelPerUnit;
|
|
1283
1306
|
// The front-most group (drawn last, e.g. AC) is fully visible, so its
|
|
1284
1307
|
// label is centered on the bar. Back groups are mostly hidden behind it
|
|
1285
|
-
// and only peek out at
|
|
1308
|
+
// and only peek out at their outer end, so their labels align with that edge.
|
|
1286
1309
|
const isFrontGroup = groupIdx === groups.length - 1;
|
|
1287
|
-
const
|
|
1288
|
-
const
|
|
1289
|
-
|
|
1290
|
-
});
|
|
1291
|
-
}
|
|
1292
|
-
else {
|
|
1293
|
-
// Single group: show individual segment headers
|
|
1294
|
-
if (this.stackConfig.order === "asc")
|
|
1295
|
-
segments.sort((a, b) => a.value - b.value);
|
|
1296
|
-
else if (this.stackConfig.order === "desc")
|
|
1297
|
-
segments.sort((a, b) => b.value - a.value);
|
|
1298
|
-
const total = segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
|
|
1299
|
-
const pixelPerUnit = segments[0].dataPoint.pixelPerUnit;
|
|
1300
|
-
let cumulativePixels = 0;
|
|
1301
|
-
segments.forEach((seg) => {
|
|
1302
|
-
let segmentHeight;
|
|
1303
|
-
if (this.stackConfig.mode === StackMode.RELATIVE) {
|
|
1304
|
-
const proportion = total !== 0 ? Math.abs(seg.value) / total : 0;
|
|
1305
|
-
segmentHeight = proportion * RELATIVE_STACK_UNITS * pixelPerUnit;
|
|
1306
|
-
}
|
|
1307
|
-
else {
|
|
1308
|
-
segmentHeight = Math.abs(seg.value * pixelPerUnit);
|
|
1309
|
-
}
|
|
1310
|
-
const centerY = axisY - cumulativePixels - segmentHeight / 2;
|
|
1311
|
-
const labelText = this.i18n.get(seg.scenario) || seg.scenario;
|
|
1312
|
-
new Label(headerGroup, labelX, centerY, "STACK_HEADER", labelText, this.styles, HookLocation.Center, HookLocation.Right).forceStringTypeDraw();
|
|
1313
|
-
cumulativePixels += segmentHeight;
|
|
1310
|
+
const outerEnd = total < 0 ? 0 - negative : positive;
|
|
1311
|
+
const centerY = axisY - (isFrontGroup ? (positive - negative) / 2 : outerEnd) * pixelPerUnit;
|
|
1312
|
+
drawHeader(centerY, (this.i18n.get(group.prefix + "1") || group.prefix.toUpperCase()));
|
|
1314
1313
|
});
|
|
1314
|
+
return;
|
|
1315
1315
|
}
|
|
1316
|
+
// Single group: one header per segment, centered on the segment
|
|
1317
|
+
const [group] = groups;
|
|
1318
|
+
group.segments.forEach((seg, segIdx) => {
|
|
1319
|
+
const { start, end } = group.layout.segments[segIdx];
|
|
1320
|
+
drawHeader(axisY - ((start + end) / 2) * seg.dataPoint.pixelPerUnit, (this.i18n.get(seg.scenario) || seg.scenario));
|
|
1321
|
+
});
|
|
1316
1322
|
}
|
|
1317
1323
|
/**
|
|
1318
1324
|
* Draw stacked area chart (line mode with stack).
|
|
@@ -1332,9 +1338,6 @@ export class TimeChart {
|
|
|
1332
1338
|
: 1;
|
|
1333
1339
|
if (layerCount === 0)
|
|
1334
1340
|
return;
|
|
1335
|
-
// Build cumulative values per layer
|
|
1336
|
-
// cumulativePoints[layerIdx][dataIdx] = cumulative y-value at that point
|
|
1337
|
-
const cumulativeValues = [];
|
|
1338
1341
|
const layerScenarios = [];
|
|
1339
1342
|
// Identify active layers
|
|
1340
1343
|
const activeLayers = [];
|
|
@@ -1352,52 +1355,34 @@ export class TimeChart {
|
|
|
1352
1355
|
return (ia === -1 ? order.length : ia) - (ib === -1 ? order.length : ib);
|
|
1353
1356
|
});
|
|
1354
1357
|
}
|
|
1355
|
-
|
|
1356
|
-
for (let layerIdx = 0; layerIdx < activeLayers.length; layerIdx++) {
|
|
1357
|
-
const key = activeLayers[layerIdx];
|
|
1358
|
-
const values = [];
|
|
1359
|
-
for (let dataIdx = 0; dataIdx < dataModel.length; dataIdx++) {
|
|
1360
|
-
const dp = dataModel[dataIdx][key];
|
|
1361
|
-
const value = dp && !dp.isEmpty() && dp.value != null ? dp.value : 0;
|
|
1362
|
-
const prevCumulative = layerIdx > 0 ? cumulativeValues[layerIdx - 1][dataIdx] : 0;
|
|
1363
|
-
if (stackMode === StackMode.RELATIVE) {
|
|
1364
|
-
// For relative: need total at each x position
|
|
1365
|
-
const total = activeLayers.reduce((sum, k) => {
|
|
1366
|
-
const d = dataModel[dataIdx][k];
|
|
1367
|
-
return sum + (d && !d.isEmpty() && d.value != null ? Math.abs(d.value) : 0);
|
|
1368
|
-
}, 0);
|
|
1369
|
-
const proportion = total !== 0 ? Math.abs(value) / total : 0;
|
|
1370
|
-
values.push(prevCumulative + proportion);
|
|
1371
|
-
}
|
|
1372
|
-
else {
|
|
1373
|
-
values.push(prevCumulative + value);
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
cumulativeValues.push(values);
|
|
1358
|
+
for (const key of activeLayers) {
|
|
1377
1359
|
const firstDp = dataModel[0][key];
|
|
1378
1360
|
layerScenarios.push((firstDp === null || firstDp === void 0 ? void 0 : firstDp.scenario) || "ac1");
|
|
1379
1361
|
}
|
|
1380
|
-
|
|
1362
|
+
const layerValue = (row, key) => {
|
|
1363
|
+
const dp = row[key];
|
|
1364
|
+
return dp && !dp.isEmpty() && Number.isFinite(dp.value) ? dp.value : 0;
|
|
1365
|
+
};
|
|
1366
|
+
// A layer that is negative over all periods stays below the axis where it has no value:
|
|
1367
|
+
// -0 is a segment without length on the negative side
|
|
1368
|
+
const emptyValues = activeLayers.map((key) => dataModel.reduce((sum, row) => sum + layerValue(row, key), 0) < 0 ? -0 : 0);
|
|
1369
|
+
// One stack per period over all layers, laid out like the columns: positive layers
|
|
1370
|
+
// above the axis, negative layers below it
|
|
1371
|
+
const relativeSpan = stackMode === StackMode.RELATIVE ? RELATIVE_STACK_UNITS : 0;
|
|
1372
|
+
const layouts = dataModel.map((row) => layoutStack(activeLayers.map((key, layerIdx) => layerValue(row, key) || emptyValues[layerIdx]), relativeSpan));
|
|
1373
|
+
// Convert the edges of a layer to pixel coordinates
|
|
1381
1374
|
const axisY = this.position.getColumnPositionY();
|
|
1382
1375
|
const pixelPerUnit = this.pixelPerUnit;
|
|
1383
|
-
const toAreaPoints = (
|
|
1384
|
-
return
|
|
1376
|
+
const toAreaPoints = (layerIdx, edge) => {
|
|
1377
|
+
return layouts.map((layout, idx) => ({
|
|
1385
1378
|
x: this.position.getColumnCenterPositionX(idx),
|
|
1386
|
-
y: axisY -
|
|
1387
|
-
(stackMode === StackMode.RELATIVE
|
|
1388
|
-
? val * RELATIVE_STACK_UNITS * pixelPerUnit // val is a 0..1 cumulative proportion
|
|
1389
|
-
: val * pixelPerUnit),
|
|
1379
|
+
y: axisY - layout.segments[layerIdx][edge] * pixelPerUnit,
|
|
1390
1380
|
}));
|
|
1391
1381
|
};
|
|
1392
|
-
//
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
}));
|
|
1397
|
-
// Draw area fills bottom-to-top
|
|
1398
|
-
for (let layerIdx = 0; layerIdx < cumulativeValues.length; layerIdx++) {
|
|
1399
|
-
const upperPoints = toAreaPoints(cumulativeValues[layerIdx]);
|
|
1400
|
-
const lowerPoints = layerIdx === 0 ? baselinePoints : toAreaPoints(cumulativeValues[layerIdx - 1]);
|
|
1382
|
+
// Draw area fills in layer order
|
|
1383
|
+
for (let layerIdx = 0; layerIdx < activeLayers.length; layerIdx++) {
|
|
1384
|
+
const upperPoints = toAreaPoints(layerIdx, "end");
|
|
1385
|
+
const lowerPoints = toAreaPoints(layerIdx, "start");
|
|
1401
1386
|
const scenarioType = isScenarioStack ? layerScenarios[layerIdx] : null;
|
|
1402
1387
|
const areaFill = new AreaFill(areaGroup, upperPoints, lowerPoints, scenarioType, layerIdx, isScenarioStack);
|
|
1403
1388
|
areaFill.draw();
|
|
@@ -1410,6 +1395,10 @@ export class TimeChart {
|
|
|
1410
1395
|
};
|
|
1411
1396
|
}
|
|
1412
1397
|
drawOverlayLayer(dataModel, svgContainer) {
|
|
1398
|
+
// no period, no average: the overlays read the first and the last period
|
|
1399
|
+
if (dataModel.length === 0) {
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1413
1402
|
const overlayGroup = svgContainer.group().id("Overlay");
|
|
1414
1403
|
const scenarioFactory = new ScenarioFactory(this.position, overlayGroup, this.styles, dataModel.length, this.i18n);
|
|
1415
1404
|
if (this.showOverlayAvg === true) {
|
|
@@ -1446,7 +1435,12 @@ export class TimeChart {
|
|
|
1446
1435
|
}
|
|
1447
1436
|
const to = DateTime.max(...validDates);
|
|
1448
1437
|
const from = DateTime.min(...validDates);
|
|
1449
|
-
const
|
|
1438
|
+
const dateStringFactory = new DateStringFactory();
|
|
1439
|
+
// an interval far finer than the data (second over a month) would add millions of empty periods
|
|
1440
|
+
if (dateStringFactory.countBetween(from, to, dateInterval) > MAX_GAP_FILLED_PERIODS) {
|
|
1441
|
+
return result;
|
|
1442
|
+
}
|
|
1443
|
+
const dateRange = dateStringFactory.datesBetween(from, to, dateInterval);
|
|
1450
1444
|
const dateRangeEntries = new Map();
|
|
1451
1445
|
dateRange.forEach((element, idx) => {
|
|
1452
1446
|
dateRangeEntries.set(element.toISO(), {
|
|
@@ -1504,13 +1498,16 @@ export class TimeChart {
|
|
|
1504
1498
|
return Array.from(dateRangeEntries.values());
|
|
1505
1499
|
}
|
|
1506
1500
|
}
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1501
|
+
/** Values of scenario1 without the periods that have no value: a gap period holds null, a period without this scenario NaN. */
|
|
1502
|
+
function finiteScenario1Values(dataModel) {
|
|
1503
|
+
return dataModel
|
|
1504
|
+
.map((elements) => { var _a; return (_a = elements["scenario1"]) === null || _a === void 0 ? void 0 : _a.value; })
|
|
1505
|
+
.filter((value) => Number.isFinite(value));
|
|
1506
|
+
}
|
|
1507
|
+
export function tranformToAvgDataModel(dataModel) {
|
|
1508
|
+
const values = finiteScenario1Values(dataModel);
|
|
1509
|
+
// NaN draws no line
|
|
1510
|
+
const average = values.length > 0 ? values.reduce((sum, value) => sum + value, 0) / values.length : NaN;
|
|
1514
1511
|
// Create a new first element
|
|
1515
1512
|
const firstElement = Object.assign(Object.assign({}, dataModel[0]), { scenario1: new DataPoint(average, dataModel[0]["scenario1"].scenario, dataModel[0]["scenario1"].pixelPerUnit, dataModel[0]["scenario1"].variance) });
|
|
1516
1513
|
// Create a new last element
|
|
@@ -1524,11 +1521,9 @@ function tranformToAvgDataModel(dataModel) {
|
|
|
1524
1521
|
lastElement,
|
|
1525
1522
|
];
|
|
1526
1523
|
}
|
|
1527
|
-
function tranformToMedianDataModel(dataModel) {
|
|
1528
|
-
const values = dataModel
|
|
1529
|
-
|
|
1530
|
-
.filter((value) => value !== undefined)
|
|
1531
|
-
.sort((a, b) => a - b);
|
|
1524
|
+
export function tranformToMedianDataModel(dataModel) {
|
|
1525
|
+
const values = finiteScenario1Values(dataModel).sort((a, b) => a - b);
|
|
1526
|
+
// an empty list gives NaN, which draws no line
|
|
1532
1527
|
const median = values.length % 2 === 0
|
|
1533
1528
|
? (values[values.length / 2 - 1] + values[values.length / 2]) / 2
|
|
1534
1529
|
: values[Math.floor(values.length / 2)];
|