@bino-bi/bn-template-engine 1.0.0-alpha.16 → 1.0.0-alpha.18
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-0107f0cc.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-5651417d.entry.js +1 -0
- package/dist/bn-template-engine/p-5bfdc1e5.entry.js +1 -0
- package/dist/bn-template-engine/p-6b75762d.entry.js +1 -0
- package/dist/bn-template-engine/{p-ff659485.entry.js → p-7bdc0e28.entry.js} +1 -1
- 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-BqhIhYr1.js +1 -0
- package/dist/bn-template-engine/p-C0Pwqx-O.js +1 -0
- package/dist/bn-template-engine/p-CBqUr7I8.js +1 -0
- package/dist/bn-template-engine/{p-BPDZcex5.js → p-CPzF3Q2m.js} +1 -1
- package/dist/bn-template-engine/p-CiudZRQr.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-a130cb43.entry.js +1 -0
- package/dist/bn-template-engine/p-aakBGfzL.js +1 -0
- package/dist/bn-template-engine/p-dc745c32.entry.js +1 -0
- package/dist/bn-template-engine/p-e96da91f.entry.js +1 -0
- package/dist/bn-template-engine/p-f3d1fa06.entry.js +1 -0
- package/dist/bn-template-engine/p-fcb43f2c.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 +1614 -9670
- 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 +2 -2
- 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-Cn5PL928.js → context-protocol-BDrMkhc4.js} +272 -1
- package/dist/cjs/editor-companion.cjs.entry.js +2 -2
- 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-p0wXIWFg.js +350 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sanitizeHtml-LuZr1IMd.js +85 -0
- package/dist/cjs/{scaling-DM2UILdF.js → scaling-BmqxcNOf.js} +1 -1
- package/dist/cjs/withScalingGroup-BmcRlWBs.js +73 -0
- package/dist/cjs/{withStyled-Dx3uRw9g.js → withStyled-CRiC9fzc.js} +44 -383
- package/dist/collection/collection-manifest.json +7 -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 +23 -2
- package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +29 -4
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +3 -0
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +27 -4
- package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +29 -4
- package/dist/collection/components/bn-chart-time/utils/TimeChart.js +16 -4
- package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +3 -3
- 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 +1 -1
- package/dist/collection/components/bn-datasource/bn-datasource.js +1 -1
- 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 +1 -1
- package/dist/collection/components/bn-layout-card/bn-layout-card.js +26 -3
- package/dist/collection/components/bn-layout-page/bn-layout-page.js +33 -4
- 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.js +1 -1
- package/dist/collection/components/bn-table/bn-table.js +146 -14
- package/dist/collection/components/bn-table/ibcs-table.css +8 -0
- package/dist/collection/components/bn-table/ibcs-table.js +64 -8
- package/dist/collection/components/bn-table/utils/Table.js +43 -5
- 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 +87 -15
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +284 -3
- package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +140 -0
- 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/TableComponentConfig.js +10 -0
- 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 -3
- package/dist/collection/components/bn-title/ibcs-title/utils/Title.js +3 -0
- package/dist/collection/components/editor-companion/editor-companion.js +1 -1
- package/dist/collection/stores/componentStyles.js +67 -0
- package/dist/collection/stores/createScopedStores.js +6 -1
- 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/ibcsRuleSet.js +14 -26
- package/dist/collection/utils/sanitizeHtml.js +81 -0
- package/dist/collection/utils/validate.js +24 -0
- package/dist/collection/utils/withComponentStyle.js +3 -5
- package/dist/collection/utils/withInheritedProps.js +1 -1
- package/dist/collection/utils/withRuleSet.js +105 -0
- package/dist/collection/utils/withScalingGroup.js +3 -0
- 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/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-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.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/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 -1
- package/dist/components/luxon.js +1 -1
- 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/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/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 +1127 -9183
- 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 +2 -2
- 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-BB-4Onmw.js → context-protocol-1Yj1uKvh.js} +268 -2
- package/dist/esm/editor-companion.entry.js +2 -2
- 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-DCbmpGrz.js +345 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sanitizeHtml-BA48JiHe.js +83 -0
- package/dist/esm/{scaling-h4KcBet3.js → scaling-B_k50v9z.js} +2 -2
- package/dist/esm/withScalingGroup-Br70pAv9.js +71 -0
- package/dist/esm/{withStyled-BBvU2f-A.js → withStyled-Br2DGTPs.js} +30 -367
- 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 +7 -0
- package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +2 -0
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +1 -0
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +10 -1
- package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +2 -0
- package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +1 -0
- package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +10 -0
- package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +14 -0
- 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-table/bn-table.d.ts +38 -5
- package/dist/types/components/bn-table/ibcs-table.d.ts +8 -1
- package/dist/types/components/bn-table/utils/Table.d.ts +8 -0
- 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 +13 -7
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +17 -0
- package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +37 -0
- 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/TableComponentConfig.d.ts +4 -0
- 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.d.ts +1383 -82
- package/dist/types/context/context-protocol.d.ts +2 -0
- package/dist/types/stores/componentStyles.d.ts +41 -0
- package/dist/types/stores/createScopedStores.d.ts +2 -0
- package/dist/types/stores/ruleSets.d.ts +40 -0
- package/dist/types/utils/constants.d.ts +5 -0
- package/dist/types/utils/ibcsRuleSet.d.ts +6 -1
- package/dist/types/utils/model/ChartStyles.d.ts +2 -1
- package/dist/types/utils/sanitizeHtml.d.ts +6 -0
- package/dist/types/utils/validate.d.ts +12 -0
- package/dist/types/utils/withInheritedProps.d.ts +11 -0
- package/dist/types/utils/withRuleSet.d.ts +24 -0
- 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 +1 -1
- package/readme.md +7 -3
- package/dist/bn-template-engine/p-19f49fbc.entry.js +0 -1
- package/dist/bn-template-engine/p-3465fcdc.entry.js +0 -1
- package/dist/bn-template-engine/p-67746414.entry.js +0 -1
- package/dist/bn-template-engine/p-6b469808.entry.js +0 -1
- package/dist/bn-template-engine/p-86ca2d5e.entry.js +0 -1
- package/dist/bn-template-engine/p-Tx6omDWp.js +0 -1
- package/dist/bn-template-engine/p-d724ab88.entry.js +0 -1
- package/dist/bn-template-engine/p-efd3b67a.entry.js +0 -1
- package/dist/bn-template-engine/p-z9bPNFYF.js +0 -1
- package/dist/components/ibcsRuleSet.js +0 -1
- package/dist/components/scaling.js +0 -1
- package/dist/components/withInheritedProps.js +0 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const SAMPLES = 64;
|
|
2
|
+
/**
|
|
3
|
+
* Hyperbolic iso-lines `x·y = k` for the scatter chart (IBCS 09C/09D):
|
|
4
|
+
* a third derived measure visualized as thin curves with value labels at
|
|
5
|
+
* the curve's exit edge, optionally shading the region `x·y >= k`.
|
|
6
|
+
*
|
|
7
|
+
* Requires a strictly positive plot domain on both axes.
|
|
8
|
+
*/
|
|
9
|
+
export class IsoCurves {
|
|
10
|
+
constructor(xScale, yScale) {
|
|
11
|
+
this.xScale = xScale;
|
|
12
|
+
this.yScale = yScale;
|
|
13
|
+
}
|
|
14
|
+
/** Iso-curves are only defined on strictly positive domains. */
|
|
15
|
+
isPositiveDomain() {
|
|
16
|
+
return this.xScale.domainMin > 0 && this.yScale.domainMin > 0;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Picks 2–4 nice k values from the 1-2-5 ladder spanning the central
|
|
20
|
+
* product range of the data (products = `x·y` per point).
|
|
21
|
+
*/
|
|
22
|
+
static autoK(products) {
|
|
23
|
+
const positive = products.filter((p) => p > 0).sort((a, b) => a - b);
|
|
24
|
+
if (positive.length === 0) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const quantile = (q) => positive[Math.min(positive.length - 1, Math.floor(q * positive.length))];
|
|
28
|
+
let candidates = IsoCurves.ladderValues(quantile(0.25), quantile(0.75));
|
|
29
|
+
if (candidates.length < 2) {
|
|
30
|
+
candidates = IsoCurves.ladderValues(positive[0], positive[positive.length - 1]);
|
|
31
|
+
}
|
|
32
|
+
if (candidates.length === 0) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
if (candidates.length === 1) {
|
|
36
|
+
return candidates;
|
|
37
|
+
}
|
|
38
|
+
if (candidates.length <= 4) {
|
|
39
|
+
return candidates;
|
|
40
|
+
}
|
|
41
|
+
// Evenly spaced subset of 4 across the candidate list.
|
|
42
|
+
const picked = [];
|
|
43
|
+
for (let i = 0; i < 4; i++) {
|
|
44
|
+
picked.push(candidates[Math.round((i * (candidates.length - 1)) / 3)]);
|
|
45
|
+
}
|
|
46
|
+
return [...new Set(picked)];
|
|
47
|
+
}
|
|
48
|
+
/** All 1-2-5 ladder values within `[min, max]`, ascending. */
|
|
49
|
+
static ladderValues(min, max) {
|
|
50
|
+
if (min <= 0 || max < min) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const values = [];
|
|
54
|
+
for (let exp = Math.floor(Math.log10(min)) - 1; exp <= Math.ceil(Math.log10(max)); exp++) {
|
|
55
|
+
for (const mantissa of [1, 2, 5]) {
|
|
56
|
+
const value = mantissa * Math.pow(10, exp);
|
|
57
|
+
if (value >= min && value <= max) {
|
|
58
|
+
values.push(value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return values;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Domain x-interval where the curve `y = k/x` lies inside the domain
|
|
66
|
+
* rectangle, or `null` when the curve misses it entirely.
|
|
67
|
+
*/
|
|
68
|
+
visibleRange(k) {
|
|
69
|
+
if (!this.isPositiveDomain() || k <= 0) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const x1 = Math.max(this.xScale.domainMin, k / this.yScale.domainMax);
|
|
73
|
+
const x2 = Math.min(this.xScale.domainMax, k / this.yScale.domainMin);
|
|
74
|
+
if (x1 >= x2) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return [x1, x2];
|
|
78
|
+
}
|
|
79
|
+
/** Curve sample points in pixel coordinates (geometric x-spacing). */
|
|
80
|
+
samples(k) {
|
|
81
|
+
const range = this.visibleRange(k);
|
|
82
|
+
if (range === null) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const [x1, x2] = range;
|
|
86
|
+
const points = [];
|
|
87
|
+
for (let i = 0; i < SAMPLES; i++) {
|
|
88
|
+
const x = x1 * Math.pow(x2 / x1, i / (SAMPLES - 1));
|
|
89
|
+
points.push({ x: this.xScale.scale(x), y: this.yScale.scale(k / x) });
|
|
90
|
+
}
|
|
91
|
+
return points;
|
|
92
|
+
}
|
|
93
|
+
/** SVG path of the curve clipped to the frame, or `null` when invisible. */
|
|
94
|
+
path(k) {
|
|
95
|
+
const points = this.samples(k);
|
|
96
|
+
if (points === null) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return points.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x} ${p.y}`).join(" ");
|
|
100
|
+
}
|
|
101
|
+
/** Where the curve leaves the frame at its high-x end (label position). */
|
|
102
|
+
exitPoint(k) {
|
|
103
|
+
const range = this.visibleRange(k);
|
|
104
|
+
if (range === null) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
const x2 = range[1];
|
|
108
|
+
const exitsRight = x2 >= this.xScale.domainMax - Math.abs(this.xScale.domainMax) * 1e-9;
|
|
109
|
+
return {
|
|
110
|
+
x: this.xScale.scale(x2),
|
|
111
|
+
y: this.yScale.scale(k / x2),
|
|
112
|
+
edge: exitsRight ? "right" : "bottom",
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Closed SVG path of the region `x·y >= k` inside the frame (the area
|
|
117
|
+
* between the curve and the top-right frame corner), or the full frame
|
|
118
|
+
* when the curve lies entirely below-left of it, or `null` when the
|
|
119
|
+
* region is empty.
|
|
120
|
+
*/
|
|
121
|
+
regionPath(k) {
|
|
122
|
+
if (!this.isPositiveDomain() || k <= 0) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const xMin = this.xScale.domainMin;
|
|
126
|
+
const xMax = this.xScale.domainMax;
|
|
127
|
+
const yMin = this.yScale.domainMin;
|
|
128
|
+
const yMax = this.yScale.domainMax;
|
|
129
|
+
const left = this.xScale.scale(xMin);
|
|
130
|
+
const right = this.xScale.scale(xMax);
|
|
131
|
+
const top = this.yScale.scale(yMax);
|
|
132
|
+
const bottom = this.yScale.scale(yMin);
|
|
133
|
+
if (k >= xMax * yMax) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
if (k <= xMin * yMin) {
|
|
137
|
+
return `M ${left} ${top} L ${right} ${top} L ${right} ${bottom} L ${left} ${bottom} Z`;
|
|
138
|
+
}
|
|
139
|
+
const points = this.samples(k);
|
|
140
|
+
const [x1, x2] = this.visibleRange(k);
|
|
141
|
+
const entersTop = x1 > xMin;
|
|
142
|
+
const exitsRight = x2 >= xMax - Math.abs(xMax) * 1e-9;
|
|
143
|
+
const path = points.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x} ${p.y}`);
|
|
144
|
+
// Walk the frame boundary from the exit point back to the entry point,
|
|
145
|
+
// enclosing the top-right corner.
|
|
146
|
+
if (!exitsRight) {
|
|
147
|
+
path.push(`L ${right} ${bottom}`);
|
|
148
|
+
}
|
|
149
|
+
path.push(`L ${right} ${top}`);
|
|
150
|
+
if (!entersTop) {
|
|
151
|
+
path.push(`L ${left} ${top}`);
|
|
152
|
+
}
|
|
153
|
+
path.push("Z");
|
|
154
|
+
return path.join(" ");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linear numeric scale with nice-tick generation for the XY charts.
|
|
3
|
+
*
|
|
4
|
+
* Domains default to the data extent padded 4% on each side; zero-inclusion
|
|
5
|
+
* is NOT forced — points encode by position, not length, so IBCS's
|
|
6
|
+
* zero-baseline rule for bars does not apply. Explicit `min`/`max`
|
|
7
|
+
* overrides disable the padding on that side.
|
|
8
|
+
*/
|
|
9
|
+
export class NumericScale {
|
|
10
|
+
constructor(domainMin, domainMax, rangeMin, rangeMax) {
|
|
11
|
+
this.domainMin = domainMin;
|
|
12
|
+
this.domainMax = domainMax;
|
|
13
|
+
this.rangeMin = rangeMin;
|
|
14
|
+
this.rangeMax = rangeMax;
|
|
15
|
+
}
|
|
16
|
+
/** Maps a domain value to range (pixel) coordinates. */
|
|
17
|
+
scale(value) {
|
|
18
|
+
const span = this.domainMax - this.domainMin;
|
|
19
|
+
if (span === 0) {
|
|
20
|
+
return (this.rangeMin + this.rangeMax) / 2;
|
|
21
|
+
}
|
|
22
|
+
return this.rangeMin + ((value - this.domainMin) / span) * (this.rangeMax - this.rangeMin);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Computes the domain from a data extent: 4% padding on each side,
|
|
26
|
+
* overridden per side by explicit `min`/`max`. Degenerate extents
|
|
27
|
+
* (single value) are widened symmetrically.
|
|
28
|
+
*/
|
|
29
|
+
static domain(dataMin, dataMax, override, pad = 0.04) {
|
|
30
|
+
let span = dataMax - dataMin;
|
|
31
|
+
if (span === 0) {
|
|
32
|
+
const widen = dataMin === 0 ? 1 : Math.abs(dataMin) * 0.1;
|
|
33
|
+
dataMin -= widen;
|
|
34
|
+
dataMax += widen;
|
|
35
|
+
span = dataMax - dataMin;
|
|
36
|
+
}
|
|
37
|
+
const min = (override === null || override === void 0 ? void 0 : override.min) !== undefined ? override.min : dataMin - span * pad;
|
|
38
|
+
const max = (override === null || override === void 0 ? void 0 : override.max) !== undefined ? override.max : dataMax + span * pad;
|
|
39
|
+
return [min, max];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Picks a nice step size from the 1-2-2.5-5 ladder so that the span
|
|
43
|
+
* yields close to `targetCount` ticks.
|
|
44
|
+
*/
|
|
45
|
+
static niceStep(span, targetCount) {
|
|
46
|
+
if (span <= 0 || targetCount <= 0) {
|
|
47
|
+
return 1;
|
|
48
|
+
}
|
|
49
|
+
const rawStep = span / targetCount;
|
|
50
|
+
const magnitude = Math.pow(10, Math.floor(Math.log10(rawStep)));
|
|
51
|
+
const normalized = rawStep / magnitude;
|
|
52
|
+
let mantissa;
|
|
53
|
+
if (normalized <= 1) {
|
|
54
|
+
mantissa = 1;
|
|
55
|
+
}
|
|
56
|
+
else if (normalized <= 2) {
|
|
57
|
+
mantissa = 2;
|
|
58
|
+
}
|
|
59
|
+
else if (normalized <= 2.5) {
|
|
60
|
+
mantissa = 2.5;
|
|
61
|
+
}
|
|
62
|
+
else if (normalized <= 5) {
|
|
63
|
+
mantissa = 5;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
mantissa = 10;
|
|
67
|
+
}
|
|
68
|
+
return mantissa * magnitude;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Nice tick values inside the domain, aiming for `targetCount` ticks
|
|
72
|
+
* (the renderer picks 4–8 depending on panel size).
|
|
73
|
+
*/
|
|
74
|
+
ticks(targetCount) {
|
|
75
|
+
const span = this.domainMax - this.domainMin;
|
|
76
|
+
if (span <= 0) {
|
|
77
|
+
return [this.domainMin];
|
|
78
|
+
}
|
|
79
|
+
const step = NumericScale.niceStep(span, targetCount);
|
|
80
|
+
const first = Math.ceil(this.domainMin / step) * step;
|
|
81
|
+
const ticks = [];
|
|
82
|
+
// Guard against floating-point drift at the domain edge.
|
|
83
|
+
for (let tick = first; tick <= this.domainMax + step * 1e-9; tick += step) {
|
|
84
|
+
ticks.push(Math.abs(tick) < step * 1e-9 ? 0 : tick);
|
|
85
|
+
}
|
|
86
|
+
return ticks;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Decimal places (0–2) needed to render the given ticks without
|
|
90
|
+
* ambiguity between adjacent values.
|
|
91
|
+
*/
|
|
92
|
+
static tickDecimals(ticks) {
|
|
93
|
+
let decimals = 0;
|
|
94
|
+
for (const tick of ticks) {
|
|
95
|
+
const text = String(tick);
|
|
96
|
+
const dot = text.indexOf(".");
|
|
97
|
+
if (dot >= 0) {
|
|
98
|
+
decimals = Math.max(decimals, Math.min(2, text.length - dot - 1));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return decimals;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { LabelCollisionManager } from "../../components/bn-chart-time/utils/helper/LabelCollisionManager";
|
|
2
|
+
import { HookLocation } from "../../components/bn-chart-time/utils/elements/Label";
|
|
3
|
+
const ANCHORS = ["n", "ne", "e", "se", "s", "sw", "w", "nw"];
|
|
4
|
+
const DIAGONAL = Math.SQRT1_2;
|
|
5
|
+
/**
|
|
6
|
+
* Selective point labeling with greedy collision-free placement for the XY
|
|
7
|
+
* charts. Composes the existing {@link LabelCollisionManager} (AABB
|
|
8
|
+
* register/hasCollision core); marks are pre-registered as bounding
|
|
9
|
+
* squares — conservative for circles, acceptable for label proximity.
|
|
10
|
+
*
|
|
11
|
+
* Placement tries eight anchors clockwise from north and rejects positions
|
|
12
|
+
* that leave the frame or collide with marks or other labels; unplaceable
|
|
13
|
+
* labels are dropped (IBCS wants proximate labels — no leader lines).
|
|
14
|
+
*/
|
|
15
|
+
export class PointLabeler {
|
|
16
|
+
constructor(frame, gapPx, manager = new LabelCollisionManager()) {
|
|
17
|
+
this.frame = frame;
|
|
18
|
+
this.gapPx = gapPx;
|
|
19
|
+
this.manager = manager;
|
|
20
|
+
}
|
|
21
|
+
/** Registers a mark so labels avoid it (bounding-square approximation). */
|
|
22
|
+
registerMark(cx, cy, r) {
|
|
23
|
+
this.manager.register(this.bounds(cx - r, cy - r, 2 * r, 2 * r));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Selects which points receive labels. `items` must be pre-ranked for
|
|
27
|
+
* `"auto"` mode (extremity for scatter, size descending for bubble).
|
|
28
|
+
*/
|
|
29
|
+
selectCandidates(items, mode, max, nameOf) {
|
|
30
|
+
if (mode === "none") {
|
|
31
|
+
return { selected: [], unknownNames: [] };
|
|
32
|
+
}
|
|
33
|
+
if (mode === "all") {
|
|
34
|
+
return { selected: [...items], unknownNames: [] };
|
|
35
|
+
}
|
|
36
|
+
if (mode === "auto") {
|
|
37
|
+
return { selected: items.slice(0, max), unknownNames: [] };
|
|
38
|
+
}
|
|
39
|
+
const wanted = new Set(mode);
|
|
40
|
+
const selected = items.filter((item) => wanted.has(nameOf(item)));
|
|
41
|
+
const found = new Set(selected.map((item) => nameOf(item)));
|
|
42
|
+
const unknownNames = mode.filter((name) => !found.has(name));
|
|
43
|
+
return { selected, unknownNames };
|
|
44
|
+
}
|
|
45
|
+
/** Greedy placement in candidate order; returns only the labels that fit. */
|
|
46
|
+
place(candidates) {
|
|
47
|
+
const placed = [];
|
|
48
|
+
for (const candidate of candidates) {
|
|
49
|
+
for (const anchor of ANCHORS) {
|
|
50
|
+
const box = this.anchorBox(candidate, anchor);
|
|
51
|
+
if (!this.insideFrame(box.x, box.y, candidate.width, candidate.height)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const bounds = this.bounds(box.x, box.y, candidate.width, candidate.height);
|
|
55
|
+
if (this.manager.hasCollision(bounds)) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
this.manager.register(bounds);
|
|
59
|
+
placed.push({ candidate, x: box.x, y: box.y, anchor });
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return placed;
|
|
64
|
+
}
|
|
65
|
+
anchorBox(c, anchor) {
|
|
66
|
+
const offset = c.r + this.gapPx;
|
|
67
|
+
const diagonal = c.r * DIAGONAL + this.gapPx * 0.5;
|
|
68
|
+
switch (anchor) {
|
|
69
|
+
case "n":
|
|
70
|
+
return { x: c.cx - c.width / 2, y: c.cy - offset - c.height };
|
|
71
|
+
case "ne":
|
|
72
|
+
return { x: c.cx + diagonal, y: c.cy - diagonal - c.height };
|
|
73
|
+
case "e":
|
|
74
|
+
return { x: c.cx + offset, y: c.cy - c.height / 2 };
|
|
75
|
+
case "se":
|
|
76
|
+
return { x: c.cx + diagonal, y: c.cy + diagonal };
|
|
77
|
+
case "s":
|
|
78
|
+
return { x: c.cx - c.width / 2, y: c.cy + offset };
|
|
79
|
+
case "sw":
|
|
80
|
+
return { x: c.cx - diagonal - c.width, y: c.cy + diagonal };
|
|
81
|
+
case "w":
|
|
82
|
+
return { x: c.cx - offset - c.width, y: c.cy - c.height / 2 };
|
|
83
|
+
case "nw":
|
|
84
|
+
return { x: c.cx - diagonal - c.width, y: c.cy - diagonal - c.height };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
insideFrame(x, y, width, height) {
|
|
88
|
+
return (x >= this.frame.x &&
|
|
89
|
+
y >= this.frame.y &&
|
|
90
|
+
x + width <= this.frame.x + this.frame.width &&
|
|
91
|
+
y + height <= this.frame.y + this.frame.height);
|
|
92
|
+
}
|
|
93
|
+
bounds(x, y, width, height) {
|
|
94
|
+
return { x, y, width, height, pointIndex: 0, preferredHook: HookLocation.Center };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Area-true bubble sizing: bubble **area** is proportional to the data
|
|
3
|
+
* value (IBCS), so radius grows with the square root.
|
|
4
|
+
*
|
|
5
|
+
* Two modes:
|
|
6
|
+
* - **Local** (default): radii are normalized to the chart's own maximum
|
|
7
|
+
* value — `r = rMax · √(v / vMax)` with a minimum visible radius.
|
|
8
|
+
* `vMax` must be the max across all panels and both scenario sets of the
|
|
9
|
+
* chart instance (shared size scale, mandatory for comparability).
|
|
10
|
+
* - **Grouped** (`bn-scaling-group`): the group value is interpreted as
|
|
11
|
+
* **area px² per data unit** — `r = √(area · v / π)` with no
|
|
12
|
+
* normalization and no radius caps, so identical values render at
|
|
13
|
+
* identical sizes across every chart referencing the group.
|
|
14
|
+
*/
|
|
15
|
+
export class RadiusScale {
|
|
16
|
+
constructor(mode, vMax, rMaxPx, rMinPx, areaPerUnitPx2) {
|
|
17
|
+
this.mode = mode;
|
|
18
|
+
this.vMax = vMax;
|
|
19
|
+
this.rMaxPx = rMaxPx;
|
|
20
|
+
this.rMinPx = rMinPx;
|
|
21
|
+
this.areaPerUnitPx2 = areaPerUnitPx2;
|
|
22
|
+
}
|
|
23
|
+
static local(vMax, rMaxPx, rMinPx) {
|
|
24
|
+
return new RadiusScale("local", vMax, rMaxPx, rMinPx, 0);
|
|
25
|
+
}
|
|
26
|
+
static grouped(areaPerUnitPx2) {
|
|
27
|
+
return new RadiusScale("grouped", 0, 0, 0, areaPerUnitPx2);
|
|
28
|
+
}
|
|
29
|
+
/** Radius in pixels for a size value (values must be >= 0). */
|
|
30
|
+
radius(value) {
|
|
31
|
+
if (this.mode === "grouped") {
|
|
32
|
+
if (value <= 0) {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
return Math.sqrt((this.areaPerUnitPx2 * value) / Math.PI);
|
|
36
|
+
}
|
|
37
|
+
if (this.vMax <= 0 || value <= 0) {
|
|
38
|
+
return this.rMinPx;
|
|
39
|
+
}
|
|
40
|
+
return Math.max(this.rMinPx, this.rMaxPx * Math.sqrt(value / this.vMax));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Series color palette and IBCS mark treatments for the XY charts
|
|
3
|
+
* (bn-chart-scatter, bn-chart-bubble).
|
|
4
|
+
*
|
|
5
|
+
* XY charts compose two orthogonal encodings: the **series hue** (which
|
|
6
|
+
* product line / group a point belongs to) and the **scenario treatment**
|
|
7
|
+
* (solid / tinted / hatched / outlined, selected through the rule-set
|
|
8
|
+
* `colorIndex`). Tints and shades are computed colors, never opacity —
|
|
9
|
+
* opacity creates blend artifacts where marks overlap.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Default series palette, assigned by series `*Index` order. The first
|
|
13
|
+
* series uses the near-black IBCS base color.
|
|
14
|
+
*/
|
|
15
|
+
export const XY_SERIES_PALETTE = ["#404040", "#F2C14E", "#F07D00", "#4E8FE0", "#7FD6C2", "#D97C7C"];
|
|
16
|
+
/**
|
|
17
|
+
* Mixes two hex colors per channel in sRGB space.
|
|
18
|
+
*
|
|
19
|
+
* @param hexA - Base color, `#rrggbb`
|
|
20
|
+
* @param hexB - Mix-in color, `#rrggbb`
|
|
21
|
+
* @param ratioOfB - Portion of `hexB` in the result, 0..1
|
|
22
|
+
*/
|
|
23
|
+
export function mixHex(hexA, hexB, ratioOfB) {
|
|
24
|
+
const channel = (offset) => {
|
|
25
|
+
const a = parseInt(hexA.slice(offset, offset + 2), 16);
|
|
26
|
+
const b = parseInt(hexB.slice(offset, offset + 2), 16);
|
|
27
|
+
const mixed = Math.round(a + (b - a) * ratioOfB);
|
|
28
|
+
return mixed.toString(16).padStart(2, "0");
|
|
29
|
+
};
|
|
30
|
+
return `#${channel(1)}${channel(3)}${channel(5)}`;
|
|
31
|
+
}
|
|
32
|
+
/** Light variant of a series hue (60% white) — the PP/PY treatment. */
|
|
33
|
+
export function tint(hex) {
|
|
34
|
+
return mixHex(hex, "#ffffff", 0.6);
|
|
35
|
+
}
|
|
36
|
+
/** Dark variant of a series hue (25% black) — used for pie-share slices. */
|
|
37
|
+
export function shade(hex) {
|
|
38
|
+
return mixHex(hex, "#000000", 0.25);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolves the color for a series by its order index. Indices beyond the
|
|
42
|
+
* palette cycle through it with a tint step per cycle; `overflowed` signals
|
|
43
|
+
* that the chart should raise the `xy-series-overflow` warning.
|
|
44
|
+
*/
|
|
45
|
+
export function resolveSeriesColor(index, seriesColors) {
|
|
46
|
+
const colors = seriesColors.length > 0 ? seriesColors : XY_SERIES_PALETTE;
|
|
47
|
+
const cycle = Math.floor(index / colors.length);
|
|
48
|
+
let color = colors[index % colors.length];
|
|
49
|
+
for (let i = 0; i < cycle; i++) {
|
|
50
|
+
color = tint(color);
|
|
51
|
+
}
|
|
52
|
+
return { color, overflowed: cycle > 0 };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Maps a rule-set `colorIndex` and a series hue to the IBCS mark treatment.
|
|
56
|
+
*
|
|
57
|
+
* | colorIndex | IBCS meaning | Bubble | Dot |
|
|
58
|
+
* | ---------- | ------------------- | ------------------------------- | ---------------------------- |
|
|
59
|
+
* | 10 (ac) | solid dark | solid hue | solid hue |
|
|
60
|
+
* | 20 (pp/py) | light | tinted hue | tinted hue |
|
|
61
|
+
* | 30 (fc) | hatched | white + hue hatch + hue stroke | white + dashed hue ring |
|
|
62
|
+
* | 50 (pl/bu) | outlined | white + solid hue stroke | white + solid hue ring |
|
|
63
|
+
*/
|
|
64
|
+
export function markTreatment(colorIndex, hue, kind) {
|
|
65
|
+
const strokeWidth = kind === "dot" ? 0.75 : 1;
|
|
66
|
+
switch (colorIndex) {
|
|
67
|
+
case 20:
|
|
68
|
+
return { fill: tint(hue), stroke: "#ffffff", strokeWidth };
|
|
69
|
+
case 30:
|
|
70
|
+
if (kind === "bubble") {
|
|
71
|
+
return { fill: "#ffffff", stroke: hue, strokeWidth, hatch: true };
|
|
72
|
+
}
|
|
73
|
+
return { fill: "#ffffff", stroke: hue, strokeWidth, dasharray: "2,1.5" };
|
|
74
|
+
case 50:
|
|
75
|
+
return { fill: "#ffffff", stroke: hue, strokeWidth };
|
|
76
|
+
case 10:
|
|
77
|
+
default:
|
|
78
|
+
return { fill: hue, stroke: "#ffffff", strokeWidth };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Scenarios } from "../constants";
|
|
2
|
+
/**
|
|
3
|
+
* Variance-token parser for XY chart axis measures.
|
|
4
|
+
*
|
|
5
|
+
* Reuses the engine's variance grammar (`d{base}_{delta}_{sentiment}` /
|
|
6
|
+
* `dr{base}_{delta}_{sentiment}`) with one deviation from
|
|
7
|
+
* {@link VarianceScenario}: on axes the trailing sentiment segment is
|
|
8
|
+
* **optional and ignored** — position encodes the value, there is no
|
|
9
|
+
* pos/neg coloring. The regex is anchored, so partial matches inside a
|
|
10
|
+
* longer token are rejected.
|
|
11
|
+
*/
|
|
12
|
+
const VARIANCE_MEASURE_REGEX = /^(dr|d)((?:ac|pp|fc|pl)[1-4])_((?:ac|pp|fc|pl)[1-4])(?:_(pos|neg|neu))?$/;
|
|
13
|
+
export class VarianceMeasure {
|
|
14
|
+
constructor(
|
|
15
|
+
/** `"d"` = absolute, `"dr"` = relative (fraction of delta). */
|
|
16
|
+
type,
|
|
17
|
+
/** Minuend scenario slot, e.g. `"ac1"`. */
|
|
18
|
+
base,
|
|
19
|
+
/** Subtrahend scenario slot, e.g. `"pp1"`. */
|
|
20
|
+
delta) {
|
|
21
|
+
this.type = type;
|
|
22
|
+
this.base = base;
|
|
23
|
+
this.delta = delta;
|
|
24
|
+
}
|
|
25
|
+
/** Parses a variance token; returns `null` when the token doesn't match the grammar. */
|
|
26
|
+
static parse(token) {
|
|
27
|
+
const match = VARIANCE_MEASURE_REGEX.exec(token);
|
|
28
|
+
if (match === null) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return new VarianceMeasure(match[1], match[2], match[3]);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Computes the variance value, mirroring the null-safe math of the
|
|
35
|
+
* existing charts: absolute = `base - delta`, relative =
|
|
36
|
+
* `(base - delta) / delta`. Returns `null` when either operand is
|
|
37
|
+
* missing or a relative variance would divide by zero.
|
|
38
|
+
*/
|
|
39
|
+
compute(base, delta) {
|
|
40
|
+
if (base == null || delta == null) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (this.type === "dr") {
|
|
44
|
+
if (delta === 0) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return (base - delta) / delta;
|
|
48
|
+
}
|
|
49
|
+
return base - delta;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Resolves a measure token to a scenario slot or a variance measure.
|
|
54
|
+
* Returns `null` for tokens matching neither vocabulary.
|
|
55
|
+
*/
|
|
56
|
+
export function resolveMeasure(token) {
|
|
57
|
+
const trimmed = token.trim();
|
|
58
|
+
if (Object.values(Scenarios).includes(trimmed)) {
|
|
59
|
+
return { kind: "scenario", slot: trimmed };
|
|
60
|
+
}
|
|
61
|
+
const variance = VarianceMeasure.parse(trimmed);
|
|
62
|
+
if (variance !== null) {
|
|
63
|
+
return { kind: "variance", measure: variance };
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Scenario family (`ac` | `pp` | `fc` | `pl`) of a plain scenario slot.
|
|
69
|
+
*/
|
|
70
|
+
export function scenarioFamily(slot) {
|
|
71
|
+
return slot.replace(/\d+$/, "");
|
|
72
|
+
}
|
|
73
|
+
/** Slot number (`1`–`4`) of a plain scenario slot. */
|
|
74
|
+
export function scenarioSlotNumber(slot) {
|
|
75
|
+
return slot.replace(/^[a-z]+/, "");
|
|
76
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Formatter } from "../formatter";
|
|
2
|
+
/**
|
|
3
|
+
* Per-panel plot frame for the XY charts: highlight bands, gridlines,
|
|
4
|
+
* reference lines, the frame rectangle, tick labels, and the panel title.
|
|
5
|
+
*
|
|
6
|
+
* Style roles are taken from the `axisStyles` scenario group:
|
|
7
|
+
* `ac` = frame + tick labels, `pp` = gridlines, `fc` = reference lines
|
|
8
|
+
* and iso-curves, `pl` = highlight band fill.
|
|
9
|
+
*/
|
|
10
|
+
export class XYFrame {
|
|
11
|
+
constructor(xScale, yScale, rect, styles) {
|
|
12
|
+
this.xScale = xScale;
|
|
13
|
+
this.yScale = yScale;
|
|
14
|
+
this.rect = rect;
|
|
15
|
+
this.styles = styles;
|
|
16
|
+
}
|
|
17
|
+
get em() {
|
|
18
|
+
return this.styles.fontStyles.size;
|
|
19
|
+
}
|
|
20
|
+
fontFamily() {
|
|
21
|
+
return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/, "");
|
|
22
|
+
}
|
|
23
|
+
/** Shaded bands behind everything; open ends run to the domain edge. */
|
|
24
|
+
drawBands(group, xHighlight, yHighlight) {
|
|
25
|
+
var _a, _b, _c, _d;
|
|
26
|
+
const fill = this.styles.axisStyles.pl.fill;
|
|
27
|
+
if (xHighlight !== undefined && (xHighlight.from !== undefined || xHighlight.to !== undefined)) {
|
|
28
|
+
const from = this.xScale.scale((_a = xHighlight.from) !== null && _a !== void 0 ? _a : this.xScale.domainMin);
|
|
29
|
+
const to = this.xScale.scale((_b = xHighlight.to) !== null && _b !== void 0 ? _b : this.xScale.domainMax);
|
|
30
|
+
group
|
|
31
|
+
.rect(Math.abs(to - from), this.rect.height)
|
|
32
|
+
.move(Math.min(from, to), this.rect.y)
|
|
33
|
+
.fill(fill);
|
|
34
|
+
}
|
|
35
|
+
if (yHighlight !== undefined && (yHighlight.from !== undefined || yHighlight.to !== undefined)) {
|
|
36
|
+
const from = this.yScale.scale((_c = yHighlight.from) !== null && _c !== void 0 ? _c : this.yScale.domainMin);
|
|
37
|
+
const to = this.yScale.scale((_d = yHighlight.to) !== null && _d !== void 0 ? _d : this.yScale.domainMax);
|
|
38
|
+
group
|
|
39
|
+
.rect(this.rect.width, Math.abs(from - to))
|
|
40
|
+
.move(this.rect.x, Math.min(from, to))
|
|
41
|
+
.fill(fill);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Horizontal gridlines at the y ticks; vertical ones only when `ticksX` is given. */
|
|
45
|
+
drawGrid(group, ticksY, ticksX) {
|
|
46
|
+
const stroke = { color: this.styles.axisStyles.pp.stroke, width: this.styles.scaleFactors.gridLineWidth };
|
|
47
|
+
for (const tick of ticksY) {
|
|
48
|
+
const y = this.yScale.scale(tick);
|
|
49
|
+
group.line(this.rect.x, y, this.rect.x + this.rect.width, y).stroke(stroke);
|
|
50
|
+
}
|
|
51
|
+
if (ticksX !== undefined) {
|
|
52
|
+
for (const tick of ticksX) {
|
|
53
|
+
const x = this.xScale.scale(tick);
|
|
54
|
+
group.line(x, this.rect.y, x, this.rect.y + this.rect.height).stroke(stroke);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Thin reference lines at the given axis values (10A quadrant crosshair). */
|
|
59
|
+
drawRefLines(group, xRef, yRef) {
|
|
60
|
+
const stroke = { color: this.styles.axisStyles.fc.stroke, width: this.styles.scaleFactors.refLineWidth };
|
|
61
|
+
if (xRef !== undefined) {
|
|
62
|
+
const x = this.xScale.scale(xRef);
|
|
63
|
+
group.line(x, this.rect.y, x, this.rect.y + this.rect.height).stroke(stroke);
|
|
64
|
+
}
|
|
65
|
+
if (yRef !== undefined) {
|
|
66
|
+
const y = this.yScale.scale(yRef);
|
|
67
|
+
group.line(this.rect.x, y, this.rect.x + this.rect.width, y).stroke(stroke);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** The four-sided thin plot frame (as in the IBCS template images). */
|
|
71
|
+
drawFrame(group) {
|
|
72
|
+
group
|
|
73
|
+
.rect(this.rect.width, this.rect.height)
|
|
74
|
+
.move(this.rect.x, this.rect.y)
|
|
75
|
+
.fill("none")
|
|
76
|
+
.stroke({ color: this.styles.axisStyles.ac.stroke, width: this.styles.scaleFactors.gridLineWidth });
|
|
77
|
+
}
|
|
78
|
+
/** Tick labels along the outer edges (no tick marks — template style). */
|
|
79
|
+
drawTickLabels(group, config) {
|
|
80
|
+
const gap = this.styles.scaleFactors.axisTickLength * this.em;
|
|
81
|
+
const font = { size: this.styles.fontStyles.size, anchor: "start" };
|
|
82
|
+
const family = this.fontFamily();
|
|
83
|
+
const color = this.styles.fontStyles.color;
|
|
84
|
+
if (config.showXLabels) {
|
|
85
|
+
for (const tick of config.ticksX) {
|
|
86
|
+
const x = this.xScale.scale(tick);
|
|
87
|
+
group
|
|
88
|
+
.text(Formatter.number(tick, "decimal", config.xDecimals, config.xDecimals))
|
|
89
|
+
.font(Object.assign(Object.assign({}, font), { anchor: "middle" }))
|
|
90
|
+
.fill(color)
|
|
91
|
+
.attr({ x, y: this.rect.y + this.rect.height + gap + this.em * 0.8, "font-family": family });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (config.showYLabels) {
|
|
95
|
+
for (const tick of config.ticksY) {
|
|
96
|
+
const y = this.yScale.scale(tick);
|
|
97
|
+
group
|
|
98
|
+
.text(Formatter.number(tick, "decimal", config.yDecimals, config.yDecimals))
|
|
99
|
+
.font(Object.assign(Object.assign({}, font), { anchor: "end" }))
|
|
100
|
+
.fill(color)
|
|
101
|
+
.attr({ x: this.rect.x - gap, y: y + this.em * 0.35, "font-family": family });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Facet panel title, top-left inside the panel, bold (10F "Europe"/"RoW"). */
|
|
106
|
+
drawPanelTitle(group, title) {
|
|
107
|
+
if (title === "") {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
group
|
|
111
|
+
.text(title)
|
|
112
|
+
.font({ size: this.styles.fontStyles.size, weight: "bold", anchor: "start" })
|
|
113
|
+
.fill(this.styles.fontStyles.color)
|
|
114
|
+
.attr({
|
|
115
|
+
x: this.rect.x + 0.5 * this.em,
|
|
116
|
+
y: this.rect.y + 1.2 * this.em,
|
|
117
|
+
"font-family": this.fontFamily(),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|