@bino-bi/bn-template-engine 1.0.0-alpha.9 → 1.0.0-next.19
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/LICENSE +203 -21
- package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/p-19bbac66.entry.js +1 -0
- package/dist/bn-template-engine/p-209351c9.entry.js +1 -0
- package/dist/bn-template-engine/p-22d0fb7a.entry.js +1 -0
- package/dist/bn-template-engine/p-2e6dc267.entry.js +1 -0
- package/dist/bn-template-engine/p-485d23d7.entry.js +1 -0
- package/dist/bn-template-engine/p-74c5a95d.entry.js +1 -0
- package/dist/bn-template-engine/p-7bdc0e28.entry.js +1 -0
- package/dist/bn-template-engine/p-83c71b16.entry.js +1 -0
- package/dist/bn-template-engine/p-90806e7a.entry.js +1 -0
- package/dist/bn-template-engine/p-9879c9b2.entry.js +1 -0
- package/dist/bn-template-engine/p-BA48JiHe.js +1 -0
- package/dist/bn-template-engine/p-BWKdb9ym.js +1 -0
- package/dist/bn-template-engine/p-BZV1b5VH.js +1 -0
- package/dist/bn-template-engine/p-Bdfxd_Ke.js +1 -0
- package/dist/bn-template-engine/p-BjBz5cSL.js +1 -0
- package/dist/bn-template-engine/p-BqhIhYr1.js +1 -0
- package/dist/bn-template-engine/p-C0Pwqx-O.js +1 -0
- package/dist/bn-template-engine/p-CiudZRQr.js +1 -0
- package/dist/bn-template-engine/p-DTuaq8Pj.js +1 -0
- package/dist/bn-template-engine/p-DY7YYmpa.js +1 -0
- package/dist/bn-template-engine/p-Dg9OcXAO.js +1 -0
- package/dist/bn-template-engine/p-DsTzlzxQ.js +1 -0
- package/dist/bn-template-engine/p-X6CxL6W-.js +1 -0
- package/dist/bn-template-engine/p-a8291de2.entry.js +1 -0
- package/dist/bn-template-engine/p-aakBGfzL.js +1 -0
- package/dist/bn-template-engine/p-b25455a7.entry.js +1 -0
- package/dist/bn-template-engine/p-e96da91f.entry.js +1 -0
- package/dist/bn-template-engine/p-eca8e2e2.entry.js +1 -0
- package/dist/bn-template-engine/p-f9dfd120.entry.js +1 -0
- package/dist/bn-template-engine/p-rdqTC0_5.js +1 -0
- package/dist/cjs/AxisConfig-VnVelfSV.js +233 -0
- package/dist/cjs/LabelCollisionManager-nfD5P__k.js +412 -0
- package/dist/cjs/NumericScale-BAyYXpKL.js +107 -0
- package/dist/cjs/Order-DobBozQC.js +87 -0
- package/dist/cjs/SVGStyle-BQOmGWLX.js +8209 -0
- package/dist/cjs/SVGVariancesStyleGroup-DCGfHrqh.js +50 -0
- package/dist/cjs/VarianceMeasure-NY9yhiNV.js +372 -0
- package/dist/cjs/XYChartDataRow-B7OKrAcC.js +829 -0
- package/dist/cjs/bn-asset_21.cjs.entry.js +16047 -0
- package/dist/cjs/bn-chart-bubble.cjs.entry.js +762 -0
- package/dist/cjs/bn-chart-bullet.cjs.entry.js +785 -0
- package/dist/cjs/bn-chart-scatter.cjs.entry.js +658 -0
- package/dist/cjs/bn-grid.cjs.entry.js +5 -3
- package/dist/cjs/bn-image.cjs.entry.js +5 -3
- package/dist/cjs/bn-internationalization.cjs.entry.js +10 -8
- package/dist/cjs/bn-ruleset.cjs.entry.js +41 -0
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/bn-template.cjs.entry.js +1 -1
- package/dist/cjs/bn-text.cjs.entry.js +8 -79
- package/dist/cjs/bn-tree.cjs.entry.js +4 -2
- package/dist/cjs/context-protocol-BDrMkhc4.js +9499 -0
- package/dist/cjs/editor-companion.cjs.entry.js +13 -6
- package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +624 -0
- package/dist/cjs/ibcs-chart-bullet.cjs.entry.js +673 -0
- package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +667 -0
- package/dist/cjs/layoutObserver-o03YUfn_.js +199 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sanitizeHtml-LuZr1IMd.js +85 -0
- package/dist/cjs/scaling-DKZyjWj5.js +587 -0
- package/dist/cjs/{withBodyObserver-D7BKWN2N.js → withBodyObserver-BKUE_ypL.js} +12 -7
- package/dist/cjs/withScalingGroup-BmcRlWBs.js +73 -0
- package/dist/cjs/withStyled-CRiC9fzc.js +1137 -0
- package/dist/collection/collection-manifest.json +9 -1
- package/dist/collection/components/bn-body/bn-body.css +1 -0
- package/dist/collection/components/bn-card/bn-card.css +2 -0
- package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.css +10 -0
- package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +1110 -0
- package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.css +9 -0
- package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.js +653 -0
- package/dist/collection/components/bn-chart-bubble/utils/BubbleChart.js +472 -0
- package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.css +10 -0
- package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.js +1014 -0
- package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.css +9 -0
- package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.js +538 -0
- package/dist/collection/components/bn-chart-bullet/utils/BulletChart.js +440 -0
- package/dist/collection/components/bn-chart-bullet/utils/model/BulletChartStyle.js +132 -0
- package/dist/collection/components/bn-chart-bullet/utils/model/BulletConfig.js +89 -0
- package/dist/collection/components/bn-chart-bullet/utils/model/index.js +2 -0
- package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.css +10 -0
- package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.js +965 -0
- package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.css +9 -0
- package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.js +580 -0
- package/dist/collection/components/bn-chart-scatter/utils/ScatterChart.js +409 -0
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +125 -42
- package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +103 -36
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +82 -58
- package/dist/collection/components/bn-chart-structure/utils/helper/ElementPositions.js +46 -4
- package/dist/collection/components/bn-chart-structure/utils/model/StructureChartComponentConfig.js +5 -4
- package/dist/collection/components/bn-chart-time/bn-chart-time.css +1 -1
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +160 -43
- package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +94 -31
- package/dist/collection/components/bn-chart-time/utils/TimeChart.js +132 -74
- package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +3 -3
- package/dist/collection/components/bn-chart-time/utils/model/TimeChartComponentConfig.js +5 -4
- package/dist/collection/components/bn-chart-time/utils/model/TimeChartDataRow.js +2 -0
- package/dist/collection/components/bn-component-style/bn-component-style.js +1 -1
- package/dist/collection/components/bn-context/bn-context.js +1 -1
- package/dist/collection/components/bn-dataset/bn-dataset.js +226 -23
- package/dist/collection/components/bn-datasource/bn-datasource.js +163 -12
- package/dist/collection/components/bn-footer/bn-footer.js +1 -1
- package/dist/collection/components/bn-grid/bn-grid.js +1 -1
- package/dist/collection/components/bn-image/bn-image.js +1 -1
- package/dist/collection/components/bn-internationalization/bn-internationalization.js +10 -7
- package/dist/collection/components/bn-layout-card/bn-layout-card.css +8 -3
- package/dist/collection/components/bn-layout-card/bn-layout-card.js +98 -35
- package/dist/collection/components/bn-layout-page/bn-layout-page.css +5 -3
- package/dist/collection/components/bn-layout-page/bn-layout-page.js +98 -25
- package/dist/collection/components/bn-message/bn-message.css +6 -2
- package/dist/collection/components/bn-message/bn-message.js +3 -2
- package/dist/collection/components/bn-page/bn-page.js +1 -1
- package/dist/collection/components/bn-ruleset/bn-ruleset.css +3 -0
- package/dist/collection/components/bn-ruleset/bn-ruleset.js +68 -0
- package/dist/collection/components/bn-scaling-group/bn-scaling-group.css +3 -0
- package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +136 -0
- package/dist/collection/components/bn-table/bn-table.js +317 -61
- package/dist/collection/components/bn-table/ibcs-table.css +8 -0
- package/dist/collection/components/bn-table/ibcs-table.js +161 -32
- package/dist/collection/components/bn-table/utils/Table.js +72 -28
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +13 -8
- package/dist/collection/components/bn-table/utils/elements/TableRow.js +3 -2
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +47 -0
- package/dist/collection/components/bn-table/utils/elements/index.js +1 -0
- package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +117 -22
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +380 -50
- package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +140 -0
- package/dist/collection/components/bn-table/utils/helper/QueryGroup.js +4 -9
- package/dist/collection/components/bn-table/utils/helper/WaterfallCalculator.js +166 -0
- package/dist/collection/components/bn-table/utils/helper/index.js +2 -0
- package/dist/collection/components/bn-table/utils/model/TableAttribute.js +46 -0
- package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +20 -4
- package/dist/collection/components/bn-template/bn-template.js +1 -1
- package/dist/collection/components/bn-text/bn-text.js +2 -75
- package/dist/collection/components/bn-title/bn-title.js +27 -3
- package/dist/collection/components/bn-title/ibcs-title/ibcs-title.css +4 -0
- package/dist/collection/components/bn-title/ibcs-title/ibcs-title.js +29 -6
- package/dist/collection/components/bn-title/ibcs-title/utils/Title.js +3 -0
- package/dist/collection/components/editor-companion/editor-companion.js +12 -5
- package/dist/collection/context/scopedDb.js +127 -0
- package/dist/collection/stores/componentStyles.js +67 -0
- package/dist/collection/stores/createScopedStores.js +11 -5
- package/dist/collection/stores/internationalization.js +68 -0
- package/dist/collection/stores/ruleSets.js +46 -0
- package/dist/collection/utils/constants.js +5 -0
- package/dist/collection/utils/dataAnalyzer.js +14 -8
- package/dist/collection/utils/ibcsRuleSet.js +14 -26
- package/dist/collection/utils/layoutObserver.js +88 -0
- package/dist/collection/utils/parentDimensions.js +71 -15
- package/dist/collection/utils/sanitizeHtml.js +81 -0
- package/dist/collection/utils/validate.js +47 -0
- package/dist/collection/utils/withBodyObserver.js +12 -7
- package/dist/collection/utils/withComponentStyle.js +3 -5
- package/dist/collection/utils/withDataset.js +43 -39
- package/dist/collection/utils/withDatasource.js +28 -18
- package/dist/collection/utils/withInheritedProps.js +26 -1
- package/dist/collection/utils/withRuleSet.js +105 -0
- package/dist/collection/utils/withScalingGroup.js +69 -0
- package/dist/collection/utils/withTranslation.js +50 -14
- package/dist/collection/utils/xy/FacetGrid.js +36 -0
- package/dist/collection/utils/xy/IsoCurves.js +156 -0
- package/dist/collection/utils/xy/NumericScale.js +103 -0
- package/dist/collection/utils/xy/PointLabeler.js +96 -0
- package/dist/collection/utils/xy/RadiusScale.js +42 -0
- package/dist/collection/utils/xy/SeriesPalette.js +80 -0
- package/dist/collection/utils/xy/VarianceMeasure.js +76 -0
- package/dist/collection/utils/xy/XYFrame.js +120 -0
- package/dist/collection/utils/xy/XYLegend.js +107 -0
- package/dist/collection/utils/xy/model/AxisConfig.js +221 -0
- package/dist/collection/utils/xy/model/ScaleFactorsXYChart.js +69 -0
- package/dist/collection/utils/xy/model/XYChartDataRow.js +0 -0
- package/dist/collection/utils/xy/model/XYChartStyle.js +52 -0
- package/dist/components/AxisConfig.js +1 -0
- package/dist/components/CompareUtil.js +1 -0
- package/dist/components/DataFormatDigits.js +1 -1
- package/dist/components/DateStringFactory.js +1 -1
- package/dist/components/LabelCollisionManager.js +1 -0
- package/dist/components/NumericScale.js +1 -0
- package/dist/components/Order.js +1 -1
- package/dist/components/SVGVariancesStyleGroup.js +1 -1
- package/dist/components/SiPrefix.js +1 -0
- package/dist/components/StringAdapter.js +1 -0
- package/dist/components/VarianceMeasure.js +1 -0
- package/dist/components/XYChartDataRow.js +1 -0
- package/dist/components/bn-body2.js +1 -1
- package/dist/components/bn-card2.js +1 -1
- package/dist/components/bn-chart-bubble.d.ts +11 -0
- package/dist/components/bn-chart-bubble.js +1 -0
- package/dist/components/bn-chart-bullet.d.ts +11 -0
- package/dist/components/bn-chart-bullet.js +1 -0
- package/dist/components/bn-chart-scatter.d.ts +11 -0
- package/dist/components/bn-chart-scatter.js +1 -0
- 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.d.ts +11 -0
- package/dist/components/bn-ruleset.js +1 -0
- package/dist/components/bn-scaling-group.d.ts +11 -0
- package/dist/components/bn-scaling-group.js +1 -0
- 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/context-protocol.js +1 -1
- package/dist/components/editor-companion.js +1 -1
- package/dist/components/formatter.js +1 -0
- package/dist/components/ibcs-chart-bubble.d.ts +11 -0
- package/dist/components/ibcs-chart-bubble.js +1 -0
- package/dist/components/ibcs-chart-bubble2.js +1 -0
- package/dist/components/ibcs-chart-bullet.d.ts +11 -0
- package/dist/components/ibcs-chart-bullet.js +1 -0
- package/dist/components/ibcs-chart-bullet2.js +1 -0
- package/dist/components/ibcs-chart-scatter.d.ts +11 -0
- package/dist/components/ibcs-chart-scatter.js +1 -0
- package/dist/components/ibcs-chart-scatter2.js +1 -0
- 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/layoutObserver.js +1 -0
- package/dist/components/luxon.js +1 -0
- package/dist/components/main.js +1 -0
- package/dist/components/merge.js +1 -0
- package/dist/components/sanitizeHtml.js +1 -0
- package/dist/components/stackColors.js +1 -0
- package/dist/components/validate.js +1 -1
- package/dist/components/withBodyObserver.js +1 -1
- package/dist/components/withComponentStyle.js +1 -1
- package/dist/components/withDataset.js +1 -0
- package/dist/components/withRuleSet.js +1 -0
- package/dist/components/withScalingGroup.js +1 -0
- package/dist/components/withStyled.js +1 -1
- package/dist/components/withTranslation.js +1 -1
- package/dist/esm/AxisConfig-C_zWCKlL.js +224 -0
- package/dist/esm/LabelCollisionManager-8swVQHKA.js +404 -0
- package/dist/esm/NumericScale-DsTzlzxQ.js +105 -0
- package/dist/esm/Order-BPeWfygb.js +83 -0
- package/dist/esm/SVGStyle-BxEDw9zh.js +8199 -0
- package/dist/esm/SVGVariancesStyleGroup-DRQYvSDD.js +48 -0
- package/dist/esm/VarianceMeasure-DnwNKspZ.js +364 -0
- package/dist/esm/XYChartDataRow-DeV4r-Wm.js +820 -0
- package/dist/esm/bn-asset_21.entry.js +16025 -0
- package/dist/esm/bn-chart-bubble.entry.js +760 -0
- package/dist/esm/bn-chart-bullet.entry.js +783 -0
- package/dist/esm/bn-chart-scatter.entry.js +656 -0
- package/dist/esm/bn-grid.entry.js +5 -3
- package/dist/esm/bn-image.entry.js +5 -3
- package/dist/esm/bn-internationalization.entry.js +10 -8
- package/dist/esm/bn-ruleset.entry.js +39 -0
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/bn-template.entry.js +1 -1
- package/dist/esm/bn-text.entry.js +7 -78
- package/dist/esm/bn-tree.entry.js +4 -2
- package/dist/esm/context-protocol-1Yj1uKvh.js +9484 -0
- package/dist/esm/editor-companion.entry.js +13 -6
- package/dist/esm/ibcs-chart-bubble.entry.js +622 -0
- package/dist/esm/ibcs-chart-bullet.entry.js +671 -0
- package/dist/esm/ibcs-chart-scatter.entry.js +665 -0
- package/dist/esm/layoutObserver-BG5dOBYH.js +196 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sanitizeHtml-BA48JiHe.js +83 -0
- package/dist/esm/scaling-CeSRcRl1.js +579 -0
- package/dist/esm/{withBodyObserver-AFk2wwHT.js → withBodyObserver-IokS6fHD.js} +12 -7
- package/dist/esm/withScalingGroup-Br70pAv9.js +71 -0
- package/dist/esm/withStyled-Br2DGTPs.js +1104 -0
- package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +193 -0
- package/dist/types/components/bn-chart-bubble/ibcs-chart-bubble.d.ts +58 -0
- package/dist/types/components/bn-chart-bubble/utils/BubbleChart.d.ts +91 -0
- package/dist/types/components/bn-chart-bullet/bn-chart-bullet.d.ts +172 -0
- package/dist/types/components/bn-chart-bullet/ibcs-chart-bullet.d.ts +52 -0
- package/dist/types/components/bn-chart-bullet/utils/BulletChart.d.ts +91 -0
- package/dist/types/components/bn-chart-bullet/utils/model/BulletChartStyle.d.ts +70 -0
- package/dist/types/components/bn-chart-bullet/utils/model/BulletConfig.d.ts +43 -0
- package/dist/types/components/bn-chart-bullet/utils/model/index.d.ts +2 -0
- package/dist/types/components/bn-chart-scatter/bn-chart-scatter.d.ts +172 -0
- package/dist/types/components/bn-chart-scatter/ibcs-chart-scatter.d.ts +53 -0
- package/dist/types/components/bn-chart-scatter/utils/ScatterChart.d.ts +66 -0
- package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +19 -5
- package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +13 -6
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +16 -12
- package/dist/types/components/bn-chart-structure/utils/helper/ElementPositions.d.ts +16 -1
- package/dist/types/components/bn-chart-structure/utils/model/StructureChartComponentConfig.d.ts +5 -3
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +53 -13
- package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +13 -6
- package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +16 -12
- package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +5 -3
- package/dist/types/components/bn-dataset/bn-dataset.d.ts +47 -5
- package/dist/types/components/bn-datasource/bn-datasource.d.ts +53 -6
- package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +35 -8
- package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +32 -1
- package/dist/types/components/bn-message/bn-message.d.ts +5 -2
- package/dist/types/components/bn-ruleset/bn-ruleset.d.ts +8 -0
- package/dist/types/components/bn-scaling-group/bn-scaling-group.d.ts +37 -0
- package/dist/types/components/bn-table/bn-table.d.ts +74 -12
- package/dist/types/components/bn-table/ibcs-table.d.ts +27 -4
- package/dist/types/components/bn-table/utils/Table.d.ts +16 -6
- package/dist/types/components/bn-table/utils/elements/Cell.d.ts +2 -0
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +33 -0
- package/dist/types/components/bn-table/utils/elements/TableRow.d.ts +2 -1
- package/dist/types/components/bn-table/utils/elements/WaterfallBar.d.ts +21 -0
- package/dist/types/components/bn-table/utils/elements/index.d.ts +1 -0
- package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +17 -9
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +35 -3
- package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +37 -0
- package/dist/types/components/bn-table/utils/helper/QueryGroup.d.ts +4 -5
- package/dist/types/components/bn-table/utils/helper/WaterfallCalculator.d.ts +55 -0
- package/dist/types/components/bn-table/utils/helper/index.d.ts +2 -0
- package/dist/types/components/bn-table/utils/model/TableAttribute.d.ts +22 -0
- package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +12 -3
- package/dist/types/components/bn-table/utils/model/index.d.ts +21 -0
- package/dist/types/components/bn-title/bn-title.d.ts +11 -1
- package/dist/types/components/bn-title/ibcs-title/ibcs-title.d.ts +2 -0
- package/dist/types/components/bn-title/ibcs-title/utils/Title.d.ts +1 -0
- package/dist/types/components/editor-companion/editor-companion.d.ts +2 -0
- package/dist/types/components.d.ts +1691 -120
- package/dist/types/context/context-protocol.d.ts +7 -3
- package/dist/types/context/scopedDb.d.ts +37 -0
- package/dist/types/stores/componentStyles.d.ts +41 -0
- package/dist/types/stores/createScopedStores.d.ts +4 -2
- package/dist/types/stores/ruleSets.d.ts +40 -0
- package/dist/types/utils/DateStringFactory.d.ts +1 -1
- package/dist/types/utils/constants.d.ts +5 -0
- package/dist/types/utils/dataAnalyzer.d.ts +2 -1
- package/dist/types/utils/ibcsRuleSet.d.ts +6 -1
- package/dist/types/utils/layoutObserver.d.ts +27 -0
- package/dist/types/utils/model/ChartStyles.d.ts +2 -1
- package/dist/types/utils/parentDimensions.d.ts +1 -1
- package/dist/types/utils/sanitizeHtml.d.ts +6 -0
- package/dist/types/utils/validate.d.ts +18 -0
- package/dist/types/utils/withDataset.d.ts +6 -2
- package/dist/types/utils/withDatasource.d.ts +3 -3
- package/dist/types/utils/withInheritedProps.d.ts +19 -0
- package/dist/types/utils/withRuleSet.d.ts +24 -0
- package/dist/types/utils/withScalingGroup.d.ts +14 -0
- package/dist/types/utils/withTranslation.d.ts +12 -4
- package/dist/types/utils/xy/FacetGrid.d.ts +27 -0
- package/dist/types/utils/xy/IsoCurves.d.ts +46 -0
- package/dist/types/utils/xy/NumericScale.d.ts +41 -0
- package/dist/types/utils/xy/PointLabeler.d.ts +58 -0
- package/dist/types/utils/xy/RadiusScale.d.ts +26 -0
- package/dist/types/utils/xy/SeriesPalette.d.ts +59 -0
- package/dist/types/utils/xy/VarianceMeasure.d.ts +37 -0
- package/dist/types/utils/xy/XYFrame.d.ts +44 -0
- package/dist/types/utils/xy/XYLegend.d.ts +43 -0
- package/dist/types/utils/xy/model/AxisConfig.d.ts +96 -0
- package/dist/types/utils/xy/model/ScaleFactorsXYChart.d.ts +36 -0
- package/dist/types/utils/xy/model/XYChartDataRow.d.ts +157 -0
- package/dist/types/utils/xy/model/XYChartStyle.d.ts +31 -0
- package/package.json +5 -4
- package/readme.md +9 -5
- package/dist/bn-template-engine/p-3141c4a2.entry.js +0 -1
- package/dist/bn-template-engine/p-67538176.entry.js +0 -1
- package/dist/bn-template-engine/p-916296a5.entry.js +0 -1
- package/dist/bn-template-engine/p-96006b06.entry.js +0 -1
- package/dist/bn-template-engine/p-Ck-NYtot.js +0 -1
- package/dist/bn-template-engine/p-CnDq0oVa.js +0 -1
- package/dist/bn-template-engine/p-DSXNgKLa.js +0 -1
- package/dist/bn-template-engine/p-bc711fb0.entry.js +0 -1
- package/dist/bn-template-engine/p-c86395b8.entry.js +0 -1
- package/dist/bn-template-engine/p-e6f646b1.entry.js +0 -1
- package/dist/bn-template-engine/p-f41d9242.entry.js +0 -1
- package/dist/bn-template-engine/p-gFbbuhtl.js +0 -1
- package/dist/cjs/bn-asset_20.cjs.entry.js +0 -23547
- package/dist/cjs/context-protocol-ohYzcb5F.js +0 -663
- package/dist/cjs/scaling-CIAClQR5.js +0 -314
- package/dist/cjs/withStyled-qd94SSb4.js +0 -9535
- package/dist/collection/stores/datasets.js +0 -14
- package/dist/collection/stores/datasources.js +0 -14
- package/dist/components/_commonjsHelpers.js +0 -1
- package/dist/components/alasql.min.js +0 -1
- package/dist/components/ibcsRuleSet.js +0 -1
- package/dist/components/scaling.js +0 -1
- package/dist/components/withInheritedProps.js +0 -1
- package/dist/esm/bn-asset_20.entry.js +0 -23526
- package/dist/esm/context-protocol-DdbSplvE.js +0 -656
- package/dist/esm/scaling-DGKKkuL9.js +0 -309
- package/dist/esm/withStyled-BIkqU2w4.js +0 -9501
- package/dist/types/stores/datasets.d.ts +0 -14
- package/dist/types/stores/datasources.d.ts +0 -14
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
import { Svg } from "@svgdotjs/svg.js";
|
|
2
|
+
import CalculateSize from "calculate-size";
|
|
3
|
+
import { AggregationLevel } from "../../../utils/constants";
|
|
4
|
+
import { Formatter } from "../../../utils/formatter";
|
|
5
|
+
import { OrderColumn } from "../../../utils/model/Order";
|
|
6
|
+
import { NumericScale } from "../../../utils/xy/NumericScale";
|
|
7
|
+
import { scenarioFamily } from "../../../utils/xy/VarianceMeasure";
|
|
8
|
+
/**
|
|
9
|
+
* SVG orchestrator for `bn-chart-bullet` (IBCS bullet graph).
|
|
10
|
+
*
|
|
11
|
+
* One horizontal row per KPI: a solid AC bar, a target marker, and — in the
|
|
12
|
+
* default normalized mode — an integrated variance bar between actual and
|
|
13
|
+
* target. Normalization maps every row to fractions of its target, so one
|
|
14
|
+
* continuous target line spans all rows (IBCS: normalized target values).
|
|
15
|
+
* Classic mode (`normalize: "none"`) draws per-row scales with tick strips
|
|
16
|
+
* and optional qualitative range bands (max two, per the IBCS critique of
|
|
17
|
+
* the arbitrary third band). The SVG is built on a detached `Svg` root and
|
|
18
|
+
* emitted via `toString()`.
|
|
19
|
+
*/
|
|
20
|
+
export class BulletChart {
|
|
21
|
+
constructor(ruleSet, db, fromExpr, config, styles, availableWidth) {
|
|
22
|
+
this.ruleSet = ruleSet;
|
|
23
|
+
this.config = config;
|
|
24
|
+
this.styles = styles;
|
|
25
|
+
this.availableWidth = availableWidth;
|
|
26
|
+
this.rows = [];
|
|
27
|
+
this.warnings = [];
|
|
28
|
+
this.i18nMap = new Map();
|
|
29
|
+
this.populateModel(db, fromExpr);
|
|
30
|
+
this.normalized = this.config.normalize === "target" && this.rows.some((row) => row.fraction !== null);
|
|
31
|
+
if (this.config.target !== null && this.rows.length > 0 && !this.rows.some((row) => row.target !== null)) {
|
|
32
|
+
this.warnings.push({ code: "bullet-target-none", data: {} });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
populateModel(db, fromExpr) {
|
|
36
|
+
var _a, _b, _c;
|
|
37
|
+
if (fromExpr === "") {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const level = this.config.level;
|
|
41
|
+
const order = this.config.order;
|
|
42
|
+
const actualSlot = this.config.actual.measure;
|
|
43
|
+
const targetSlot = (_b = (_a = this.config.target) === null || _a === void 0 ? void 0 : _a.measure) !== null && _b !== void 0 ? _b : null;
|
|
44
|
+
const measureSelect = [actualSlot, ...(targetSlot !== null ? [targetSlot] : [])]
|
|
45
|
+
.map((slot) => `SUM(${slot}) as ${slot}, COUNT(ISNULL(${slot})) as ${slot}_cnt`)
|
|
46
|
+
.join(", ");
|
|
47
|
+
let result;
|
|
48
|
+
try {
|
|
49
|
+
// transformOperator maps the operation strings to ±1 — alasql cannot MIN/MAX over VARCHAR columns.
|
|
50
|
+
result = db.exec(`SELECT ${this.createSelectString(level, order)}, ${measureSelect},
|
|
51
|
+
MIN(transformOperator(operation)) as opMin, MAX(transformOperator(operation)) as opMax
|
|
52
|
+
FROM ${fromExpr}
|
|
53
|
+
GROUP BY ${this.createGroupByStr(level, order)}
|
|
54
|
+
ORDER BY ${this.createOrderStr(level, order)}`);
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
console.error("BulletChart: populateModel query failed", e);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let records = result !== null && result !== void 0 ? result : [];
|
|
61
|
+
if (this.config.limit > 0) {
|
|
62
|
+
records = records.slice(0, this.config.limit);
|
|
63
|
+
}
|
|
64
|
+
let mixedOperations = 0;
|
|
65
|
+
let targetMissing = 0;
|
|
66
|
+
let targetInvalid = 0;
|
|
67
|
+
for (const record of records) {
|
|
68
|
+
const actual = this.readValue(record, actualSlot);
|
|
69
|
+
const target = targetSlot !== null ? this.readValue(record, targetSlot) : null;
|
|
70
|
+
const opMin = typeof record.opMin === "number" ? record.opMin : 1;
|
|
71
|
+
const opMax = typeof record.opMax === "number" ? record.opMax : 1;
|
|
72
|
+
let operation = opMin === -1 && opMax === -1 ? "-" : "+";
|
|
73
|
+
if (opMin !== opMax) {
|
|
74
|
+
operation = "+";
|
|
75
|
+
mixedOperations++;
|
|
76
|
+
}
|
|
77
|
+
let fraction = null;
|
|
78
|
+
if (this.config.normalize === "target") {
|
|
79
|
+
if (target === null) {
|
|
80
|
+
if (targetSlot !== null) {
|
|
81
|
+
targetMissing++;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (target <= 0) {
|
|
85
|
+
targetInvalid++;
|
|
86
|
+
}
|
|
87
|
+
else if (actual !== null) {
|
|
88
|
+
if (actual < 0) {
|
|
89
|
+
targetInvalid++;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
fraction = actual / target;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
this.rows.push({
|
|
97
|
+
category: String((_c = record.category) !== null && _c !== void 0 ? _c : ""),
|
|
98
|
+
actual,
|
|
99
|
+
target,
|
|
100
|
+
operation,
|
|
101
|
+
sentiment: this.sentiment(actual, target, operation),
|
|
102
|
+
fraction,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (mixedOperations > 0) {
|
|
106
|
+
this.warnings.push({ code: "bullet-mixed-operation", data: { count: String(mixedOperations) } });
|
|
107
|
+
}
|
|
108
|
+
if (targetMissing > 0) {
|
|
109
|
+
this.warnings.push({ code: "bullet-target-missing", data: { count: String(targetMissing) } });
|
|
110
|
+
}
|
|
111
|
+
if (targetInvalid > 0) {
|
|
112
|
+
this.warnings.push({ code: "bullet-target-invalid", data: { count: String(targetInvalid) } });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
readValue(record, slot) {
|
|
116
|
+
if (record[`${slot}_cnt`] === 0) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const value = record[slot];
|
|
120
|
+
return typeof value === "number" && isFinite(value) ? value : null;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Favorable/unfavorable direction of the actual-vs-target variance.
|
|
124
|
+
* `operation: "-"` marks cost-type KPIs, inverting the reading — the sign
|
|
125
|
+
* flip philosophy of the structure chart's `DataPoint.getVarianceStyle()`,
|
|
126
|
+
* keyed on the row operation because bullet variances are implicit rather
|
|
127
|
+
* than user-declared `_pos`/`_neg` tokens.
|
|
128
|
+
*/
|
|
129
|
+
sentiment(actual, target, operation) {
|
|
130
|
+
if (actual === null || target === null || actual === target) {
|
|
131
|
+
return "neu";
|
|
132
|
+
}
|
|
133
|
+
return actual > target !== (operation === "-") ? "pos" : "neg";
|
|
134
|
+
}
|
|
135
|
+
createSelectString(level, sortOrder) {
|
|
136
|
+
if (level === AggregationLevel.CATEGORY && sortOrder.hierarchy.includes(OrderColumn.CATEGORYINDEX)) {
|
|
137
|
+
return `${OrderColumn.CATEGORYINDEX}, ${AggregationLevel.CATEGORY} as category`;
|
|
138
|
+
}
|
|
139
|
+
else if (level === AggregationLevel.ROWGROUP && sortOrder.hierarchy.includes(OrderColumn.ROWGROUPINDEX)) {
|
|
140
|
+
return `${OrderColumn.ROWGROUPINDEX}, ${AggregationLevel.ROWGROUP} as category`;
|
|
141
|
+
}
|
|
142
|
+
else if (level === AggregationLevel.SUBCATEGORY && sortOrder.hierarchy.includes(OrderColumn.SUBCATEGORYINDEX)) {
|
|
143
|
+
return `${OrderColumn.SUBCATEGORYINDEX}, ${AggregationLevel.SUBCATEGORY} as category`;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
return `${level.toString()} as category`;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
createGroupByStr(level, sortOrder) {
|
|
150
|
+
if (level === AggregationLevel.CATEGORY && sortOrder.hierarchy.includes(OrderColumn.CATEGORYINDEX)) {
|
|
151
|
+
return `${OrderColumn.CATEGORYINDEX}, ${AggregationLevel.CATEGORY}`;
|
|
152
|
+
}
|
|
153
|
+
else if (level === AggregationLevel.ROWGROUP && sortOrder.hierarchy.includes(OrderColumn.ROWGROUPINDEX)) {
|
|
154
|
+
return `${OrderColumn.ROWGROUPINDEX}, ${AggregationLevel.ROWGROUP}`;
|
|
155
|
+
}
|
|
156
|
+
else if (level === AggregationLevel.SUBCATEGORY && sortOrder.hierarchy.includes(OrderColumn.SUBCATEGORYINDEX)) {
|
|
157
|
+
return `${OrderColumn.SUBCATEGORYINDEX}, ${AggregationLevel.SUBCATEGORY}`;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
return `${level.toString()}`;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
createOrderStr(level, sortOrder) {
|
|
164
|
+
let orderStr = `${level.toLowerCase()}`;
|
|
165
|
+
if (sortOrder.hierarchy.length >= 1) {
|
|
166
|
+
orderStr = `${sortOrder.hierarchy.toString()} ${sortOrder === null || sortOrder === void 0 ? void 0 : sortOrder.direction}`;
|
|
167
|
+
}
|
|
168
|
+
return orderStr;
|
|
169
|
+
}
|
|
170
|
+
get em() {
|
|
171
|
+
return this.styles.fontStyles.size;
|
|
172
|
+
}
|
|
173
|
+
fontFamily() {
|
|
174
|
+
return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/, "");
|
|
175
|
+
}
|
|
176
|
+
textWidth(text, bold = false) {
|
|
177
|
+
const width = CalculateSize(text, {
|
|
178
|
+
font: this.styles.fontStyles.font,
|
|
179
|
+
fontSize: this.styles.fontStyles.size + "px",
|
|
180
|
+
fontWeight: bold ? "bold" : "normal",
|
|
181
|
+
}).width;
|
|
182
|
+
// calculate-size needs a live DOM; fall back to an estimate in test environments.
|
|
183
|
+
return Number.isFinite(width) && width > 0 ? width : text.length * 0.6 * this.em;
|
|
184
|
+
}
|
|
185
|
+
drawText(group, text, x, y, options = {}) {
|
|
186
|
+
var _a, _b, _c;
|
|
187
|
+
group
|
|
188
|
+
.text(text)
|
|
189
|
+
.font({
|
|
190
|
+
size: (_a = options.size) !== null && _a !== void 0 ? _a : this.styles.fontStyles.size,
|
|
191
|
+
weight: options.bold ? "bold" : "normal",
|
|
192
|
+
anchor: (_b = options.anchor) !== null && _b !== void 0 ? _b : "start",
|
|
193
|
+
})
|
|
194
|
+
.fill((_c = options.color) !== null && _c !== void 0 ? _c : this.styles.fontStyles.color)
|
|
195
|
+
.attr({ x, y, "font-family": this.fontFamily() });
|
|
196
|
+
}
|
|
197
|
+
setI18n(i18n) {
|
|
198
|
+
this.i18nMap = i18n;
|
|
199
|
+
}
|
|
200
|
+
hasNoData() {
|
|
201
|
+
return this.rows.length === 0;
|
|
202
|
+
}
|
|
203
|
+
/** Warnings collected during data resolution (bullet-* codes). */
|
|
204
|
+
getWarnings() {
|
|
205
|
+
return this.warnings;
|
|
206
|
+
}
|
|
207
|
+
getAllocatedCanvasWidth() {
|
|
208
|
+
return this.availableWidth;
|
|
209
|
+
}
|
|
210
|
+
getAllocatedCanvasHeight() {
|
|
211
|
+
return (this.styles.padding.top +
|
|
212
|
+
this.titleHeight() +
|
|
213
|
+
this.headerHeight() +
|
|
214
|
+
this.rows.length * this.rowBlockHeight() +
|
|
215
|
+
this.styles.padding.bottom);
|
|
216
|
+
}
|
|
217
|
+
titleHeight() {
|
|
218
|
+
return this.config.chartTitle !== "" ? 1.6 * this.em : 0;
|
|
219
|
+
}
|
|
220
|
+
headerHeight() {
|
|
221
|
+
return this.rows.length > 0 ? 1.2 * this.em : 0;
|
|
222
|
+
}
|
|
223
|
+
rowBlockHeight() {
|
|
224
|
+
const em = this.em;
|
|
225
|
+
const rowH = this.styles.scaleFactors.rowHeight * em;
|
|
226
|
+
return this.normalized ? rowH : rowH + this.styles.scaleFactors.tickStripHeight * em;
|
|
227
|
+
}
|
|
228
|
+
valueLabel(value) {
|
|
229
|
+
if (value === null || this.config.labels.show === "none") {
|
|
230
|
+
return "";
|
|
231
|
+
}
|
|
232
|
+
return Formatter.number(value, "decimal", this.config.labels.decimals, 0);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Style family of the target marker, resolved through the rule set's
|
|
236
|
+
* colorIndex so custom rule sets restyle the marker (10=AC solid,
|
|
237
|
+
* 20=PP light, 30=FC dashed, 50=PL outlined).
|
|
238
|
+
*/
|
|
239
|
+
targetFamily() {
|
|
240
|
+
var _a, _b, _c;
|
|
241
|
+
const slot = (_b = (_a = this.config.target) === null || _a === void 0 ? void 0 : _a.measure) !== null && _b !== void 0 ? _b : "pl1";
|
|
242
|
+
const byColorIndex = { 10: "ac", 20: "pp", 30: "fc", 50: "pl" };
|
|
243
|
+
return (_c = byColorIndex[this.ruleSet.getScenarioColorIndex(slot)]) !== null && _c !== void 0 ? _c : scenarioFamily(slot);
|
|
244
|
+
}
|
|
245
|
+
/** Measure label shown above the first row, e.g. "AC". */
|
|
246
|
+
actualLabel() {
|
|
247
|
+
var _a;
|
|
248
|
+
return (_a = this.config.actual.label) !== null && _a !== void 0 ? _a : Formatter.translateScenarioLabel(this.config.actual.measure, this.i18nMap);
|
|
249
|
+
}
|
|
250
|
+
targetLabel() {
|
|
251
|
+
if (this.config.target === null) {
|
|
252
|
+
return "";
|
|
253
|
+
}
|
|
254
|
+
if (this.config.target.label !== undefined) {
|
|
255
|
+
return this.config.target.label;
|
|
256
|
+
}
|
|
257
|
+
if (this.normalized) {
|
|
258
|
+
return this.i18nMap.get("target") || "Target";
|
|
259
|
+
}
|
|
260
|
+
return Formatter.translateScenarioLabel(this.config.target.measure, this.i18nMap);
|
|
261
|
+
}
|
|
262
|
+
toString() {
|
|
263
|
+
const container = new Svg();
|
|
264
|
+
this.draw(container);
|
|
265
|
+
container.id("drawCanvas");
|
|
266
|
+
container.width(this.getAllocatedCanvasWidth());
|
|
267
|
+
container.height(this.getAllocatedCanvasHeight());
|
|
268
|
+
container.attr("overflow", "visible");
|
|
269
|
+
return container.svg();
|
|
270
|
+
}
|
|
271
|
+
draw(container) {
|
|
272
|
+
var _a, _b;
|
|
273
|
+
const em = this.em;
|
|
274
|
+
const factors = this.styles.scaleFactors;
|
|
275
|
+
const padding = this.styles.padding;
|
|
276
|
+
const root = container.group();
|
|
277
|
+
if (this.config.chartTitle !== "") {
|
|
278
|
+
this.drawText(root, this.config.chartTitle, padding.left, padding.top + em, { bold: true });
|
|
279
|
+
}
|
|
280
|
+
if (this.rows.length === 0) {
|
|
281
|
+
container.group().addClass("annotations");
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const rowH = factors.rowHeight * em;
|
|
285
|
+
const rowBlockH = this.rowBlockHeight();
|
|
286
|
+
const rowsTop = padding.top + this.titleHeight() + this.headerHeight();
|
|
287
|
+
const rowsBottom = rowsTop + (this.rows.length - 1) * rowBlockH + rowH;
|
|
288
|
+
const labelColW = Math.max(...this.rows.map((row) => this.textWidth(row.category, true)), em);
|
|
289
|
+
const valueTexts = this.rows.map((row) => this.valueLabel(row.actual));
|
|
290
|
+
const valueColW = this.config.labels.show === "none" ? 0 : Math.max(...valueTexts.map((text) => this.textWidth(text)), 0);
|
|
291
|
+
const plotX = padding.left + labelColW + factors.labelToAxis * em;
|
|
292
|
+
const plotW = Math.max(10, this.availableWidth - plotX - padding.right - valueColW - (valueColW > 0 ? factors.labelToBar * em : 0));
|
|
293
|
+
// Header: unit once ("in EUR k") and the measure label above the first row's bar.
|
|
294
|
+
const unit = (_a = this.config.actual.unit) !== null && _a !== void 0 ? _a : (_b = this.config.target) === null || _b === void 0 ? void 0 : _b.unit;
|
|
295
|
+
const inWord = this.i18nMap.get("axis.in") || "in";
|
|
296
|
+
const headerBaseline = rowsTop - 0.35 * em;
|
|
297
|
+
if (unit !== undefined && unit !== "") {
|
|
298
|
+
this.drawText(root, `${inWord} ${unit}`, padding.left, headerBaseline, {});
|
|
299
|
+
}
|
|
300
|
+
this.drawText(root, this.actualLabel(), plotX + 0.2 * em, headerBaseline, {});
|
|
301
|
+
if (this.normalized) {
|
|
302
|
+
this.drawNormalized(root, plotX, plotW, rowsTop, rowsBottom, rowH, rowBlockH, valueTexts);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
this.drawClassic(root, plotX, plotW, rowsTop, rowH, rowBlockH, valueTexts);
|
|
306
|
+
}
|
|
307
|
+
// Category labels and the shared baseline at x = 0.
|
|
308
|
+
this.rows.forEach((row, index) => {
|
|
309
|
+
const cy = rowsTop + index * rowBlockH + rowH / 2;
|
|
310
|
+
this.drawText(root, row.category, plotX - factors.labelToAxis * em, cy + 0.35 * em, {
|
|
311
|
+
anchor: "end",
|
|
312
|
+
bold: true,
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
root
|
|
316
|
+
.line(plotX, rowsTop - 0.2 * em, plotX, rowsBottom + 0.2 * em)
|
|
317
|
+
.stroke({ color: this.styles.axisStyles.ac.stroke, width: factors.axisLineWidth });
|
|
318
|
+
// Stable, empty hook for a future annotation layer.
|
|
319
|
+
container.group().addClass("annotations");
|
|
320
|
+
}
|
|
321
|
+
/** Default IBCS mode: shared fraction-of-target scale, one continuous target line, variance bars. */
|
|
322
|
+
drawNormalized(root, plotX, plotW, rowsTop, rowsBottom, rowH, rowBlockH, valueTexts) {
|
|
323
|
+
const em = this.em;
|
|
324
|
+
const factors = this.styles.scaleFactors;
|
|
325
|
+
const maxFraction = Math.max(1, ...this.rows.map((row) => { var _a; return (_a = row.fraction) !== null && _a !== void 0 ? _a : 0; }));
|
|
326
|
+
const span = maxFraction * 1.05;
|
|
327
|
+
const x = (fraction) => plotX + (fraction / span) * plotW;
|
|
328
|
+
const targetX = x(1);
|
|
329
|
+
// One continuous target line across all rows, styled by the target family.
|
|
330
|
+
const targetStyle = this.styles.barStyles.getSVGStyle(this.targetFamily());
|
|
331
|
+
const targetLine = root
|
|
332
|
+
.line(targetX, rowsTop - 0.3 * em, targetX, rowsBottom + 0.3 * em)
|
|
333
|
+
.stroke({ color: targetStyle.stroke, width: factors.targetLineWidth });
|
|
334
|
+
if (targetStyle.dasharray !== undefined) {
|
|
335
|
+
targetLine.attr("stroke-dasharray", targetStyle.dasharray);
|
|
336
|
+
}
|
|
337
|
+
this.drawText(root, this.targetLabel(), targetX, rowsTop - 0.35 * em, { anchor: "middle", bold: true });
|
|
338
|
+
this.rows.forEach((row, index) => {
|
|
339
|
+
const cy = rowsTop + index * rowBlockH + rowH / 2;
|
|
340
|
+
if (row.fraction === null) {
|
|
341
|
+
// Not normalizable (missing/invalid target or negative actual): value text only.
|
|
342
|
+
this.drawValueText(root, valueTexts[index], plotX + factors.labelToBar * em, cy);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const barH = factors.barHeight * em;
|
|
346
|
+
const barEnd = x(row.fraction);
|
|
347
|
+
root
|
|
348
|
+
.rect(Math.max(0, barEnd - plotX), barH)
|
|
349
|
+
.move(plotX, cy - barH / 2)
|
|
350
|
+
.fill(this.styles.barStyles.ac.fill)
|
|
351
|
+
.stroke({ color: this.styles.barStyles.ac.stroke, width: this.styles.barStyles.ac.width });
|
|
352
|
+
if (this.config.showVariances && row.sentiment !== "neu") {
|
|
353
|
+
const varianceH = factors.varianceHeight * em;
|
|
354
|
+
const varianceStyle = this.styles.varianceStyles.getSVGStyle(row.sentiment);
|
|
355
|
+
root
|
|
356
|
+
.rect(Math.abs(barEnd - targetX), varianceH)
|
|
357
|
+
.move(Math.min(barEnd, targetX), cy - varianceH / 2)
|
|
358
|
+
.fill(varianceStyle.fill)
|
|
359
|
+
.stroke({ color: varianceStyle.stroke, width: varianceStyle.width });
|
|
360
|
+
}
|
|
361
|
+
this.drawValueText(root, valueTexts[index], Math.max(barEnd, targetX) + factors.labelToBar * em, cy);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
/** Classic mode: per-row scales with tick strips, target ticks, optional range bands. */
|
|
365
|
+
drawClassic(root, plotX, plotW, rowsTop, rowH, rowBlockH, valueTexts) {
|
|
366
|
+
const em = this.em;
|
|
367
|
+
const factors = this.styles.scaleFactors;
|
|
368
|
+
const barH = factors.barHeight * em;
|
|
369
|
+
const drawRanges = this.config.ranges.length > 0;
|
|
370
|
+
this.rows.forEach((row, index) => {
|
|
371
|
+
var _a, _b;
|
|
372
|
+
const rowTop = rowsTop + index * rowBlockH;
|
|
373
|
+
const cy = rowTop + rowH / 2;
|
|
374
|
+
const bandEnds = drawRanges && row.target !== null ? this.config.ranges.map((r) => r * row.target) : [];
|
|
375
|
+
const rowMax = Math.max((_a = row.actual) !== null && _a !== void 0 ? _a : 0, (_b = row.target) !== null && _b !== void 0 ? _b : 0, ...bandEnds);
|
|
376
|
+
if (rowMax <= 0) {
|
|
377
|
+
this.drawValueText(root, valueTexts[index], plotX + factors.labelToBar * em, cy);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const step = NumericScale.niceStep(rowMax, 4);
|
|
381
|
+
const niceMax = Math.ceil(rowMax / step - step * 1e-9) * step;
|
|
382
|
+
const scale = new NumericScale(0, niceMax, plotX, plotX + plotW);
|
|
383
|
+
// Qualitative range bands, behind everything: darker [0, r1·t], lighter [r1·t, r2·t].
|
|
384
|
+
let bandStart = plotX;
|
|
385
|
+
bandEnds.forEach((end, bandIndex) => {
|
|
386
|
+
const bandH = rowH * 0.8;
|
|
387
|
+
root
|
|
388
|
+
.rect(Math.max(0, scale.scale(end) - bandStart), bandH)
|
|
389
|
+
.move(bandStart, cy - bandH / 2)
|
|
390
|
+
.fill(this.styles.rangeColors[Math.min(bandIndex, this.styles.rangeColors.length - 1)])
|
|
391
|
+
.stroke("none");
|
|
392
|
+
bandStart = scale.scale(end);
|
|
393
|
+
});
|
|
394
|
+
let rowRight = plotX;
|
|
395
|
+
if (row.actual !== null && row.actual > 0) {
|
|
396
|
+
const barEnd = scale.scale(row.actual);
|
|
397
|
+
root
|
|
398
|
+
.rect(barEnd - plotX, barH)
|
|
399
|
+
.move(plotX, cy - barH / 2)
|
|
400
|
+
.fill(this.styles.barStyles.ac.fill)
|
|
401
|
+
.stroke({ color: this.styles.barStyles.ac.stroke, width: this.styles.barStyles.ac.width });
|
|
402
|
+
rowRight = barEnd;
|
|
403
|
+
}
|
|
404
|
+
if (row.target !== null && row.target > 0) {
|
|
405
|
+
const tickX = scale.scale(row.target);
|
|
406
|
+
const tickH = factors.targetTickHeight * em;
|
|
407
|
+
const targetStyle = this.styles.barStyles.getSVGStyle(this.targetFamily());
|
|
408
|
+
const tick = root
|
|
409
|
+
.line(tickX, cy - tickH / 2, tickX, cy + tickH / 2)
|
|
410
|
+
.stroke({ color: targetStyle.stroke, width: factors.targetLineWidth });
|
|
411
|
+
if (targetStyle.dasharray !== undefined) {
|
|
412
|
+
tick.attr("stroke-dasharray", targetStyle.dasharray);
|
|
413
|
+
}
|
|
414
|
+
if (index === 0) {
|
|
415
|
+
this.drawText(root, this.targetLabel(), tickX, rowsTop - 0.35 * em, { anchor: "middle" });
|
|
416
|
+
}
|
|
417
|
+
rowRight = Math.max(rowRight, tickX);
|
|
418
|
+
}
|
|
419
|
+
rowRight = Math.max(rowRight, bandStart);
|
|
420
|
+
this.drawValueText(root, valueTexts[index], rowRight + factors.labelToBar * em, cy);
|
|
421
|
+
// Per-row tick strip below the band.
|
|
422
|
+
const ticks = scale.ticks(4);
|
|
423
|
+
const decimals = NumericScale.tickDecimals(ticks);
|
|
424
|
+
const tickTop = rowTop + rowH;
|
|
425
|
+
for (const tick of ticks) {
|
|
426
|
+
const tickX = scale.scale(tick);
|
|
427
|
+
root
|
|
428
|
+
.line(tickX, tickTop, tickX, tickTop + factors.axisTickLength * em)
|
|
429
|
+
.stroke({ color: this.styles.axisStyles.ac.stroke, width: factors.axisLineWidth });
|
|
430
|
+
this.drawText(root, Formatter.number(tick, "decimal", decimals, decimals), tickX, tickTop + factors.tickStripHeight * em - 0.2 * em, { anchor: "middle" });
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
drawValueText(root, text, x, cy) {
|
|
435
|
+
if (text === "") {
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
this.drawText(root, text, x, cy + 0.35 * this.em, {});
|
|
439
|
+
}
|
|
440
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { CompareUtil } from "../../../../utils/helper/CompareUtil";
|
|
2
|
+
/**
|
|
3
|
+
* Proportional scale factors for bullet graph elements.
|
|
4
|
+
*
|
|
5
|
+
* All values except the `*LineWidth` entries are expressed in **font-size
|
|
6
|
+
* multiples** (em-like units), so the chart scales uniformly when the base
|
|
7
|
+
* font size changes. Line widths are absolute pixel values (hairlines must
|
|
8
|
+
* not scale with the font).
|
|
9
|
+
*/
|
|
10
|
+
export class ScaleFactorsBulletChart {
|
|
11
|
+
constructor() {
|
|
12
|
+
/** Height of one KPI row. */
|
|
13
|
+
this.rowHeight = 1.9;
|
|
14
|
+
/** Height of the actual-value bar. */
|
|
15
|
+
this.barHeight = 0.66;
|
|
16
|
+
/** Height of the integrated variance bar overlay. */
|
|
17
|
+
this.varianceHeight = 0.4;
|
|
18
|
+
/** Height of a per-row target tick (classic mode). */
|
|
19
|
+
this.targetTickHeight = 1.1;
|
|
20
|
+
/** Stroke width of the shared target line, in pixels. */
|
|
21
|
+
this.targetLineWidth = 2;
|
|
22
|
+
/** Stroke width of the baseline axis, in pixels. */
|
|
23
|
+
this.axisLineWidth = 1;
|
|
24
|
+
/** Gap between a bar end and its value label. */
|
|
25
|
+
this.labelToBar = 0.3;
|
|
26
|
+
/** Gap between the category label column and the baseline axis. */
|
|
27
|
+
this.labelToAxis = 0.3;
|
|
28
|
+
/** Length of axis tick marks (classic mode). */
|
|
29
|
+
this.axisTickLength = 0.35;
|
|
30
|
+
/** Height of the per-row tick-label strip (classic mode). */
|
|
31
|
+
this.tickStripHeight = 1.2;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Converts untyped JSON into a validated {@link ScaleFactorsBulletChart}. */
|
|
35
|
+
export class ScaleFactorsBulletChartAdapter {
|
|
36
|
+
adapt(data) {
|
|
37
|
+
const scaleFactors = new ScaleFactorsBulletChart();
|
|
38
|
+
if (CompareUtil.isNumber(data.rowHeight)) {
|
|
39
|
+
scaleFactors.rowHeight = data.rowHeight;
|
|
40
|
+
}
|
|
41
|
+
if (CompareUtil.isNumber(data.barHeight)) {
|
|
42
|
+
scaleFactors.barHeight = data.barHeight;
|
|
43
|
+
}
|
|
44
|
+
if (CompareUtil.isNumber(data.varianceHeight)) {
|
|
45
|
+
scaleFactors.varianceHeight = data.varianceHeight;
|
|
46
|
+
}
|
|
47
|
+
if (CompareUtil.isNumber(data.targetTickHeight)) {
|
|
48
|
+
scaleFactors.targetTickHeight = data.targetTickHeight;
|
|
49
|
+
}
|
|
50
|
+
if (CompareUtil.isNumber(data.targetLineWidth)) {
|
|
51
|
+
scaleFactors.targetLineWidth = data.targetLineWidth;
|
|
52
|
+
}
|
|
53
|
+
if (CompareUtil.isNumber(data.axisLineWidth)) {
|
|
54
|
+
scaleFactors.axisLineWidth = data.axisLineWidth;
|
|
55
|
+
}
|
|
56
|
+
if (CompareUtil.isNumber(data.labelToBar)) {
|
|
57
|
+
scaleFactors.labelToBar = data.labelToBar;
|
|
58
|
+
}
|
|
59
|
+
if (CompareUtil.isNumber(data.labelToAxis)) {
|
|
60
|
+
scaleFactors.labelToAxis = data.labelToAxis;
|
|
61
|
+
}
|
|
62
|
+
if (CompareUtil.isNumber(data.axisTickLength)) {
|
|
63
|
+
scaleFactors.axisTickLength = data.axisTickLength;
|
|
64
|
+
}
|
|
65
|
+
if (CompareUtil.isNumber(data.tickStripHeight)) {
|
|
66
|
+
scaleFactors.tickStripHeight = data.tickStripHeight;
|
|
67
|
+
}
|
|
68
|
+
return scaleFactors;
|
|
69
|
+
}
|
|
70
|
+
default() {
|
|
71
|
+
return new ScaleFactorsBulletChart();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Aggregates all style configuration for a bullet graph: scale factors,
|
|
76
|
+
* fonts, scenario colors, variance colors, range-band grays, and padding.
|
|
77
|
+
*
|
|
78
|
+
* The analog of {@link StructureChartStyle} with `rangeColors` (the max two
|
|
79
|
+
* qualitative band grays) in place of `stackColors` and no fill patterns
|
|
80
|
+
* (the FC target treatment uses a dashed stroke, not hatching).
|
|
81
|
+
*/
|
|
82
|
+
export class BulletChartStyle {
|
|
83
|
+
constructor(scaleFactors, fontStyles, axisStyles, barStyles, varianceStyles, padding) {
|
|
84
|
+
this.scaleFactors = scaleFactors;
|
|
85
|
+
this.fontStyles = fontStyles;
|
|
86
|
+
this.axisStyles = axisStyles;
|
|
87
|
+
this.barStyles = barStyles;
|
|
88
|
+
this.varianceStyles = varianceStyles;
|
|
89
|
+
this.padding = padding;
|
|
90
|
+
this.rangeColors = ["#D9D9D9", "#EFEFEF"];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** Adapts raw componentStyle JSON into a BulletChartStyle, falling back to defaults for missing properties. */
|
|
94
|
+
export class BulletChartStylesAdapter {
|
|
95
|
+
constructor(scaleFactorsBulletChartAdapter, fontStyleAdapter, svgStyleGroupAdapter, svgVariancesStyleGroupAdapter, paddingAdapter) {
|
|
96
|
+
this.scaleFactorsBulletChartAdapter = scaleFactorsBulletChartAdapter;
|
|
97
|
+
this.fontStyleAdapter = fontStyleAdapter;
|
|
98
|
+
this.svgStyleGroupAdapter = svgStyleGroupAdapter;
|
|
99
|
+
this.svgVariancesStyleGroupAdapter = svgVariancesStyleGroupAdapter;
|
|
100
|
+
this.paddingAdapter = paddingAdapter;
|
|
101
|
+
}
|
|
102
|
+
adapt(data) {
|
|
103
|
+
const styles = this.default();
|
|
104
|
+
if (CompareUtil.isExisting(data)) {
|
|
105
|
+
if (CompareUtil.isExisting(data.scaleFactors)) {
|
|
106
|
+
styles.scaleFactors = this.scaleFactorsBulletChartAdapter.adapt(data.scaleFactors);
|
|
107
|
+
}
|
|
108
|
+
if (CompareUtil.isExisting(data.fontStyles)) {
|
|
109
|
+
styles.fontStyles = this.fontStyleAdapter.adapt(data.fontStyles);
|
|
110
|
+
}
|
|
111
|
+
if (CompareUtil.isExisting(data.axisStyles)) {
|
|
112
|
+
styles.axisStyles = this.svgStyleGroupAdapter.adapt(data.axisStyles);
|
|
113
|
+
}
|
|
114
|
+
if (CompareUtil.isExisting(data.barStyles)) {
|
|
115
|
+
styles.barStyles = this.svgStyleGroupAdapter.adapt(data.barStyles);
|
|
116
|
+
}
|
|
117
|
+
if (CompareUtil.isExisting(data.varianceStyles)) {
|
|
118
|
+
styles.varianceStyles = this.svgVariancesStyleGroupAdapter.adapt(data.varianceStyles);
|
|
119
|
+
}
|
|
120
|
+
if (CompareUtil.isExisting(data.padding)) {
|
|
121
|
+
styles.padding = this.paddingAdapter.adapt(data.padding);
|
|
122
|
+
}
|
|
123
|
+
if (Array.isArray(data.rangeColors) && data.rangeColors.length > 0) {
|
|
124
|
+
styles.rangeColors = data.rangeColors;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return styles;
|
|
128
|
+
}
|
|
129
|
+
default() {
|
|
130
|
+
return new BulletChartStyle(this.scaleFactorsBulletChartAdapter.default(), this.fontStyleAdapter.default(), this.svgStyleGroupAdapter.default(), this.svgStyleGroupAdapter.default(), this.svgVariancesStyleGroupAdapter.default(), this.paddingAdapter.default());
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { CompareUtil } from "../../../../utils/helper/CompareUtil";
|
|
2
|
+
const MEASURE_KEYS = ["measure", "label", "unit"];
|
|
3
|
+
export function toBulletMeasureConfig(data) {
|
|
4
|
+
const invalidFields = [];
|
|
5
|
+
const measure = readString(data, "measure", invalidFields);
|
|
6
|
+
if (measure === undefined || measure.trim() === "") {
|
|
7
|
+
invalidFields.push("measure");
|
|
8
|
+
return { config: null, unknownKeys: collectUnknownKeys(data, MEASURE_KEYS), invalidFields };
|
|
9
|
+
}
|
|
10
|
+
const config = { measure: measure.trim() };
|
|
11
|
+
config.label = readString(data, "label", invalidFields);
|
|
12
|
+
config.unit = readString(data, "unit", invalidFields);
|
|
13
|
+
return { config, unknownKeys: collectUnknownKeys(data, MEASURE_KEYS), invalidFields };
|
|
14
|
+
}
|
|
15
|
+
const LABEL_KEYS = ["show", "decimals"];
|
|
16
|
+
export function toBulletLabelConfig(data, defaults) {
|
|
17
|
+
const invalidFields = [];
|
|
18
|
+
const config = { show: defaults.show, decimals: defaults.decimals };
|
|
19
|
+
if (CompareUtil.isExisting(data.show)) {
|
|
20
|
+
if (data.show === "auto" || data.show === "none") {
|
|
21
|
+
config.show = data.show;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
invalidFields.push("show");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (CompareUtil.isExisting(data.decimals)) {
|
|
28
|
+
if (CompareUtil.isNumber(data.decimals) && data.decimals >= 0 && data.decimals <= 4) {
|
|
29
|
+
config.decimals = Math.floor(data.decimals);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
invalidFields.push("decimals");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return { config, unknownKeys: collectUnknownKeys(data, LABEL_KEYS), invalidFields };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parses the raw `ranges` attribute value. A blank value yields no ranges
|
|
39
|
+
* without error. Anything else must be a JSON array of positive numbers —
|
|
40
|
+
* ascending fractions of the target, e.g. `[0.6, 0.9]`. `parseSpec` cannot
|
|
41
|
+
* be used here because it rejects top-level JSON arrays. Unsorted input is
|
|
42
|
+
* sorted and more than two entries are truncated; both repairs are reported
|
|
43
|
+
* as issues.
|
|
44
|
+
*/
|
|
45
|
+
export function parseRanges(raw) {
|
|
46
|
+
var _a;
|
|
47
|
+
const trimmed = (_a = raw === null || raw === void 0 ? void 0 : raw.trim()) !== null && _a !== void 0 ? _a : "";
|
|
48
|
+
if (trimmed === "" || trimmed === "null") {
|
|
49
|
+
return { ranges: [], parseError: false, issues: [] };
|
|
50
|
+
}
|
|
51
|
+
let parsed;
|
|
52
|
+
try {
|
|
53
|
+
parsed = JSON.parse(trimmed);
|
|
54
|
+
}
|
|
55
|
+
catch (_b) {
|
|
56
|
+
return { ranges: [], parseError: true, issues: [] };
|
|
57
|
+
}
|
|
58
|
+
if (!Array.isArray(parsed) || parsed.length === 0) {
|
|
59
|
+
return { ranges: [], parseError: true, issues: [] };
|
|
60
|
+
}
|
|
61
|
+
if (!parsed.every((entry) => CompareUtil.isNumber(entry) && isFinite(entry) && entry > 0)) {
|
|
62
|
+
return { ranges: [], parseError: true, issues: [] };
|
|
63
|
+
}
|
|
64
|
+
const issues = [];
|
|
65
|
+
let ranges = parsed;
|
|
66
|
+
const sorted = [...ranges].sort((a, b) => a - b);
|
|
67
|
+
if (sorted.some((value, index) => value !== ranges[index])) {
|
|
68
|
+
issues.push("not ascending, sorted");
|
|
69
|
+
}
|
|
70
|
+
ranges = sorted;
|
|
71
|
+
if (ranges.length > 2) {
|
|
72
|
+
issues.push(`${ranges.length} entries, first 2 kept`);
|
|
73
|
+
ranges = ranges.slice(0, 2);
|
|
74
|
+
}
|
|
75
|
+
return { ranges, parseError: false, issues };
|
|
76
|
+
}
|
|
77
|
+
function collectUnknownKeys(data, knownKeys) {
|
|
78
|
+
return Object.keys(data).filter((key) => !knownKeys.includes(key));
|
|
79
|
+
}
|
|
80
|
+
function readString(data, key, invalid) {
|
|
81
|
+
if (!CompareUtil.isExisting(data[key])) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
if (CompareUtil.isString(data[key])) {
|
|
85
|
+
return data[key];
|
|
86
|
+
}
|
|
87
|
+
invalid.push(key);
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|