@bino-bi/bn-template-engine 1.0.0-next.26 → 1.0.0-next.28

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