@bino-bi/bn-template-engine 1.0.0-next.49 → 1.0.0-next.51

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 (107) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-0cad5598.entry.js +1 -0
  3. package/dist/bn-template-engine/{p-2de524d0.entry.js → p-150bdb68.entry.js} +1 -1
  4. package/dist/bn-template-engine/{p-Bxa4pX1M.js → p-Bvunba5p.js} +1 -1
  5. package/dist/bn-template-engine/p-NxJ6P79y.js +1 -0
  6. package/dist/bn-template-engine/{p-8fc90dc8.entry.js → p-b75a4b52.entry.js} +1 -1
  7. package/dist/bn-template-engine/{p-510d2ee6.entry.js → p-fdf42a77.entry.js} +1 -1
  8. package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +1045 -63
  9. package/dist/cjs/bn-grid.cjs.entry.js +1 -1
  10. package/dist/cjs/bn-image.cjs.entry.js +1 -1
  11. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  12. package/dist/cjs/bn-text.cjs.entry.js +2 -2
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/cjs/{withStyled-pkdctrK9.js → withStyled-BISQLGLe.js} +9 -0
  15. package/dist/cjs/{withTranslation-BIzTNYZM.js → withTranslation-B7T30EVU.js} +1 -1
  16. package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.js +109 -11
  17. package/dist/collection/components/bn-annotation-layer/utils/marks.js +126 -4
  18. package/dist/collection/components/bn-annotation-layer/utils/matchPoint.js +2 -1
  19. package/dist/collection/components/bn-chart-structure/bn-chart-structure-renderer/bn-chart-structure-renderer.js +133 -0
  20. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +258 -2
  21. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +507 -27
  22. package/dist/collection/components/bn-chart-structure/utils/elements/Bar.js +3 -1
  23. package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +12 -0
  24. package/dist/collection/components/bn-chart-structure/utils/elements/StackedBar.js +23 -8
  25. package/dist/collection/components/bn-chart-structure/utils/helper/ElementPositions.js +19 -3
  26. package/dist/collection/components/bn-chart-structure/utils/model/StructureChartComponentConfig.js +23 -0
  27. package/dist/collection/components/bn-context/bn-context.js +56 -1
  28. package/dist/collection/components/bn-layout-card/bn-layout-card.js +62 -2
  29. package/dist/collection/utils/formatter.js +13 -2
  30. package/dist/collection/utils/validate.js +9 -0
  31. package/dist/components/bn-annotation-layer.js +1 -1
  32. package/dist/components/bn-chart-bubble-renderer.js +1 -1
  33. package/dist/components/bn-chart-bubble.js +1 -1
  34. package/dist/components/bn-chart-bullet-renderer.js +1 -1
  35. package/dist/components/bn-chart-bullet.js +1 -1
  36. package/dist/components/bn-chart-scatter-renderer.js +1 -1
  37. package/dist/components/bn-chart-scatter.js +1 -1
  38. package/dist/components/bn-chart-structure-renderer.js +1 -1
  39. package/dist/components/bn-chart-structure.js +1 -1
  40. package/dist/components/bn-chart-time-renderer.js +1 -1
  41. package/dist/components/bn-chart-time.js +1 -1
  42. package/dist/components/bn-context.js +1 -1
  43. package/dist/components/bn-grid.js +1 -1
  44. package/dist/components/bn-image.js +1 -1
  45. package/dist/components/bn-layout-card.js +1 -1
  46. package/dist/components/bn-layout-page.js +1 -1
  47. package/dist/components/bn-page.js +1 -1
  48. package/dist/components/bn-table-renderer.js +1 -1
  49. package/dist/components/bn-table.js +1 -1
  50. package/dist/components/bn-text.js +1 -1
  51. package/dist/components/bn-title-renderer.js +1 -1
  52. package/dist/components/bn-title.js +1 -1
  53. package/dist/components/bn-tree.js +1 -1
  54. package/dist/components/p-BOwmXBm-.js +1 -0
  55. package/dist/components/p-Bs5V6Ibu.js +1 -0
  56. package/dist/components/{p-CVfmhtEW.js → p-CU9CdEBF.js} +1 -1
  57. package/dist/components/{p-Cc0gaLwp.js → p-CZSp0rSS.js} +1 -1
  58. package/dist/components/p-CcfvGlBq.js +1 -0
  59. package/dist/components/p-CiljAoC5.js +1 -0
  60. package/dist/components/p-D0v9GMIf.js +1 -0
  61. package/dist/components/{p-DBj1Yd3M.js → p-D65TnLS9.js} +1 -1
  62. package/dist/components/p-DKcw-1ot.js +1 -0
  63. package/dist/components/{p-k7heRDPP.js → p-DLmQ_mi7.js} +1 -1
  64. package/dist/components/p-DOKqRsAu.js +1 -0
  65. package/dist/components/p-Dpc8_R-Y.js +1 -0
  66. package/dist/components/p-LHIKI9Dp.js +1 -0
  67. package/dist/components/{p-Blre9f28.js → p-NdDdfez6.js} +1 -1
  68. package/dist/components/p-Zz3fAPcH.js +1 -0
  69. package/dist/components/{p-y12CmIFS.js → p-dSUX43yf.js} +1 -1
  70. package/dist/components/p-jEqo8YD5.js +1 -0
  71. package/dist/esm/bn-annotation-layer_30.entry.js +1045 -63
  72. package/dist/esm/bn-grid.entry.js +1 -1
  73. package/dist/esm/bn-image.entry.js +1 -1
  74. package/dist/esm/bn-template-engine.js +1 -1
  75. package/dist/esm/bn-text.entry.js +2 -2
  76. package/dist/esm/loader.js +1 -1
  77. package/dist/esm/{withStyled-B62R20Zx.js → withStyled-CrTxIZ0Q.js} +9 -0
  78. package/dist/esm/{withTranslation-BEseMLQ6.js → withTranslation-BtSJmx1J.js} +1 -1
  79. package/dist/schemas/stack.schema.json +42 -0
  80. package/dist/types/components/bn-annotation-layer/utils/marks.d.ts +53 -0
  81. package/dist/types/components/bn-annotation-layer/utils/matchPoint.d.ts +2 -0
  82. package/dist/types/components/bn-chart-structure/bn-chart-structure-renderer/bn-chart-structure-renderer.d.ts +11 -1
  83. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +49 -0
  84. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +45 -0
  85. package/dist/types/components/bn-chart-structure/utils/elements/Label.d.ts +4 -0
  86. package/dist/types/components/bn-chart-structure/utils/elements/StackedBar.d.ts +13 -1
  87. package/dist/types/components/bn-chart-structure/utils/helper/ElementPositions.d.ts +13 -1
  88. package/dist/types/components/bn-chart-structure/utils/model/StructureChartComponentConfig.d.ts +23 -0
  89. package/dist/types/components/bn-context/bn-context.d.ts +11 -0
  90. package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +12 -0
  91. package/dist/types/components.d.ts +113 -2
  92. package/dist/types/schemas.d.ts +12 -0
  93. package/dist/types/utils/annotations.d.ts +1 -1
  94. package/dist/types/utils/formatter.d.ts +5 -0
  95. package/package.json +1 -1
  96. package/dist/bn-template-engine/p-BFl7OwcC.js +0 -1
  97. package/dist/bn-template-engine/p-c1d679af.entry.js +0 -1
  98. package/dist/components/p-B11cXOLy.js +0 -1
  99. package/dist/components/p-BVNOmHh4.js +0 -1
  100. package/dist/components/p-CHhxQoF9.js +0 -1
  101. package/dist/components/p-CO6bgquz.js +0 -1
  102. package/dist/components/p-CmvpJzLd.js +0 -1
  103. package/dist/components/p-CuUfiEu0.js +0 -1
  104. package/dist/components/p-DHloMyxV.js +0 -1
  105. package/dist/components/p-Dd1QOWDV.js +0 -1
  106. package/dist/components/p-HVN8BNWN.js +0 -1
  107. package/dist/components/p-x0W2_FAX.js +0 -1
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, h, a as Host, g as getElement, f as forceUpdate, d as writeTask, e as createEvent, F as Fragment$1 } from './index-GstO_GU5.js';
2
2
  import { S as SYSTEM_STYLE_DEFAULTS, w as withComponentStatus, a as withHasError, g as getStores, C as ComponentRegister, r as runIfExisits, c as clearStoresCache, h as hasInlineJs, d as globalLabelKeys, e as SYSTEM_RULESET_DEFAULTS, X as XY_SERIES_PALETTE, i as getDefaultExportFromCjs, D as DateTime, j as resolveSeriesColor, m as markTreatment, s as shade, k as sourceExpr, l as reportOverflow, u as unknownStyleKeys, n as getOrCreateStores } from './withHasError-BDWEBrrb.js';
3
- import { a as withComponentStyle, m as merge, C as CompareUtil, i as isBlankInput, b as isValidInteger, w as withStyled, c as isValidMeasureToken, r as resolveMeasure, s as scenarioFamily, d as scenarioSlotNumber, e as axisInValueUnits, f as isRelativeMeasure, v as validateOrderList, g as isValidDirection, A as AggregationLevel, O as OrderDirection, h as Order, j as OrderColumn, k as isNoScenarios, l as validateScenarioList, n as validateVariancesList, o as isValidLevel, p as isValidMeasureScale, q as validateStackConfig, S as StackBy, t as StackOrder, u as StackMode, x as AdapterUtils, y as OrderAdapter, N as NOT_AVAILABLE, z as relativeVariance, B as isValidNumber, D as isValidDateFormat, E as isValidAxisLabelsMode, F as DateDistance, G as AxisLabelsMode, H as ChartMode, I as DateStringFactory, R as RELATIVE_STACK_UNITS, J as mergeStyleLayers, K as murmur2, L as validateBarColumnsList, M as isTableBarColumnWidth, P as isValidDataFormat, Q as isValidTableType, T as validateThereOfJsonStr, U as isValidThereofPosition, V as validatePartOfJsonStr, W as validateTableOrderList, X as isValidMeasureType, Y as isTableCategoryWidth, Z as validateColumnThereOfJsonStr, _ as validateAttributesJsonStr, $ as DataFormat, a0 as ThereofPosition, a1 as TableType$2, a2 as normalizeOrderToken, a3 as I18nMode, a4 as TableCategoryWidth, a5 as MeasureType, a6 as parseTableAttributeExpression, a7 as BAR_COLUMN_WIDTH_EM, a8 as TableBarColumnWidth, a9 as TableRowType, aa as FIELD_IDENTIFIER_REGEX, ab as parseOrderToken, ac as Scenarios, ad as OrderDirection$1, ae as FactoryState$3, af as validateMeasureList, ag as isValidDate, ah as isValidDateLink, ai as DateLink } from './withStyled-B62R20Zx.js';
4
- import { s as sanitizeHtml, g as getParentDimensions, b as getClippedHeight, i as isInheritedValue, f as findLayoutAncestors, r as readInherited, a as withDataset, w as withTranslation, p as parseScaling, c as strokeWidthPx, d as resolveScalingValue, e as formatScalingValue, h as withInheritedProps, j as parseScalingValue } from './withTranslation-BEseMLQ6.js';
3
+ import { a as withComponentStyle, m as merge, C as CompareUtil, i as isBlankInput, b as isValidInteger, w as withStyled, c as isValidMeasureToken, r as resolveMeasure, s as scenarioFamily, d as scenarioSlotNumber, e as axisInValueUnits, f as isRelativeMeasure, v as validateOrderList, g as isValidDirection, A as AggregationLevel, O as OrderDirection, h as Order, j as OrderColumn, k as isNoScenarios, l as validateScenarioList, n as validateVariancesList, o as isValidLevel, p as isValidMeasureScale, q as validateStackConfig, S as StackBy, t as StackOrder, u as StackMode, x as AdapterUtils, y as OrderAdapter, N as NOT_AVAILABLE, z as relativeVariance, B as isValidNumber, D as isValidDateFormat, E as isValidAxisLabelsMode, F as DateDistance, G as AxisLabelsMode, H as ChartMode, I as DateStringFactory, R as RELATIVE_STACK_UNITS, J as mergeStyleLayers, K as murmur2, L as validateBarColumnsList, M as isTableBarColumnWidth, P as isValidDataFormat, Q as isValidTableType, T as validateThereOfJsonStr, U as isValidThereofPosition, V as validatePartOfJsonStr, W as validateTableOrderList, X as isValidMeasureType, Y as isTableCategoryWidth, Z as validateColumnThereOfJsonStr, _ as validateAttributesJsonStr, $ as DataFormat, a0 as ThereofPosition, a1 as TableType$2, a2 as normalizeOrderToken, a3 as I18nMode, a4 as TableCategoryWidth, a5 as MeasureType, a6 as parseTableAttributeExpression, a7 as BAR_COLUMN_WIDTH_EM, a8 as TableBarColumnWidth, a9 as TableRowType, aa as FIELD_IDENTIFIER_REGEX, ab as parseOrderToken, ac as Scenarios, ad as OrderDirection$1, ae as FactoryState$3, af as validateMeasureList, ag as isValidDate, ah as isValidDateLink, ai as DateLink } from './withStyled-CrTxIZ0Q.js';
4
+ import { s as sanitizeHtml, g as getParentDimensions, b as getClippedHeight, i as isInheritedValue, f as findLayoutAncestors, r as readInherited, a as withDataset, w as withTranslation, p as parseScaling, c as strokeWidthPx, d as resolveScalingValue, e as formatScalingValue, h as withInheritedProps, j as parseScalingValue } from './withTranslation-BtSJmx1J.js';
5
5
  import { w as withBodyObserver } from './withBodyObserver-wJgSN1Pj.js';
6
6
  import { r as readDiagnostics, m as measure, a as resolveStandaloneId, l as localFrameOf, o as originsFor, b as assignIds, c as resolveOwnIdentity, t as toLayoutRect, d as measureContent, e as measureSign } from './localFrame-WNu1bAPm.js';
7
7
  import { L as LAYOUT_STATE_VERSION } from './types-DY5fMUX8.js';
@@ -247,9 +247,12 @@ function buildMark(item, box, toBox, em, options = {}) {
247
247
  }
248
248
  if (item.mark === "frame") {
249
249
  // a text of its own stands in the upper part of the target, above a value label in its middle
250
- const caption = item.text != null && !whole
251
- ? { x: box.x + box.width / 2, y: box.y + Math.min(box.height / 2, Math.max(0.9 * em, 0.3 * box.height)) }
252
- : undefined;
250
+ const caption = item.text == null || whole
251
+ ? undefined
252
+ : options.label
253
+ ? // right of a value label, so both can be read
254
+ { x: box.x + box.width + 0.7 * em + textWidth(item.text, em) / 2, y: box.y + box.height / 2 }
255
+ : { x: box.x + box.width / 2, y: box.y + Math.min(box.height / 2, Math.max(0.9 * em, 0.3 * box.height)) };
253
256
  const captionBox = caption && {
254
257
  x: caption.x - textWidth(item.text, em) / 2,
255
258
  y: caption.y - 0.6 * em,
@@ -300,7 +303,20 @@ function buildMark(item, box, toBox, em, options = {}) {
300
303
  const size = (label == null ? 0.4 : 0.75) * unit;
301
304
  const r = isRow ? Math.min(size, box.height / 2) : size;
302
305
  let at = whole ? { x: box.x + box.width - r, y: box.y + r } : centre(box);
303
- if (!whole && options.stacked && ((_c = item.point) === null || _c === void 0 ? void 0 : _c.part) !== "label" && ((_d = item.point) === null || _d === void 0 ? void 0 : _d.part) !== "total") {
306
+ if (!whole && options.label) {
307
+ // right of the label of a chart, not on it
308
+ at = { x: box.x + box.width + 0.25 * unit + r, y: box.y + box.height / 2 };
309
+ }
310
+ else if (!whole && options.stacked && options.horizontal) {
311
+ // in a wide segment right of its label, like in a table. Else on the upper edge at its end.
312
+ // The total behind the bar stays free in both cases.
313
+ const beside = 1.3 * unit + r;
314
+ at =
315
+ box.width / 2 >= beside + r
316
+ ? { x: box.x + box.width / 2 + beside, y: box.y + box.height / 2 }
317
+ : { x: box.x + box.width - Math.min(r, box.width / 2), y: box.y };
318
+ }
319
+ else if (!whole && options.stacked && ((_c = item.point) === null || _c === void 0 ? void 0 : _c.part) !== "label" && ((_d = item.point) === null || _d === void 0 ? void 0 : _d.part) !== "total") {
304
320
  // on the upper right corner: the label in the middle and a name beside the segment stay free
305
321
  at = { x: box.x + box.width, y: box.y + Math.min(0.5 * r, box.height / 2) };
306
322
  }
@@ -315,6 +331,112 @@ function buildMark(item, box, toBox, em, options = {}) {
315
331
  }
316
332
  return { kind: "marker", color, badge: keepInside({ cx: at.x, cy: at.y, r, label }, area) };
317
333
  }
334
+ /**
335
+ * The difference of two bars that run from left to right. `levels` are the x of the
336
+ * two values. The bar of the difference lies in the gap below the second row, or above
337
+ * it when that row is the upper one. A thin line runs from each value to it, and the
338
+ * label stands right of it.
339
+ */
340
+ function buildHorizontalDifference(item, box, toBox, fromValue, toValue, em, levels) {
341
+ var _a;
342
+ if (fromValue == null || toValue == null)
343
+ return undefined;
344
+ const difference = toValue - fromValue;
345
+ const digits = Number.isInteger(item.digits) && item.digits >= 0 ? item.digits : 1;
346
+ const good = item.sentiment === "good-down" ? difference <= 0 : difference >= 0;
347
+ const direction = toBox.y + toBox.height / 2 >= box.y + box.height / 2 ? 1 : -1;
348
+ const edge = (of) => (direction === 1 ? of.y + of.height : of.y);
349
+ const barHeight = 0.25 * em;
350
+ const barY = edge(toBox) + direction * 0.25 * em;
351
+ const left = Math.min(levels.from, levels.to);
352
+ const right = Math.max(levels.from, levels.to);
353
+ const percent = item.percent && fromValue !== 0 ? `(${signed((difference / Math.abs(fromValue)) * 100, 0)}%)` : undefined;
354
+ const value = signed(difference, digits);
355
+ const textX = right + 0.5 * em;
356
+ const valueWidth = value.length * 0.5 * em;
357
+ const percentWidth = percent ? textWidth(percent, 0.85 * em) : 0;
358
+ const percentX = textX + valueWidth + 0.35 * em;
359
+ return {
360
+ kind: "difference",
361
+ color: (_a = item.color) !== null && _a !== void 0 ? _a : (good ? "positive" : "negative"),
362
+ lines: [
363
+ { x1: levels.from, y1: edge(box), x2: levels.from, y2: barY },
364
+ { x1: levels.to, y1: edge(toBox), x2: levels.to, y2: barY },
365
+ ],
366
+ bar: { x: left, y: barY - barHeight / 2, width: Math.max(right - left, 1), height: barHeight },
367
+ text: { x: textX, y: barY, anchor: "start", value, percent },
368
+ frame: percent && item.highlight
369
+ ? {
370
+ x: percentX - 0.25 * em,
371
+ y: barY - 0.65 * em,
372
+ width: percentWidth + 0.5 * em,
373
+ height: 1.3 * em,
374
+ r: 0.65 * em,
375
+ }
376
+ : undefined,
377
+ badge: item.label != null ? { cx: left - 0.9 * em, cy: barY, r: 0.65 * em, label: item.label } : undefined,
378
+ };
379
+ }
380
+ /** A thick arrow that points down at `tip`: the value end of a bar, or the top of a column. */
381
+ function buildPointer(item, at, em) {
382
+ const x = at.x;
383
+ const tip = at.y - 0.15 * em;
384
+ const neck = tip - 0.7 * em;
385
+ const top = tip - 1.9 * em;
386
+ const head = 0.55 * em;
387
+ const shaft = 0.22 * em;
388
+ const points = [
389
+ [x, tip],
390
+ [x - head, neck],
391
+ [x - shaft, neck],
392
+ [x - shaft, top],
393
+ [x + shaft, top],
394
+ [x + shaft, neck],
395
+ [x + head, neck],
396
+ ];
397
+ return {
398
+ kind: "pointer",
399
+ color: item.color,
400
+ shape: points.map(([px, py]) => `${px},${py}`).join(" "),
401
+ badge: item.label != null ? { cx: x + 1.1 * em, cy: top + 0.65 * em, r: 0.65 * em, label: item.label } : undefined,
402
+ };
403
+ }
404
+ /**
405
+ * A bracket around a range of rows of a chart with bars from left to right. A line
406
+ * runs below the last row from `left` to the end of its bar, and from there up to the
407
+ * end of the bar of the first row. `ends` are the x of the two values. `text` stands
408
+ * in a frame at the left, above the first row.
409
+ */
410
+ function buildBracket(item, first, last, ends, left, text, em) {
411
+ const firstIsUpper = first.y <= last.y;
412
+ const [upper, lower] = firstIsUpper ? [first, last] : [last, first];
413
+ const [upperEnd, lowerEnd] = firstIsUpper ? [ends.first, ends.last] : [ends.last, ends.first];
414
+ const bottom = lower.y + lower.height + 0.2 * em;
415
+ const points = [
416
+ [left, bottom],
417
+ [lowerEnd, bottom],
418
+ [upperEnd, upper.y - 0.1 * em],
419
+ ];
420
+ const width = text ? textWidth(text, em) : 0;
421
+ const captionY = upper.y - 0.9 * em;
422
+ const caption = text ? { x: left + 0.5 * em + width / 2, y: captionY, text } : undefined;
423
+ // the number stands behind the text, or in its place
424
+ const badgeX = caption ? caption.x + width / 2 + 1.2 * em : left + 0.65 * em;
425
+ return {
426
+ kind: "bracket",
427
+ color: item.color,
428
+ path: points.map(([px, py]) => `${px},${py}`).join(" "),
429
+ caption,
430
+ frame: caption && {
431
+ x: caption.x - width / 2 - 0.45 * em,
432
+ y: caption.y - 0.7 * em,
433
+ width: width + 0.9 * em,
434
+ height: 1.4 * em,
435
+ r: 0.7 * em,
436
+ },
437
+ badge: item.label != null ? { cx: badgeX, cy: captionY, r: 0.65 * em, label: item.label } : undefined,
438
+ };
439
+ }
318
440
 
319
441
  const KEY_FIELDS = ["rowGroup", "category", "subCategory", "date", "scenario", "row"];
320
442
  /** A point without a field, or no point at all, means the component as a whole. */
@@ -339,17 +461,30 @@ function matchPoint(state, point) {
339
461
  const noThereof = state.table != null && point.subCategory == null;
340
462
  return candidates
341
463
  .filter((candidate) => matches(candidate.point, point) && !(noThereof && candidate.point.subCategory != null))
342
- .map(({ rect, content, contentSign, value, scenario }) => ({
464
+ .map(({ rect, content, contentSign, value, scenario, kind }) => ({
343
465
  rect,
344
466
  content,
345
467
  contentSign,
346
468
  value,
347
469
  stacked: typeof scenario === "string" && scenario.startsWith("stack:"),
470
+ label: kind === "label",
348
471
  }));
349
472
  }
350
473
 
351
474
  const bnAnnotationLayerCss = () => `:host{position:absolute;inset:0;z-index:1;display:block;pointer-events:none;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px)}svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}.badge-text{fill:#ffffff;font-weight:bold;text-anchor:middle;dominant-baseline:central}.mark-text{fill:#000000;dominant-baseline:central}.mark-text.caption{text-anchor:middle;font-size:0.9em}.mark-text .percent{font-size:0.85em}.difference-line{stroke:#000000;stroke-width:0.75}`;
352
475
 
476
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
477
+ var t = {};
478
+ for (var p in s)
479
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
480
+ t[p] = s[p];
481
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
482
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
483
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
484
+ t[p[i]] = s[p[i]];
485
+ }
486
+ return t;
487
+ };
353
488
  /** A chart can draw its data late: a point without a match is reported when the page has been quiet for two checks. */
354
489
  const REPORT_CHECK_MS = 200;
355
490
  const REPORT_MAX_CHECKS = 50;
@@ -451,12 +586,12 @@ const AnnotationLayer = class {
451
586
  (_a = document.fonts) === null || _a === void 0 ? void 0 : _a.addEventListener("loadingdone", this.schedule);
452
587
  }
453
588
  disconnectedCallback() {
454
- var _a, _b, _c, _d;
589
+ var _a, _b, _e, _f;
455
590
  (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
456
591
  (_b = this.mutationObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
457
- (_c = document.fonts) === null || _c === void 0 ? void 0 : _c.removeEventListener("loadingdone", this.schedule);
592
+ (_e = document.fonts) === null || _e === void 0 ? void 0 : _e.removeEventListener("loadingdone", this.schedule);
458
593
  this.run++;
459
- if ((_d = this.stores) === null || _d === void 0 ? void 0 : _d.annotationsUnplaced.state[this.pageKey]) {
594
+ if ((_f = this.stores) === null || _f === void 0 ? void 0 : _f.annotationsUnplaced.state[this.pageKey]) {
460
595
  this.stores.annotationsUnplaced.set(this.pageKey, undefined);
461
596
  }
462
597
  }
@@ -481,7 +616,7 @@ const AnnotationLayer = class {
481
616
  this.parsedItems = items !== null && items !== void 0 ? items : [];
482
617
  }
483
618
  async place() {
484
- var _a, _b;
619
+ var _a, _b, _e, _f;
485
620
  const run = ++this.run;
486
621
  if (!this.element.isConnected || !this.svg)
487
622
  return;
@@ -541,8 +676,9 @@ const AnnotationLayer = class {
541
676
  return { problem: `the point ${JSON.stringify(point)} in "${id}" is cut off` };
542
677
  }
543
678
  const content = found[0].content;
544
- if (!state.table)
545
- return { box, whole: false, stacked: found[0].stacked };
679
+ if (!state.table) {
680
+ return { box, whole: false, stacked: found[0].stacked, label: found[0].label, horizontal: isHorizontal(state) };
681
+ }
546
682
  const cells = ((_a = state.elements) !== null && _a !== void 0 ? _a : []).flatMap((element) => element.kind === "cell" && element.content
547
683
  ? [{ box: onScreen(element.content), sign: element.contentSign }]
548
684
  : []);
@@ -553,6 +689,8 @@ const AnnotationLayer = class {
553
689
  obstacles: cells,
554
690
  };
555
691
  };
692
+ // the bars of a structure chart run from left to right: its value axis is an upright line
693
+ const isHorizontal = (state) => { var _a; return ((_a = state === null || state === void 0 ? void 0 : state.elements) !== null && _a !== void 0 ? _a : []).some((element) => element.kind === "axis" && element.orientation === "vertical"); };
556
694
  // a difference takes all bars of a point: the segments of a stack together are its sum
557
695
  const sumOf = (id, point) => {
558
696
  const visual = id != null ? targets.get(id) : undefined;
@@ -583,8 +721,27 @@ const AnnotationLayer = class {
583
721
  box: { x: host.left + left, y: host.top + top, width: right - left, height: bottom - top },
584
722
  negatives: bars.filter((bar) => bar.value < 0).map((bar) => screen(bar.rect.component)),
585
723
  value: bars.reduce((sum, bar) => sum + bar.value, 0),
724
+ horizontal: isHorizontal(state),
586
725
  };
587
726
  };
727
+ // the share of the rows from one point to another in all rows of the chart, for the bars the points name
728
+ const shareOf = (item, upper, lower) => {
729
+ const visual = targets.get(item.target);
730
+ const state = visual && states.get(visual);
731
+ if (!visual || !state || !item.point)
732
+ return undefined;
733
+ const host = visual.getBoundingClientRect();
734
+ const _a = item.point, series = __rest(_a, ["rowGroup", "category", "subCategory", "date"]);
735
+ const bars = matchPoint(state, Object.assign(Object.assign({}, series), { part: "element" })).filter((bar) => bar.value != null);
736
+ const all = bars.reduce((sum, bar) => sum + bar.value, 0);
737
+ const inside = bars
738
+ .filter((bar) => {
739
+ const middle = host.top + bar.rect.component.y + bar.rect.component.height / 2;
740
+ return middle >= upper.y && middle <= lower.y + lower.height;
741
+ })
742
+ .reduce((sum, bar) => sum + bar.value, 0);
743
+ return all !== 0 ? inside / all : undefined;
744
+ };
588
745
  const toLocal = this.toLocalSpace();
589
746
  // here the text runs along x and a layout px is a px, also on a rotated or scaled page
590
747
  const textToLocal = ({ box, sign = 0 }) => {
@@ -606,6 +763,20 @@ const AnnotationLayer = class {
606
763
  continue;
607
764
  }
608
765
  const [a, b] = [first, second];
766
+ if (a.horizontal) {
767
+ // the level of a sum is the right end, and left of it by the length of the negative values
768
+ const endOf = (anchor) => {
769
+ const local = toLocal(anchor.box);
770
+ return local.x + local.width - anchor.negatives.reduce((sum, bar) => sum + toLocal(bar).width, 0);
771
+ };
772
+ const mark = buildHorizontalDifference(item, toLocal(a.box), toLocal(b.box), a.value, b.value, em, {
773
+ from: endOf(a),
774
+ to: endOf(b),
775
+ });
776
+ if (mark)
777
+ marks.push(mark);
778
+ continue;
779
+ }
609
780
  // the level of a sum: the top for positive values, and below it by the length of the negative ones.
610
781
  // Measured in the space of the layer, so it holds on a turned page too.
611
782
  const levelOf = (anchor) => toLocal(anchor.box).y + anchor.negatives.reduce((sum, bar) => sum + toLocal(bar).height, 0);
@@ -617,6 +788,48 @@ const AnnotationLayer = class {
617
788
  marks.push(mark);
618
789
  continue;
619
790
  }
791
+ if (item.mark === "pointer" || item.mark === "bracket") {
792
+ const first = sumOf(item.target, item.point);
793
+ const second = item.mark === "bracket" ? sumOf((_b = item.to) !== null && _b !== void 0 ? _b : item.target, item.toPoint) : first;
794
+ const failed = "problem" in first ? first : "problem" in second ? second : undefined;
795
+ if (failed) {
796
+ problems.push({ item, problem: failed.problem });
797
+ continue;
798
+ }
799
+ const [a, b] = [first, second];
800
+ // the end of a value: the right end of a bar or the top of a column, moved by the negative values
801
+ const endOf = (anchor) => {
802
+ const local = toLocal(anchor.box);
803
+ return anchor.horizontal
804
+ ? {
805
+ x: local.x + local.width - anchor.negatives.reduce((sum, bar) => sum + toLocal(bar).width, 0),
806
+ y: local.y,
807
+ }
808
+ : {
809
+ x: local.x + local.width / 2,
810
+ y: local.y + anchor.negatives.reduce((sum, bar) => sum + toLocal(bar).height, 0),
811
+ };
812
+ };
813
+ if (item.mark === "pointer") {
814
+ marks.push(buildPointer(item, endOf(a), em));
815
+ continue;
816
+ }
817
+ if (!a.horizontal) {
818
+ problems.push({ item, problem: "a bracket needs bars that run from left to right" });
819
+ continue;
820
+ }
821
+ if (item.to != null && item.to !== item.target) {
822
+ problems.push({ item, problem: "both ends of a bracket must be in one chart" });
823
+ continue;
824
+ }
825
+ const [upper, lower] = a.box.y <= b.box.y ? [a.box, b.box] : [b.box, a.box];
826
+ const share = item.percent ? shareOf(item, upper, lower) : undefined;
827
+ const host = targets.get(item.target).getBoundingClientRect();
828
+ const hostBox = toLocal({ x: host.left, y: host.top, width: host.width, height: host.height });
829
+ const caption = (_e = item.text) !== null && _e !== void 0 ? _e : (share != null ? `${Math.round(share * 100)}%` : undefined);
830
+ marks.push(buildBracket(item, toLocal(a.box), toLocal(b.box), { first: endOf(a).x, last: endOf(b).x }, hostBox.x, caption, em));
831
+ continue;
832
+ }
620
833
  const from = anchorOf(item.target, item.point);
621
834
  const to = item.mark === "arrow" ? anchorOf(item.to, item.toPoint) : undefined;
622
835
  const failed = "problem" in from ? from : to && "problem" in to ? to : undefined;
@@ -630,8 +843,10 @@ const AnnotationLayer = class {
630
843
  whole: start.whole,
631
844
  area,
632
845
  text: start.text && textToLocal(start.text),
633
- obstacles: (_b = start.obstacles) === null || _b === void 0 ? void 0 : _b.map(textToLocal),
846
+ obstacles: (_f = start.obstacles) === null || _f === void 0 ? void 0 : _f.map(textToLocal),
634
847
  stacked: start.stacked,
848
+ label: start.label,
849
+ horizontal: start.horizontal,
635
850
  });
636
851
  if (mark) {
637
852
  marks.push(mark);
@@ -751,7 +966,7 @@ const AnnotationLayer = class {
751
966
  return (h("g", null, h("circle", { cx: badge.cx, cy: badge.cy, r: badge.r, style: { fill: color } }), badge.label != null ? (h("text", { class: "badge-text", x: badge.cx, y: badge.cy, style: { fontSize: `${badge.r * 1.1}px` } }, badge.label)) : null));
752
967
  }
753
968
  renderMark(mark) {
754
- var _a, _b, _c;
969
+ var _a, _b, _e, _f, _g;
755
970
  const color = annotationColor(mark.color, this.componentStyle(($) => $["bn-annotation"]));
756
971
  if (mark.kind === "marker") {
757
972
  return (h("g", { class: "mark marker", "data-label": mark.badge.label }, this.renderBadge(mark.badge, color)));
@@ -763,10 +978,16 @@ const AnnotationLayer = class {
763
978
  const main = annotationColor(undefined, this.componentStyle(($) => $["bn-annotation"]));
764
979
  return (h("g", { class: "mark difference", "data-label": (_b = mark.badge) === null || _b === void 0 ? void 0 : _b.label }, mark.lines.map((line) => (h("line", { class: "difference-line", x1: line.x1, y1: line.y1, x2: line.x2, y2: line.y2 }))), h("rect", { x: mark.bar.x, y: mark.bar.y, width: mark.bar.width, height: mark.bar.height, style: { fill: color } }), h("text", { class: "mark-text", x: mark.text.x, y: mark.text.y, style: { textAnchor: mark.text.anchor } }, mark.text.value, mark.text.percent ? (h("tspan", { class: "percent", dx: "0.35em" }, mark.text.percent)) : null), mark.frame ? (h("rect", { x: mark.frame.x, y: mark.frame.y, width: mark.frame.width, height: mark.frame.height, rx: mark.frame.r, ry: mark.frame.r, style: { fill: "none", stroke: main, strokeWidth: "1.5" } })) : null, this.renderBadge(mark.badge, main)));
765
980
  }
766
- return (h("g", { class: "mark arrow", "data-label": (_c = mark.badge) === null || _c === void 0 ? void 0 : _c.label }, h("line", { x1: mark.x1, y1: mark.y1, x2: mark.x2, y2: mark.y2, style: { stroke: color, strokeWidth: "1.5" } }), h("polygon", { points: mark.head, style: { fill: color } }), this.renderBadge(mark.badge, color)));
981
+ if (mark.kind === "pointer") {
982
+ return (h("g", { class: "mark pointer", "data-label": (_e = mark.badge) === null || _e === void 0 ? void 0 : _e.label }, h("polygon", { points: mark.shape, style: { fill: color } }), this.renderBadge(mark.badge, color)));
983
+ }
984
+ if (mark.kind === "bracket") {
985
+ return (h("g", { class: "mark bracket", "data-label": (_f = mark.badge) === null || _f === void 0 ? void 0 : _f.label }, h("polyline", { points: mark.path, style: { fill: "none", stroke: color, strokeWidth: "1.5" } }), mark.frame ? (h("rect", { x: mark.frame.x, y: mark.frame.y, width: mark.frame.width, height: mark.frame.height, rx: mark.frame.r, ry: mark.frame.r, style: { fill: "#ffffff", stroke: color, strokeWidth: "1.5" } })) : null, mark.caption ? (h("text", { class: "mark-text caption", x: mark.caption.x, y: mark.caption.y }, mark.caption.text)) : null, this.renderBadge(mark.badge, color)));
986
+ }
987
+ return (h("g", { class: "mark arrow", "data-label": (_g = mark.badge) === null || _g === void 0 ? void 0 : _g.label }, h("line", { x1: mark.x1, y1: mark.y1, x2: mark.x2, y2: mark.y2, style: { stroke: color, strokeWidth: "1.5" } }), h("polygon", { points: mark.head, style: { fill: color } }), this.renderBadge(mark.badge, color)));
767
988
  }
768
989
  render() {
769
- return (h(Host, { key: 'f2864246b86078e97a15f58cab7f46a792e6d300' }, h("svg", { key: '52f932a7f8dff3e00773f8f827c82ec62848cb34', ref: (el) => (this.svg = el) }, this.marks.map((mark) => this.renderMark(mark)))));
990
+ return (h(Host, { key: '3b82cff435bdbabe51cdb7581afef428a16716b0' }, h("svg", { key: '0613bd3ecb59150c6959c9f96322b0f3eafc6164', ref: (el) => (this.svg = el) }, this.marks.map((mark) => this.renderMark(mark)))));
770
991
  }
771
992
  get element() { return getElement(this); }
772
993
  static get watchers() { return {
@@ -9462,9 +9683,15 @@ class Formatter {
9462
9683
  }
9463
9684
  this.formats.set(key, format);
9464
9685
  }
9465
- const text = format.format(value / scale);
9686
+ const print = (number) => this.groupSeparator === null
9687
+ ? format.format(number)
9688
+ : format
9689
+ .formatToParts(number)
9690
+ .map((part) => (part.type === "group" ? this.groupSeparator : part.value))
9691
+ .join("");
9692
+ const text = print(value / scale);
9466
9693
  // a small negative that rounds to zero would print "-0"
9467
- return (text === format.format(-0) ? format.format(0) : text).replace(/\s+(%)/g, "$1");
9694
+ return (text === print(-0) ? print(0) : text).replace(/\s+(%)/g, "$1");
9468
9695
  }
9469
9696
  /**
9470
9697
  * Translates a technical scenario identifier into a human-readable IBCS label.
@@ -9522,6 +9749,11 @@ class Formatter {
9522
9749
  }
9523
9750
  /** One formatter per locale, style and digits: building one per cell is slow. */
9524
9751
  Formatter.formats = new Map();
9752
+ /**
9753
+ * Replaces the group separator of the locale in every number, for example by a thin
9754
+ * space. Null: the separator of the locale. One setting for the page: `bn-context` sets it.
9755
+ */
9756
+ Formatter.groupSeparator = null;
9525
9757
 
9526
9758
  /** Most decimals a label gets: a double has about 15 significant digits. */
9527
9759
  const MAX_DECIMALS = 15;
@@ -14594,6 +14826,55 @@ const Chart$1 = class Chart {
14594
14826
  this.errors.remove(errId);
14595
14827
  }
14596
14828
  }
14829
+ validateSums(newValue) {
14830
+ this.warnUnless("sums", ["none", "groups", "total", "all"].includes(newValue), newValue);
14831
+ }
14832
+ validateScenarioLabelPosition(newValue) {
14833
+ this.warnUnless("scenarioLabelPosition", ["bottom", "top"].includes(newValue), newValue);
14834
+ }
14835
+ validateReferenceLine(newValue) {
14836
+ this.warnUnless("referenceLine", isBlankInput(newValue) || this.prepareReferenceLine() !== null, newValue);
14837
+ }
14838
+ validateItalicCategories(newValue) {
14839
+ this.warnUnless("italicCategories", isBlankInput(newValue) || this.prepareItalicCategories() !== null, newValue);
14840
+ }
14841
+ warnUnless(name, valid, value) {
14842
+ const errId = `WARN_${name}`;
14843
+ if (valid) {
14844
+ this.errors.remove(errId);
14845
+ }
14846
+ else {
14847
+ this.errors.addOrReplace({
14848
+ id: errId,
14849
+ type: "warning",
14850
+ message: name + ": invalid value '" + value + "' is not supported.",
14851
+ });
14852
+ }
14853
+ }
14854
+ prepareReferenceLine() {
14855
+ if (isBlankInput(this.referenceLine))
14856
+ return null;
14857
+ try {
14858
+ const parsed = JSON.parse(this.referenceLine);
14859
+ if (typeof (parsed === null || parsed === void 0 ? void 0 : parsed.value) !== "number" || !Number.isFinite(parsed.value))
14860
+ return null;
14861
+ return { value: parsed.value, label: typeof parsed.label === "string" ? parsed.label : undefined };
14862
+ }
14863
+ catch (_a) {
14864
+ return null;
14865
+ }
14866
+ }
14867
+ prepareItalicCategories() {
14868
+ if (isBlankInput(this.italicCategories))
14869
+ return [];
14870
+ try {
14871
+ const parsed = JSON.parse(this.italicCategories);
14872
+ return Array.isArray(parsed) && parsed.every((entry) => typeof entry === "string") ? parsed : null;
14873
+ }
14874
+ catch (_a) {
14875
+ return null;
14876
+ }
14877
+ }
14597
14878
  validateStack(newValue) {
14598
14879
  const errId = "WARN_stack";
14599
14880
  const errors = validateStackConfig(newValue);
@@ -14707,6 +14988,48 @@ const Chart$1 = class Chart {
14707
14988
  * Number of decimal digits of the percent labels (relative variances, shares of a 100 % stack)
14708
14989
  */
14709
14990
  this.dataFormatDigitsPercent = 2;
14991
+ /**
14992
+ * Sum rows. `groups` adds a row below the rows of each `rowGroup` (level
14993
+ * `category`), `total` a row over all rows, `all` both. A sum row has no
14994
+ * bar: it prints the sum in bold, in a stack one number per series with a
14995
+ * small square in the colour of the series. In a 100 % stack it is a bar
14996
+ * of shares. A sum row does not count for the scale.
14997
+ *
14998
+ * @default "none"
14999
+ * @example sums="all"
15000
+ */
15001
+ this.sums = "none";
15002
+ /**
15003
+ * Label of the sum row over all rows.
15004
+ *
15005
+ * @default "" (the `SUM_TOTAL` text)
15006
+ * @example sum-title="World"
15007
+ */
15008
+ this.sumTitle = "";
15009
+ /**
15010
+ * Where the name of the scenario of a chart with plain bars stands:
15011
+ * `bottom` below the last bar, `top` above the first one.
15012
+ *
15013
+ * @default "bottom"
15014
+ * @example scenario-label-position="top"
15015
+ */
15016
+ this.scenarioLabelPosition = "bottom";
15017
+ /**
15018
+ * A line across the bars at one value of the axis, as a JSON string:
15019
+ * `value` and an optional `label`. In a 100 % stack the value is a percent.
15020
+ *
15021
+ * @default "" (no line)
15022
+ * @example reference-line='{"value":50,"label":"50%"}'
15023
+ */
15024
+ this.referenceLine = "";
15025
+ /**
15026
+ * Rows that are printed in italics, as a JSON array of values of the
15027
+ * level column, for example the rest rows.
15028
+ *
15029
+ * @default "" (none)
15030
+ * @example italic-categories='["Rest of world"]'
15031
+ */
15032
+ this.italicCategories = "";
14710
15033
  /**
14711
15034
  * Stacking configuration as a JSON string. When set, bars are drawn as
14712
15035
  * stacked segments instead of side-by-side.
@@ -14809,6 +15132,10 @@ const Chart$1 = class Chart {
14809
15132
  this.validateOrderList(this.order);
14810
15133
  this.validateMeasureScale(this.measureScale);
14811
15134
  this.validateStack(this.stack);
15135
+ this.validateSums(this.sums);
15136
+ this.validateScenarioLabelPosition(this.scenarioLabelPosition);
15137
+ this.validateReferenceLine(this.referenceLine);
15138
+ this.validateItalicCategories(this.italicCategories);
14812
15139
  this.validateScaling(this.scale);
14813
15140
  }
14814
15141
  componentDidRender() {
@@ -15209,6 +15536,7 @@ const Chart$1 = class Chart {
15209
15536
  prepareStackConfig() {
15210
15537
  if (isBlankInput(this.stack)) {
15211
15538
  this.errors.remove("WARN_stack_dimensions_scenarios");
15539
+ this.errors.remove("WARN_stack_thickness_variances");
15212
15540
  return null;
15213
15541
  }
15214
15542
  try {
@@ -15231,10 +15559,27 @@ const Chart$1 = class Chart {
15231
15559
  else {
15232
15560
  this.errors.remove(errId);
15233
15561
  }
15562
+ // rows of different height are for the base chart alone: a variance bar has one thickness
15563
+ const byTotal = parsed.thickness === "total";
15564
+ const withVariances = byTotal && this.prepareVariances().length > 0;
15565
+ if (withVariances) {
15566
+ this.errors.addOrReplace({
15567
+ id: "WARN_stack_thickness_variances",
15568
+ type: "warning",
15569
+ message: "stack thickness total: not used together with variances, the rows keep one height.",
15570
+ });
15571
+ }
15572
+ else {
15573
+ this.errors.remove("WARN_stack_thickness_variances");
15574
+ }
15234
15575
  return {
15235
15576
  by,
15236
15577
  mode: parsed.mode || StackMode.ABSOLUTE,
15237
15578
  order: parsed.order || StackOrder.DATASET,
15579
+ percentMark: parsed.percentMark === true,
15580
+ labels: parsed.labels === "value" ? "value" : "share",
15581
+ thickness: byTotal && !withVariances ? "total" : "equal",
15582
+ totalTitle: typeof parsed.totalTitle === "string" ? parsed.totalTitle : undefined,
15238
15583
  };
15239
15584
  }
15240
15585
  catch (_a) {
@@ -15308,6 +15653,7 @@ const Chart$1 = class Chart {
15308
15653
  return this.measureUnit;
15309
15654
  }
15310
15655
  chartTemplate(localScenarioString, idx) {
15656
+ var _a;
15311
15657
  const ppu = this.preparePixelPerUnit();
15312
15658
  const ppp = this.preparePixelPerPercentage();
15313
15659
  const stackConfig = this.prepareStackConfig();
@@ -15315,7 +15661,7 @@ const Chart$1 = class Chart {
15315
15661
  const scenarios = this.hidesScenarios() ? variancesScenarios([localScenarioString]) : this.prepareScenarios();
15316
15662
  // Dimension stacking uses only the first scenario. Only the base chart draws a stack, a variance needs both of its scenarios
15317
15663
  const effectiveScenarios = isBase && (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
15318
- return (h("bn-chart-structure-renderer", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideCategories: this.prepareHideCategories(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, limit: this.prepareLimit(), styles: this.prepareStyle(), i18n: this.prepareI18n(), order: this.prepareOrder(), level: this.prepareLevel(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(idx), stackConfig: stackConfig, dataFormatDigits: { percent: this.dataFormatDigitsPercent, decimal: this.dataFormatDigitsDecimal }, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
15664
+ return (h("bn-chart-structure-renderer", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideCategories: this.prepareHideCategories(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, limit: this.prepareLimit(), styles: this.prepareStyle(), i18n: this.prepareI18n(), order: this.prepareOrder(), level: this.prepareLevel(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(idx), stackConfig: stackConfig, sums: ["groups", "total", "all"].includes(this.sums) ? this.sums : "none", sumTitle: this.sumTitle, scenarioLabelTop: this.scenarioLabelPosition === "top", referenceLine: isBase ? this.prepareReferenceLine() : null, italicCategories: (_a = this.prepareItalicCategories()) !== null && _a !== void 0 ? _a : [], dataFormatDigits: { percent: this.dataFormatDigitsPercent, decimal: this.dataFormatDigitsDecimal }, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
15319
15665
  }
15320
15666
  /**
15321
15667
  * The line this chart wants to be aligned on, in CSS px from the host's
@@ -15445,7 +15791,7 @@ const Chart$1 = class Chart {
15445
15791
  this.errors.remove("WARN_scenarios_none");
15446
15792
  }
15447
15793
  const fontStyles = this.getFontStyles();
15448
- return (h(Host, { key: 'a9b487fd43e785b1f14d0599ad0145a248b35f5d', style: fontStyles }, h("div", { key: '950ab383346b288ab17c2a1bbdfcfcd240e0f4d8', class: "container" }, scenariosArray.map(this.chartTemplate))));
15794
+ return (h(Host, { key: 'eb0b081632a3d8e9475f280357c0b22b17b23df3', style: fontStyles }, h("div", { key: '8ecaea33bcd96b312e39868f008aa630e12077c2', class: "container" }, scenariosArray.map(this.chartTemplate))));
15449
15795
  }
15450
15796
  get element() { return getElement(this); }
15451
15797
  static get watchers() { return {
@@ -15485,6 +15831,18 @@ const Chart$1 = class Chart {
15485
15831
  "dataFormatDigitsPercent": [{
15486
15832
  "validateDataFormatDigitsPercent": 0
15487
15833
  }],
15834
+ "sums": [{
15835
+ "validateSums": 0
15836
+ }],
15837
+ "scenarioLabelPosition": [{
15838
+ "validateScenarioLabelPosition": 0
15839
+ }],
15840
+ "referenceLine": [{
15841
+ "validateReferenceLine": 0
15842
+ }],
15843
+ "italicCategories": [{
15844
+ "validateItalicCategories": 0
15845
+ }],
15488
15846
  "stack": [{
15489
15847
  "validateStack": 0
15490
15848
  }],
@@ -15512,7 +15870,7 @@ Chart$1.style = bnChartStructureCss$1();
15512
15870
  */
15513
15871
  let ElementPositions$1 = class ElementPositions {
15514
15872
  // private smallestDataPoint: DataPoint;
15515
- constructor(padding, scaleFactors, fontSize, numberOfColumns, leftSideLengthSync, titleLength, leftSideWidth, categoryWidth, hasStackedHeaders = false) {
15873
+ constructor(padding, scaleFactors, fontSize, numberOfColumns, leftSideLengthSync, titleLength, leftSideWidth, categoryWidth, hasStackedHeaders = false, rows = null) {
15516
15874
  this.categoryPosition = { x: 0, y: 0 };
15517
15875
  this.spacings = {
15518
15876
  scenarioOffset: 0,
@@ -15543,6 +15901,7 @@ let ElementPositions$1 = class ElementPositions {
15543
15901
  this.leftSideLengthSync = leftSideLengthSync;
15544
15902
  this.topSideLabelHeight = titleLength > 0 ? this.fontSize : 0;
15545
15903
  this.hasStackedHeaders = hasStackedHeaders;
15904
+ this.rows = rows;
15546
15905
  this.leftSideLabelLength = this.calculateSideLabelLength(titleLength, leftSideWidth, categoryWidth);
15547
15906
  this.calculateSpacings();
15548
15907
  this.calculateCategoryPosition();
@@ -15552,8 +15911,22 @@ let ElementPositions$1 = class ElementPositions {
15552
15911
  return this.axisPosition.x;
15553
15912
  }
15554
15913
  getBarCenterPositionY(index) {
15914
+ if (this.rows && index < this.rows.start.length) {
15915
+ const middle = this.rows.start[index] + this.rows.weight[index] / 2;
15916
+ return this.getAxisPositionY() + this.spacings.scenarioOffset + middle * this.spacings.categoryWidth;
15917
+ }
15555
15918
  return this.categoryPosition.y + this.spacings.scenarioOffset + index * this.spacings.categoryWidth;
15556
15919
  }
15920
+ /** Upper edge of the room of a row. */
15921
+ getRowTopPositionY(index) {
15922
+ const start = this.rows && index < this.rows.start.length ? this.rows.start[index] : index;
15923
+ return this.getAxisPositionY() + this.spacings.scenarioOffset + start * this.spacings.categoryWidth;
15924
+ }
15925
+ /** Thickness of the bar of a row. Rows have one thickness unless the chart sets a row layout. */
15926
+ getBarWidthAt(index) {
15927
+ const weight = this.rows && index < this.rows.weight.length ? this.rows.weight[index] : 1;
15928
+ return this.spacings.barWidth * weight;
15929
+ }
15557
15930
  getBarPositionY(index, isPrimaryMarker) {
15558
15931
  if (isPrimaryMarker) {
15559
15932
  return this.getBarCenterPositionY(index);
@@ -15574,7 +15947,7 @@ let ElementPositions$1 = class ElementPositions {
15574
15947
  return this.axisPosition.y - this.spacings.labelToAxis - this.getTopLabelOverhang();
15575
15948
  }
15576
15949
  getStackedHeaderPositionY() {
15577
- return this.getBarCenterPositionY(0) - this.spacings.barWidth * 0.5 - this.spacings.scenarioLabelToBar;
15950
+ return this.getBarCenterPositionY(0) - this.getBarWidthAt(0) * 0.5 - this.spacings.scenarioLabelToBar;
15578
15951
  }
15579
15952
  getNeedleWidth() {
15580
15953
  return this.spacings.needleWidth;
@@ -15626,7 +15999,8 @@ let ElementPositions$1 = class ElementPositions {
15626
15999
  return this.spacings.scenarioOffset; // this.categoryOffset;
15627
16000
  }
15628
16001
  getAxisEndPositionY() {
15629
- return this.getAxisPositionY() + (this.numberOfColumns + 1 / 2) * this.spacings.categoryWidth;
16002
+ const rows = this.rows ? this.rows.total : this.numberOfColumns;
16003
+ return this.getAxisPositionY() + (rows + 1 / 2) * this.spacings.categoryWidth;
15630
16004
  }
15631
16005
  getScenarioLabelPositionOffsetY(isPrimaryBar) {
15632
16006
  if (isPrimaryBar) {
@@ -16021,6 +16395,14 @@ class StructureChartComponentConfig {
16021
16395
  this.showMeasureScale = true;
16022
16396
  this.dataFormatDigits = { decimal: 1, percent: 2 };
16023
16397
  this.stackConfig = null;
16398
+ this.sums = "none";
16399
+ /** Label of the row over all rows. Empty: the `SUM_TOTAL` text. */
16400
+ this.sumTitle = "";
16401
+ /** The name of the scenario stands above the first bar and not below the last one. */
16402
+ this.scenarioLabelTop = false;
16403
+ this.referenceLine = null;
16404
+ /** Values of the level column whose row is printed in italics. */
16405
+ this.italicCategories = [];
16024
16406
  }
16025
16407
  }
16026
16408
  /**
@@ -16084,6 +16466,21 @@ class StructureChartComponentConfigAdapter {
16084
16466
  if (CompareUtil.isExisting(data.stackConfig)) {
16085
16467
  config.stackConfig = data.stackConfig;
16086
16468
  }
16469
+ if (CompareUtil.isString(data.sums) && ["groups", "total", "all"].includes(data.sums)) {
16470
+ config.sums = data.sums;
16471
+ }
16472
+ if (CompareUtil.isString(data.sumTitle)) {
16473
+ config.sumTitle = data.sumTitle;
16474
+ }
16475
+ if (CompareUtil.isBoolean(data.scenarioLabelTop)) {
16476
+ config.scenarioLabelTop = data.scenarioLabelTop;
16477
+ }
16478
+ if (CompareUtil.isExisting(data.referenceLine)) {
16479
+ config.referenceLine = data.referenceLine;
16480
+ }
16481
+ if (CompareUtil.isArray(data.italicCategories)) {
16482
+ config.italicCategories = AdapterUtils.adaptArray(data.italicCategories, this.stringAdapter);
16483
+ }
16087
16484
  return config;
16088
16485
  }
16089
16486
  default() {
@@ -16553,6 +16950,8 @@ class Label {
16553
16950
  this.group = null;
16554
16951
  this.segmentFillColor = null;
16555
16952
  this.maxWidth = null;
16953
+ this.bold = false;
16954
+ this.italic = false;
16556
16955
  this.ID_SCENARIOLABEL = "Label";
16557
16956
  this.CSS_CATEGORIES = "categories";
16558
16957
  this.pointPart = "label";
@@ -16581,6 +16980,12 @@ class Label {
16581
16980
  this.segmentFillColor = color;
16582
16981
  return this;
16583
16982
  }
16983
+ /** Bold for a sum row, italic for a rest row. */
16984
+ setEmphasis(bold, italic) {
16985
+ this.bold = bold;
16986
+ this.italic = italic;
16987
+ return this;
16988
+ }
16584
16989
  setMaxWidth(width) {
16585
16990
  this.maxWidth = width;
16586
16991
  return this;
@@ -16636,6 +17041,10 @@ class Label {
16636
17041
  }
16637
17042
  // @ts-ignore
16638
17043
  const text = label.text(prefix + valueStr);
17044
+ if (this.bold)
17045
+ text.font({ weight: "bold" });
17046
+ if (this.italic)
17047
+ text.font({ style: "italic" });
16639
17048
  text.move(this.x, this.y);
16640
17049
  // One bbox() per label, not two: svg.js caches nothing, and on a detached
16641
17050
  // tree each call clones the subtree into the document to measure it.
@@ -16805,7 +17214,7 @@ class Bar {
16805
17214
  return this;
16806
17215
  }
16807
17216
  draw(dataFormatDigits = { percent: 2, decimal: 1 }, measureScale = new SiPrefix()) {
16808
- var _a, _b;
17217
+ var _a, _b, _c;
16809
17218
  if (this.isEmpty() || this.dataPoint.getScenario() == null) {
16810
17219
  return this;
16811
17220
  }
@@ -16825,6 +17234,8 @@ class Bar {
16825
17234
  }
16826
17235
  (_a = this.scenarioGroup) === null || _a === void 0 ? void 0 : _a.attr(dataPointAttributes(this.dataPoint.key));
16827
17236
  (_b = this.barGroup) === null || _b === void 0 ? void 0 : _b.attr(dataPointAttributes(this.dataPoint.key, "element"));
17237
+ if (!this.isVarianceBar)
17238
+ (_c = this.barGroup) === null || _c === void 0 ? void 0 : _c.attr("data-bn-value", this.dataPoint.value);
16828
17239
  if (this.barGroup != null) {
16829
17240
  if (this.isOverflowing && this.overflowConfig) {
16830
17241
  this.drawOverdriveBar(fillStyle, strokeStyle);
@@ -17301,7 +17712,7 @@ let Needle$1 = class Needle {
17301
17712
  * Renders a single horizontal stacked bar segment for the structure chart.
17302
17713
  */
17303
17714
  class StackedBar {
17304
- constructor(position, styles, dataPoint, index, segment, _segmentLabel, segmentIndex, stackMode, stack, _isScenarioStack, parentGroup) {
17715
+ constructor(position, styles, dataPoint, index, segment, _segmentLabel, segmentIndex, stackMode, stack, _isScenarioStack, parentGroup, options = {}) {
17305
17716
  this.hasData = false;
17306
17717
  this.position = position;
17307
17718
  this.styles = styles;
@@ -17311,6 +17722,7 @@ class StackedBar {
17311
17722
  this.segmentIndex = segmentIndex;
17312
17723
  this.stackMode = stackMode;
17313
17724
  this.stack = stack;
17725
+ this.options = options;
17314
17726
  this.group = parentGroup;
17315
17727
  this.barGroup = parentGroup.group().id(`stacked_bar_${index}_seg_${segmentIndex}`);
17316
17728
  if ((dataPoint === null || dataPoint === void 0 ? void 0 : dataPoint.isEmpty()) !== true && dataPoint.value != null) {
@@ -17318,6 +17730,7 @@ class StackedBar {
17318
17730
  }
17319
17731
  }
17320
17732
  draw(dataFormatDigits = { percent: 2, decimal: 1 }, measureScale = new SiPrefix()) {
17733
+ var _a;
17321
17734
  // a segment without a value (NaN) keeps its place in the stack, so the colours stay, but draws nothing
17322
17735
  if (!this.hasData || !Number.isFinite(this.dataPoint.value)) {
17323
17736
  return;
@@ -17325,7 +17738,7 @@ class StackedBar {
17325
17738
  const value = this.dataPoint.value;
17326
17739
  const pixelPerUnit = this.dataPoint.pixelPerUnit;
17327
17740
  const axisX = this.position.getBarPositionX();
17328
- const barWidth = this.position.getBarWidth();
17741
+ const barWidth = this.position.getBarWidthAt(this.index);
17329
17742
  // a negative segment ends left of its start: the rect begins at the edge that is further left
17330
17743
  const segmentLength = Math.abs(this.segment.end - this.segment.start) * pixelPerUnit;
17331
17744
  const xPos = axisX + Math.min(this.segment.start, this.segment.end) * pixelPerUnit;
@@ -17335,16 +17748,24 @@ class StackedBar {
17335
17748
  const fillStyle = { color: fillColor };
17336
17749
  const strokeStyle = { color: fillColor, width: 0.5 };
17337
17750
  this.barGroup.attr(dataPointAttributes(this.dataPoint.key, "element"));
17751
+ this.barGroup.attr("data-bn-value", value);
17338
17752
  this.barGroup.rect(Math.max(segmentLength, 0.5), barWidth).fill(fillStyle).stroke(strokeStyle).cy(yPos).x(xPos);
17339
17753
  // Draw segment value label centered on bar if wide enough
17340
- const LABEL_PADDING = 6;
17341
- const availableWidth = segmentLength - LABEL_PADDING;
17754
+ // 6 px at the base font of 16 px, less with a smaller font
17755
+ const labelPadding = Math.min(6, this.styles.fontStyles.size * 0.375);
17756
+ const availableWidth = segmentLength - labelPadding;
17757
+ const { bold = false, italic = false } = this.options;
17758
+ const relative = this.stackMode === StackMode.RELATIVE || this.stackMode === StackMode.ABSOLUTE_RELATIVE;
17759
+ const labelKind = this.stackMode === StackMode.RELATIVE ? ((_a = this.options.label) !== null && _a !== void 0 ? _a : "share") : "share";
17342
17760
  if (availableWidth > 0) {
17343
17761
  const labelX = xPos + segmentLength / 2;
17344
- if (this.stackMode === StackMode.RELATIVE || this.stackMode === StackMode.ABSOLUTE_RELATIVE) {
17345
- const labelValue = Formatter.number(this.segment.share, "percent", dataFormatDigits.percent, dataFormatDigits.percent, 1, this.styles.locale);
17762
+ if (relative && labelKind !== "value") {
17763
+ const labelValue = labelKind === "plain-share"
17764
+ ? Formatter.number(this.segment.share * 100, "decimal", dataFormatDigits.percent, dataFormatDigits.percent, 1, this.styles.locale)
17765
+ : Formatter.number(this.segment.share, "percent", dataFormatDigits.percent, dataFormatDigits.percent, 1, this.styles.locale);
17346
17766
  new Label(this.group, labelX, yPos, "STACK_SEG", labelValue, this.styles, HookLocation.Center, HookLocation.Center)
17347
17767
  .setSegmentFill(fillColor)
17768
+ .setEmphasis(bold, italic)
17348
17769
  .setMaxWidth(availableWidth)
17349
17770
  .setPoint(this.dataPoint.key)
17350
17771
  .draw();
@@ -17353,6 +17774,7 @@ class StackedBar {
17353
17774
  // Pass raw numeric value - Label.draw() formats with measureScale
17354
17775
  new Label(this.group, labelX, yPos, "STACK_SEG", value, this.styles, HookLocation.Center, HookLocation.Center)
17355
17776
  .setSegmentFill(fillColor)
17777
+ .setEmphasis(bold, italic)
17356
17778
  .setMaxWidth(availableWidth)
17357
17779
  .setPoint(this.dataPoint.key)
17358
17780
  .draw(dataFormatDigits, measureScale);
@@ -17360,7 +17782,8 @@ class StackedBar {
17360
17782
  }
17361
17783
  }
17362
17784
  drawTotalLabel(dataFormatDigits = { percent: 2, decimal: 1 }, measureScale = new SiPrefix(), key) {
17363
- if (this.stackMode === StackMode.RELATIVE) {
17785
+ var _a, _b;
17786
+ if (this.stackMode === StackMode.RELATIVE && !this.options.total) {
17364
17787
  return;
17365
17788
  }
17366
17789
  // like a plain bar: the label of a negative total sits left of the negative side
@@ -17369,7 +17792,10 @@ class StackedBar {
17369
17792
  const labelX = this.position.getLabelPositionX(end * this.dataPoint.pixelPerUnit);
17370
17793
  const yPos = this.position.getBarPositionY(this.index, true);
17371
17794
  const label = new Label(this.group, labelX, yPos, "STACK_TOTAL", this.stack.total, this.styles, HookLocation.Center, isNegative ? HookLocation.Right : HookLocation.Left);
17372
- label.setPoint(key, "total").draw(dataFormatDigits, measureScale);
17795
+ label
17796
+ .setEmphasis((_a = this.options.bold) !== null && _a !== void 0 ? _a : false, (_b = this.options.italic) !== null && _b !== void 0 ? _b : false)
17797
+ .setPoint(key, "total")
17798
+ .draw(dataFormatDigits, measureScale);
17373
17799
  }
17374
17800
  }
17375
17801
 
@@ -17626,6 +18052,8 @@ function stackLabelSide(layouts, totalLabelRoom = () => 0) {
17626
18052
  return { flipped, clearance: Math.max(0, ...clearance) };
17627
18053
  }
17628
18054
 
18055
+ /** The id of the row that sums the rows a limit cut off. */
18056
+ const REST_ROW_ID = 9999;
17629
18057
  /**
17630
18058
  * Orchestrates the full rendering pipeline for an IBCS structure (categorical) chart.
17631
18059
  *
@@ -17682,6 +18110,11 @@ class StructureChart {
17682
18110
  this.stackLabelClearance = { left: 0, right: 0 };
17683
18111
  this.fromExpr = "";
17684
18112
  this.rowCount = 0;
18113
+ this.sums = "none";
18114
+ this.sumTitle = "";
18115
+ this.scenarioLabelTop = false;
18116
+ this.referenceLine = null;
18117
+ this.italicCategories = [];
17685
18118
  this.db = db;
17686
18119
  this.tableName = tableName;
17687
18120
  this.ruleSet = ruleSet || new IBCSRuleSet();
@@ -17700,7 +18133,7 @@ class StructureChart {
17700
18133
  if (this.titleLength > leftSideWidth) {
17701
18134
  leftSideWidth = this.titleLength;
17702
18135
  }
17703
- return new ElementPositions$1(new Padding$1(this.styles.padding), this.styles.scaleFactors, this.styles.fontStyles.size, this.dataModel.length, this.leftSideOffsetForHorizontalSync, this.titleLength, leftSideWidth, categoryWidth, !!this.stackConfig && this.variancesDataModel.length === 0);
18136
+ return new ElementPositions$1(new Padding$1(this.styles.padding), this.styles.scaleFactors, this.styles.fontStyles.size, this.dataModel.length, this.leftSideOffsetForHorizontalSync, this.titleLength, leftSideWidth, categoryWidth, (!!this.stackConfig && this.variancesDataModel.length === 0) || this.scenarioLabelTop, this.rowLayout());
17704
18137
  }
17705
18138
  setStyles(newStyle) {
17706
18139
  this.styles = newStyle;
@@ -17719,7 +18152,17 @@ class StructureChart {
17719
18152
  this.pixelPerPercentage = config.pixelPerPercentage || 100;
17720
18153
  this.setSource(config.filter);
17721
18154
  this.level = config.level;
18155
+ this.sums = config.sums;
18156
+ this.sumTitle = config.sumTitle;
18157
+ this.scenarioLabelTop = config.scenarioLabelTop;
18158
+ this.referenceLine = config.referenceLine;
18159
+ this.italicCategories = config.italicCategories;
17722
18160
  this.dataModel = this.populateModel(scenarios, config.level, config.sortOrder);
18161
+ // Populate per-dimension stack segments when stacking by a data dimension
18162
+ if (config.stackConfig && config.stackConfig.by !== StackBy.SCENARIOS) {
18163
+ this.populateDimensionStackSegments(scenarios, config.stackConfig, config.level);
18164
+ }
18165
+ this.addSumRows(scenarios);
17723
18166
  for (const row of this.dataModel) {
17724
18167
  for (const dataPoint of [row.scenario1, row.scenario2, row.scenario3, row.scenario4]) {
17725
18168
  // a category without a value has no bar: nothing an annotation can point at
@@ -17728,18 +18171,17 @@ class StructureChart {
17728
18171
  }
17729
18172
  }
17730
18173
  }
17731
- // Populate per-dimension stack segments when stacking by a data dimension
17732
- if (config.stackConfig && config.stackConfig.by !== StackBy.SCENARIOS) {
17733
- this.populateDimensionStackSegments(scenarios, config.stackConfig, config.level);
17734
- }
17735
18174
  this.variancesDataModel = this.populateVarianceModel(config.variances, this.dataModel);
17736
18175
  this.configTitle = config.title;
17737
18176
  this.configVariances = (_b = config === null || config === void 0 ? void 0 : config.variances) !== null && _b !== void 0 ? _b : [];
17738
18177
  this.updateTitle();
17739
- this.smallestDataPointValue = this.findSmallestDataPointValue(this.dataModel);
17740
- this.smallestVarianceDataPointValue = this.findSmallestDataPointValue(this.variancesDataModel);
17741
- this.highestDataPointValue = this.findHighestDataPointValue(this.dataModel);
17742
- this.highestVarianceDataPointValue = this.findHighestDataPointValue(this.variancesDataModel);
18178
+ // a sum row has no bar: it does not count for the scale
18179
+ const bars = this.dataModel.filter((row) => !row.sum);
18180
+ this.smallestDataPointValue = this.findSmallestDataPointValue(bars);
18181
+ const varianceBars = this.variancesDataModel.filter((row) => !row.sum);
18182
+ this.smallestVarianceDataPointValue = this.findSmallestDataPointValue(varianceBars);
18183
+ this.highestDataPointValue = this.findHighestDataPointValue(bars);
18184
+ this.highestVarianceDataPointValue = this.findHighestDataPointValue(varianceBars);
17743
18185
  this.axisScenario = this.setAxisScenario(config.variances);
17744
18186
  this.measureScale = config.measureScale;
17745
18187
  this.measureUnit = config.measureUnit;
@@ -17855,7 +18297,7 @@ class StructureChart {
17855
18297
  * from variable width components.
17856
18298
  */
17857
18299
  getUnitBarExtent() {
17858
- var _a, _b;
18300
+ var _a, _b, _c, _d;
17859
18301
  const stacked = this.isStacked();
17860
18302
  const vt = this.getVarianceType();
17861
18303
  const isVariance = vt !== VarianceType$1.NONE;
@@ -17865,8 +18307,9 @@ class StructureChart {
17865
18307
  // both sides of the axis; a relative stack is laid out on a span of 1, so its sides add up to 1 * ppu
17866
18308
  fixedDomain: stacked ? this.stackSides.positive + this.stackSides.negative : undefined,
17867
18309
  relativeVariance: vt === VarianceType$1.RELATIVE,
17868
- maxPositive: (_a = highest === null || highest === void 0 ? void 0 : highest.value) !== null && _a !== void 0 ? _a : 0,
17869
- minNegative: (_b = smallest === null || smallest === void 0 ? void 0 : smallest.value) !== null && _b !== void 0 ? _b : 0,
18310
+ // a reference line right of the longest bar needs its room too
18311
+ maxPositive: Math.max((_a = highest === null || highest === void 0 ? void 0 : highest.value) !== null && _a !== void 0 ? _a : 0, !stacked && !isVariance ? ((_c = (_b = this.referenceLine) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : 0) : 0),
18312
+ minNegative: (_d = smallest === null || smallest === void 0 ? void 0 : smallest.value) !== null && _d !== void 0 ? _d : 0,
17870
18313
  });
17871
18314
  }
17872
18315
  /**
@@ -17900,6 +18343,8 @@ class StructureChart {
17900
18343
  return (this.position.getAxisEndPositionY() +
17901
18344
  this.position.spacings.labelToAxis +
17902
18345
  this.position.fontSize +
18346
+ // the 100% mark stands below the axis end
18347
+ (this.hasPercentMark() ? this.position.fontSize * 0.8 : 0) +
17903
18348
  this.styles.padding.bottom);
17904
18349
  }
17905
18350
  patternToString() {
@@ -17961,11 +18406,15 @@ class StructureChart {
17961
18406
  this.drawStackedScenarios(this.dataModel, svgContainer);
17962
18407
  this.drawStackedHeaders(this.dataModel, svgContainer);
17963
18408
  this.drawAxisAndLabels(this.dataModel, svgContainer, true);
18409
+ this.drawPercentMark(svgContainer);
17964
18410
  }
17965
18411
  else {
17966
18412
  this.drawScenarios(this.dataModel, svgContainer);
17967
18413
  this.drawAxisAndLabels(this.dataModel, svgContainer);
17968
18414
  }
18415
+ if (this.variancesDataModel.length === 0) {
18416
+ this.drawReferenceLine(svgContainer);
18417
+ }
17969
18418
  }
17970
18419
  setPattern(fc, fcPolygonPattern) {
17971
18420
  this.styles.pattern.set(fc, fcPolygonPattern);
@@ -18082,7 +18531,7 @@ class StructureChart {
18082
18531
  };
18083
18532
  return obj;
18084
18533
  }, {
18085
- id: 9999,
18534
+ id: REST_ROW_ID,
18086
18535
  category: "REST",
18087
18536
  type: VarianceType$1.NONE,
18088
18537
  scenario1: new DataPoint$1(NaN, selectedScenarios[0], this.pixelPerUnit, Scenario$1.NEU),
@@ -18269,7 +18718,7 @@ class StructureChart {
18269
18718
  // a 100 % stack prints no total
18270
18719
  const totalLabelRoom = (layout) => {
18271
18720
  var _a;
18272
- return ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) === StackMode.RELATIVE
18721
+ return ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) === StackMode.RELATIVE && this.stackConfig.labels !== "value"
18273
18722
  ? 0
18274
18723
  : (labelToBar + this.calculateTotalLabelWidth(layout.total)) / this.pixelPerUnit;
18275
18724
  };
@@ -18277,6 +18726,8 @@ class StructureChart {
18277
18726
  }
18278
18727
  /** Layouts of the stacks of a row that are drawn, back to front. */
18279
18728
  drawnStackLayouts(row) {
18729
+ if (this.isTextSum(row))
18730
+ return [];
18280
18731
  return this.stackGroups(row)
18281
18732
  .filter((group) => group.hasValue)
18282
18733
  .map((group) => group.layout);
@@ -18324,6 +18775,7 @@ class StructureChart {
18324
18775
  scenario2: new DataPoint$1(null, null, null, null),
18325
18776
  scenario3: new DataPoint$1(null, null, null, null),
18326
18777
  scenario4: new DataPoint$1(null, null, null, null),
18778
+ sum: dataModel[index].sum,
18327
18779
  });
18328
18780
  }
18329
18781
  }
@@ -18395,6 +18847,7 @@ class StructureChart {
18395
18847
  let isRelative = false;
18396
18848
  if (!this.hideCategories) {
18397
18849
  dataModel.forEach((elements, index) => {
18850
+ var _a;
18398
18851
  if (elements["type"] === VarianceType$1.RELATIVE) {
18399
18852
  isRelative = true;
18400
18853
  }
@@ -18416,9 +18869,23 @@ class StructureChart {
18416
18869
  new Label(axisLabelGroup, this.position.getCategoryPositionX(isPositive) + clearance, this.position.getBarCenterPositionY(index), "",
18417
18870
  // Category labels come from the data, but the synthetic "REST"
18418
18871
  // overflow bucket is engine-generated and translatable, as in bn-table.
18419
- this.i18n.get(elements.category) || elements.category, this.styles, HookLocation.Center, textHook).draw();
18872
+ this.i18n.get(elements.category) || elements.category, this.styles, HookLocation.Center, textHook)
18873
+ .setEmphasis(!!((_a = this.dataModel[index]) === null || _a === void 0 ? void 0 : _a.sum), this.isItalic(elements.category))
18874
+ .draw();
18420
18875
  });
18421
18876
  }
18877
+ // a thin line above a sum row, from the labels to the end of the row
18878
+ dataModel.forEach((_elements, index) => {
18879
+ const row = this.dataModel[index];
18880
+ if (!(row === null || row === void 0 ? void 0 : row.sum))
18881
+ return;
18882
+ const y = this.position.getBarCenterPositionY(index) - this.position.spacings.categoryWidth / 2;
18883
+ const left = this.hideCategories ? this.position.getAxisPositionX() : this.styles.padding.left;
18884
+ axisLabelGroup
18885
+ .line(left, y, this.position.getAxisPositionX() + this.sumRowExtent(row), y)
18886
+ .stroke({ color: "#000000", width: Math.max(0.5, this.position.spacings.axisLineWidth / 2) })
18887
+ .addClass("sum-line");
18888
+ });
18422
18889
  new Axis$1({
18423
18890
  scenarioType: this.axisScenario,
18424
18891
  labelText: this.title,
@@ -18427,20 +18894,60 @@ class StructureChart {
18427
18894
  }
18428
18895
  drawScenarios(dataModel, svgContainer) {
18429
18896
  const barsGroup = svgContainer.group().id("Scenarios");
18430
- const scenarioFactory = new ScenarioFactory$1(this.position, barsGroup, this.scenarioStyles(), dataModel.length, this.i18n);
18897
+ // the name of the scenario stands below the last bar, or above the first one
18898
+ let lastBar = -1;
18899
+ dataModel.forEach((row, index) => {
18900
+ if (!row.sum)
18901
+ lastBar = index;
18902
+ });
18903
+ const scenarioFactory = new ScenarioFactory$1(this.position, barsGroup, this.scenarioStyles(),
18904
+ // the factory names the last bar. The row layout leaves room for the name when a sum row follows.
18905
+ this.scenarioLabelTop ? 0 : lastBar + 1, this.i18n);
18431
18906
  scenarioFactory.setOverflowConfig(this.overflowConfig);
18432
18907
  dataModel.forEach((elements, index) => {
18908
+ if (elements.sum) {
18909
+ this.drawSumValue(elements, index, barsGroup);
18910
+ return;
18911
+ }
18433
18912
  scenarioFactory.createPrimaryBar(elements["scenario1"], index).draw(this.dataFormatDigits, this.measureScale);
18434
18913
  scenarioFactory.createSecondaryBar(elements["scenario2"], index).draw();
18435
18914
  scenarioFactory.createPrimaryMarker(elements["scenario3"], index).draw();
18436
18915
  scenarioFactory.createSecondaryMarker(elements["scenario4"], index).draw();
18437
18916
  });
18917
+ const first = dataModel.find((row) => !row.sum);
18918
+ if (this.scenarioLabelTop && first && !first.scenario1.isEmpty() && first.scenario1.scenario != null) {
18919
+ const scenario = first.scenario1.scenario;
18920
+ new Label(barsGroup,
18921
+ // from the axis on: the first bar can be shorter than the name
18922
+ this.position.getBarPositionX() + this.position.spacings.labelToAxis, this.position.getStackedHeaderPositionY(), "SCENARIO_HEADER", this.i18n.get(scenario) || scenario, this.styles, HookLocation.Bottom, HookLocation.Left).draw();
18923
+ }
18924
+ }
18925
+ /** The value of a sum row of a chart with plain bars or variances: a bold number at the axis, no bar. */
18926
+ drawSumValue(row, index, group) {
18927
+ const point = row.scenario1;
18928
+ if (point.isEmpty() || !Number.isFinite(point.value))
18929
+ return;
18930
+ const negative = point.value < 0;
18931
+ const label = new Label(group,
18932
+ // like the label of a bar without length: a negative number stands left of the axis
18933
+ this.position.getLabelPositionX(negative ? -1e-6 : 0), this.position.getBarCenterPositionY(index), "SUM_" + index, point.value, this.styles, HookLocation.Center, negative ? HookLocation.Right : HookLocation.Left)
18934
+ .setEmphasis(true, false)
18935
+ .setPoint(point.key);
18936
+ if (row.type === VarianceType$1.RELATIVE)
18937
+ label.setToRelativeVarianceLabel();
18938
+ else if (row.type === VarianceType$1.ABSOLUTE)
18939
+ label.setToVarianceLabel();
18940
+ label.draw(this.dataFormatDigits, this.measureScale);
18438
18941
  }
18439
18942
  drawVarianceScenario(dataModel, svgContainer) {
18440
18943
  const barsGroup = svgContainer.group().id("Scenarios");
18441
18944
  const scenarioFactory = new ScenarioFactory$1(this.position, barsGroup, this.scenarioStyles(), dataModel.length, this.i18n);
18442
18945
  scenarioFactory.setOverflowConfig(this.overflowConfig);
18443
18946
  dataModel.forEach((elements, index) => {
18947
+ if (elements.sum) {
18948
+ this.drawSumValue(elements, index, barsGroup);
18949
+ return;
18950
+ }
18444
18951
  if (elements["type"] === VarianceType$1.RELATIVE) {
18445
18952
  scenarioFactory.createRelativeVarianceBar(elements["scenario1"], index).draw(this.dataFormatDigits);
18446
18953
  }
@@ -18473,14 +18980,27 @@ class StructureChart {
18473
18980
  return;
18474
18981
  const stackGroup = svgContainer.group().id("StackedScenarios");
18475
18982
  const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
18983
+ const relative = this.stackConfig.mode === StackMode.RELATIVE;
18984
+ const valueLabels = relative && this.stackConfig.labels === "value";
18985
+ const label = valueLabels ? "value" : this.stackConfig.percentMark ? "plain-share" : "share";
18476
18986
  dataModel.forEach((elements, index) => {
18477
18987
  const groups = this.stackGroups(elements);
18988
+ if (this.isTextSum(elements)) {
18989
+ this.drawSumText(elements, index, stackGroup);
18990
+ return;
18991
+ }
18992
+ const options = {
18993
+ label,
18994
+ total: valueLabels,
18995
+ bold: !!elements.sum,
18996
+ italic: this.isItalic(elements.category),
18997
+ };
18478
18998
  groups.forEach((group, groupIdx) => {
18479
18999
  let lastBar = null;
18480
19000
  group.segments.forEach((seg, segIdx) => {
18481
19001
  const bar = new StackedBar(this.position, this.styles, seg.dataPoint, index, group.layout.segments[segIdx], seg.scenario,
18482
19002
  // overlay: one colour per group, back=lighter, front=darker
18483
- groups.length > 1 ? groups.length - 1 - groupIdx : segIdx, this.stackConfig.mode, group.layout, isScenarioStack, stackGroup);
19003
+ groups.length > 1 ? groups.length - 1 - groupIdx : segIdx, this.stackConfig.mode, group.layout, isScenarioStack, stackGroup, options);
18484
19004
  bar.draw(this.dataFormatDigits, this.measureScale);
18485
19005
  lastBar = bar;
18486
19006
  });
@@ -18498,9 +19018,10 @@ class StructureChart {
18498
19018
  * The headers take their place from the first row.
18499
19019
  */
18500
19020
  drawStackedHeaders(dataModel, svgContainer) {
19021
+ var _a;
18501
19022
  if (!this.stackConfig || dataModel.length === 0)
18502
19023
  return;
18503
- const firstRow = dataModel[0];
19024
+ const firstRow = (_a = dataModel.find((row) => !this.isTextSum(row))) !== null && _a !== void 0 ? _a : dataModel[0];
18504
19025
  // Dimension stacking without segments draws one plain bar: nothing to name
18505
19026
  if (this.stackConfig.by !== StackBy.SCENARIOS && (!firstRow.stackSegments || firstRow.stackSegments.length === 0)) {
18506
19027
  return;
@@ -18525,6 +19046,11 @@ class StructureChart {
18525
19046
  }
18526
19047
  // Single group: one header per segment, centered on the segment
18527
19048
  const [group] = groups;
19049
+ const totalDrawn = this.stackConfig.mode !== StackMode.RELATIVE || this.stackConfig.labels === "value";
19050
+ if (this.stackConfig.totalTitle && totalDrawn) {
19051
+ // above the total of the first bar, which starts behind the bar
19052
+ new Label(headerGroup, this.position.getLabelPositionX(group.layout.positive * this.pixelPerUnit), headerY, "STACK_TOTAL_HEADER", this.stackConfig.totalTitle, this.styles, HookLocation.Bottom, HookLocation.Left).draw();
19053
+ }
18528
19054
  group.segments.forEach((seg, segIdx) => {
18529
19055
  const { start, end } = group.layout.segments[segIdx];
18530
19056
  drawHeader(axisX + ((start + end) / 2) * seg.dataPoint.pixelPerUnit, this.i18n.get(seg.scenario) || seg.scenario);
@@ -18577,7 +19103,7 @@ class StructureChart {
18577
19103
  return width;
18578
19104
  }
18579
19105
  calculateRightSideWidth(varianceType) {
18580
- var _a, _b, _c;
19106
+ var _a, _b, _c, _d, _e, _f;
18581
19107
  // Stacked charts: width based on the positive side of the stacks, not individual max
18582
19108
  if (this.isStacked()) {
18583
19109
  const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
@@ -18589,28 +19115,42 @@ class StructureChart {
18589
19115
  this.position.getCategoryToAxisSpaceing() +
18590
19116
  this.calculateCategoryWidth());
18591
19117
  }
18592
- return Math.max(width, this.titleLength);
19118
+ if ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.totalTitle) {
19119
+ const title = CalculateSize(this.stackConfig.totalTitle, {
19120
+ font: this.styles.fontStyles.font,
19121
+ fontSize: this.styles.fontStyles.size + "px",
19122
+ }).width;
19123
+ width = Math.max(width, this.stackSides.positive * this.pixelPerUnit + labelToBar + title);
19124
+ }
19125
+ return Math.max(width, this.titleLength, (_c = (_b = this.sumColumns()) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 0, this.referenceLineExtent());
18593
19126
  }
18594
19127
  let width = 0;
18595
19128
  const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
18596
19129
  if (VarianceType$1.NONE === varianceType &&
18597
- ((_a = this.highestDataPointValue) === null || _a === void 0 ? void 0 : _a.value) != null &&
19130
+ ((_d = this.highestDataPointValue) === null || _d === void 0 ? void 0 : _d.value) != null &&
18598
19131
  this.highestDataPointValue.value >= 0) {
18599
19132
  const sizeLabelValue = this.calculateTextBoxWidth(this.highestDataPointValue.value);
18600
19133
  width = Math.abs(this.highestDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
18601
19134
  }
18602
19135
  else if (VarianceType$1.RELATIVE === varianceType &&
18603
- ((_b = this.highestVarianceDataPointValue) === null || _b === void 0 ? void 0 : _b.value) != null &&
19136
+ ((_e = this.highestVarianceDataPointValue) === null || _e === void 0 ? void 0 : _e.value) != null &&
18604
19137
  this.highestVarianceDataPointValue.value >= 0) {
18605
19138
  const sizeLabelValue = this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);
18606
19139
  width = Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit()) + labelToBar + sizeLabelValue;
18607
19140
  }
18608
19141
  else if (VarianceType$1.ABSOLUTE === varianceType &&
18609
- ((_c = this.highestVarianceDataPointValue) === null || _c === void 0 ? void 0 : _c.value) != null &&
19142
+ ((_f = this.highestVarianceDataPointValue) === null || _f === void 0 ? void 0 : _f.value) != null &&
18610
19143
  this.highestVarianceDataPointValue.value >= 0) {
18611
19144
  const sizeLabelValue = this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);
18612
19145
  width = Math.abs(this.highestVarianceDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
18613
19146
  }
19147
+ width = Math.max(width, this.referenceLineExtent());
19148
+ // the bold number of a sum row stands at the axis
19149
+ for (const row of this.dataModel) {
19150
+ if (row.sum && VarianceType$1.NONE === varianceType && Number.isFinite(row.scenario1.value)) {
19151
+ width = Math.max(width, this.sumRowExtent(row));
19152
+ }
19153
+ }
18614
19154
  if (width <= this.titleLength) {
18615
19155
  return this.titleLength;
18616
19156
  }
@@ -18621,6 +19161,7 @@ class StructureChart {
18621
19161
  * at the stack dimension level and attach stackSegments to each dataModel row.
18622
19162
  */
18623
19163
  populateDimensionStackSegments(scenarios, _stackConfig, level) {
19164
+ var _a;
18624
19165
  if (this.rowCount === 0 || !this.fromExpr || scenarios.length === 0)
18625
19166
  return;
18626
19167
  // Derive stack column from level: stack by the next-lower hierarchy dimension
@@ -18639,6 +19180,7 @@ class StructureChart {
18639
19180
  let result;
18640
19181
  try {
18641
19182
  result = this.db.exec(`SELECT [${displayColumn}] as displayGroup, [${stackColumn}] as stackLabel, ` +
19183
+ `MIN([${stackColumn}Index]) as stackIndex, ` +
18642
19184
  `SUM([${scenario}] * transformOperator(operation)) as stackValue ` +
18643
19185
  `FROM ${this.fromExpr} GROUP BY [${displayColumn}], [${stackColumn}]`);
18644
19186
  }
@@ -18646,19 +19188,46 @@ class StructureChart {
18646
19188
  this.failQuery(e);
18647
19189
  return;
18648
19190
  }
19191
+ // The series of the chart: by the index column of the stack dimension, else in the order of the rows
19192
+ const series = new Map();
19193
+ for (const row of result) {
19194
+ if (row.stackValue == null || row.stackLabel == null)
19195
+ continue;
19196
+ const label = row.stackLabel;
19197
+ const index = Number.isFinite(Number(row.stackIndex)) && row.stackIndex != null ? Number(row.stackIndex) : NaN;
19198
+ const known = series.get(label);
19199
+ if (known === undefined || (Number.isNaN(known) && !Number.isNaN(index)) || index < known) {
19200
+ series.set(label, index);
19201
+ }
19202
+ }
19203
+ const order = [...series.keys()];
19204
+ if ([...series.values()].every((index) => !Number.isNaN(index))) {
19205
+ order.sort((a, b) => series.get(a) - series.get(b));
19206
+ }
18649
19207
  // Group results by displayGroup
18650
19208
  const groupMap = new Map();
18651
19209
  for (const row of result) {
18652
19210
  const key = row.displayGroup;
18653
19211
  if (!groupMap.has(key))
18654
- groupMap.set(key, []);
19212
+ groupMap.set(key, new Map());
18655
19213
  if (row.stackValue != null && row.stackLabel != null) {
18656
- groupMap.get(key).push({ label: row.stackLabel, value: row.stackValue });
19214
+ groupMap.get(key).set(row.stackLabel, row.stackValue);
18657
19215
  }
18658
19216
  }
18659
- // Attach stackSegments to each dataModel row
19217
+ // the REST row stands for the rows the limit cut off: it gets their sum per series
19218
+ const shown = new Set(this.dataModel.map((row) => row.category));
19219
+ const rest = new Map();
19220
+ for (const [category, values] of groupMap) {
19221
+ if (shown.has(category))
19222
+ continue;
19223
+ for (const [label, value] of values) {
19224
+ rest.set(label, ((_a = rest.get(label)) !== null && _a !== void 0 ? _a : 0) + value);
19225
+ }
19226
+ }
19227
+ // Attach stackSegments to each dataModel row: every row has every series, so place and colour stay
18660
19228
  for (const row of this.dataModel) {
18661
- const segments = groupMap.get(row.category);
19229
+ const values = row.id === REST_ROW_ID && !groupMap.has(row.category) ? rest : groupMap.get(row.category);
19230
+ const segments = values && values.size > 0 ? order.map((label) => { var _a; return ({ label, value: (_a = values.get(label)) !== null && _a !== void 0 ? _a : NaN }); }) : undefined;
18662
19231
  if (segments && segments.length > 0) {
18663
19232
  row.stackSegments = segments.map((seg) => {
18664
19233
  const dataPoint = new DataPoint$1(seg.value, scenario, this.pixelPerUnit, Scenario$1.NEU);
@@ -18671,6 +19240,342 @@ class StructureChart {
18671
19240
  }
18672
19241
  }
18673
19242
  }
19243
+ /** A sum row that is printed as numbers: every stack but a 100 % stack, where it is a bar of shares. */
19244
+ isTextSum(row) {
19245
+ return !!row.sum && !!this.stackConfig && this.stackConfig.mode !== StackMode.RELATIVE;
19246
+ }
19247
+ isItalic(category) {
19248
+ return this.italicCategories.includes(category);
19249
+ }
19250
+ hasPercentMark() {
19251
+ var _a;
19252
+ return (!!((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.percentMark) &&
19253
+ this.stackConfig.mode === StackMode.RELATIVE &&
19254
+ this.variancesDataModel.length === 0 &&
19255
+ this.isStacked());
19256
+ }
19257
+ /**
19258
+ * Adds the sum rows: one below the rows of each `rowGroup`, which keeps the rows of a
19259
+ * group together, and one over all rows at the end.
19260
+ */
19261
+ addSumRows(scenarios) {
19262
+ if (this.sums === "none" || this.dataModel.length === 0)
19263
+ return;
19264
+ // a cell without a value is left out, and a sum over no value stays NaN
19265
+ const add = (sum, value) => Number.isFinite(value) ? (Number.isFinite(sum) ? sum : 0) + value : sum;
19266
+ const sumRow = (members, category, sum) => {
19267
+ var _a, _b;
19268
+ const point = (key, index) => new DataPoint$1(scenarios[index] === undefined
19269
+ ? undefined
19270
+ : members.reduce((total, row) => add(total, row[key].value), NaN), scenarios[index], this.pixelPerUnit, Scenario$1.NEU);
19271
+ const row = {
19272
+ id: 10000 + this.dataModel.length,
19273
+ category,
19274
+ type: VarianceType$1.NONE,
19275
+ scenario1: point("scenario1", 0),
19276
+ scenario2: point("scenario2", 1),
19277
+ scenario3: point("scenario3", 2),
19278
+ scenario4: point("scenario4", 3),
19279
+ sum,
19280
+ };
19281
+ if (members.some((member) => member.stackSegments)) {
19282
+ const values = new Map();
19283
+ for (const member of members) {
19284
+ for (const segment of (_a = member.stackSegments) !== null && _a !== void 0 ? _a : []) {
19285
+ values.set(segment.label, add((_b = values.get(segment.label)) !== null && _b !== void 0 ? _b : NaN, segment.value));
19286
+ }
19287
+ }
19288
+ row.stackSegments = [...values].map(([label, value]) => {
19289
+ const dataPoint = new DataPoint$1(value, scenarios[0], this.pixelPerUnit, Scenario$1.NEU);
19290
+ return { label, value, dataPoint };
19291
+ });
19292
+ }
19293
+ return row;
19294
+ };
19295
+ const rows = this.dataModel;
19296
+ const result = [];
19297
+ const groups = this.sums === "total" ? new Map() : this.rowGroups();
19298
+ if (groups.size > 0) {
19299
+ const names = [...new Set([...groups.values()].sort((a, b) => a.index - b.index).map((group) => group.name))];
19300
+ for (const name of names) {
19301
+ const members = rows.filter((row) => { var _a; return ((_a = groups.get(row.category)) === null || _a === void 0 ? void 0 : _a.name) === name; });
19302
+ if (members.length === 0)
19303
+ continue;
19304
+ const sum = sumRow(members, name, "group");
19305
+ sum.gapAfter = true;
19306
+ result.push(...members, sum);
19307
+ }
19308
+ // a row without a group, like REST, comes last
19309
+ result.push(...rows.filter((row) => !groups.has(row.category)));
19310
+ }
19311
+ else {
19312
+ result.push(...rows);
19313
+ }
19314
+ if (this.sums === "total" || this.sums === "all") {
19315
+ result.push(sumRow(rows, this.sumTitle || "SUM_TOTAL", "total"));
19316
+ }
19317
+ this.dataModel = result;
19318
+ }
19319
+ /** The `rowGroup` of each row of a chart at level `category`, with the place of the group. */
19320
+ rowGroups() {
19321
+ const groups = new Map();
19322
+ if (this.level !== AggregationLevel.CATEGORY && this.level !== AggregationLevel.CATEGORYINDEX)
19323
+ return groups;
19324
+ let result;
19325
+ try {
19326
+ result = this.db.exec(`SELECT [category] as category, [rowGroup] as rowGroup, MIN([rowGroupIndex]) as rowGroupIndex ` +
19327
+ `FROM ${this.fromExpr} GROUP BY [category], [rowGroup]`);
19328
+ }
19329
+ catch (e) {
19330
+ this.failQuery(e);
19331
+ return groups;
19332
+ }
19333
+ const first = new Map();
19334
+ result.forEach((row, position) => {
19335
+ var _a;
19336
+ if (row.rowGroup == null || row.rowGroup === "")
19337
+ return;
19338
+ const name = String(row.rowGroup);
19339
+ const given = Number(row.rowGroupIndex);
19340
+ // without an index column the groups keep the order of the rows
19341
+ const index = row.rowGroupIndex != null && Number.isFinite(given) ? given : ((_a = first.get(name)) !== null && _a !== void 0 ? _a : position);
19342
+ if (!first.has(name))
19343
+ first.set(name, index);
19344
+ groups.set(String(row.category), { name, index: Math.min(index, first.get(name)) });
19345
+ });
19346
+ return groups;
19347
+ }
19348
+ /** Rows of different height (`stack.thickness: total`) and the room below a group. Null: all rows are equal. */
19349
+ rowLayout() {
19350
+ var _a;
19351
+ const rows = this.dataModel;
19352
+ // the component does not set it together with variances: a variance bar has one thickness
19353
+ const byTotal = ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.thickness) === "total";
19354
+ // the name of the scenario stands below the last bar: it needs room when a sum row follows
19355
+ const lastBar = rows.reduce((last, row, index) => (row.sum ? last : index), -1);
19356
+ const nameBelow = !this.stackConfig && !this.scenarioLabelTop && lastBar >= 0 && lastBar < rows.length - 1;
19357
+ if (!byTotal && !nameBelow && !rows.some((row) => row.gapAfter))
19358
+ return null;
19359
+ const totals = rows.map((row) => {
19360
+ if (!byTotal || row.sum)
19361
+ return null;
19362
+ const groups = this.stackGroups(row);
19363
+ const front = groups[groups.length - 1];
19364
+ return front ? Math.abs(front.layout.total) : 0;
19365
+ });
19366
+ const weights = this.rowWeights(totals);
19367
+ const start = [];
19368
+ const weight = [];
19369
+ let at = 0;
19370
+ rows.forEach((row, index) => {
19371
+ const rowWeight = weights[index];
19372
+ start.push(at);
19373
+ weight.push(rowWeight);
19374
+ at +=
19375
+ rowWeight + (row.gapAfter && index < rows.length - 1 ? 0.5 : 0) + (nameBelow && index === lastBar ? 0.8 : 0);
19376
+ });
19377
+ return { start, weight, total: at };
19378
+ }
19379
+ /**
19380
+ * The height of each row in units of a normal row: by its total, with the same height
19381
+ * over all. A row is at least one line of text high, and the others give up that room.
19382
+ * Null stands for a row that keeps the normal height.
19383
+ */
19384
+ rowWeights(totals) {
19385
+ const minimum = Math.min(1, 1 / this.styles.scaleFactors.categoryWidth);
19386
+ const weights = totals.map((total) => (total === null ? 1 : 0));
19387
+ const open = new Set(totals.flatMap((total, index) => (total === null ? [] : [index])));
19388
+ let room = open.size;
19389
+ // a row below the minimum is set to it, then the rest is shared again
19390
+ for (;;) {
19391
+ const sum = [...open].reduce((all, index) => all + totals[index], 0);
19392
+ if (sum <= 0) {
19393
+ open.forEach((index) => (weights[index] = room / open.size));
19394
+ break;
19395
+ }
19396
+ const small = [...open].filter((index) => (totals[index] / sum) * room < minimum);
19397
+ if (small.length === 0 || small.length === open.size) {
19398
+ open.forEach((index) => (weights[index] = (totals[index] / sum) * room));
19399
+ break;
19400
+ }
19401
+ for (const index of small) {
19402
+ weights[index] = minimum;
19403
+ room -= minimum;
19404
+ open.delete(index);
19405
+ }
19406
+ }
19407
+ return weights;
19408
+ }
19409
+ boldWidth(text) {
19410
+ return CalculateSize(text, {
19411
+ font: this.styles.fontStyles.font,
19412
+ fontSize: this.styles.fontStyles.size + "px",
19413
+ fontWeight: "bold",
19414
+ }).width;
19415
+ }
19416
+ sumText(value) {
19417
+ const digits = this.dataFormatDigits.decimal;
19418
+ return Formatter.number(value, "decimal", digits, digits, this.measureScale.value, this.styles.locale);
19419
+ }
19420
+ /**
19421
+ * Where the numbers of the text sum rows stand, as distance from the axis: one column
19422
+ * per series, the same for all sum rows, then the total. Null without such a row.
19423
+ */
19424
+ sumColumns() {
19425
+ const rows = this.dataModel.filter((row) => this.isTextSum(row));
19426
+ if (rows.length === 0)
19427
+ return null;
19428
+ const font = this.styles.fontStyles.size;
19429
+ const key = font * 0.6;
19430
+ const keyGap = font * 0.3;
19431
+ const columnGap = font * 1.4;
19432
+ const widths = [];
19433
+ let totalWidth = 0;
19434
+ for (const row of rows) {
19435
+ const groups = this.stackGroups(row);
19436
+ const front = groups[groups.length - 1];
19437
+ if (!front)
19438
+ continue;
19439
+ front.segments.forEach((segment, index) => {
19440
+ var _a;
19441
+ const width = Number.isFinite(segment.value) ? this.boldWidth(this.sumText(segment.value)) : 0;
19442
+ widths[index] = Math.max((_a = widths[index]) !== null && _a !== void 0 ? _a : 0, width);
19443
+ });
19444
+ totalWidth = Math.max(totalWidth, this.boldWidth(this.sumText(front.layout.total)));
19445
+ }
19446
+ const x = [];
19447
+ let at = font * 0.3;
19448
+ // one series: its sum is the total
19449
+ for (const width of widths.length > 1 ? widths : []) {
19450
+ x.push(at);
19451
+ at += key + keyGap + width + columnGap;
19452
+ }
19453
+ return { x, totalX: at, width: at + totalWidth, key, keyGap };
19454
+ }
19455
+ /** A sum row of a stack as numbers: per series a small square in its colour and the sum, then the total. */
19456
+ drawSumText(row, index, group) {
19457
+ const columns = this.sumColumns();
19458
+ const groups = this.stackGroups(row);
19459
+ const front = groups[groups.length - 1];
19460
+ if (!columns || !front)
19461
+ return;
19462
+ const axisX = this.position.getBarPositionX();
19463
+ const y = this.position.getBarCenterPositionY(index);
19464
+ const colors = this.styles.stackColors;
19465
+ const sumGroup = group.group().id(`stacked_sum_${index}`);
19466
+ front.segments.forEach((segment, segmentIndex) => {
19467
+ if (!Number.isFinite(segment.value) || columns.x[segmentIndex] === undefined)
19468
+ return;
19469
+ const x = axisX + columns.x[segmentIndex];
19470
+ sumGroup
19471
+ .rect(columns.key, columns.key)
19472
+ .fill({ color: colors[segmentIndex % colors.length] })
19473
+ .cy(y)
19474
+ .x(x);
19475
+ new Label(sumGroup, x + columns.key + columns.keyGap, y, `SUM_SEG_${segmentIndex}`, segment.value, this.styles, HookLocation.Center, HookLocation.Left)
19476
+ .setEmphasis(true, false)
19477
+ .setPoint(segment.dataPoint.key)
19478
+ .draw(this.dataFormatDigits, this.measureScale);
19479
+ });
19480
+ new Label(sumGroup, axisX + columns.totalX, y, "SUM_TOTAL", front.layout.total, this.styles, HookLocation.Center, HookLocation.Left)
19481
+ .setEmphasis(true, false)
19482
+ .setPoint(levelKey(this.level, row.category), "total")
19483
+ .draw(this.dataFormatDigits, this.measureScale);
19484
+ }
19485
+ /** How far a sum row reaches right of the axis, in px. */
19486
+ sumRowExtent(row) {
19487
+ var _a, _b, _c;
19488
+ const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
19489
+ if (this.variancesDataModel.length > 0)
19490
+ return 0;
19491
+ if (this.isTextSum(row))
19492
+ return (_b = (_a = this.sumColumns()) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0;
19493
+ if (this.stackConfig) {
19494
+ const total = this.stackConfig.labels === "value" ? labelToBar + this.boldWidth(this.sumText((_c = row.scenario1.value) !== null && _c !== void 0 ? _c : 0)) : 0;
19495
+ return this.stackSides.positive * this.pixelPerUnit + total;
19496
+ }
19497
+ return Number.isFinite(row.scenario1.value)
19498
+ ? labelToBar + this.boldWidth(this.sumText(row.scenario1.value))
19499
+ : 0;
19500
+ }
19501
+ /** Where the reference line stands, as distance from the axis in px. Null without a line in this chart. */
19502
+ referenceLineOffset() {
19503
+ var _a;
19504
+ const line = this.referenceLine;
19505
+ if (!line || !Number.isFinite(line.value) || this.variancesDataModel.length > 0)
19506
+ return null;
19507
+ const relative = ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) === StackMode.RELATIVE;
19508
+ return (relative ? line.value / 100 : line.value) * this.pixelPerUnit;
19509
+ }
19510
+ /** The room right of the axis that the reference line and its label need. */
19511
+ referenceLineExtent() {
19512
+ var _a;
19513
+ const offset = this.referenceLineOffset();
19514
+ if (offset === null || offset <= 0)
19515
+ return 0;
19516
+ const label = ((_a = this.referenceLine) === null || _a === void 0 ? void 0 : _a.label)
19517
+ ? CalculateSize(this.referenceLine.label, {
19518
+ font: this.styles.fontStyles.font,
19519
+ fontSize: this.styles.fontStyles.size + "px",
19520
+ }).width
19521
+ : 0;
19522
+ return offset + Math.max(label / 2, this.styles.fontStyles.size * 0.25);
19523
+ }
19524
+ /** The end of a 100 % stack: a line along the bar ends and one `100%` below it. */
19525
+ drawPercentMark(svgContainer) {
19526
+ if (!this.hasPercentMark())
19527
+ return;
19528
+ const group = svgContainer.group().id("PercentMark");
19529
+ const font = this.styles.fontStyles.size;
19530
+ const x = this.position.getBarPositionX() + this.stackSides.positive * this.pixelPerUnit;
19531
+ const top = this.position.getAxisPositionY();
19532
+ const bottom = this.position.getAxisEndPositionY();
19533
+ const tip = bottom + font * 0.15;
19534
+ const base = tip + font * 0.5;
19535
+ group.line(x, top, x, bottom).stroke({ color: "#000000", width: this.position.spacings.axisLineWidth });
19536
+ group.polygon(`${x},${tip} ${x - font * 0.25},${base} ${x + font * 0.25},${base}`).fill("#000000");
19537
+ new Label(group, x, base + font * 0.1, "PERCENT_MARK", "100%", this.styles, HookLocation.Top, HookLocation.Center)
19538
+ .setEmphasis(true, false)
19539
+ .draw();
19540
+ }
19541
+ /** A line across the bars at one value, with its label above the first bar. In a 100 % stack the value is a percent. */
19542
+ drawReferenceLine(svgContainer) {
19543
+ const line = this.referenceLine;
19544
+ const offset = this.referenceLineOffset();
19545
+ if (!line || offset === null || this.dataModel.length === 0)
19546
+ return;
19547
+ const group = svgContainer.group().id("ReferenceLine");
19548
+ const font = this.styles.fontStyles.size;
19549
+ const color = `var(--bn-annotation-color, ${SYSTEM_STYLE_DEFAULTS["bn-annotation"].color})`;
19550
+ const x = this.position.getBarPositionX() + offset;
19551
+ const top = this.position.getStackedHeaderPositionY() - (this.stackConfig || this.scenarioLabelTop ? font * 1.1 : 0);
19552
+ // down to the last row from the top that reaches the line, or over all rows when the first one does not
19553
+ const reaches = (row) => {
19554
+ var _a, _b;
19555
+ if (row.sum)
19556
+ return false;
19557
+ if (!this.stackConfig)
19558
+ return ((_a = row.scenario1.value) !== null && _a !== void 0 ? _a : 0) >= line.value;
19559
+ const first = (_b = this.stackGroups(row)[0]) === null || _b === void 0 ? void 0 : _b.layout.segments[0];
19560
+ return first != null && first.end * this.pixelPerUnit >= x - this.position.getBarPositionX();
19561
+ };
19562
+ let lastBar = this.dataModel.findIndex((row) => !reaches(row)) - 1;
19563
+ if (lastBar < 0)
19564
+ lastBar = this.dataModel.reduce((last, row, index) => (row.sum ? last : index), 0);
19565
+ const bottom = this.position.getBarCenterPositionY(lastBar) + this.position.getBarWidthAt(lastBar) / 2;
19566
+ group
19567
+ .line(x, top, x, bottom)
19568
+ .attr("style", `stroke: ${color}; stroke-width: ${Math.max(1, this.position.spacings.axisLineWidth)}px`);
19569
+ group
19570
+ .polygon(`${x},${top + font * 0.5} ${x - font * 0.25},${top} ${x + font * 0.25},${top}`)
19571
+ .attr("style", `fill: ${color}`);
19572
+ if (line.label) {
19573
+ group
19574
+ .plain(line.label)
19575
+ .attr({ x, y: top - font * 0.3, "text-anchor": "middle" })
19576
+ .attr("style", `fill: ${color}`);
19577
+ }
19578
+ }
18674
19579
  hasNoData() {
18675
19580
  return this.dataModel.length === 0;
18676
19581
  }
@@ -18820,6 +19725,16 @@ const BnChartStructureRenderer = class {
18820
19725
  /** @internal */
18821
19726
  this.stackConfig = null;
18822
19727
  /** @internal */
19728
+ this.sums = "none";
19729
+ /** @internal */
19730
+ this.sumTitle = "";
19731
+ /** @internal */
19732
+ this.scenarioLabelTop = false;
19733
+ /** @internal */
19734
+ this.referenceLine = null;
19735
+ /** @internal */
19736
+ this.italicCategories = [];
19737
+ /** @internal */
18823
19738
  this.parentDimensions = { width: 0, height: 0 };
18824
19739
  withComponentStatus(this);
18825
19740
  }
@@ -19057,6 +19972,11 @@ const BnChartStructureRenderer = class {
19057
19972
  showMeasureScale: this.showMeasureScale,
19058
19973
  dataFormatDigits: this.dataFormatDigits,
19059
19974
  stackConfig: this.stackConfig,
19975
+ sums: this.sums,
19976
+ sumTitle: this.sumTitle,
19977
+ scenarioLabelTop: this.scenarioLabelTop,
19978
+ referenceLine: this.referenceLine,
19979
+ italicCategories: this.italicCategories,
19060
19980
  });
19061
19981
  }
19062
19982
  prepareStyle() {
@@ -25333,12 +26253,29 @@ const Context = class {
25333
26253
  constructor(hostRef) {
25334
26254
  registerInstance(this, hostRef);
25335
26255
  this.bnNotationChange = createEvent(this, "bnNotationChange", 7);
26256
+ /**
26257
+ * Group separator of every number in the document, in place of the one of
26258
+ * the locale: `thin-space`, `space`, `none`, or the separator itself. It
26259
+ * holds for the whole page, also for a context that does not set it.
26260
+ *
26261
+ * @default "" (the separator of the locale)
26262
+ * @example group-separator="thin-space"
26263
+ */
26264
+ this.groupSeparator = "";
26265
+ this.setsGroupSeparator = false;
25336
26266
  /** The page numbers this context wrote. A number that is not in here was set by the author and is left alone. */
25337
26267
  this.assignedPageNumbers = new WeakMap();
25338
26268
  this.notationSubscriptions = [];
25339
26269
  withComponentStatus(this);
25340
26270
  this.errors = withHasError(this);
25341
26271
  }
26272
+ setGroupSeparator(newValue) {
26273
+ var _a;
26274
+ const named = { "thin-space": "\u2009", space: "\u00a0", none: "" };
26275
+ // no value: the separator of the locale
26276
+ Formatter.groupSeparator = newValue ? ((_a = named[newValue]) !== null && _a !== void 0 ? _a : newValue) : null;
26277
+ this.setsGroupSeparator = !!newValue;
26278
+ }
25342
26279
  setLocale(newValue) {
25343
26280
  this.stores.context.state.locale = newValue;
25344
26281
  }
@@ -25350,6 +26287,9 @@ const Context = class {
25350
26287
  if (this.locale) {
25351
26288
  this.stores.context.state.locale = this.locale;
25352
26289
  }
26290
+ if (this.groupSeparator) {
26291
+ this.setGroupSeparator(this.groupSeparator);
26292
+ }
25353
26293
  // a removed scaling group is a "set" too: its entry is set to undefined
25354
26294
  const notify = () => this.bnNotationChange.emit();
25355
26295
  this.notationSubscriptions = [
@@ -25368,6 +26308,11 @@ const Context = class {
25368
26308
  }
25369
26309
  disconnectedCallback() {
25370
26310
  var _a, _b;
26311
+ // only the context that set it takes it back
26312
+ if (this.setsGroupSeparator) {
26313
+ Formatter.groupSeparator = null;
26314
+ this.setsGroupSeparator = false;
26315
+ }
25371
26316
  this.notationSubscriptions.forEach((unsubscribe) => unsubscribe());
25372
26317
  this.notationSubscriptions = [];
25373
26318
  (_a = this.pageObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
@@ -25520,10 +26465,13 @@ const Context = class {
25520
26465
  componentWillUpdate() { }
25521
26466
  componentDidUpdate() { }
25522
26467
  render() {
25523
- return (h(Host, { key: 'e2c985d07c329d796c37804f492907f0f49366d2' }, h("slot", { key: '90c11954a1a9365bc46ddacb2a3b8f72bbc4e523' })));
26468
+ return (h(Host, { key: '71bdc7dcbcadcae35b67f4d3fbb47e8ee204b3bb' }, h("slot", { key: 'c2fb4c85cb1a3b3af6ec013d0e558c0ef611358d' })));
25524
26469
  }
25525
26470
  get element() { return getElement(this); }
25526
26471
  static get watchers() { return {
26472
+ "groupSeparator": [{
26473
+ "setGroupSeparator": 0
26474
+ }],
25527
26475
  "locale": [{
25528
26476
  "setLocale": 0
25529
26477
  }]
@@ -27017,6 +27965,16 @@ const LayoutCard = class {
27017
27965
  * card-custom-template='"a a" "b c"'></bn-layout-card>
27018
27966
  */
27019
27967
  this.cardCustomTemplate = '"a b" "c d"';
27968
+ /**
27969
+ * Puts the child after the last slot of the template on top of the grid,
27970
+ * in the cells this CSS `grid-area` names by line numbers:
27971
+ * `row-start / column-start / row-end / column-end`. Use it for a text or a
27972
+ * comment list in the free part of a chart.
27973
+ *
27974
+ * @default "" (no overlay)
27975
+ * @example card-overlay-area="4 / 3 / 7 / 5"
27976
+ */
27977
+ this.cardOverlayArea = "";
27020
27978
  /**
27021
27979
  * Gap between grid cells in pixels.
27022
27980
  */
@@ -27097,7 +28055,20 @@ const LayoutCard = class {
27097
28055
  const items = this.createDivAreaStyles(slotNames);
27098
28056
  return (h(Fragment$1, null, items.map((value, index) => {
27099
28057
  return (h("div", { style: value }, h("slot", { name: "card-slot-" + index })));
27100
- })));
28058
+ }), this.overlayArea() ? (h("div", { style: { display: "flex", overflow: "hidden", "grid-area": this.overlayArea(), "z-index": "1" } }, h("slot", { name: "card-slot-" + items.length }))) : null));
28059
+ }
28060
+ /** The overlay area when it is four line numbers inside the grid of the layout, else nothing. */
28061
+ overlayArea() {
28062
+ var _a, _b;
28063
+ const area = ((_a = this.cardOverlayArea) !== null && _a !== void 0 ? _a : "").trim();
28064
+ if (!/^\d+(\s*\/\s*\d+){3}$/.test(area))
28065
+ return undefined;
28066
+ const [rowStart, columnStart, rowEnd, columnEnd] = area.split("/").map((line) => Number(line.trim()));
28067
+ const rows = this.getRowCount(this.cardLayout);
28068
+ const columns = ((_b = templateRows(this.getTemplatePattern(this.cardLayout))[0]) === null || _b === void 0 ? void 0 : _b.length) || 1;
28069
+ // a line outside the template would add rows or columns to the grid
28070
+ const inside = rowStart >= 1 && columnStart >= 1 && rowEnd <= rows + 1 && columnEnd <= columns + 1;
28071
+ return inside && rowStart < rowEnd && columnStart < columnEnd ? area : undefined;
27101
28072
  }
27102
28073
  extractSlotNames(styleElement) {
27103
28074
  return templateSlotNames(styleElement);
@@ -27106,6 +28077,7 @@ const LayoutCard = class {
27106
28077
  return templateAreas(name, this.cardCustomTemplate);
27107
28078
  }
27108
28079
  componentWillRender() {
28080
+ var _a;
27109
28081
  const problem = this.cardLayout === CUSTOM_TEMPLATE ? templateProblem(this.cardCustomTemplate) : undefined;
27110
28082
  if (problem) {
27111
28083
  this.errors.addOrReplace({
@@ -27117,6 +28089,16 @@ const LayoutCard = class {
27117
28089
  else {
27118
28090
  this.errors.remove("WARN_cardCustomTemplate");
27119
28091
  }
28092
+ if (((_a = this.cardOverlayArea) !== null && _a !== void 0 ? _a : "").trim() !== "" && !this.overlayArea()) {
28093
+ this.errors.addOrReplace({
28094
+ id: "WARN_cardOverlayArea",
28095
+ type: "warning",
28096
+ message: `cardOverlayArea: '${this.cardOverlayArea}' is not 'row-start / column-start / row-end / column-end' in line numbers of the layout.`,
28097
+ });
28098
+ }
28099
+ else {
28100
+ this.errors.remove("WARN_cardOverlayArea");
28101
+ }
27120
28102
  }
27121
28103
  setCardClass() {
27122
28104
  if (this.cardShowBorder === true) {
@@ -27143,7 +28125,7 @@ const LayoutCard = class {
27143
28125
  var _a;
27144
28126
  const style = this.getLayoutStyle();
27145
28127
  const arrOfSlots = this.extractSlotNames(style["grid-template-areas"]);
27146
- return (h("bn-card", { key: '3db479047905de01ac517491f2d68a9bd0a3a576', styles: this.styles, "selected-style": this.selectedStyle, class: this.setCardClass() }, h("div", { key: 'fd9948acd84ce55badf87a7e03d733d1e75a1bea', class: "cardtitle" }, h("bn-title", { key: '21200c96fb03d403fa616b093d753ea4b746c6f2', "i18n-namespace": (_a = this.i18nNamespace) !== null && _a !== void 0 ? _a : this.titleNamespace, ruleset: this.titleProp("ruleset"), "title-font-size": this.componentStyle(($) => { var _a; return (_a = $ === null || $ === void 0 ? void 0 : $["bn-layout-card"]) === null || _a === void 0 ? void 0 : _a.titleFontSize; }), "business-unit": this.titleBusinessUnit, scenarios: this.titleProp("titleScenarios"), variances: this.titleProp("titleVariances"), order: this.titleProp("titleOrder"), "order-direction": this.titleProp("titleOrderDirection"), measures: this.titleMeasures, "date-start": this.titleDateStart, "date-end": this.titleDateEnd, "date-format": this.titleDateFormat, "date-link": this.titleDateLink }), this.titleImage != null && this.titleImage !== "" ? (h("img", { class: "image", src: this.prepareTitleImage(this.titleImage) })) : ("")), h("bn-body", { key: 'c5b1957822ff216d33084154afdf6deb3e4426cc' }, h("div", { key: 'bc17f6f73825894641f775137eaefd5059a25cf6', style: style, "data-bn-fit-content": this.cardFitToContent ? String(this.getRowCount(this.cardLayout)) : null }, this.getSlots(arrOfSlots))), h("bn-footer", { key: 'cfbeba76eaf11358e92002d309cafae19d2525e2', text: this.footerText, "page-number": "0", "display-page-number": "false" })));
28128
+ return (h("bn-card", { key: 'ef0b6da39a573f162c096c21803e4d647b2817c2', styles: this.styles, "selected-style": this.selectedStyle, class: this.setCardClass() }, h("div", { key: '9116df8c88198ebc922dc91d5f45a032a81d37d1', class: "cardtitle" }, h("bn-title", { key: '6d9645d5229c3bf32ef944c1f296a55dbe4b3bee', "i18n-namespace": (_a = this.i18nNamespace) !== null && _a !== void 0 ? _a : this.titleNamespace, ruleset: this.titleProp("ruleset"), "title-font-size": this.componentStyle(($) => { var _a; return (_a = $ === null || $ === void 0 ? void 0 : $["bn-layout-card"]) === null || _a === void 0 ? void 0 : _a.titleFontSize; }), "business-unit": this.titleBusinessUnit, scenarios: this.titleProp("titleScenarios"), variances: this.titleProp("titleVariances"), order: this.titleProp("titleOrder"), "order-direction": this.titleProp("titleOrderDirection"), measures: this.titleMeasures, "date-start": this.titleDateStart, "date-end": this.titleDateEnd, "date-format": this.titleDateFormat, "date-link": this.titleDateLink }), this.titleImage != null && this.titleImage !== "" ? (h("img", { class: "image", src: this.prepareTitleImage(this.titleImage) })) : ("")), h("bn-body", { key: '65803497adad305f02874acf441867e9ba200945' }, h("div", { key: '61a57b87b0ffb76c238b2e2facb7d5b855d5dc10', style: style, "data-bn-fit-content": this.cardFitToContent ? String(this.getRowCount(this.cardLayout)) : null }, this.getSlots(arrOfSlots))), h("bn-footer", { key: '8589da921d0f8dac8e9a2af23315ded3a3ee3d51', text: this.footerText, "page-number": "0", "display-page-number": "false" })));
27147
28129
  }
27148
28130
  get element() { return getElement(this); }
27149
28131
  };