@bino-bi/bn-template-engine 1.0.0-next.57 → 1.0.0-next.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/{p-e7b13801.entry.js → p-bc538e7d.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +40 -13
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +40 -13
- package/dist/components/bn-chart-structure-renderer.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/{p-DFkSF8_m.js → p-Q6JHDy4s.js} +1 -1
- package/dist/esm/bn-annotation-layer_30.entry.js +40 -13
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as i,h as s,d as h,t as e}from"./p-BnmylmXF.js";import{S as n,F as r,a as o,P as a}from"./p-CSJCkHEL.js";import{C as l,A as c,g as u,e as d}from"./p-DguYWLBj.js";import{D as f,b as v}from"./p-keKnrAVS.js";import{c as p,O as m,a as b}from"./p-BBdzTx8V.js";import{S as g}from"./p-CeE4_3wQ.js";import{r as w,F as S,C as P,V as y}from"./p-Zz3fAPcH.js";import{g as x,a as L,I as M}from"./p-4q8nRcWC.js";import{d as k,l as T,S as N}from"./p-DHX92KDP.js";import{N as C,r as $}from"./p-fCjsrD7I.js";import{s as O,c as A,a as E,l as _,b as R,d as W,M as B}from"./p-BTnRaHPb.js";import{I as D,a as j,s as X}from"./p-D0v9GMIf.js";import{d as G,S as V,g as Y}from"./p-5LbdDgZ5.js";import{e as z,r as H}from"./p-ClruFZD_.js";import{S as F}from"./p-Do-IGHJk.js";import{w as U}from"./p-BrQCbmG0.js";import{S as I}from"./p-CJ0-xdfZ.js";import{A as K}from"./p-DsC0ew4j.js";class Z{constructor(t,i,s,h,e,n,r,o,a=!1,l=null){this.categoryPosition={x:0,y:0},this.spacings={scenarioOffset:0,markerOffset:0,scenarioLabelToBar:0,labelToBar:0,labelToAxis:0,needleWidth:0,needleHeadWidth:0,barWidth:0,varianceAxisLineWidth:0,axisLineWidth:0,auxiliaryLineWidth:0,scenarioLineWidth:0,markerWidth:0,categoryWidth:0,axisTickLength:0},this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontSize=s,this.axisPosition={x:0,y:0},this.numberOfColumns=h,this.leftSideLengthSync=e,this.topSideLabelHeight=n>0?this.fontSize:0,this.hasStackedHeaders=a,this.rows=l,this.leftSideLabelLength=this.calculateSideLabelLength(n,r,o),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){if(this.rows&&t<this.rows.start.length){const i=this.rows.start[t]+this.rows.weight[t]/2;return this.getAxisPositionY()+this.spacings.scenarioOffset+i*this.spacings.categoryWidth}return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}isNameBelowBar(){var t;return!!(null===(t=this.rows)||void 0===t?void 0:t.nameBelowBar)}getRowTopPositionY(t){const i=this.rows&&t<this.rows.start.length?this.rows.start[t]:t;return this.getAxisPositionY()+this.spacings.scenarioOffset+i*this.spacings.categoryWidth}getBarWidthAt(t){return this.spacings.barWidth*(this.rows&&t<this.rows.weight.length?this.rows.weight[t]:1)}getBarPositionY(t,i){return i?this.getBarCenterPositionY(t):this.getBarCenterPositionY(t)-this.spacings.scenarioOffset}getCategoryPositionX(t){let i=this.spacings.labelToAxis;return t&&(i=-this.spacings.labelToAxis),this.getAxisPositionX()+i}getAxisTitlePositionX(){return this.axisPosition.x}getAxisTitlePositionY(){return this.axisPosition.y-this.spacings.labelToAxis-this.getTopLabelOverhang()}getStackedHeaderPositionY(){return this.getBarCenterPositionY(0)-.5*this.getBarWidthAt(0)-this.spacings.scenarioLabelToBar}getNeedleWidth(){return this.spacings.needleWidth}getAxisPositionX(){return this.leftSideLabelLength+this.padding.left+this.spacings.labelToAxis}getAxisPositionY(){return this.padding.top+this.getAxisTitleOffset()}loadCategoriesBox(t){this.categoriesBoxOffset=t,this.calculateAxisPosition()}addOffsetByNegativeDataPoints(t,i,s,h){null!=t&&null!=t.value&&t.value<0&&(s&&t.isClipped()?this.axisPosition.x+=Math.abs(t.getClippedValue()*t.pixelPerUnit):this.axisPosition.x+=Math.abs(t.value*t.pixelPerUnit),this.axisPosition.x+=i,this.axisPosition.x+=this.spacings.labelToBar),this.axisPosition.x<h/2&&(this.axisPosition.x=h/2+this.spacings.labelToBar)}getLabelPositionX(t){let i=this.spacings.labelToBar;return t<0&&(i*=-1),this.axisPosition.x+t+i}getLabelPositionY(t){return this.axisPosition.y+t+this.spacings.labelToBar}getCategoryToAxisSpaceing(){return this.spacings.labelToAxis}getCategoryToTopSpaceing(){return this.spacings.scenarioOffset}getCategoryToBottomSpaceing(){return this.spacings.scenarioOffset}getAxisEndPositionY(){const t=this.rows?this.rows.total:this.numberOfColumns;return this.getAxisPositionY()+(t+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){var i;if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return(null===(i=this.rows)||void 0===i?void 0:i.nameBelowBar)?t:Math.max(t,this.spacings.categoryWidth-this.spacings.scenarioOffset+this.spacings.labelToAxis)}return-(.5*this.getBarWidth()+this.spacings.scenarioLabelToBar)}getBarWidth(){return this.spacings.barWidth}getMarkerPositionY(t,i){return i?this.getBarCenterPositionY(t)-this.spacings.markerOffset-.5*this.getBarWidth():this.getBarCenterPositionY(t)+this.spacings.markerOffset+.5*this.getBarWidth()}getMarkerPositionX(){return this.getBarPositionX()}getMarkerScenarioLabelPositionOffsetY(t){return t?-(.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar):this.spacings.scenarioLabelToBar+.5*this.spacings.markerWidth}getAxisEndPositionX(){return this.getAxisPositionX()}calculateSpacings(){this.spacings={scenarioOffset:this.fontSize*this.scaleFactors.scenarioOffset,markerOffset:this.fontSize*this.scaleFactors.markerOffset,scenarioLabelToBar:this.fontSize*this.scaleFactors.scenarioLabelToBar,labelToBar:this.fontSize*this.scaleFactors.labelToBar,labelToAxis:this.fontSize*this.scaleFactors.labelToAxis,needleWidth:this.fontSize*this.scaleFactors.needleWidth,needleHeadWidth:this.fontSize*this.scaleFactors.needleHeadWidth,barWidth:this.fontSize*this.scaleFactors.barWidth,varianceAxisLineWidth:this.fontSize*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontSize*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontSize*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontSize*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontSize*this.scaleFactors.markerWidth,categoryWidth:this.fontSize*this.scaleFactors.categoryWidth,axisTickLength:this.fontSize*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left,y:this.getAxisPositionY()+.5*this.spacings.categoryWidth}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY()}}recalculatePositions(){this.calculateCategoryPosition(),this.calculateAxisPosition()}getAxisTitleOffset(){return this.topSideLabelHeight+this.spacings.labelToAxis+this.getTopLabelOverhang()}getTopLabelOverhang(){return this.hasStackedHeaders?this.getStackedHeaderOverhang():this.getTopScenarioLabelOverhang()}getStackedHeaderOverhang(){return Math.max(0,this.fontSize+this.spacings.scenarioLabelToBar+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}getTopScenarioLabelOverhang(){return Math.max(0,this.fontSize+.5*this.spacings.barWidth+this.spacings.scenarioLabelToBar-.5*this.spacings.categoryWidth,this.fontSize+.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar+this.spacings.markerOffset+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}calculateSideLabelLength(t,i,s){if(this.leftSideLengthSync)return this.leftSideLengthSync;const h=t/2;let e=i;return h>e&&(e=h),s>e&&(e=s),e}}class Q{constructor(t){this.top=t.top,this.bottom=t.bottom,this.left=t.left,this.right=t.right}addBoxTopLeft(t){return this.top+=t.height|this.top,this.left+=t.width|this.top,this}}class q{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t}}class J{constructor(t){this.container=new n,this.pattern=this.createFCPattern(this.container.group(),t),this.styles=t;let i=10;null!=t&&null!=t.fontStyles&&t.fontStyles.size&&(i=t.fontStyles.size),this.bgOffset=(1*i-.7*i)/2}createFCPattern(t,i){const s=i;return t.pattern(10,10,(function(t){t.rect(10,10).fill(s.barStyles.fc.fill),t.line(0,5,5,0).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"}),t.line(5,10,10,5).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"})})).id("pattern-structure-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}var tt,it,st,ht,et;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(tt||(tt={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(it||(it={}));class nt{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.sortOrder=new p(new F).default(),this.level=c.CATEGORY,this.filter="",this.measureScale=new g,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[]}}class rt{constructor(t,i,s,h,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=h,this.db=e,this.fromExpr=n,this.onQueryError=r}adapt(t){const i=K.adaptArray(t.data,this.dataRowAdapter),s=K.adaptArray(t.scenarios,this.stringAdapter),h=new nt(i,s);return l.isArray(t.variances)&&(h.variances=K.adaptArray(t.variances,this.stringAdapter)),l.isString(t.title)&&(h.title=t.title),l.isBoolean(t.hideCategories)&&(h.hideCategories=t.hideCategories),l.isNumber(t.pixelPerUnit)&&(h.pixelPerUnit=t.pixelPerUnit),l.isNumber(t.pixelPerPercentage)&&(h.pixelPerPercentage=t.pixelPerPercentage),l.isNumber(t.limit)&&(h.limit=t.limit),l.isExisting(t.sortOrder)&&(h.sortOrder=this.orderAdapter.adapt(t.sortOrder)),l.isExisting(t.level)&&(h.level=t.level),l.isString(t.filter)&&(h.filter=t.filter.trim()),l.isExisting(t.measureScale)&&(h.measureScale=f.calculateMeasureScale(this.db,this.fromExpr,h.scenarios,t.measureScale,this.onQueryError)),l.isString(t.measureUnit)&&(h.measureUnit=t.measureUnit),l.isBoolean(t.showMeasureScale)&&(h.showMeasureScale=t.showMeasureScale),l.isExisting(t.dataFormatDigits)&&(h.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),l.isExisting(t.stackConfig)&&(h.stackConfig=t.stackConfig),l.isString(t.sums)&&["groups","total","all"].includes(t.sums)&&(h.sums=t.sums),l.isString(t.sumTitle)&&(h.sumTitle=t.sumTitle),l.isString(t.valueSuffix)&&(h.valueSuffix=t.valueSuffix),l.isBoolean(t.scenarioLabelTop)&&(h.scenarioLabelTop=t.scenarioLabelTop),l.isBoolean(t.hideScenarioName)&&(h.hideScenarioName=t.hideScenarioName),l.isExisting(t.referenceLine)&&(h.referenceLine=t.referenceLine),l.isArray(t.italicCategories)&&(h.italicCategories=K.adaptArray(t.italicCategories,this.stringAdapter)),h}default(){return new nt([],[])}}class ot{constructor(t,i,s,h){this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const e="string"==typeof h?w(h,null,!0):h;this.variance="neg"===e||e===st.NEG?st.NEG:"pos"===e||e===st.POS?st.POS:st.NEU}isEmpty(){return null==this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:Math.abs(this.value)>1.45?this.value>=0?1.45*this.pixelPerUnit:-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:st.NEU===this.variance?st.NEU:st.POS===this.variance?st.NEG:st.POS}isClipped(){return null!=this.value&&Math.abs(this.value)>1.45}getClippedValue(){return 145}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class at{constructor(){this.operation="+"}addRowGroup(t,i){this.rowGroup=t,this.rowGroupIndex=i}addCategory(t,i){this.category=t,this.categoryIndex=i}addSubCategory(t,i){this.subCategory=t,this.subCategoryIndex=i}addColumnGroup(t,i){this.columnGroup=t,this.columnGroupIndex=i}addSubColumnGroup(t,i){this.columnSubGroup=t,this.columnSubGroupIndex=i}}class lt{constructor(){}adapt(t){const i=new at;return l.isOperator(t.operation)&&(i.operation=t.operation),l.isNumber(t.rowGroupIndex)&&l.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),l.isNumber(t.categoryIndex)&&l.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),l.isNumber(t.subCategoryIndex)&&l.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),l.isNumber(t.columnGroupIndex)&&l.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),l.isNumber(t.columnSubGroupIndex)&&l.isString(t.columnSubGroup)&&i.addSubColumnGroup(t.columnSubGroup,t.columnSubGroupIndex),this.setActualValues(t,i),this.setPlanValues(t,i),this.setPreviousPeriodValues(t,i),this.setForecastValues(t,i),i}default(){return new at}setActualValues(t,i){l.isNumber(t.ac1)&&(i.ac1=t.ac1),l.isNumber(t.ac2)&&(i.ac2=t.ac2),l.isNumber(t.ac3)&&(i.ac3=t.ac3),l.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){l.isNumber(t.pl1)&&(i.pl1=t.pl1),l.isNumber(t.pl2)&&(i.pl2=t.pl2),l.isNumber(t.pl3)&&(i.pl3=t.pl3),l.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){l.isNumber(t.pp1)&&(i.pp1=t.pp1),l.isNumber(t.pp2)&&(i.pp2=t.pp2),l.isNumber(t.pp3)&&(i.pp3=t.pp3),l.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){l.isNumber(t.fc1)&&(i.fc1=t.fc1),l.isNumber(t.fc2)&&(i.fc2=t.fc2),l.isNumber(t.fc3)&&(i.fc3=t.fc3),l.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class ct{constructor(t,i,s,h,e,n){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=h,this.varianceStyles=e,this.padding=n,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"],this.titleBold=!1,this.valueSuffix="",this.locale="de"}}class ut{constructor(t,i,s,h,e){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=h,this.paddingadapter=e}adapt(t){const i=new ct(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return l.isExisting(t)&&(l.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),l.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),l.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),l.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),l.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),l.isExisting(t.padding)&&(i.padding=this.paddingadapter.adapt(t.padding)),Array.isArray(t.stackColors)&&t.stackColors.length>0&&(i.stackColors=t.stackColors),i.titleBold=!0===t.titleBold,i.pattern=new q(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new ct(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class dt{constructor(){this.scenarioOffset=.3,this.scenarioLabelToBar=.1,this.labelToBar=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.barWidth=1.2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=1.9,this.axisTickLength=.3}}class ft{adapt(t){const i=new dt;return l.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),l.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),l.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),l.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),l.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),l.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),l.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),l.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),l.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),l.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),l.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),l.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),l.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),l.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),l.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new dt}}!function(t){t.AC1="ac1",t.PP1="pp1",t.FC1="fc1",t.PL1="pl1",t.AC2="ac2",t.PP2="pp2",t.FC2="fc2",t.PL2="pl2",t.AC3="ac3",t.PP3="pp3",t.FC3="fc3",t.PL3="pl3",t.AC4="ac4",t.PP4="pp4",t.FC4="fc4",t.PL4="pl4",t.POS="pos",t.NEG="neg",t.NEU="neu"}(st||(st={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(ht||(ht={})),function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right",t[t.Top=3]="Top",t[t.Bottom=4]="Bottom"}(et||(et={}));class vt{constructor(t,i,s,h,e,n,r,o){this.group=null,this.segmentFillColor=null,this.maxWidth=null,this.bold=!1,this.italic=!1,this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.pointPart="label",this.x=i,this.y=s,this.value=e,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),h))),this.styles=n,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=r||et.Top,this.horizontalHookLocation=o||et.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setEmphasis(t,i){return this.bold=t,this.italic=i,this}setMaxWidth(t){return this.maxWidth=t,this}setPoint(t,i="label"){return this.pointKey=t,this.pointPart=i,this}updateGroup(t){return this.group=t,this}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}draw(t={percent:2,decimal:1},i=new g){var s,h,e,n;if(this.isEmpty())return this;const r=this.group;let o;const a=this.styles.fontStyles.background||"#ffffff";let l="";if(!1===Number.isNaN(Number(this.value))){let h=t.percent,e=t.percent,n=1,r="percent";!1===this.isRelativeLabel&&(h=t.decimal,e=t.decimal,n=i.value,r="decimal"),o=S.number(Number(this.value),r,h,e,n,this.styles.locale);const a=S.number(0,r,h,e,n,this.styles.locale);this.isVarianceLabel&&Number(this.value)>0&&o!==a&&(l="+"),"number"!=typeof this.value||this.isVarianceLabel||this.isRelativeLabel||(o+=null!==(s=this.styles.valueSuffix)&&void 0!==s?s:"")}else o=""+this.value;const c=r.text(l+o);(null===(h=this.styles.fontStyles)||void 0===h?void 0:h.size)&&c.attr("font-size",this.styles.fontStyles.size),(null===(e=this.styles.fontStyles)||void 0===e?void 0:e.family)&&c.attr("font-family",this.styles.fontStyles.family),this.bold&&c.font({weight:"bold"}),this.italic&&c.font({style:"italic"}),c.move(this.x,this.y);const u=c.bbox(),d=u.w,f=u.h;if(null!=this.maxWidth&&d>this.maxWidth)return null===(n=this.group)||void 0===n||n.remove(),this.group=null,this;let v="start";return this.horizontalHookLocation===et.Right?(v="end",c.move(c.x()-c.length(),c.y())):this.horizontalHookLocation===et.Center&&(v="middle",c.move(c.x()-c.length()/2,c.y())),this.verticalHookLocation===et.Center?c.move(c.x(),c.y()-f/2):this.verticalHookLocation===et.Bottom&&c.move(c.x(),c.y()-f),c.font({anchor:v}),null!=this.segmentFillColor?c.fill(x(this.segmentFillColor)):null==r||r.rect(d,.9*f).stroke(a).fill(a).opacity(.7).move(c.x(),c.y()+.1*f).insertBefore(c),this.pointKey&&(null==r||r.attr(k(this.pointKey,this.pointPart))),this}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}class pt{constructor(t,i,s,h){this.height=0,this.ID_AXIS="axis",this.ID_AXIS_TITLE="axis-title",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.position=i,this.style=h,this.label=new vt(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,et.Bottom,et.Center).setEmphasis(this.style.titleBold,!1),this.svgGroup=s.group().id(this.ID_AXIS)}draw(){return this.labelText&&this.label.draw(),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(),this.position.getAxisEndPositionX(),this.position.getAxisEndPositionY()).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this.height=this.svgGroup.height(),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class mt{constructor(t,i,s,h,e,n,r,o=null){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.barGroup=null,this.isVarianceBar=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveWidth=0,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.isPrimaryBar=e,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=n,this.styles=i,null!=n&&(this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=et.Left;s.value<0&&(i=et.Right),this.dimensions=this.createDimensions(t,s,h,e),this.label=new vt(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,et.Center,i).setPoint(s.key),this.scenarioLabel=this.getScenarioLabel(r)}}setAsVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}isRelativeVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToRelativeVarianceLabel(),this}emphasize(){var t;return null===(t=this.label)||void 0===t||t.setEmphasis(!0,!1),this}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new g){var s,h,e;if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let n=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(n=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const r=this.convertToSVGStyle(n,"stroke");let o=this.convertToSVGStyle(n,"fill");const a=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=a){const t=this.styles.pattern.get(a);null!=t&&(o=t.pattern)}null===(s=this.scenarioGroup)||void 0===s||s.attr(k(this.dataPoint.key)),null===(h=this.barGroup)||void 0===h||h.attr(k(this.dataPoint.key,"element")),this.isVarianceBar||null===(e=this.barGroup)||void 0===e||e.attr("data-bn-value",this.dataPoint.value),null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(o,r):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(o).stroke(r).cy(this.dimensions.yPos).x(this.dimensions.xPos)),this.drawBarDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.barGroup||!this.overflowConfig)return;const s=this.position.getBarPositionX(),h=this.position.getBarWidth(),e=this.dimensions.barLength,{breakGap:n}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(e,h).fill(t).stroke(i).x(s-e).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s-e-n-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-e-n,n)):(this.barGroup.rect(e,h).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s+e+n).cy(this.dimensions.yPos),this.drawBreakIndicator(s+e,n))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),h=this.dimensions.yPos-s/2,e=t+i/2,n=.35*i,r=s/3;let o=`M ${e-n} ${h}`;for(let t=0;t<3;t++)o+=` L ${e-n-.3*i} ${h+r*(t+.5)} L ${e-n} ${h+r*(t+1)}`;let a=`M ${e+n} ${h}`;for(let t=0;t<3;t++)a+=` L ${e+n+.3*i} ${h+r*(t+.5)} L ${e+n} ${h+r*(t+1)}`;this.barGroup.rect(i,s+2).fill("#ffffff").stroke("none").x(t).cy(this.dimensions.yPos),this.barGroup.path(o).fill("none").stroke({color:"#000000",width:1}),this.barGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,h){const e=i.getScaledUnit(),n=Math.abs(e);if(this.overflowConfig&&n>0){const r="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(n>r){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:o,maxOverflow:a}=this.overflowConfig;this.overdriveWidth=a>0?(n-r)/a*o:0;const l=r+i+this.overdriveWidth;return e<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()-r,yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:r,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}}}return e<0?{clipped:!1,barLength:n,xPos:t.getBarPositionX()+e,yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()-.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:e,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()+.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){if(null!=this.scenarioLabel&&!this.scenarioLabel.isEmpty()&&!this.isVarianceBar){let t=this.dimensions.scenarioLabelXPos;if(this.nameBesideAxis()){const i=this.dataPoint.getScaledUnit()<0?-1:1;t=this.position.getBarPositionX()+i*this.position.spacings.labelToAxis}this.scenarioLabel.setPos(t,this.dimensions.scenarioLabelYPos).draw()}}nameBesideAxis(){return this.isPrimaryBar&&this.position.isNameBelowBar()}drawBarDataLabel(t,i=new g){var s;this.isPrimaryBar&&(null===(s=this.label)||void 0===s||s.draw(t,i))}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getScenarioLabel(t){if(this.isPrimaryBar){let i=et.Center;return this.nameBesideAxis()&&(i=this.dataPoint.getScaledUnit()<0?et.Right:et.Left),new vt(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,et.Top,i)}return new vt(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,et.Bottom,et.Center)}}class bt{constructor(t,i,s,h,e,n,r,o,a){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=e,this.barStyles=e?e.barStyles:null,this.scenario=h,!0!==(null==n?void 0:n.isEmpty())&&(this.hasData=!0,this.pointKey=n.key,this.dimensions=this.createMarkerDimensions(n,r,a),this.scenarioLabel=this.getScenarioLabel(o,e,a))}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelXPos:0,barLength:Math.abs(t.getScaledUnit()),xPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}:{clipped:!1,labelXPos:0,barLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX()+t.getScaledUnit(),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()+t.getScaledUnit(),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new vt(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?et.Bottom:et.Top,et.Center)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}draw(){if(this.isEmpty())return this;const t=this.convertToSVGStyle(this.barStyles[this.getScenario()],"stroke");let i=this.convertToSVGStyle(this.barStyles[this.getScenario()],"fill");const s=this.barStyles[this.getScenario()];if(null!=s&&s.fillpattern){const t=this.styles.pattern.get(s.fillpattern);null!=t&&(i=t.pattern)}return this.markerGroup.attr(k(this.pointKey)),this.markerGroup.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos).cx(this.dimensions.xPos).attr(k(this.pointKey,"element")),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class gt{constructor(t,i,s,h,e){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=e,this.styles=i,this.barGroup=e.group().id(e.toString()+"_"+this.ID_RECT);const n=void 0===(null==s?void 0:s.value)&&null!=(null==s?void 0:s.scenario);if(!0!==(null==s?void 0:s.isEmpty())&&null!=s.value||n){this.hasData=!0,this.dimensions=this.createDimensions(t,s,h);let i=et.Left;s.value<0&&(i=et.Right),this.label=new vt(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,n?C:s.value,this.styles,et.Center,i),this.label.setToRelativeVarianceLabel().setPoint(s.key)}}emphasize(){var t;return null===(t=this.label)||void 0===t||t.setEmphasis(!0,!1),this}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1}){var i,s,h;if(void 0===(null===(i=this.dataPoint)||void 0===i?void 0:i.value))return null===(s=this.label)||void 0===s||s.draw(t),this;if(this.isEmpty())return this;if(null==this.dimensions)return this;this.scenarioGroup.attr(k(this.dataPoint.key)),this.barGroup.attr(k(this.dataPoint.key,"element"));const e=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),n=e.stroke;let r=e.fill;const o=this.barStyles[this.dataPoint.getScenario()];if(null!=o&&o.fillpattern){const t=this.styles.pattern.get(o.fillpattern);null!=t&&null!=t.pattern&&(r=t.pattern)}this.drawNeedleHead(r,n),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(r).stroke(n).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(h=this.label)||void 0===h||h.draw(t)}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{barLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getBarPositionX()+i.getScaledPercentUnit(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()-this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}:{barLength:i.getScaledPercentUnit(),xPos:t.getBarPositionX(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()+this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}}drawNeedleHead(t,i){if(null===this.dimensions)return;const s=this.styles.varianceStyles.needleHeadColour,h=this.styles.varianceStyles.needleHeadColour;if(this.dimensions.clipped){let s="13,0 4,-5 4,5 13,0 8,0 0,-5 0,5 8,0";null!=this.dataPoint.value&&this.dataPoint.value<0&&(s="0,0 9,-5 9,5 0,0 5,0 13,-5 13,5 5,0"),this.barGroup.polygon(s).fill(t).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(t).stroke(i)}else this.barGroup.rect(2*this.position.getNeedleWidth(),2*this.position.getNeedleWidth()).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(s).stroke(h)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadXPosition(){let t=this.dimensions.xPos;return null!=this.dataPoint.value&&this.dataPoint.value>0&&(t+=this.dimensions.barLength),t}}class wt{constructor(t,i,s,h,e,n,r,o,a,l,c,u={}){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=h,this.segment=e,this.segmentIndex=r,this.stackMode=o,this.stack=a,this.options=u,this.group=c,this.barGroup=c.group().id(`stacked_bar_${h}_seg_${r}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new g){var s;if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const h=this.dataPoint.value,e=this.dataPoint.pixelPerUnit,n=this.position.getBarPositionX(),r=this.position.getBarWidthAt(this.index),o=Math.abs(this.segment.end-this.segment.start)*e,a=n+Math.min(this.segment.start,this.segment.end)*e,l=this.position.getBarPositionY(this.index,!0),c=this.styles.stackColors,d=c[this.segmentIndex%c.length],f={color:d},v={color:d,width:.5};this.barGroup.attr(k(this.dataPoint.key,"element")),this.barGroup.attr("data-bn-value",h),this.barGroup.rect(Math.max(o,.5),r).fill(f).stroke(v).cy(l).x(a);const p=o-Math.min(6,.375*this.styles.fontStyles.size),{bold:m=!1,italic:b=!1}=this.options,w=this.stackMode===u.RELATIVE&&null!==(s=this.options.label)&&void 0!==s?s:"share";if(p>0){const s=a+o/2;if(this.stackMode!==u.RELATIVE&&this.stackMode!==u.ABSOLUTE_RELATIVE||"value"===w)new vt(this.group,s,l,"STACK_SEG",h,this.styles,et.Center,et.Center).setSegmentFill(d).setEmphasis(m,b).setMaxWidth(p).setPoint(this.dataPoint.key).draw(t,i);else{const i="plain-share"===w?S.number(100*this.segment.share,"decimal",t.percent,t.percent,1,this.styles.locale):S.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);new vt(this.group,s,l,"STACK_SEG",i,this.styles,et.Center,et.Center).setSegmentFill(d).setEmphasis(m,b).setMaxWidth(p).setPoint(this.dataPoint.key).draw()}}}drawTotalLabel(t={percent:2,decimal:1},i=new g,s){var h,e;if(this.stackMode===u.RELATIVE&&!this.options.total)return;const n=this.stack.total<0,r=this.position.getLabelPositionX((n?0-this.stack.negative:this.stack.positive)*this.dataPoint.pixelPerUnit),o=this.position.getBarPositionY(this.index,!0);new vt(this.group,r,o,"STACK_TOTAL",this.stack.total,this.styles,et.Center,n?et.Right:et.Left).setEmphasis(null!==(h=this.options.bold)&&void 0!==h&&h,null!==(e=this.options.italic)&&void 0!==e&&e).setPoint(s,"total").draw(t,i)}}class St{constructor(t,i,s,h,e){this.overflowConfig=null,this.i18n=e;const n=i.group().id("Scenario1"),r=i.group().id("Scenario2").insertBefore(n);this.svgGroups={parent:i,scenario1:n,scenario2:r,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=h}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new mt(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o)}createVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new mt(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o).setAsVariance()}createRelativeVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);return new gt(this.position,this.styles,t,i,r).updateLabelGroup(o)}createSecondaryBar(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===h?void 0:h.group().id(""+i);let n=null;return this.isFirsttDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new mt(this.position,this.styles,t,i,!1,e,n,this.overflowConfig)}createPrimaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-down")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isFirstDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new bt(this.position,e,n,t.scenario,this.styles,t,i,r,!0)}createSecondaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-up")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isLastDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new bt(this.position,e,n,t.scenario,this.styles,t,i,r,!1)}isFirstDataPoint(t){return 0===t}}class Pt{constructor(t,i,s,h,e){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new ot(0,st.AC1,1,st.NEU),this.highestDataPointValue=new ot(0,st.AC1,1,st.NEU),this.smallestVarianceDataPointValue=new ot(0,st.AC1,1,st.NEU),this.highestVarianceDataPointValue=new ot(0,st.AC1,1,st.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.level=c.CATEGORY,this.hideCategories=!1,this.axisScenario=st.AC1,this.CSS_CATEGORIES="categories",this.state=tt.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new g,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.scenarioPropOrder=[],this.overflowConfig=null,this.stackSides=O([]),this.stackLabelClearance={left:0,right:0},this.fromExpr="",this.rowCount=0,this.sums="none",this.sumTitle="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[],this.db=i,this.tableName=s,this.ruleSet=t||new D,this.i18n=this.createI18n(new Map),this.styles=e,this.setConfig(h),this.position=this.createElementPosition()}updatePosition(){this.position=this.createElementPosition()}createElementPosition(){this.titleLength=this.calculateTitleLength(0);let t=this.calculateLeftSideWidth(this.getVarianceType());const i=this.calculateCategoryWidth();return this.titleLength>t&&(t=this.titleLength),new Z(new Q(this.styles.padding),this.styles.scaleFactors,this.styles.fontStyles.size,this.dataModel.length,this.leftSideOffsetForHorizontalSync,this.titleLength,t,i,!!this.stackConfig&&0===this.variancesDataModel.length||this.scenarioLabelTop,this.rowLayout())}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new D}setConfig(t){var i,s;this.state=tt.DIRTY,this.scenarioPropOrder=[...t.scenarios];const h=this.sortScenariosbyVisualisationRules(t.scenarios);this.hideCategories=t.hideCategories||!1,this.limit=t.limit,this.pixelPerUnit=t.pixelPerUnit||1,this.pixelPerPercentage=t.pixelPerPercentage||100,this.setSource(t.filter),this.level=t.level,this.sums=t.sums,this.sumTitle=t.sumTitle,this.styles.valueSuffix=t.valueSuffix,this.scenarioLabelTop=t.scenarioLabelTop,this.hideScenarioName=t.hideScenarioName,this.referenceLine=t.referenceLine,this.italicCategories=t.italicCategories,this.dataModel=this.populateModel(h,t.level,t.sortOrder),t.stackConfig&&t.stackConfig.by!==d.SCENARIOS&&this.populateDimensionStackSegments(h,t.stackConfig,t.level),this.addSumRows(h);for(const t of this.dataModel)for(const s of[t.scenario1,t.scenario2,t.scenario3,t.scenario4])null==s.value||Number.isNaN(s.value)||(s.key=Object.assign(Object.assign({},T(this.level,t.category)),{scenario:null!==(i=s.scenario)&&void 0!==i?i:void 0}));this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(s=null==t?void 0:t.variances)&&void 0!==s?s:[],this.updateTitle();const e=this.dataModel.filter((t=>!t.sum));this.smallestDataPointValue=this.findSmallestDataPointValue(e),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(e),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.stackConfig=t.stackConfig,this.measureStacks(),this.updatePosition()}sortScenariosbyVisualisationRules(t){const i=this;return[...t].sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t),this.updateTitle()}updateTitle(){var t;this.title=this.configTitle||S.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=tt.DIRTY;const i=new Map([["SEPARATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["category"," "],["operation"," "],["thereof","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return new Map([...i,...t])}setSource(t){var i,s;if(this.state=tt.DIRTY,this.queryError=void 0,this.fromExpr=G(this.db,this.tableName,t),this.fromExpr)try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(s=null===(i=t[0])||void 0===i?void 0:i.cnt)&&void 0!==s?s:0}catch(t){this.rowCount=0,this.failQuery(t)}else this.rowCount=0}getQueryError(){return this.queryError}failQuery(t){var i;null!==(i=this.queryError)&&void 0!==i||(this.queryError=z(t))}getUnitBarExtent(){var t,i,s,h;const e=this.isStacked(),n=this.getVarianceType(),r=n!==it.NONE,o=r?this.highestVarianceDataPointValue:this.highestDataPointValue,a=r?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return A({fixedDomain:e?this.stackSides.positive+this.stackSides.negative:void 0,relativeVariance:n===it.RELATIVE,maxPositive:Math.max(null!==(t=null==o?void 0:o.value)&&void 0!==t?t:0,e||r?0:null!==(s=null===(i=this.referenceLine)||void 0===i?void 0:i.value)&&void 0!==s?s:0),minNegative:null!==(h=null==a?void 0:a.value)&&void 0!==h?h:0})}getPercentBarExtent(){var t,i,s,h;return E({relativeVariance:this.getVarianceType()===it.RELATIVE,maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:null!==(h=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==h?h:0})}getAllocatedCanvasWidth(){const t=this.position.getAxisPositionX(),i=this.calculateRightSideWidth(this.getVarianceType());let s=t+i+ +this.styles.padding.left+this.styles.padding.right;return i<this.titleLength/2&&(s+=this.titleLength/2),t<this.titleLength/2&&(s+=this.titleLength/2),s}getAllocatedCanvasHeight(){return this.position.getAxisEndPositionY()+this.position.spacings.labelToAxis+this.position.fontSize+(this.hasPercentMark()?.8*this.position.fontSize:0)+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}layout(){this.draw(new n)}toString(){const t=new n;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.svg()}applyFontToContainer(t){t.attr({"font-size":this.styles.fontStyles.size,"font-family":this.styles.fontStyles.family})}draw(t){this.cleanSVGforRedraw(t),this.applyFontToContainer(t),this.state===tt.DIRTY&&(this.state=tt.UP_TO_DATE),this.variancesDataModel&&this.variancesDataModel.length>0?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t,!0),this.drawPercentMark(t)):(this.drawScenarios(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)),0===this.variancesDataModel.length&&this.drawReferenceLine(t)}setPattern(t,i){this.styles.pattern.set(t,i)}calculateTitleLength(t){const i=P(this.title.length>7?this.title:"_______",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:this.styles.titleBold?"bold":"normal"}).width;return i<t?t:i/2}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":S.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}scenarioStyles(){const t=j(this.styles.barStyles,this.ruleSet);return t===this.styles.barStyles?this.styles:Object.assign(Object.create(Object.getPrototypeOf(this.styles)),this.styles,{barStyles:t})}setAxisScenario(t){let i=st.AC1;if(null!=t&&t.length>0){const s=new y(t.toString());s.isValid&&(i=X(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=st.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const h=[],e=this.createOrderStr(i,s),n=this.createSelectString(i,s),r=this.createGroupByStr(i,s);let o;try{o=this.db.exec(`SELECT ${n} ${t.length>0?","+t.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(","):""}\n FROM ${this.fromExpr}\n GROUP BY ${r}\n ORDER BY ${e}`)}catch(t){return this.failQuery(t),[]}return this.detectNaNCells(t,o),this.createDataRows(this.limit>0?o.slice(0,this.limit):o,h,t),this.crateRESTRow(o,t,h),h}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new y(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}crateRESTRow(t,i,s){if(this.limit<=0||this.limit>=t.length)return;const h=[];this.createDataRows(t.slice(this.limit),h,i);const e=(t,i)=>Number.isFinite(i)?(Number.isFinite(t)?t:0)+i:t,n=h.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new ot(e(t.scenario1.value,s.scenario1.value),i[0],t.scenario1.pixelPerUnit,st.NEU),scenario2:new ot(e(t.scenario2.value,s.scenario2.value),i[1],t.scenario2.pixelPerUnit,st.NEU),scenario3:new ot(e(t.scenario3.value,s.scenario3.value),i[2],t.scenario3.pixelPerUnit,st.NEU),scenario4:new ot(e(t.scenario4.value,s.scenario4.value),i[3],t.scenario4.pixelPerUnit,st.NEU)}}),{id:9999,category:"REST",type:it.NONE,scenario1:new ot(NaN,i[0],this.pixelPerUnit,st.NEU),scenario2:new ot(NaN,i[1],this.pixelPerUnit,st.NEU),scenario3:new ot(NaN,i[2],this.pixelPerUnit,st.NEU),scenario4:new ot(NaN,i[3],this.pixelPerUnit,st.NEU)});s.push(n)}createDataRows(t,i,s){t.forEach(((t,h)=>{i.push({id:h,category:t.category,type:it.NONE,scenario1:new ot(t[s[0]],s[0],this.pixelPerUnit,st.NEU),scenario2:new ot(t[s[1]],s[1],this.pixelPerUnit,st.NEU),scenario3:new ot(t[s[2]],s[2],this.pixelPerUnit,st.NEU),scenario4:new ot(t[s[3]],s[3],this.pixelPerUnit,st.NEU)})}))}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=i.hierarchy.map((t=>`${t} ${i.direction}`)).toString()),s}createSelectString(t,i){return t===c.CATEGORY&&i.hierarchy.includes(m.CATEGORYINDEX)?`${m.CATEGORYINDEX}, ${c.CATEGORY} as category`:t===c.ROWGROUP&&i.hierarchy.includes(m.ROWGROUPINDEX)?`${m.ROWGROUPINDEX}, ${c.ROWGROUP} as category`:t===c.SUBCATEGORY&&i.hierarchy.includes(m.SUBCATEGORYINDEX)?`${m.SUBCATEGORYINDEX}, ${c.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===c.CATEGORY&&i.hierarchy.includes(m.CATEGORYINDEX)?`${m.CATEGORYINDEX}, ${c.CATEGORY}`:t===c.ROWGROUP&&i.hierarchy.includes(m.ROWGROUPINDEX)?`${m.ROWGROUPINDEX}, ${c.ROWGROUP}`:t===c.SUBCATEGORY&&i.hierarchy.includes(m.SUBCATEGORYINDEX)?`${m.SUBCATEGORYINDEX}, ${c.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=P(i.category,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"});s.width>t&&(t=s.width)}return 1.1125*t}findSmallestDataPointValue(t){let i=new ot(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value<i.value&&(i=t);return i}findHighestDataPointValue(t){let i=new ot(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value>i.value&&(i=t);return i}stackGroups(t){if(!this.stackConfig)return[];const i=this.stackConfig.by===d.SCENARIOS;let s=[];for(const h of i?["scenario1","scenario2","scenario3","scenario4"]:["scenario1"]){const i=t[h];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===s.length)return[];const h=this.stackConfig.mode===u.RELATIVE?1:0,e=(t,i)=>({prefix:t,segments:i,layout:_(i.map((t=>t.value)),h),hasValue:i.some((t=>Number.isFinite(t.value)))});if(i){this.sortSegmentsByPropOrder(s);const t=new Map;for(const i of s){const s=L(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of M)t.has(s)&&(i.push(e(s,t.get(s))),t.delete(s));for(const[s,h]of t)i.push(e(s,h));return i}}else t.stackSegments&&t.stackSegments.length>0&&(s=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint}))));const n=t=>Number.isFinite(t.value)?t.value:0;return"asc"===this.stackConfig.order?s.sort(((t,i)=>n(t)-n(i))):"desc"===this.stackConfig.order&&s.sort(((t,i)=>n(i)-n(t))),[e("",s)]}measureStacks(){const t=[];this.stackLabelClearance={left:0,right:0};for(const i of this.dataModel){const{flipped:s,clearance:h}=this.stackLabelPlace(i),e=this.drawnStackLayouts(i),n=s?"right":"left";this.stackLabelClearance[n]=Math.max(this.stackLabelClearance[n],h),t.push(...e)}this.stackSides=O(t)}stackLabelPlace(t){const i=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;return R(this.drawnStackLayouts(t),(t=>{var s;return(null===(s=this.stackConfig)||void 0===s?void 0:s.mode)===u.RELATIVE&&"value"!==this.stackConfig.labels?0:(i+this.calculateTotalLabelWidth(t.total))/this.pixelPerUnit}))}drawnStackLayouts(t){return this.isTextSum(t)?[]:this.stackGroups(t).filter((t=>t.hasValue)).map((t=>t.layout))}calculateTotalLabelWidth(t){const i=this.dataFormatDigits.decimal;return P(S.number(t,"decimal",i,i,this.measureScale.value,this.styles.locale)+this.styles.valueSuffix,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}isStacked(){return null!=this.stackConfig&&this.stackSides.positive+this.stackSides.negative>0}populateVarianceModel(t,i){const s=[];if(0===t.length)return s;let h=null;null!=i&&i.length>0&&(h=i[0]);for(const e in t){const n=new y(t[e]);if(n.isValid){const r=this.mapScenarios(n,h),o=n.direction;let a=this.pixelPerUnit;"dr"===n.type&&(a=this.pixelPerPercentage);for(const h in i){const l=new ot(this.calculateVariance(n,i[h],r),n.base,a,o);null===l.value||Number.isNaN(l.value)||(l.key=Object.assign(Object.assign({},T(this.level,i[h].category)),{scenario:t[e]})),s.push({id:Number(h),category:i[h].category,type:"dr"===n.type?it.RELATIVE:it.ABSOLUTE,scenario1:l,scenario2:new ot(null,null,null,null),scenario3:new ot(null,null,null,null),scenario4:new ot(null,null,null,null),sum:i[h].sum})}}}return s}calculateVariance(t,i,s){const h=s.get(t.base),e=s.get(t.delta);return null==h||null==e?null:t.type===it.RELATIVE?$(i[h].value-i[e].value,i[e].value):i[h].value-i[e].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((h=>{i[h].scenario===t.delta?s.set(t.delta,h):i[h].scenario===t.base&&s.set(t.base,h)})),s}calculateTextBoxWidth(t,i=!1){const s=i?"":this.styles.valueSuffix;return P(S.number(t,"decimal",1,0,1,this.styles.locale)+s,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}calculatePercentageTextBoxWidth(t){let i=0;const s=this.dataFormatDigits.percent,h=t=>S.number(t,"percent",s,s,1,this.styles.locale);return t>0&&h(t)!==h(0)&&(i+=P("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=P(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,P(S.number(t,"decimal",1,1,1,this.styles.locale),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width+i+i}cleanSVGforRedraw(t){t.clear()}drawAxisAndLabels(t,i,s=!1){const h=i.group().id("AxisAndDateLables");let e=!1;this.hideCategories||t.forEach(((t,i)=>{var n;t.type===it.RELATIVE&&(e=!0);let r=et.Right,o=!0,a=0;if(s){const i=this.stackLabelPlace(t);o=!i.flipped,a=i.clearance*this.pixelPerUnit*(i.flipped?1:-1)}else t.scenario1.value<0&&!this.hasSumNumbers(this.dataModel[i])&&(o=!1);o||(r=et.Left),new vt(h,this.position.getCategoryPositionX(o)+a,this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,et.Center,r).setEmphasis(!!(null===(n=this.dataModel[i])||void 0===n?void 0:n.sum),this.isItalic(t.category)).draw()})),t.forEach(((t,i)=>{const s=this.dataModel[i];if(!(null==s?void 0:s.sum))return;const e=this.position.getBarCenterPositionY(i)-this.position.spacings.categoryWidth/2,n=this.hideCategories?this.position.getAxisPositionX():this.styles.padding.left;h.line(n,e,this.position.getAxisPositionX()+this.sumRowExtent(s),e).stroke({color:"#000000",width:Math.max(.5,this.position.spacings.axisLineWidth/2)}).addClass("sum-line")})),new pt({scenarioType:this.axisScenario,labelText:this.title,isRelative:e},this.position,h,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios");let h=-1;t.forEach(((t,i)=>{t.sum||(h=i)}));const e=new St(this.position,s,this.scenarioStyles(),this.scenarioLabelTop?0:h+1,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.sum?this.drawSumValue(t,i,s):(e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),e.createSecondaryBar(t.scenario2,i).draw(),e.createPrimaryMarker(t.scenario3,i).draw(),e.createSecondaryMarker(t.scenario4,i).draw())}));const n=t.find((t=>!t.sum));if(this.scenarioLabelTop&&n&&!n.scenario1.isEmpty()&&null!=n.scenario1.scenario){const t=n.scenario1.scenario;new vt(s,this.position.getBarPositionX()+this.position.spacings.labelToAxis,this.position.getStackedHeaderPositionY(),"SCENARIO_HEADER",this.i18n.get(t)||t,this.styles,et.Bottom,et.Left).draw()}}sumPoints(t){const i=[t.scenario1,t.scenario2,t.scenario3,t.scenario4].filter((t=>null!=t&&!t.isEmpty()&&Number.isFinite(t.value))),s=this.scenarioPropOrder,h=t=>{const i=s.indexOf(t.scenario);return-1===i?s.length:i};return i.sort(((t,i)=>h(t)-h(i)))}hasSumNumbers(t){return!!(null==t?void 0:t.sum)&&0===this.variancesDataModel.length&&!this.stackConfig&&this.sumPoints(t).length>1}sumValuesWidth(t){const i=this.styles.fontStyles.size,s=i*this.styles.scaleFactors.labelToBar,h=this.sumPoints(t);if(0===h.length)return 0;const e=h.map((t=>this.boldWidth(this.sumText(t.value))));return 1===h.length?s+e[0]:s+e.reduce(((t,s)=>t+.9*i+s),0)+(h.length-1)*i*1.4}drawSumValue(t,i,s){const h=this.sumPoints(t);if(0===h.length)return;const e=this.styles.fontStyles.size,n=this.position.getBarCenterPositionY(i),r=s.group().id(`sum_${i}`),o=(t,i,s)=>{new vt(r,i,n,`SUM_${t.scenario}`,t.value,this.styles,et.Center,s).setEmphasis(!0,!1).setPoint(t.key).draw(this.dataFormatDigits,this.measureScale)};if(1===h.length){const t=h[0].value<0;return void o(h[0],this.position.getLabelPositionX(t?-1e-6:0),t?et.Right:et.Left)}const a=.6*e,l=this.scenarioStyles().barStyles;let c=this.position.getLabelPositionX(0);for(const t of h){const i=l.getSVGStyle(t.getScenario());r.rect(a,a).fill({color:(null==i?void 0:i.fill)||"#000000"}).stroke({color:(null==i?void 0:i.stroke)||"#000000",width:1}).cy(n).x(c),o(t,c+a+.3*e,et.Left),c+=.9*e+this.boldWidth(this.sumText(t.value))+1.4*e}}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),h=new St(this.position,s,this.scenarioStyles(),t.length,this.i18n);return h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{if(t.type===it.RELATIVE){const s=h.createRelativeVarianceBar(t.scenario1,i);t.sum&&s.emphasize(),s.draw(this.dataFormatDigits)}else{const s=h.createVarianceBar(t.scenario1,i);t.sum&&s.emphasize(),s.draw(this.dataFormatDigits,this.measureScale)}})),s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const h=i.indexOf(t.scenario),e=i.indexOf(s.scenario);return(-1===h?i.length:h)-(-1===e?i.length:e)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),h=this.stackConfig.by===d.SCENARIOS,e=this.stackConfig.mode===u.RELATIVE&&"value"===this.stackConfig.labels,n=e?"value":this.stackConfig.percentMark?"plain-share":"share";t.forEach(((t,i)=>{const r=this.stackGroups(t);if(this.isTextSum(t))return void this.drawSumText(t,i,s);const o={label:n,total:e,bold:!!t.sum,italic:this.isItalic(t.category)};r.forEach(((e,n)=>{let a=null;e.segments.forEach(((t,l)=>{const c=new wt(this.position,this.styles,t.dataPoint,i,e.layout.segments[l],t.scenario,r.length>1?r.length-1-n:l,this.stackConfig.mode,e.layout,h,s,o);c.draw(this.dataFormatDigits,this.measureScale),a=c})),a&&e.hasValue&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale,Object.assign(Object.assign({},T(this.level,t.category)),{scenario:r.length>1?e.prefix:void 0}))}))}))}drawStackedHeaders(t,i){var s;if(!this.stackConfig||0===t.length)return;const h=null!==(s=t.find((t=>!this.isTextSum(t))))&&void 0!==s?s:t[0];if(this.stackConfig.by!==d.SCENARIOS&&(!h.stackSegments||0===h.stackSegments.length))return;const e=this.stackGroups(h);if(0===e.length)return;const n=i.group().id("StackedHeaders"),r=this.position.getBarPositionX(),o=this.position.getStackedHeaderPositionY(),a=(t,i)=>{new vt(n,t,o,"STACK_HEADER",i,this.styles,et.Bottom,et.Center).draw()};if(e.length>1)return void e.forEach((t=>{a(r+(t.layout.positive-t.layout.negative)/2*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[l]=e;this.stackConfig.totalTitle&&(this.stackConfig.mode!==u.RELATIVE||"value"===this.stackConfig.labels)&&new vt(n,this.position.getLabelPositionX(l.layout.positive*this.pixelPerUnit),o,"STACK_TOTAL_HEADER",this.stackConfig.totalTitle,this.styles,et.Bottom,et.Left).draw(),l.segments.forEach(((t,i)=>{const{start:s,end:h}=l.layout.segments[i];a(r+(s+h)/2*t.dataPoint.pixelPerUnit,this.i18n.get(t.scenario)||t.scenario)}))}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:it.NONE}calculateLeftSideWidth(t){var i,s,h;let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(it.NONE===t&&this.isStacked())this.stackSides.negative>0&&(e=this.stackSides.negative*this.pixelPerUnit,this.stackSides.minTotal<0&&(e+=n+this.calculateTotalLabelWidth(this.stackSides.minTotal))),this.stackLabelClearance.left>0&&(e=Math.max(e,this.stackLabelClearance.left*this.pixelPerUnit+this.calculateCategoryWidth()));else if(it.NONE===t&&null!=(null===(i=this.smallestDataPointValue)||void 0===i?void 0:i.value)&&this.smallestDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestDataPointValue.value);e=Math.abs(this.smallestDataPointValue.getScaledUnit())+n+t}else if(it.RELATIVE===t&&null!=(null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);e=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(it.ABSOLUTE===t&&null!=(null===(h=this.smallestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value,!0);e=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}calculateRightSideWidth(t){var i,s,h,e,n,r;if(this.isStacked()){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar,e=this.calculateTextBoxWidth(this.stackSides.maxTotal);let n=this.stackSides.positive*this.pixelPerUnit+t+e;if(this.stackSides.minTotal<0&&(n=Math.max(n,this.stackLabelClearance.right*this.pixelPerUnit+this.position.getCategoryToAxisSpaceing()+this.calculateCategoryWidth())),null===(i=this.stackConfig)||void 0===i?void 0:i.totalTitle){const i=P(this.stackConfig.totalTitle,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;n=Math.max(n,this.stackSides.positive*this.pixelPerUnit+t+i)}return Math.max(n,this.titleLength,null!==(h=null===(s=this.sumColumns())||void 0===s?void 0:s.width)&&void 0!==h?h:0,this.referenceLineExtent())}let o=0;const a=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(it.NONE===t&&null!=(null===(e=this.highestDataPointValue)||void 0===e?void 0:e.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);o=Math.abs(this.highestDataPointValue.getScaledUnit())+a+t}else if(it.RELATIVE===t&&null!=(null===(n=this.highestVarianceDataPointValue)||void 0===n?void 0:n.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);o=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+a+t}else if(it.ABSOLUTE===t&&null!=(null===(r=this.highestVarianceDataPointValue)||void 0===r?void 0:r.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value,!0);o=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+a+t}o=Math.max(o,this.referenceLineExtent());for(const i of this.dataModel)i.sum&&it.NONE===t&&(o=Math.max(o,this.sumRowExtent(i)));return o<=this.titleLength?this.titleLength:o}populateDimensionStackSegments(t,i,s){var h;if(0===this.rowCount||!this.fromExpr||0===t.length)return;const e={[c.ROWGROUP]:"category",[c.ROWGROUPINDEX]:"category",[c.CATEGORY]:"subCategory",[c.CATEGORYINDEX]:"subCategory"}[s];if(!e)return;const n=s.toString(),r=t[0];let o;try{o=this.db.exec(`SELECT [${n}] as displayGroup, [${e}] as stackLabel, MIN([${e}Index]) as stackIndex, SUM([${r}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${n}], [${e}]`)}catch(t){return void this.failQuery(t)}const a=new Map;for(const t of o){if(null==t.stackValue||null==t.stackLabel)continue;const i=t.stackLabel,s=Number.isFinite(Number(t.stackIndex))&&null!=t.stackIndex?Number(t.stackIndex):NaN,h=a.get(i);(void 0===h||Number.isNaN(h)&&!Number.isNaN(s)||s<h)&&a.set(i,s)}const l=[...a.keys()];[...a.values()].every((t=>!Number.isNaN(t)))&&l.sort(((t,i)=>a.get(t)-a.get(i)));const u=new Map;for(const t of o){const i=t.displayGroup;u.has(i)||u.set(i,new Map),null!=t.stackValue&&null!=t.stackLabel&&u.get(i).set(t.stackLabel,t.stackValue)}const d=new Set(this.dataModel.map((t=>t.category))),f=new Map;for(const[t,i]of u)if(!d.has(t))for(const[t,s]of i)f.set(t,(null!==(h=f.get(t))&&void 0!==h?h:0)+s);for(const t of this.dataModel){const i=9999!==t.id||u.has(t.category)?u.get(t.category):f,s=i&&i.size>0?l.map((t=>{var s;return{label:t,value:null!==(s=i.get(t))&&void 0!==s?s:NaN}})):void 0;t.stackSegments=s&&s.length>0?s.map((i=>{const s=new ot(i.value,r,this.pixelPerUnit,st.NEU);return s.key=Object.assign(Object.assign({},T(this.level,t.category)),{[e]:i.label,scenario:r}),{label:i.label,value:i.value,dataPoint:s}})):[]}}isTextSum(t){return!!t.sum&&!!this.stackConfig&&this.stackConfig.mode!==u.RELATIVE}isItalic(t){return this.italicCategories.includes(t)}hasPercentMark(){var t;return!!(null===(t=this.stackConfig)||void 0===t?void 0:t.percentMark)&&this.stackConfig.mode===u.RELATIVE&&0===this.variancesDataModel.length&&this.isStacked()}addSumRows(t){if("none"===this.sums||0===this.dataModel.length)return;const i=(t,i)=>Number.isFinite(i)?(Number.isFinite(t)?t:0)+i:t,s=(s,h,e)=>{var n,r;const o=(h,e)=>new ot(void 0===t[e]?void 0:s.reduce(((t,s)=>i(t,s[h].value)),NaN),t[e],this.pixelPerUnit,st.NEU),a={id:1e4+this.dataModel.length,category:h,type:it.NONE,scenario1:o("scenario1",0),scenario2:o("scenario2",1),scenario3:o("scenario3",2),scenario4:o("scenario4",3),sum:e};if(s.some((t=>t.stackSegments))){const h=new Map;for(const t of s)for(const s of null!==(n=t.stackSegments)&&void 0!==n?n:[])h.set(s.label,i(null!==(r=h.get(s.label))&&void 0!==r?r:NaN,s.value));a.stackSegments=[...h].map((([i,s])=>({label:i,value:s,dataPoint:new ot(s,t[0],this.pixelPerUnit,st.NEU)})))}return a},h=this.dataModel,e=[],n="total"===this.sums?new Map:this.rowGroups();if(n.size>0){const t=[...new Set([...n.values()].sort(((t,i)=>t.index-i.index)).map((t=>t.name)))];for(const i of t){const t=h.filter((t=>{var s;return(null===(s=n.get(t.category))||void 0===s?void 0:s.name)===i}));if(0===t.length)continue;const r=s(t,i,"group");r.gapAfter=!0,e.push(...t,r)}e.push(...h.filter((t=>!n.has(t.category))))}else e.push(...h);"total"!==this.sums&&"all"!==this.sums||e.push(s(h,this.sumTitle||"SUM_TOTAL","total")),this.dataModel=e}rowGroups(){const t=new Map;if(this.level!==c.CATEGORY&&this.level!==c.CATEGORYINDEX)return t;let i;try{i=this.db.exec(`SELECT [category] as category, [rowGroup] as rowGroup, MIN([rowGroupIndex]) as rowGroupIndex FROM ${this.fromExpr} GROUP BY [category], [rowGroup]`)}catch(i){return this.failQuery(i),t}const s=new Map;return i.forEach(((i,h)=>{var e;if(null==i.rowGroup||""===i.rowGroup)return;const n=String(i.rowGroup),r=Number(i.rowGroupIndex),o=null!=i.rowGroupIndex&&Number.isFinite(r)?r:null!==(e=s.get(n))&&void 0!==e?e:h;s.has(n)||s.set(n,o),t.set(String(i.category),{name:n,index:Math.min(o,s.get(n))})})),t}rowLayout(){var t;const i=this.dataModel,s="total"===(null===(t=this.stackConfig)||void 0===t?void 0:t.thickness),h=i.reduce(((t,i,s)=>i.sum?t:s),-1),e=!this.stackConfig&&!this.scenarioLabelTop&&!this.hideScenarioName&&h>=0&&h<i.length-1;if(!s&&!e&&!i.some((t=>t.gapAfter)))return null;const n=i.map((t=>{if(!s||t.sum)return null;const i=this.stackGroups(t),h=i[i.length-1];return h?Math.abs(h.layout.total):0})),r=this.rowWeights(n),o=[],a=[];let l=0;return i.forEach(((t,s)=>{const n=r[s];o.push(l),a.push(n),l+=n+(t.gapAfter&&s<i.length-1?.5:0)+(e&&s===h?1:0)})),{start:o,weight:a,total:l,nameBelowBar:e}}rowWeights(t){const i=Math.min(1,1/this.styles.scaleFactors.categoryWidth),s=t.map((t=>null===t?1:0)),h=new Set(t.flatMap(((t,i)=>null===t?[]:[i])));let e=h.size;for(;;){const n=[...h].reduce(((i,s)=>i+t[s]),0);if(n<=0){h.forEach((t=>s[t]=e/h.size));break}const r=[...h].filter((s=>t[s]/n*e<i));if(0===r.length||r.length===h.size){h.forEach((i=>s[i]=t[i]/n*e));break}for(const t of r)s[t]=i,e-=i,h.delete(t)}return s}boldWidth(t){return P(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:"bold"}).width}sumText(t){const i=this.dataFormatDigits.decimal;return S.number(t,"decimal",i,i,this.measureScale.value,this.styles.locale)+this.styles.valueSuffix}sumColumns(){const t=this.dataModel.filter((t=>this.isTextSum(t)));if(0===t.length)return null;const i=this.styles.fontStyles.size,s=.6*i,h=.3*i,e=1.4*i,n=[];let r=0;for(const i of t){const t=this.stackGroups(i),s=t[t.length-1];s&&(s.segments.forEach(((t,i)=>{var s;const h=Number.isFinite(t.value)?this.boldWidth(this.sumText(t.value)):0;n[i]=Math.max(null!==(s=n[i])&&void 0!==s?s:0,h)})),r=Math.max(r,this.boldWidth(this.sumText(s.layout.total))))}const o=[];let a=.3*i;for(const t of n.length>1?n:[])o.push(a),a+=s+h+t+e;return{x:o,totalX:a,width:a+r,key:s,keyGap:h}}drawSumText(t,i,s){const h=this.sumColumns(),e=this.stackGroups(t),n=e[e.length-1];if(!h||!n)return;const r=this.position.getBarPositionX(),o=this.position.getBarCenterPositionY(i),a=this.styles.stackColors,l=s.group().id(`stacked_sum_${i}`);n.segments.forEach(((t,i)=>{if(!Number.isFinite(t.value)||void 0===h.x[i])return;const s=r+h.x[i];l.rect(h.key,h.key).fill({color:a[i%a.length]}).cy(o).x(s),new vt(l,s+h.key+h.keyGap,o,`SUM_SEG_${i}`,t.value,this.styles,et.Center,et.Left).setEmphasis(!0,!1).setPoint(t.dataPoint.key).draw(this.dataFormatDigits,this.measureScale)})),new vt(l,r+h.totalX,o,"SUM_TOTAL",n.layout.total,this.styles,et.Center,et.Left).setEmphasis(!0,!1).setPoint(T(this.level,t.category),"total").draw(this.dataFormatDigits,this.measureScale)}sumRowExtent(t){var i,s,h;const e=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(this.variancesDataModel.length>0)return 0;if(this.isTextSum(t))return null!==(s=null===(i=this.sumColumns())||void 0===i?void 0:i.width)&&void 0!==s?s:0;if(this.stackConfig){const i="value"===this.stackConfig.labels?e+this.boldWidth(this.sumText(null!==(h=t.scenario1.value)&&void 0!==h?h:0)):0;return this.stackSides.positive*this.pixelPerUnit+i}return this.sumValuesWidth(t)}referenceLineOffset(){var t;const i=this.referenceLine;return!i||!Number.isFinite(i.value)||this.variancesDataModel.length>0?null:((null===(t=this.stackConfig)||void 0===t?void 0:t.mode)===u.RELATIVE?i.value/100:i.value)*this.pixelPerUnit}referenceLineExtent(){var t;const i=this.referenceLineOffset();if(null===i||i<=0)return 0;const s=(null===(t=this.referenceLine)||void 0===t?void 0:t.label)?P(this.referenceLine.label,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width:0;return i+Math.max(s/2,.25*this.styles.fontStyles.size)}drawPercentMark(t){if(!this.hasPercentMark())return;const i=t.group().id("PercentMark"),s=this.styles.fontStyles.size,h=this.position.getBarPositionX()+this.stackSides.positive*this.pixelPerUnit,e=this.position.getAxisPositionY(),n=this.position.getAxisEndPositionY(),r=n+.15*s,o=r+.75*s;i.line(h,e,h,n).stroke({color:"#000000",width:this.position.spacings.axisLineWidth}),i.polygon(`${h},${r} ${h-.28*s},${o} ${h+.28*s},${o}`).fill("#000000"),new vt(i,h,o+.1*s,"PERCENT_MARK","100%",this.styles,et.Top,et.Center).setEmphasis(!0,!1).draw()}drawReferenceLine(t){const i=this.referenceLine,s=this.referenceLineOffset();if(!i||null===s||0===this.dataModel.length)return;const h=t.group().id("ReferenceLine"),e=this.styles.fontStyles.size,n=`var(--bn-annotation-color, ${V["bn-annotation"].color})`,r=this.position.getBarPositionX()+s,o=this.position.getStackedHeaderPositionY()-(this.stackConfig||this.scenarioLabelTop?1.1*e:0),a=t=>{var s,h;if(t.sum)return!1;if(!this.stackConfig)return(null!==(s=t.scenario1.value)&&void 0!==s?s:0)>=i.value;const e=null===(h=this.stackGroups(t)[0])||void 0===h?void 0:h.layout.segments[0];return null!=e&&e.end*this.pixelPerUnit>=r-this.position.getBarPositionX()};let l=this.dataModel.findIndex((t=>!a(t)))-1;l<0&&(l=this.dataModel.reduce(((t,i,s)=>i.sum?t:s),0));const c=this.position.getBarCenterPositionY(l)+this.position.getBarWidthAt(l)/2;h.line(r,o,r,c).attr("style",`stroke: ${n}; stroke-width: ${Math.max(1,this.position.spacings.axisLineWidth)}px`),h.polygon(`${r},${o+.5*e} ${r-.25*e},${o} ${r+.25*e},${o}`).attr("style",`fill: ${n}`),i.label&&h.plain(i.label).attr({x:r,y:o-.3*e,"text-anchor":"middle"}).attr("style",`fill: ${n}`)}hasNoData(){return 0===this.dataModel.length}setAvailableWidth(t){if(this.pixelPerUnit<=0||t<=0)this.overflowConfig=null;else if(null==this.stackConfig){if(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig){const{cutWidth:t,overdriveZoneWidth:i,breakGap:s}=this.overflowConfig,h=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new ot(h,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new ot(-h,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new ot(h,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new ot(-h,this.smallestDataPointValue.scenario,1,this.smallestDataPointValue.variance))),this.updatePosition()}}else this.overflowConfig=null}calculateOverflowConfig(t){const i=this.variancesDataModel&&this.variancesDataModel.length>0;if(this.getVarianceType()===it.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,h=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,e=s.getScaledUnit(),n=null!=h.value?Math.abs(h.getScaledUnit()):0,r=Math.max(e,n);if(r<=0)return null;const o=this.styles.fontStyles.size,a=o*this.styles.scaleFactors.labelToBar,l=1.5*o,c=.3*o,u=.8*o,d=t-this.position.getAxisPositionX()-this.styles.padding.left-this.styles.padding.right-a-this.calculateTextBoxWidth(s.value||0)-l-c;if(d<=u)return null;const f=d-u;return r<=f?null:{cutWidth:d,overdriveZoneWidth:l,breakGap:c,maxOverflow:r-f,scenarioCutOffset:u}}}const yt=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.scenarios=[],this.variances=[],this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.i18n=new Map,this.order={hierarchy:[],direction:b.ASC},this.level=c.CATEGORY,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[],this.parentDimensions={width:0,height:0},U(this)}getDb(){return this.stores||(this.stores=Y(this.element)),this.stores.db.db}render(){var t,i,e,n;if(void 0===this.chart||void 0!==this.queryError)return s(h,null);if(this.chart.hasNoData()){const i=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return s(h,{class:"no-data"},s("div",{class:"empty-state"},i))}return s(h,null,s("div",{innerHTML:null===(i=this.pattern)||void 0===i?void 0:i.toString(),class:"hidePatternContainer",style:{width:"0",height:"0",overflow:"hidden"}}),s("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),s("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}syncQueryError(){var t,i;this.queryError=null!==(t=this.measureScaleError)&&void 0!==t?t:null===(i=this.chart)||void 0===i?void 0:i.getQueryError(),H(this.errors,this.queryError)}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),h=this.prepareStyle();this.chart=new Pt(new D(this.ruleSetConfig),i,this.tableName,s,h),this.chart.setI18n(this.i18n);const e=s.pixelPerUnit<=0;this.autoFitScaling(s,h),this.chart.setAvailableWidth(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new J(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}async componentWillUpdate(){var t;if(null==this.chart)return;const i=this.prepareConfig(),s=this.prepareStyle();this.chart.setI18n(this.i18n),this.chart.setStyles(s),this.chart.setRuleSet(new D(this.ruleSetConfig)),this.chart.setConfig(i);const h=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableWidth(h?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new J(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}autoFitScaling(t,i){var s;const h=t.pixelPerUnit<=0,e=t.pixelPerPercentage<=0;if(!h&&!e)return;const n=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:h?t.pixelPerUnit:void 0,percentage:e?t.pixelPerPercentage:void 0})},r=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,o=this.getDb(),a=()=>{this.chart=new Pt(new D(this.ruleSetConfig),o,this.tableName,t,i),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasWidth());if(!r||r<=0)return h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=50),a(),void n();h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=1),a();let c=l();if(c<=0)return void n();const u=Math.max(B,.9*r/c);let d=!1,f=!1,v=null;for(let i=0;i<=3;i++){const i=W({target:r,measured:c,unitExtent:h?this.chart.getUnitBarExtent():0,pctExtent:e?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(h&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,d=!0),e&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,f=!0),a(),c=l(),c<=r+.5&&(v={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*r))break}let p=!1;if(h&&!d&&(t.pixelPerUnit=u,p=!0),e&&!f&&(t.pixelPerPercentage=u,p=!0),c>r+.5){if(v)d&&(t.pixelPerUnit=v.ppu),f&&(t.pixelPerPercentage=v.ppp);else{const i=r/c;h&&(t.pixelPerUnit=Math.max(B,t.pixelPerUnit*i)),e&&(t.pixelPerPercentage=Math.max(B,t.pixelPerPercentage*i))}p=!0}p&&a(),n()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=G(t,this.tableName,this.filter);return this.measureScaleError=void 0,new rt(new lt,new p(new F),new F,new v,t,i,(t=>{this.measureScaleError=z(t)})).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideCategories:this.hideCategories,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,level:this.level,limit:this.limit,sortOrder:this.order,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,stackConfig:this.stackConfig,sums:this.sums,sumTitle:this.sumTitle,valueSuffix:this.valueSuffix,scenarioLabelTop:this.scenarioLabelTop,hideScenarioName:this.hideScenarioName,referenceLine:this.referenceLine,italicCategories:this.italicCategories})}prepareStyle(){var t,i;const s=new ut(new ft,new r,new o(new N),new I(new N),new a).adapt(this.styles);return s.locale=(null===(i=null===(t=Y(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return this}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"bn-chart-structure-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],scenarios:[16],variances:[16],hideCategories:[4,"hide-categories"],pixelPerUnit:[2,"pixel-per-unit"],pixelPerPercentage:[2,"pixel-per-percentage"],reportAutoScaling:[16],errors:[16],limit:[2],styles:[1040],i18n:[1040],order:[16],level:[1],filter:[1],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],dataFormatDigits:[16],stackConfig:[16],sums:[1],sumTitle:[1,"sum-title"],valueSuffix:[1,"value-suffix"],scenarioLabelTop:[4,"scenario-label-top"],hideScenarioName:[4,"hide-scenario-name"],referenceLine:[16],italicCategories:[16],parentDimensions:[16],ruleSetConfig:[16]}]);function xt(){"undefined"!=typeof customElements&&["bn-chart-structure-renderer"].forEach((t=>{"bn-chart-structure-renderer"===t&&(customElements.get(e(t))||customElements.define(e(t),yt))}))}export{yt as B,xt as d}
|
|
1
|
+
import{p as t,H as i,h as s,d as h,t as e}from"./p-BnmylmXF.js";import{S as n,F as r,a as o,P as a}from"./p-CSJCkHEL.js";import{C as l,A as c,g as u,e as d}from"./p-DguYWLBj.js";import{D as f,b as v}from"./p-keKnrAVS.js";import{c as p,O as m,a as g}from"./p-BBdzTx8V.js";import{S as b}from"./p-CeE4_3wQ.js";import{r as w,F as S,C as P,V as y}from"./p-Zz3fAPcH.js";import{g as x,a as L,I as M}from"./p-4q8nRcWC.js";import{d as k,l as T,S as N}from"./p-DHX92KDP.js";import{N as C,r as $}from"./p-fCjsrD7I.js";import{s as O,c as A,a as E,l as _,b as R,d as W,M as B}from"./p-BTnRaHPb.js";import{I as D,a as j,s as X}from"./p-D0v9GMIf.js";import{d as G,S as V,g as Y}from"./p-5LbdDgZ5.js";import{e as z,r as H}from"./p-ClruFZD_.js";import{S as F}from"./p-Do-IGHJk.js";import{w as U}from"./p-BrQCbmG0.js";import{S as I}from"./p-CJ0-xdfZ.js";import{A as K}from"./p-DsC0ew4j.js";class Z{constructor(t,i,s,h,e,n,r,o,a=!1,l=null){this.categoryPosition={x:0,y:0},this.spacings={scenarioOffset:0,markerOffset:0,scenarioLabelToBar:0,labelToBar:0,labelToAxis:0,needleWidth:0,needleHeadWidth:0,barWidth:0,varianceAxisLineWidth:0,axisLineWidth:0,auxiliaryLineWidth:0,scenarioLineWidth:0,markerWidth:0,categoryWidth:0,axisTickLength:0},this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontSize=s,this.axisPosition={x:0,y:0},this.numberOfColumns=h,this.leftSideLengthSync=e,this.topSideLabelHeight=n>0?this.fontSize:0,this.hasStackedHeaders=a,this.rows=l,this.leftSideLabelLength=this.calculateSideLabelLength(n,r,o),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){if(this.rows&&t<this.rows.start.length){const i=this.rows.start[t]+this.rows.weight[t]/2;return this.getAxisPositionY()+this.spacings.scenarioOffset+i*this.spacings.categoryWidth}return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}isNameBelowBar(){var t;return!!(null===(t=this.rows)||void 0===t?void 0:t.nameBelowBar)}getRowTopPositionY(t){const i=this.rows&&t<this.rows.start.length?this.rows.start[t]:t;return this.getAxisPositionY()+this.spacings.scenarioOffset+i*this.spacings.categoryWidth}getBarWidthAt(t){return this.spacings.barWidth*(this.rows&&t<this.rows.weight.length?this.rows.weight[t]:1)}getBarPositionY(t,i){return i?this.getBarCenterPositionY(t):this.getBarCenterPositionY(t)-this.spacings.scenarioOffset}getCategoryPositionX(t){let i=this.spacings.labelToAxis;return t&&(i=-this.spacings.labelToAxis),this.getAxisPositionX()+i}getAxisTitlePositionX(){return this.axisPosition.x}getAxisTitlePositionY(){return this.axisPosition.y-this.spacings.labelToAxis-this.getTopLabelOverhang()}getStackedHeaderPositionY(){return this.getBarCenterPositionY(0)-.5*this.getBarWidthAt(0)-this.spacings.scenarioLabelToBar}getNeedleWidth(){return this.spacings.needleWidth}getAxisPositionX(){return this.leftSideLabelLength+this.padding.left+this.spacings.labelToAxis}getAxisPositionY(){return this.padding.top+this.getAxisTitleOffset()}loadCategoriesBox(t){this.categoriesBoxOffset=t,this.calculateAxisPosition()}addOffsetByNegativeDataPoints(t,i,s,h){null!=t&&null!=t.value&&t.value<0&&(s&&t.isClipped()?this.axisPosition.x+=Math.abs(t.getClippedValue()*t.pixelPerUnit):this.axisPosition.x+=Math.abs(t.value*t.pixelPerUnit),this.axisPosition.x+=i,this.axisPosition.x+=this.spacings.labelToBar),this.axisPosition.x<h/2&&(this.axisPosition.x=h/2+this.spacings.labelToBar)}getLabelPositionX(t){let i=this.spacings.labelToBar;return t<0&&(i*=-1),this.axisPosition.x+t+i}getLabelPositionY(t){return this.axisPosition.y+t+this.spacings.labelToBar}getCategoryToAxisSpaceing(){return this.spacings.labelToAxis}getCategoryToTopSpaceing(){return this.spacings.scenarioOffset}getCategoryToBottomSpaceing(){return this.spacings.scenarioOffset}getAxisEndPositionY(){const t=this.rows?this.rows.total:this.numberOfColumns;return this.getAxisPositionY()+(t+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){var i;if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return(null===(i=this.rows)||void 0===i?void 0:i.nameBelowBar)?t:Math.max(t,this.spacings.categoryWidth-this.spacings.scenarioOffset+this.spacings.labelToAxis)}return-(.5*this.getBarWidth()+this.spacings.scenarioLabelToBar)}getBarWidth(){return this.spacings.barWidth}getMarkerPositionY(t,i){return i?this.getBarCenterPositionY(t)-this.spacings.markerOffset-.5*this.getBarWidth():this.getBarCenterPositionY(t)+this.spacings.markerOffset+.5*this.getBarWidth()}getMarkerPositionX(){return this.getBarPositionX()}getMarkerScenarioLabelPositionOffsetY(t){return t?-(.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar):this.spacings.scenarioLabelToBar+.5*this.spacings.markerWidth}getAxisEndPositionX(){return this.getAxisPositionX()}calculateSpacings(){this.spacings={scenarioOffset:this.fontSize*this.scaleFactors.scenarioOffset,markerOffset:this.fontSize*this.scaleFactors.markerOffset,scenarioLabelToBar:this.fontSize*this.scaleFactors.scenarioLabelToBar,labelToBar:this.fontSize*this.scaleFactors.labelToBar,labelToAxis:this.fontSize*this.scaleFactors.labelToAxis,needleWidth:this.fontSize*this.scaleFactors.needleWidth,needleHeadWidth:this.fontSize*this.scaleFactors.needleHeadWidth,barWidth:this.fontSize*this.scaleFactors.barWidth,varianceAxisLineWidth:this.fontSize*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontSize*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontSize*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontSize*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontSize*this.scaleFactors.markerWidth,categoryWidth:this.fontSize*this.scaleFactors.categoryWidth,axisTickLength:this.fontSize*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left,y:this.getAxisPositionY()+.5*this.spacings.categoryWidth}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY()}}recalculatePositions(){this.calculateCategoryPosition(),this.calculateAxisPosition()}getAxisTitleOffset(){return this.topSideLabelHeight+this.spacings.labelToAxis+this.getTopLabelOverhang()}getTopLabelOverhang(){return this.hasStackedHeaders?this.getStackedHeaderOverhang():this.getTopScenarioLabelOverhang()}getStackedHeaderOverhang(){return Math.max(0,this.fontSize+this.spacings.scenarioLabelToBar+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}getTopScenarioLabelOverhang(){return Math.max(0,this.fontSize+.5*this.spacings.barWidth+this.spacings.scenarioLabelToBar-.5*this.spacings.categoryWidth,this.fontSize+.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar+this.spacings.markerOffset+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}calculateSideLabelLength(t,i,s){if(this.leftSideLengthSync)return this.leftSideLengthSync;const h=t/2;let e=i;return h>e&&(e=h),s>e&&(e=s),e}}class Q{constructor(t){this.top=t.top,this.bottom=t.bottom,this.left=t.left,this.right=t.right}addBoxTopLeft(t){return this.top+=t.height|this.top,this.left+=t.width|this.top,this}}class q{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t}}class J{constructor(t){this.container=new n,this.pattern=this.createFCPattern(this.container.group(),t),this.styles=t;let i=10;null!=t&&null!=t.fontStyles&&t.fontStyles.size&&(i=t.fontStyles.size),this.bgOffset=(1*i-.7*i)/2}createFCPattern(t,i){const s=i;return t.pattern(10,10,(function(t){t.rect(10,10).fill(s.barStyles.fc.fill),t.line(0,5,5,0).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"}),t.line(5,10,10,5).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"})})).id("pattern-structure-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}var tt,it,st,ht,et;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(tt||(tt={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(it||(it={}));class nt{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.sortOrder=new p(new F).default(),this.level=c.CATEGORY,this.filter="",this.measureScale=new b,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[]}}class rt{constructor(t,i,s,h,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=h,this.db=e,this.fromExpr=n,this.onQueryError=r}adapt(t){const i=K.adaptArray(t.data,this.dataRowAdapter),s=K.adaptArray(t.scenarios,this.stringAdapter),h=new nt(i,s);return l.isArray(t.variances)&&(h.variances=K.adaptArray(t.variances,this.stringAdapter)),l.isString(t.title)&&(h.title=t.title),l.isBoolean(t.hideCategories)&&(h.hideCategories=t.hideCategories),l.isNumber(t.pixelPerUnit)&&(h.pixelPerUnit=t.pixelPerUnit),l.isNumber(t.pixelPerPercentage)&&(h.pixelPerPercentage=t.pixelPerPercentage),l.isNumber(t.limit)&&(h.limit=t.limit),l.isExisting(t.sortOrder)&&(h.sortOrder=this.orderAdapter.adapt(t.sortOrder)),l.isExisting(t.level)&&(h.level=t.level),l.isString(t.filter)&&(h.filter=t.filter.trim()),l.isExisting(t.measureScale)&&(h.measureScale=f.calculateMeasureScale(this.db,this.fromExpr,h.scenarios,t.measureScale,this.onQueryError)),l.isString(t.measureUnit)&&(h.measureUnit=t.measureUnit),l.isBoolean(t.showMeasureScale)&&(h.showMeasureScale=t.showMeasureScale),l.isExisting(t.dataFormatDigits)&&(h.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),l.isExisting(t.stackConfig)&&(h.stackConfig=t.stackConfig),l.isString(t.sums)&&["groups","total","all"].includes(t.sums)&&(h.sums=t.sums),l.isString(t.sumTitle)&&(h.sumTitle=t.sumTitle),l.isString(t.valueSuffix)&&(h.valueSuffix=t.valueSuffix),l.isBoolean(t.scenarioLabelTop)&&(h.scenarioLabelTop=t.scenarioLabelTop),l.isBoolean(t.hideScenarioName)&&(h.hideScenarioName=t.hideScenarioName),l.isExisting(t.referenceLine)&&(h.referenceLine=t.referenceLine),l.isArray(t.italicCategories)&&(h.italicCategories=K.adaptArray(t.italicCategories,this.stringAdapter)),h}default(){return new nt([],[])}}class ot{constructor(t,i,s,h){this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const e="string"==typeof h?w(h,null,!0):h;this.variance="neg"===e||e===st.NEG?st.NEG:"pos"===e||e===st.POS?st.POS:st.NEU}isEmpty(){return null==this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:Math.abs(this.value)>1.45?this.value>=0?1.45*this.pixelPerUnit:-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:st.NEU===this.variance?st.NEU:st.POS===this.variance?st.NEG:st.POS}isClipped(){return null!=this.value&&Math.abs(this.value)>1.45}getClippedValue(){return 145}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class at{constructor(){this.operation="+"}addRowGroup(t,i){this.rowGroup=t,this.rowGroupIndex=i}addCategory(t,i){this.category=t,this.categoryIndex=i}addSubCategory(t,i){this.subCategory=t,this.subCategoryIndex=i}addColumnGroup(t,i){this.columnGroup=t,this.columnGroupIndex=i}addSubColumnGroup(t,i){this.columnSubGroup=t,this.columnSubGroupIndex=i}}class lt{constructor(){}adapt(t){const i=new at;return l.isOperator(t.operation)&&(i.operation=t.operation),l.isNumber(t.rowGroupIndex)&&l.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),l.isNumber(t.categoryIndex)&&l.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),l.isNumber(t.subCategoryIndex)&&l.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),l.isNumber(t.columnGroupIndex)&&l.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),l.isNumber(t.columnSubGroupIndex)&&l.isString(t.columnSubGroup)&&i.addSubColumnGroup(t.columnSubGroup,t.columnSubGroupIndex),this.setActualValues(t,i),this.setPlanValues(t,i),this.setPreviousPeriodValues(t,i),this.setForecastValues(t,i),i}default(){return new at}setActualValues(t,i){l.isNumber(t.ac1)&&(i.ac1=t.ac1),l.isNumber(t.ac2)&&(i.ac2=t.ac2),l.isNumber(t.ac3)&&(i.ac3=t.ac3),l.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){l.isNumber(t.pl1)&&(i.pl1=t.pl1),l.isNumber(t.pl2)&&(i.pl2=t.pl2),l.isNumber(t.pl3)&&(i.pl3=t.pl3),l.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){l.isNumber(t.pp1)&&(i.pp1=t.pp1),l.isNumber(t.pp2)&&(i.pp2=t.pp2),l.isNumber(t.pp3)&&(i.pp3=t.pp3),l.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){l.isNumber(t.fc1)&&(i.fc1=t.fc1),l.isNumber(t.fc2)&&(i.fc2=t.fc2),l.isNumber(t.fc3)&&(i.fc3=t.fc3),l.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class ct{constructor(t,i,s,h,e,n){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=h,this.varianceStyles=e,this.padding=n,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"],this.titleBold=!1,this.valueSuffix="",this.locale="de"}}class ut{constructor(t,i,s,h,e){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=h,this.paddingadapter=e}adapt(t){const i=new ct(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return l.isExisting(t)&&(l.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),l.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),l.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),l.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),l.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),l.isExisting(t.padding)&&(i.padding=this.paddingadapter.adapt(t.padding)),Array.isArray(t.stackColors)&&t.stackColors.length>0&&(i.stackColors=t.stackColors),i.titleBold=!0===t.titleBold,i.pattern=new q(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new ct(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class dt{constructor(){this.scenarioOffset=.3,this.scenarioLabelToBar=.1,this.labelToBar=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.barWidth=1.2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=1.9,this.axisTickLength=.3}}class ft{adapt(t){const i=new dt;return l.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),l.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),l.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),l.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),l.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),l.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),l.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),l.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),l.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),l.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),l.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),l.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),l.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),l.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),l.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new dt}}!function(t){t.AC1="ac1",t.PP1="pp1",t.FC1="fc1",t.PL1="pl1",t.AC2="ac2",t.PP2="pp2",t.FC2="fc2",t.PL2="pl2",t.AC3="ac3",t.PP3="pp3",t.FC3="fc3",t.PL3="pl3",t.AC4="ac4",t.PP4="pp4",t.FC4="fc4",t.PL4="pl4",t.POS="pos",t.NEG="neg",t.NEU="neu"}(st||(st={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(ht||(ht={})),function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right",t[t.Top=3]="Top",t[t.Bottom=4]="Bottom"}(et||(et={}));class vt{constructor(t,i,s,h,e,n,r,o){this.group=null,this.segmentFillColor=null,this.maxWidth=null,this.bold=!1,this.italic=!1,this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.pointPart="label",this.x=i,this.y=s,this.value=e,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),h))),this.styles=n,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=r||et.Top,this.horizontalHookLocation=o||et.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setEmphasis(t,i){return this.bold=t,this.italic=i,this}setMaxWidth(t){return this.maxWidth=t,this}setPoint(t,i="label"){return this.pointKey=t,this.pointPart=i,this}updateGroup(t){return this.group=t,this}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}draw(t={percent:2,decimal:1},i=new b){var s,h,e,n;if(this.isEmpty())return this;const r=this.group;let o;const a=this.styles.fontStyles.background||"#ffffff";let l="";if(!1===Number.isNaN(Number(this.value))){let h=t.percent,e=t.percent,n=1,r="percent";!1===this.isRelativeLabel&&(h=t.decimal,e=t.decimal,n=i.value,r="decimal"),o=S.number(Number(this.value),r,h,e,n,this.styles.locale);const a=S.number(0,r,h,e,n,this.styles.locale);this.isVarianceLabel&&Number(this.value)>0&&o!==a&&(l="+"),"number"!=typeof this.value||this.isVarianceLabel||this.isRelativeLabel||(o+=null!==(s=this.styles.valueSuffix)&&void 0!==s?s:"")}else o=""+this.value;const c=r.text(l+o);(null===(h=this.styles.fontStyles)||void 0===h?void 0:h.size)&&c.attr("font-size",this.styles.fontStyles.size),(null===(e=this.styles.fontStyles)||void 0===e?void 0:e.family)&&c.attr("font-family",this.styles.fontStyles.family),this.bold&&c.font({weight:"bold"}),this.italic&&c.font({style:"italic"}),c.move(this.x,this.y);const u=c.bbox(),d=u.w,f=u.h;if(null!=this.maxWidth&&d>this.maxWidth)return null===(n=this.group)||void 0===n||n.remove(),this.group=null,this;let v="start";return this.horizontalHookLocation===et.Right?(v="end",c.move(c.x()-c.length(),c.y())):this.horizontalHookLocation===et.Center&&(v="middle",c.move(c.x()-c.length()/2,c.y())),this.verticalHookLocation===et.Center?c.move(c.x(),c.y()-f/2):this.verticalHookLocation===et.Bottom&&c.move(c.x(),c.y()-f),c.font({anchor:v}),null!=this.segmentFillColor?c.fill(x(this.segmentFillColor)):null==r||r.rect(d,.9*f).stroke(a).fill(a).opacity(.7).move(c.x(),c.y()+.1*f).insertBefore(c),this.pointKey&&(null==r||r.attr(k(this.pointKey,this.pointPart))),this}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}class pt{constructor(t,i,s,h){this.height=0,this.ID_AXIS="axis",this.ID_AXIS_TITLE="axis-title",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.position=i,this.style=h,this.label=new vt(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,et.Bottom,et.Center).setEmphasis(this.style.titleBold,!1),this.svgGroup=s.group().id(this.ID_AXIS)}draw(){return this.labelText&&this.label.draw(),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(),this.position.getAxisEndPositionX(),this.position.getAxisEndPositionY()).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this.height=this.svgGroup.height(),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class mt{constructor(t,i,s,h,e,n,r,o=null){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.barGroup=null,this.isVarianceBar=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveWidth=0,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.isPrimaryBar=e,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=n,this.styles=i,null!=n&&(this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=et.Left;s.value<0&&(i=et.Right),this.dimensions=this.createDimensions(t,s,h,e),this.label=new vt(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,et.Center,i).setPoint(s.key),this.scenarioLabel=this.getScenarioLabel(r)}}setAsVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}isRelativeVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToRelativeVarianceLabel(),this}emphasize(){var t;return null===(t=this.label)||void 0===t||t.setEmphasis(!0,!1),this}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new b){var s,h,e;if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let n=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(n=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const r=this.convertToSVGStyle(n,"stroke");let o=this.convertToSVGStyle(n,"fill");const a=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=a){const t=this.styles.pattern.get(a);null!=t&&(o=t.pattern)}null===(s=this.scenarioGroup)||void 0===s||s.attr(k(this.dataPoint.key)),null===(h=this.barGroup)||void 0===h||h.attr(k(this.dataPoint.key,"element")),this.isVarianceBar||null===(e=this.barGroup)||void 0===e||e.attr("data-bn-value",this.dataPoint.value),null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(o,r):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(o).stroke(r).cy(this.dimensions.yPos).x(this.dimensions.xPos)),this.drawBarDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.barGroup||!this.overflowConfig)return;const s=this.position.getBarPositionX(),h=this.position.getBarWidth(),e=this.dimensions.barLength,{breakGap:n}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(e,h).fill(t).stroke(i).x(s-e).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s-e-n-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-e-n,n)):(this.barGroup.rect(e,h).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s+e+n).cy(this.dimensions.yPos),this.drawBreakIndicator(s+e,n))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),h=this.dimensions.yPos-s/2,e=t+i/2,n=.35*i,r=s/3;let o=`M ${e-n} ${h}`;for(let t=0;t<3;t++)o+=` L ${e-n-.3*i} ${h+r*(t+.5)} L ${e-n} ${h+r*(t+1)}`;let a=`M ${e+n} ${h}`;for(let t=0;t<3;t++)a+=` L ${e+n+.3*i} ${h+r*(t+.5)} L ${e+n} ${h+r*(t+1)}`;this.barGroup.rect(i,s+2).fill("#ffffff").stroke("none").x(t).cy(this.dimensions.yPos),this.barGroup.path(o).fill("none").stroke({color:"#000000",width:1}),this.barGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,h){const e=i.getScaledUnit(),n=Math.abs(e);if(this.overflowConfig&&n>0){const r="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(n>r){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:o,maxOverflow:a}=this.overflowConfig;this.overdriveWidth=a>0?(n-r)/a*o:0;const l=r+i+this.overdriveWidth;return e<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()-r,yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:r,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}}}return e<0?{clipped:!1,barLength:n,xPos:t.getBarPositionX()+e,yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()-.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:e,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()+.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){if(null!=this.scenarioLabel&&!this.scenarioLabel.isEmpty()&&!this.isVarianceBar){let t=this.dimensions.scenarioLabelXPos;if(this.nameBesideAxis()){const i=this.dataPoint.getScaledUnit()<0?-1:1;t=this.position.getBarPositionX()+i*this.position.spacings.labelToAxis}this.scenarioLabel.setPos(t,this.dimensions.scenarioLabelYPos).draw()}}nameBesideAxis(){return this.isPrimaryBar&&this.position.isNameBelowBar()}drawBarDataLabel(t,i=new b){var s;this.isPrimaryBar&&(null===(s=this.label)||void 0===s||s.draw(t,i))}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getScenarioLabel(t){if(this.isPrimaryBar){let i=et.Center;return this.nameBesideAxis()&&(i=this.dataPoint.getScaledUnit()<0?et.Right:et.Left),new vt(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,et.Top,i)}return new vt(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,et.Bottom,et.Center)}}class gt{constructor(t,i,s,h,e,n,r,o,a){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=e,this.barStyles=e?e.barStyles:null,this.scenario=h,!0!==(null==n?void 0:n.isEmpty())&&(this.hasData=!0,this.pointKey=n.key,this.dimensions=this.createMarkerDimensions(n,r,a),this.scenarioLabel=this.getScenarioLabel(o,e,a))}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelXPos:0,barLength:Math.abs(t.getScaledUnit()),xPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}:{clipped:!1,labelXPos:0,barLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX()+t.getScaledUnit(),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()+t.getScaledUnit(),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new vt(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?et.Bottom:et.Top,et.Center)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}draw(){if(this.isEmpty())return this;const t=this.convertToSVGStyle(this.barStyles[this.getScenario()],"stroke");let i=this.convertToSVGStyle(this.barStyles[this.getScenario()],"fill");const s=this.barStyles[this.getScenario()];if(null!=s&&s.fillpattern){const t=this.styles.pattern.get(s.fillpattern);null!=t&&(i=t.pattern)}return this.markerGroup.attr(k(this.pointKey)),this.markerGroup.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos).cx(this.dimensions.xPos).attr(k(this.pointKey,"element")),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class bt{constructor(t,i,s,h,e){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=e,this.styles=i,this.barGroup=e.group().id(e.toString()+"_"+this.ID_RECT);const n=void 0===(null==s?void 0:s.value)&&null!=(null==s?void 0:s.scenario);if(!0!==(null==s?void 0:s.isEmpty())&&null!=s.value||n){this.hasData=!0,this.dimensions=this.createDimensions(t,s,h);let i=et.Left;s.value<0&&(i=et.Right),this.label=new vt(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,n?C:s.value,this.styles,et.Center,i),this.label.setToRelativeVarianceLabel().setPoint(s.key)}}emphasize(){var t;return null===(t=this.label)||void 0===t||t.setEmphasis(!0,!1),this}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1}){var i,s,h;if(void 0===(null===(i=this.dataPoint)||void 0===i?void 0:i.value))return null===(s=this.label)||void 0===s||s.draw(t),this;if(this.isEmpty())return this;if(null==this.dimensions)return this;this.scenarioGroup.attr(k(this.dataPoint.key)),this.barGroup.attr(k(this.dataPoint.key,"element"));const e=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),n=e.stroke;let r=e.fill;const o=this.barStyles[this.dataPoint.getScenario()];if(null!=o&&o.fillpattern){const t=this.styles.pattern.get(o.fillpattern);null!=t&&null!=t.pattern&&(r=t.pattern)}this.drawNeedleHead(r,n),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(r).stroke(n).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(h=this.label)||void 0===h||h.draw(t)}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{barLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getBarPositionX()+i.getScaledPercentUnit(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()-this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}:{barLength:i.getScaledPercentUnit(),xPos:t.getBarPositionX(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()+this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}}drawNeedleHead(t,i){if(null===this.dimensions)return;const s=this.styles.varianceStyles.needleHeadColour,h=this.styles.varianceStyles.needleHeadColour;if(this.dimensions.clipped){let s="13,0 4,-5 4,5 13,0 8,0 0,-5 0,5 8,0";null!=this.dataPoint.value&&this.dataPoint.value<0&&(s="0,0 9,-5 9,5 0,0 5,0 13,-5 13,5 5,0"),this.barGroup.polygon(s).fill(t).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(t).stroke(i)}else this.barGroup.rect(2*this.position.getNeedleWidth(),2*this.position.getNeedleWidth()).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(s).stroke(h)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadXPosition(){let t=this.dimensions.xPos;return null!=this.dataPoint.value&&this.dataPoint.value>0&&(t+=this.dimensions.barLength),t}}class wt{constructor(t,i,s,h,e,n,r,o,a,l,c,u={}){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=h,this.segment=e,this.segmentIndex=r,this.stackMode=o,this.stack=a,this.options=u,this.group=c,this.barGroup=c.group().id(`stacked_bar_${h}_seg_${r}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new b){var s;if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const h=this.dataPoint.value,e=this.dataPoint.pixelPerUnit,n=this.position.getBarPositionX(),r=this.position.getBarWidthAt(this.index),o=Math.abs(this.segment.end-this.segment.start)*e,a=n+Math.min(this.segment.start,this.segment.end)*e,l=this.position.getBarPositionY(this.index,!0),c=this.styles.stackColors,d=c[this.segmentIndex%c.length],f={color:d},v={color:d,width:.5};this.barGroup.attr(k(this.dataPoint.key,"element")),this.barGroup.attr("data-bn-value",h),this.barGroup.rect(Math.max(o,.5),r).fill(f).stroke(v).cy(l).x(a);const p=o-Math.min(6,.375*this.styles.fontStyles.size),{bold:m=!1,italic:g=!1}=this.options,w=this.stackMode===u.RELATIVE&&null!==(s=this.options.label)&&void 0!==s?s:"share";if(p>0){const s=a+o/2;if(this.stackMode!==u.RELATIVE&&this.stackMode!==u.ABSOLUTE_RELATIVE||"value"===w)new vt(this.group,s,l,"STACK_SEG",h,this.styles,et.Center,et.Center).setSegmentFill(d).setEmphasis(m,g).setMaxWidth(p).setPoint(this.dataPoint.key).draw(t,i);else{const i="plain-share"===w?S.number(100*this.segment.share,"decimal",t.percent,t.percent,1,this.styles.locale):S.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);new vt(this.group,s,l,"STACK_SEG",i,this.styles,et.Center,et.Center).setSegmentFill(d).setEmphasis(m,g).setMaxWidth(p).setPoint(this.dataPoint.key).draw()}}}drawTotalLabel(t={percent:2,decimal:1},i=new b,s){var h,e;if(this.stackMode===u.RELATIVE&&!this.options.total)return;const n=this.stack.total<0,r=this.position.getLabelPositionX((n?0-this.stack.negative:this.stack.positive)*this.dataPoint.pixelPerUnit),o=this.position.getBarPositionY(this.index,!0);new vt(this.group,r,o,"STACK_TOTAL",this.stack.total,this.styles,et.Center,n?et.Right:et.Left).setEmphasis(null!==(h=this.options.bold)&&void 0!==h&&h,null!==(e=this.options.italic)&&void 0!==e&&e).setPoint(s,"total").draw(t,i)}}class St{constructor(t,i,s,h,e){this.overflowConfig=null,this.i18n=e;const n=i.group().id("Scenario1"),r=i.group().id("Scenario2").insertBefore(n);this.svgGroups={parent:i,scenario1:n,scenario2:r,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=h}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new mt(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o)}createVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new mt(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o).setAsVariance()}createRelativeVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);return new bt(this.position,this.styles,t,i,r).updateLabelGroup(o)}createSecondaryBar(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===h?void 0:h.group().id(""+i);let n=null;return this.isFirsttDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new mt(this.position,this.styles,t,i,!1,e,n,this.overflowConfig)}createPrimaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-down")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isFirstDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new gt(this.position,e,n,t.scenario,this.styles,t,i,r,!0)}createSecondaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-up")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isLastDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new gt(this.position,e,n,t.scenario,this.styles,t,i,r,!1)}isFirstDataPoint(t){return 0===t}}class Pt{constructor(t,i,s,h,e){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new ot(0,st.AC1,1,st.NEU),this.highestDataPointValue=new ot(0,st.AC1,1,st.NEU),this.smallestVarianceDataPointValue=new ot(0,st.AC1,1,st.NEU),this.highestVarianceDataPointValue=new ot(0,st.AC1,1,st.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.level=c.CATEGORY,this.hideCategories=!1,this.axisScenario=st.AC1,this.CSS_CATEGORIES="categories",this.state=tt.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new b,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.scenarioPropOrder=[],this.overflowConfig=null,this.stackSides=O([]),this.stackLabelClearance={left:0,right:0},this.fromExpr="",this.rowCount=0,this.sums="none",this.sumTitle="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[],this.db=i,this.tableName=s,this.ruleSet=t||new D,this.i18n=this.createI18n(new Map),this.styles=e,this.setConfig(h),this.position=this.createElementPosition()}updatePosition(){this.position=this.createElementPosition()}createElementPosition(){this.titleLength=this.calculateTitleLength(0);let t=this.calculateLeftSideWidth(this.getVarianceType());const i=this.calculateCategoryWidth();return this.titleLength>t&&(t=this.titleLength),new Z(new Q(this.styles.padding),this.styles.scaleFactors,this.styles.fontStyles.size,this.dataModel.length,this.leftSideOffsetForHorizontalSync,this.titleLength,t,i,!!this.stackConfig&&0===this.variancesDataModel.length||this.scenarioLabelTop,this.rowLayout())}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new D}setConfig(t){var i,s;this.state=tt.DIRTY,this.scenarioPropOrder=[...t.scenarios];const h=this.sortScenariosbyVisualisationRules(t.scenarios);this.hideCategories=t.hideCategories||!1,this.limit=t.limit,this.pixelPerUnit=t.pixelPerUnit||1,this.pixelPerPercentage=t.pixelPerPercentage||100,this.setSource(t.filter),this.level=t.level,this.sums=t.sums,this.sumTitle=t.sumTitle,this.styles.valueSuffix=t.valueSuffix,this.scenarioLabelTop=t.scenarioLabelTop,this.hideScenarioName=t.hideScenarioName,this.referenceLine=t.referenceLine,this.italicCategories=t.italicCategories,this.dataModel=this.populateModel(h,t.level,t.sortOrder),t.stackConfig&&t.stackConfig.by!==d.SCENARIOS&&this.populateDimensionStackSegments(h,t.stackConfig,t.level),this.addSumRows(h);for(const t of this.dataModel)for(const s of[t.scenario1,t.scenario2,t.scenario3,t.scenario4])null==s.value||Number.isNaN(s.value)||(s.key=Object.assign(Object.assign({},T(this.level,t.category)),{scenario:null!==(i=s.scenario)&&void 0!==i?i:void 0}));this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(s=null==t?void 0:t.variances)&&void 0!==s?s:[],this.updateTitle();const e=this.dataModel.filter((t=>!t.sum));this.smallestDataPointValue=this.findSmallestDataPointValue(e),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(e),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.stackConfig=t.stackConfig,this.measureStacks(),this.updatePosition()}sortScenariosbyVisualisationRules(t){const i=this;return[...t].sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t),this.updateTitle()}updateTitle(){var t;this.title=this.configTitle||S.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=tt.DIRTY;const i=new Map([["SEPARATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["category"," "],["operation"," "],["thereof","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return new Map([...i,...t])}setSource(t){var i,s;if(this.state=tt.DIRTY,this.queryError=void 0,this.fromExpr=G(this.db,this.tableName,t),this.fromExpr)try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(s=null===(i=t[0])||void 0===i?void 0:i.cnt)&&void 0!==s?s:0}catch(t){this.rowCount=0,this.failQuery(t)}else this.rowCount=0}getQueryError(){return this.queryError}failQuery(t){var i;null!==(i=this.queryError)&&void 0!==i||(this.queryError=z(t))}getUnitBarExtent(){var t,i,s,h;const e=this.isStacked(),n=this.getVarianceType(),r=n!==it.NONE,o=r?this.highestVarianceDataPointValue:this.highestDataPointValue,a=r?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return A({fixedDomain:e?this.stackSides.positive+this.stackSides.negative:void 0,relativeVariance:n===it.RELATIVE,maxPositive:Math.max(null!==(t=null==o?void 0:o.value)&&void 0!==t?t:0,e||r?0:null!==(s=null===(i=this.referenceLine)||void 0===i?void 0:i.value)&&void 0!==s?s:0),minNegative:null!==(h=null==a?void 0:a.value)&&void 0!==h?h:0})}getPercentBarExtent(){var t,i,s,h;return E({relativeVariance:this.getVarianceType()===it.RELATIVE,maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:null!==(h=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==h?h:0})}getAllocatedCanvasWidth(){const t=this.position.getAxisPositionX(),i=this.calculateRightSideWidth(this.getVarianceType());let s=t+i+ +this.styles.padding.left+this.styles.padding.right;return i<this.titleLength/2&&(s+=this.titleLength/2),t<this.titleLength/2&&(s+=this.titleLength/2),s}getAllocatedCanvasHeight(){return this.position.getAxisEndPositionY()+this.position.spacings.labelToAxis+this.position.fontSize+(this.hasPercentMark()?.8*this.position.fontSize:0)+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}layout(){this.draw(new n)}toString(){const t=new n;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.svg()}applyFontToContainer(t){t.attr({"font-size":this.styles.fontStyles.size,"font-family":this.styles.fontStyles.family})}draw(t){this.cleanSVGforRedraw(t),this.applyFontToContainer(t),this.state===tt.DIRTY&&(this.state=tt.UP_TO_DATE),this.variancesDataModel&&this.variancesDataModel.length>0?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t,!0),this.drawPercentMark(t)):(this.drawScenarios(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)),0===this.variancesDataModel.length&&this.drawReferenceLine(t)}setPattern(t,i){this.styles.pattern.set(t,i)}calculateTitleLength(t){const i=P(this.title.length>7?this.title:"_______",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:this.styles.titleBold?"bold":"normal"}).width;return i<t?t:i/2}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":S.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}scenarioStyles(){const t=j(this.styles.barStyles,this.ruleSet);return t===this.styles.barStyles?this.styles:Object.assign(Object.create(Object.getPrototypeOf(this.styles)),this.styles,{barStyles:t})}setAxisScenario(t){let i=st.AC1;if(null!=t&&t.length>0){const s=new y(t.toString());s.isValid&&(i=X(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=st.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const h=[],e=this.createOrderStr(i,s),n=this.createSelectString(i,s),r=this.createGroupByStr(i,s);let o;try{o=this.db.exec(`SELECT ${n} ${t.length>0?","+t.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(","):""}\n FROM ${this.fromExpr}\n GROUP BY ${r}\n ORDER BY ${e}`)}catch(t){return this.failQuery(t),[]}return this.detectNaNCells(t,o),this.createDataRows(this.limit>0?o.slice(0,this.limit):o,h,t),this.crateRESTRow(o,t,h),h}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new y(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}crateRESTRow(t,i,s){if(this.limit<=0||this.limit>=t.length)return;const h=[];this.createDataRows(t.slice(this.limit),h,i);const e=(t,i)=>Number.isFinite(i)?(Number.isFinite(t)?t:0)+i:t,n=h.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new ot(e(t.scenario1.value,s.scenario1.value),i[0],t.scenario1.pixelPerUnit,st.NEU),scenario2:new ot(e(t.scenario2.value,s.scenario2.value),i[1],t.scenario2.pixelPerUnit,st.NEU),scenario3:new ot(e(t.scenario3.value,s.scenario3.value),i[2],t.scenario3.pixelPerUnit,st.NEU),scenario4:new ot(e(t.scenario4.value,s.scenario4.value),i[3],t.scenario4.pixelPerUnit,st.NEU)}}),{id:9999,category:"REST",type:it.NONE,scenario1:new ot(NaN,i[0],this.pixelPerUnit,st.NEU),scenario2:new ot(NaN,i[1],this.pixelPerUnit,st.NEU),scenario3:new ot(NaN,i[2],this.pixelPerUnit,st.NEU),scenario4:new ot(NaN,i[3],this.pixelPerUnit,st.NEU)});s.push(n)}createDataRows(t,i,s){t.forEach(((t,h)=>{i.push({id:h,category:t.category,type:it.NONE,scenario1:new ot(t[s[0]],s[0],this.pixelPerUnit,st.NEU),scenario2:new ot(t[s[1]],s[1],this.pixelPerUnit,st.NEU),scenario3:new ot(t[s[2]],s[2],this.pixelPerUnit,st.NEU),scenario4:new ot(t[s[3]],s[3],this.pixelPerUnit,st.NEU)})}))}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=i.hierarchy.map((t=>`${t} ${i.direction}`)).toString()),s}createSelectString(t,i){return t===c.CATEGORY&&i.hierarchy.includes(m.CATEGORYINDEX)?`${m.CATEGORYINDEX}, ${c.CATEGORY} as category`:t===c.ROWGROUP&&i.hierarchy.includes(m.ROWGROUPINDEX)?`${m.ROWGROUPINDEX}, ${c.ROWGROUP} as category`:t===c.SUBCATEGORY&&i.hierarchy.includes(m.SUBCATEGORYINDEX)?`${m.SUBCATEGORYINDEX}, ${c.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===c.CATEGORY&&i.hierarchy.includes(m.CATEGORYINDEX)?`${m.CATEGORYINDEX}, ${c.CATEGORY}`:t===c.ROWGROUP&&i.hierarchy.includes(m.ROWGROUPINDEX)?`${m.ROWGROUPINDEX}, ${c.ROWGROUP}`:t===c.SUBCATEGORY&&i.hierarchy.includes(m.SUBCATEGORYINDEX)?`${m.SUBCATEGORYINDEX}, ${c.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=P(i.category,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"});s.width>t&&(t=s.width)}return 1.1125*t}findSmallestDataPointValue(t){let i=new ot(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value<i.value&&(i=t);return i}findHighestDataPointValue(t){let i=new ot(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value>i.value&&(i=t);return i}stackGroups(t){if(!this.stackConfig)return[];const i=this.stackConfig.by===d.SCENARIOS;let s=[];for(const h of i?["scenario1","scenario2","scenario3","scenario4"]:["scenario1"]){const i=t[h];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===s.length)return[];const h=this.stackConfig.mode===u.RELATIVE?1:0,e=(t,i)=>({prefix:t,segments:i,layout:_(i.map((t=>t.value)),h),hasValue:i.some((t=>Number.isFinite(t.value)))});if(i){this.sortSegmentsByPropOrder(s);const t=new Map;for(const i of s){const s=L(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of M)t.has(s)&&(i.push(e(s,t.get(s))),t.delete(s));for(const[s,h]of t)i.push(e(s,h));return i}}else t.stackSegments&&t.stackSegments.length>0&&(s=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint}))));const n=t=>Number.isFinite(t.value)?t.value:0;return"asc"===this.stackConfig.order?s.sort(((t,i)=>n(t)-n(i))):"desc"===this.stackConfig.order&&s.sort(((t,i)=>n(i)-n(t))),[e("",s)]}measureStacks(){const t=[];this.stackLabelClearance={left:0,right:0};for(const i of this.dataModel){const{flipped:s,clearance:h}=this.stackLabelPlace(i),e=this.drawnStackLayouts(i),n=s?"right":"left";this.stackLabelClearance[n]=Math.max(this.stackLabelClearance[n],h),t.push(...e)}this.stackSides=O(t)}stackLabelPlace(t){const i=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;return R(this.drawnStackLayouts(t),(t=>{var s;return(null===(s=this.stackConfig)||void 0===s?void 0:s.mode)===u.RELATIVE&&"value"!==this.stackConfig.labels?0:(i+this.calculateTotalLabelWidth(t.total))/this.pixelPerUnit}))}drawnStackLayouts(t){return this.isTextSum(t)?[]:this.stackGroups(t).filter((t=>t.hasValue)).map((t=>t.layout))}calculateTotalLabelWidth(t){const i=this.dataFormatDigits.decimal;return P(S.number(t,"decimal",i,i,this.measureScale.value,this.styles.locale)+this.styles.valueSuffix,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}isStacked(){return null!=this.stackConfig&&this.stackSides.positive+this.stackSides.negative>0}populateVarianceModel(t,i){const s=[];if(0===t.length)return s;let h=null;null!=i&&i.length>0&&(h=i[0]);for(const e in t){const n=new y(t[e]);if(n.isValid){const r=this.mapScenarios(n,h),o=n.direction;let a=this.pixelPerUnit;"dr"===n.type&&(a=this.pixelPerPercentage);for(const h in i){const l=new ot(this.calculateVariance(n,i[h],r),n.base,a,o);null===l.value||Number.isNaN(l.value)||(l.key=Object.assign(Object.assign({},T(this.level,i[h].category)),{scenario:t[e]})),s.push({id:Number(h),category:i[h].category,type:"dr"===n.type?it.RELATIVE:it.ABSOLUTE,scenario1:l,scenario2:new ot(null,null,null,null),scenario3:new ot(null,null,null,null),scenario4:new ot(null,null,null,null),sum:i[h].sum})}}}return s}calculateVariance(t,i,s){const h=s.get(t.base),e=s.get(t.delta);return null==h||null==e?null:t.type===it.RELATIVE?$(i[h].value-i[e].value,i[e].value):i[h].value-i[e].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((h=>{i[h].scenario===t.delta?s.set(t.delta,h):i[h].scenario===t.base&&s.set(t.base,h)})),s}calculateTextBoxWidth(t,i=!1){const s=i?"":this.styles.valueSuffix;return P(S.number(t,"decimal",1,0,1,this.styles.locale)+s,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}calculatePercentageTextBoxWidth(t){let i=0;const s=this.dataFormatDigits.percent,h=t=>S.number(t,"percent",s,s,1,this.styles.locale);return t>0&&h(t)!==h(0)&&(i+=P("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=P(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,P(S.number(t,"decimal",1,1,1,this.styles.locale),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width+i+i}cleanSVGforRedraw(t){t.clear()}drawAxisAndLabels(t,i,s=!1){const h=i.group().id("AxisAndDateLables");let e=!1;this.hideCategories||t.forEach(((t,i)=>{var n;t.type===it.RELATIVE&&(e=!0);let r=et.Right,o=!0,a=0;if(s){const i=this.stackLabelPlace(t);o=!i.flipped,a=i.clearance*this.pixelPerUnit*(i.flipped?1:-1)}else t.scenario1.value<0&&!this.hasSumNumbers(this.dataModel[i])&&(o=!1);o||(r=et.Left),new vt(h,this.position.getCategoryPositionX(o)+a,this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,et.Center,r).setEmphasis(!!(null===(n=this.dataModel[i])||void 0===n?void 0:n.sum),this.isItalic(t.category)).draw()})),t.forEach(((t,i)=>{const s=this.dataModel[i];if(!(null==s?void 0:s.sum))return;const e=this.position.getBarCenterPositionY(i)-this.position.spacings.categoryWidth/2,n=this.hideCategories?this.position.getAxisPositionX():this.styles.padding.left;h.line(n,e,this.position.getAxisPositionX()+this.sumRowExtent(s),e).stroke({color:"#000000",width:Math.max(.5,this.position.spacings.axisLineWidth/2)}).addClass("sum-line")})),new pt({scenarioType:this.axisScenario,labelText:this.title,isRelative:e},this.position,h,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios");let h=-1;t.forEach(((t,i)=>{t.sum||(h=i)}));const e=new St(this.position,s,this.scenarioStyles(),this.scenarioLabelTop?0:h+1,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.sum?this.drawSumValue(t,i,s):(e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),e.createSecondaryBar(t.scenario2,i).draw(),e.createPrimaryMarker(t.scenario3,i).draw(),e.createSecondaryMarker(t.scenario4,i).draw())}));const n=t.find((t=>!t.sum));if(this.scenarioLabelTop&&n&&!n.scenario1.isEmpty()&&null!=n.scenario1.scenario){const t=n.scenario1.scenario;new vt(s,this.position.getBarPositionX()+this.position.spacings.labelToAxis,this.position.getStackedHeaderPositionY(),"SCENARIO_HEADER",this.i18n.get(t)||t,this.styles,et.Bottom,et.Left).draw()}}sumPoints(t){const i=[t.scenario1,t.scenario2,t.scenario3,t.scenario4].filter((t=>null!=t&&!t.isEmpty()&&Number.isFinite(t.value))),s=this.scenarioPropOrder,h=t=>{const i=s.indexOf(t.scenario);return-1===i?s.length:i};return i.sort(((t,i)=>h(t)-h(i)))}hasSumNumbers(t){return!!(null==t?void 0:t.sum)&&0===this.variancesDataModel.length&&!this.stackConfig&&this.sumPoints(t).length>1}sumValuesWidth(t){const i=this.styles.fontStyles.size,s=i*this.styles.scaleFactors.labelToBar,h=this.sumPoints(t);if(0===h.length)return 0;const e=h.map((t=>this.boldWidth(this.sumText(t.value))));return 1===h.length?s+e[0]:s+e.reduce(((t,s)=>t+.9*i+s),0)+(h.length-1)*i*1.4}drawSumValue(t,i,s){const h=this.sumPoints(t);if(0===h.length)return;const e=this.styles.fontStyles.size,n=this.position.getBarCenterPositionY(i),r=s.group().id(`sum_${i}`),o=(t,i,s)=>{new vt(r,i,n,`SUM_${t.scenario}`,t.value,this.styles,et.Center,s).setEmphasis(!0,!1).setPoint(t.key).draw(this.dataFormatDigits,this.measureScale)};if(1===h.length){const t=h[0].value<0;return void o(h[0],this.position.getLabelPositionX(t?-1e-6:0),t?et.Right:et.Left)}const a=.6*e,l=this.scenarioStyles().barStyles;let c=this.position.getLabelPositionX(0);for(const t of h){const i=l.getSVGStyle(t.getScenario());r.rect(a,a).fill({color:(null==i?void 0:i.fill)||"#000000"}).stroke({color:(null==i?void 0:i.stroke)||"#000000",width:1}).cy(n).x(c),o(t,c+a+.3*e,et.Left),c+=.9*e+this.boldWidth(this.sumText(t.value))+1.4*e}}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),h=new St(this.position,s,this.scenarioStyles(),t.length,this.i18n);return h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{if(t.type===it.RELATIVE){const s=h.createRelativeVarianceBar(t.scenario1,i);t.sum&&s.emphasize(),s.draw(this.dataFormatDigits)}else{const s=h.createVarianceBar(t.scenario1,i);t.sum&&s.emphasize(),s.draw(this.dataFormatDigits,this.measureScale)}})),s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const h=i.indexOf(t.scenario),e=i.indexOf(s.scenario);return(-1===h?i.length:h)-(-1===e?i.length:e)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),h=this.stackConfig.by===d.SCENARIOS,e=this.stackConfig.mode===u.RELATIVE&&"value"===this.stackConfig.labels,n=e?"value":this.stackConfig.percentMark?"plain-share":"share";t.forEach(((t,i)=>{const r=this.stackGroups(t);if(this.isTextSum(t))return void this.drawSumText(t,i,s);const o={label:n,total:e,bold:!!t.sum,italic:this.isItalic(t.category)};r.forEach(((e,n)=>{let a=null;e.segments.forEach(((t,l)=>{const c=new wt(this.position,this.styles,t.dataPoint,i,e.layout.segments[l],t.scenario,r.length>1?r.length-1-n:l,this.stackConfig.mode,e.layout,h,s,o);c.draw(this.dataFormatDigits,this.measureScale),a=c})),a&&e.hasValue&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale,Object.assign(Object.assign({},T(this.level,t.category)),{scenario:r.length>1?e.prefix:void 0}))}))}))}drawStackedHeaders(t,i){var s;if(!this.stackConfig||0===t.length)return;const h=null!==(s=t.find((t=>!this.isTextSum(t))))&&void 0!==s?s:t[0];if(this.stackConfig.by!==d.SCENARIOS&&(!h.stackSegments||0===h.stackSegments.length))return;const e=this.stackGroups(h);if(0===e.length)return;const n=i.group().id("StackedHeaders"),r=this.position.getBarPositionX(),o=this.position.getStackedHeaderPositionY(),a=(t,i)=>{new vt(n,t,o,"STACK_HEADER",i,this.styles,et.Bottom,et.Center).draw()};if(e.length>1)return void e.forEach((t=>{a(r+(t.layout.positive-t.layout.negative)/2*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[l]=e;this.stackConfig.totalTitle&&(this.stackConfig.mode!==u.RELATIVE||"value"===this.stackConfig.labels)&&new vt(n,this.position.getLabelPositionX(l.layout.positive*this.pixelPerUnit),o,"STACK_TOTAL_HEADER",this.stackConfig.totalTitle,this.styles,et.Bottom,et.Left).draw(),l.segments.forEach(((t,i)=>{const{start:s,end:h}=l.layout.segments[i];a(r+(s+h)/2*t.dataPoint.pixelPerUnit,this.i18n.get(t.scenario)||t.scenario)}))}stackHeaderExtent(){var t;if(!this.stackConfig||0===this.dataModel.length)return 0;const i=null!==(t=this.dataModel.find((t=>!this.isTextSum(t))))&&void 0!==t?t:this.dataModel[0],s=this.stackGroups(i);if(1!==s.length)return 0;const[h]=s;let e=0;return h.segments.forEach(((t,i)=>{const{start:s,end:n}=h.layout.segments[i],r=String(this.i18n.get(t.scenario)||t.scenario),o=P(r,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;e=Math.max(e,(s+n)/2*t.dataPoint.pixelPerUnit+o/2)})),e}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:it.NONE}calculateLeftSideWidth(t){var i,s,h,e,n;let r=0;const o=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(it.NONE===t&&this.isStacked()){if(this.stackSides.negative>0){r=this.stackSides.negative*this.pixelPerUnit;const t=(null===(i=this.stackConfig)||void 0===i?void 0:i.mode)!==u.RELATIVE||"value"===(null===(s=this.stackConfig)||void 0===s?void 0:s.labels);this.stackSides.minTotal<0&&t&&(r+=o+this.calculateTotalLabelWidth(this.stackSides.minTotal))}this.stackLabelClearance.left>0&&(r=Math.max(r,this.stackLabelClearance.left*this.pixelPerUnit+this.calculateCategoryWidth()))}else if(it.NONE===t&&null!=(null===(h=this.smallestDataPointValue)||void 0===h?void 0:h.value)&&this.smallestDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestDataPointValue.value);r=Math.abs(this.smallestDataPointValue.getScaledUnit())+o+t}else if(it.RELATIVE===t&&null!=(null===(e=this.smallestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);r=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+o+t}else if(it.ABSOLUTE===t&&null!=(null===(n=this.smallestVarianceDataPointValue)||void 0===n?void 0:n.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value,!0);r=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+o+t}return r<=this.titleLength?this.titleLength:r}calculateRightSideWidth(t){var i,s,h,e,n,r,o,a;if(this.isStacked()){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar,r=(null===(i=this.stackConfig)||void 0===i?void 0:i.mode)!==u.RELATIVE||"value"===(null===(s=this.stackConfig)||void 0===s?void 0:s.labels);let o=t+this.calculateTextBoxWidth(this.stackSides.maxTotal);r||(o=this.hasPercentMark()?this.boldWidth("100%")/2:0);let a=Math.max(this.stackSides.positive*this.pixelPerUnit+o,this.stackHeaderExtent());if(this.stackSides.minTotal<0&&(a=Math.max(a,this.stackLabelClearance.right*this.pixelPerUnit+this.position.getCategoryToAxisSpaceing()+this.calculateCategoryWidth())),(null===(h=this.stackConfig)||void 0===h?void 0:h.totalTitle)&&r){const i=P(this.stackConfig.totalTitle,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;a=Math.max(a,this.stackSides.positive*this.pixelPerUnit+t+i)}return Math.max(a,this.titleLength,null!==(n=null===(e=this.sumColumns())||void 0===e?void 0:e.width)&&void 0!==n?n:0,this.referenceLineExtent())}let l=0;const c=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(it.NONE===t&&null!=(null===(r=this.highestDataPointValue)||void 0===r?void 0:r.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);l=Math.abs(this.highestDataPointValue.getScaledUnit())+c+t}else if(it.RELATIVE===t&&null!=(null===(o=this.highestVarianceDataPointValue)||void 0===o?void 0:o.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);l=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+c+t}else if(it.ABSOLUTE===t&&null!=(null===(a=this.highestVarianceDataPointValue)||void 0===a?void 0:a.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value,!0);l=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+c+t}l=Math.max(l,this.referenceLineExtent());for(const i of this.dataModel)i.sum&&it.NONE===t&&(l=Math.max(l,this.sumRowExtent(i)));return l<=this.titleLength?this.titleLength:l}populateDimensionStackSegments(t,i,s){var h;if(0===this.rowCount||!this.fromExpr||0===t.length)return;const e={[c.ROWGROUP]:"category",[c.ROWGROUPINDEX]:"category",[c.CATEGORY]:"subCategory",[c.CATEGORYINDEX]:"subCategory"}[s];if(!e)return;const n=s.toString(),r=t[0];let o;try{o=this.db.exec(`SELECT [${n}] as displayGroup, [${e}] as stackLabel, MIN([${e}Index]) as stackIndex, SUM([${r}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${n}], [${e}]`)}catch(t){return void this.failQuery(t)}const a=new Map;for(const t of o){if(null==t.stackValue||null==t.stackLabel)continue;const i=t.stackLabel,s=Number.isFinite(Number(t.stackIndex))&&null!=t.stackIndex?Number(t.stackIndex):NaN,h=a.get(i);(void 0===h||Number.isNaN(h)&&!Number.isNaN(s)||s<h)&&a.set(i,s)}const l=[...a.keys()];[...a.values()].every((t=>!Number.isNaN(t)))&&l.sort(((t,i)=>a.get(t)-a.get(i)));const u=new Map;for(const t of o){const i=t.displayGroup;u.has(i)||u.set(i,new Map),null!=t.stackValue&&null!=t.stackLabel&&u.get(i).set(t.stackLabel,t.stackValue)}const d=new Set(this.dataModel.map((t=>t.category))),f=new Map;for(const[t,i]of u)if(!d.has(t))for(const[t,s]of i)f.set(t,(null!==(h=f.get(t))&&void 0!==h?h:0)+s);for(const t of this.dataModel){const i=9999!==t.id||u.has(t.category)?u.get(t.category):f,s=i&&i.size>0?l.map((t=>{var s;return{label:t,value:null!==(s=i.get(t))&&void 0!==s?s:NaN}})):void 0;t.stackSegments=s&&s.length>0?s.map((i=>{const s=new ot(i.value,r,this.pixelPerUnit,st.NEU);return s.key=Object.assign(Object.assign({},T(this.level,t.category)),{[e]:i.label,scenario:r}),{label:i.label,value:i.value,dataPoint:s}})):[]}}isTextSum(t){return!!t.sum&&!!this.stackConfig&&this.stackConfig.mode!==u.RELATIVE}isItalic(t){return this.italicCategories.includes(t)}hasPercentMark(){var t;return!!(null===(t=this.stackConfig)||void 0===t?void 0:t.percentMark)&&this.stackConfig.mode===u.RELATIVE&&0===this.variancesDataModel.length&&this.isStacked()}addSumRows(t){if("none"===this.sums||0===this.dataModel.length)return;const i=(t,i)=>Number.isFinite(i)?(Number.isFinite(t)?t:0)+i:t,s=(s,h,e)=>{var n,r;const o=(h,e)=>new ot(void 0===t[e]?void 0:s.reduce(((t,s)=>i(t,s[h].value)),NaN),t[e],this.pixelPerUnit,st.NEU),a={id:1e4+this.dataModel.length,category:h,type:it.NONE,scenario1:o("scenario1",0),scenario2:o("scenario2",1),scenario3:o("scenario3",2),scenario4:o("scenario4",3),sum:e};if(s.some((t=>t.stackSegments))){const h=new Map;for(const t of s)for(const s of null!==(n=t.stackSegments)&&void 0!==n?n:[])h.set(s.label,i(null!==(r=h.get(s.label))&&void 0!==r?r:NaN,s.value));a.stackSegments=[...h].map((([i,s])=>({label:i,value:s,dataPoint:new ot(s,t[0],this.pixelPerUnit,st.NEU)})))}return a},h=this.dataModel,e=[],n="total"===this.sums?new Map:this.rowGroups();if(n.size>0){const t=[...new Set([...n.values()].sort(((t,i)=>t.index-i.index)).map((t=>t.name)))];for(const i of t){const t=h.filter((t=>{var s;return(null===(s=n.get(t.category))||void 0===s?void 0:s.name)===i}));if(0===t.length)continue;const r=s(t,i,"group");r.gapAfter=!0,e.push(...t,r)}e.push(...h.filter((t=>!n.has(t.category))))}else e.push(...h);"total"!==this.sums&&"all"!==this.sums||e.push(s(h,this.sumTitle||"SUM_TOTAL","total")),this.dataModel=e}rowGroups(){const t=new Map;if(this.level!==c.CATEGORY&&this.level!==c.CATEGORYINDEX)return t;let i;try{i=this.db.exec(`SELECT [category] as category, [rowGroup] as rowGroup, MIN([rowGroupIndex]) as rowGroupIndex FROM ${this.fromExpr} GROUP BY [category], [rowGroup]`)}catch(i){return this.failQuery(i),t}const s=new Map;return i.forEach(((i,h)=>{var e;if(null==i.rowGroup||""===i.rowGroup)return;const n=String(i.rowGroup),r=Number(i.rowGroupIndex),o=null!=i.rowGroupIndex&&Number.isFinite(r)?r:null!==(e=s.get(n))&&void 0!==e?e:h;s.has(n)||s.set(n,o),t.set(String(i.category),{name:n,index:Math.min(o,s.get(n))})})),t}rowLayout(){var t;const i=this.dataModel,s="total"===(null===(t=this.stackConfig)||void 0===t?void 0:t.thickness),h=i.reduce(((t,i,s)=>i.sum?t:s),-1),e=!this.stackConfig&&!this.scenarioLabelTop&&!this.hideScenarioName&&h>=0&&h<i.length-1;if(!s&&!e&&!i.some((t=>t.gapAfter)))return null;const n=i.map((t=>{if(!s||t.sum)return null;const i=this.stackGroups(t),h=i[i.length-1];return h?Math.abs(h.layout.total):0})),r=this.rowWeights(n),o=[],a=[];let l=0;return i.forEach(((t,s)=>{const n=r[s];o.push(l),a.push(n),l+=n+(t.gapAfter&&s<i.length-1?.5:0)+(e&&s===h?1:0)})),{start:o,weight:a,total:l,nameBelowBar:e}}rowWeights(t){const i=Math.min(1,1/this.styles.scaleFactors.categoryWidth),s=t.map((t=>null===t?1:0)),h=new Set(t.flatMap(((t,i)=>null===t?[]:[i])));let e=h.size;for(;;){const n=[...h].reduce(((i,s)=>i+t[s]),0);if(n<=0){h.forEach((t=>s[t]=e/h.size));break}const r=[...h].filter((s=>t[s]/n*e<i));if(0===r.length||r.length===h.size){h.forEach((i=>s[i]=t[i]/n*e));break}for(const t of r)s[t]=i,e-=i,h.delete(t)}return s}boldWidth(t){return P(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:"bold"}).width}sumText(t){const i=this.dataFormatDigits.decimal;return S.number(t,"decimal",i,i,this.measureScale.value,this.styles.locale)+this.styles.valueSuffix}sumColumns(){const t=this.dataModel.filter((t=>this.isTextSum(t)));if(0===t.length)return null;const i=this.styles.fontStyles.size,s=.6*i,h=.3*i,e=1.4*i,n=[];let r=0;for(const i of t){const t=this.stackGroups(i),s=t[t.length-1];s&&(s.segments.forEach(((t,i)=>{var s;const h=Number.isFinite(t.value)?this.boldWidth(this.sumText(t.value)):0;n[i]=Math.max(null!==(s=n[i])&&void 0!==s?s:0,h)})),r=Math.max(r,this.boldWidth(this.sumText(s.layout.total))))}const o=[];let a=.3*i;for(const t of n.length>1?n:[])o.push(a),a+=s+h+t+e;return{x:o,totalX:a,width:a+r,key:s,keyGap:h}}drawSumText(t,i,s){const h=this.sumColumns(),e=this.stackGroups(t),n=e[e.length-1];if(!h||!n)return;const r=this.position.getBarPositionX(),o=this.position.getBarCenterPositionY(i),a=this.styles.stackColors,l=s.group().id(`stacked_sum_${i}`);n.segments.forEach(((t,i)=>{if(!Number.isFinite(t.value)||void 0===h.x[i])return;const s=r+h.x[i];l.rect(h.key,h.key).fill({color:a[i%a.length]}).cy(o).x(s),new vt(l,s+h.key+h.keyGap,o,`SUM_SEG_${i}`,t.value,this.styles,et.Center,et.Left).setEmphasis(!0,!1).setPoint(t.dataPoint.key).draw(this.dataFormatDigits,this.measureScale)})),new vt(l,r+h.totalX,o,"SUM_TOTAL",n.layout.total,this.styles,et.Center,et.Left).setEmphasis(!0,!1).setPoint(T(this.level,t.category),"total").draw(this.dataFormatDigits,this.measureScale)}sumRowExtent(t){var i,s,h;const e=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(this.variancesDataModel.length>0)return 0;if(this.isTextSum(t))return null!==(s=null===(i=this.sumColumns())||void 0===i?void 0:i.width)&&void 0!==s?s:0;if(this.stackConfig){const i="value"===this.stackConfig.labels?e+this.boldWidth(this.sumText(null!==(h=t.scenario1.value)&&void 0!==h?h:0)):0;return this.stackSides.positive*this.pixelPerUnit+i}return this.sumValuesWidth(t)}referenceLineOffset(){var t;const i=this.referenceLine;return!i||!Number.isFinite(i.value)||this.variancesDataModel.length>0?null:((null===(t=this.stackConfig)||void 0===t?void 0:t.mode)===u.RELATIVE?i.value/100:i.value)*this.pixelPerUnit}referenceLineExtent(){var t;const i=this.referenceLineOffset();if(null===i||i<=0)return 0;const s=(null===(t=this.referenceLine)||void 0===t?void 0:t.label)?P(this.referenceLine.label,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width:0;return i+Math.max(s/2,.25*this.styles.fontStyles.size)}drawPercentMark(t){if(!this.hasPercentMark())return;const i=t.group().id("PercentMark"),s=this.styles.fontStyles.size,h=this.position.getBarPositionX()+this.stackSides.positive*this.pixelPerUnit,e=this.position.getAxisPositionY(),n=this.position.getAxisEndPositionY(),r=n+.15*s,o=r+.75*s;i.line(h,e,h,n).stroke({color:"#000000",width:this.position.spacings.axisLineWidth}),i.polygon(`${h},${r} ${h-.28*s},${o} ${h+.28*s},${o}`).fill("#000000"),new vt(i,h,o+.1*s,"PERCENT_MARK","100%",this.styles,et.Top,et.Center).setEmphasis(!0,!1).draw()}drawReferenceLine(t){const i=this.referenceLine,s=this.referenceLineOffset();if(!i||null===s||0===this.dataModel.length)return;const h=t.group().id("ReferenceLine"),e=this.styles.fontStyles.size,n=`var(--bn-annotation-color, ${V["bn-annotation"].color})`,r=this.position.getBarPositionX()+s,o=this.position.getStackedHeaderPositionY()-(this.stackConfig||this.scenarioLabelTop?1.1*e:0),a=t=>{var s,h;if(t.sum)return!1;if(!this.stackConfig)return(null!==(s=t.scenario1.value)&&void 0!==s?s:0)>=i.value;const e=null===(h=this.stackGroups(t)[0])||void 0===h?void 0:h.layout.segments[0];return null!=e&&e.end*this.pixelPerUnit>=r-this.position.getBarPositionX()};let l=this.dataModel.findIndex((t=>!a(t)))-1;l<0&&(l=this.dataModel.reduce(((t,i,s)=>i.sum?t:s),0));const c=this.position.getBarCenterPositionY(l)+this.position.getBarWidthAt(l)/2;h.line(r,o,r,c).attr("style",`stroke: ${n}; stroke-width: ${Math.max(1,this.position.spacings.axisLineWidth)}px`),h.polygon(`${r},${o+.5*e} ${r-.25*e},${o} ${r+.25*e},${o}`).attr("style",`fill: ${n}`),i.label&&h.plain(i.label).attr({x:r,y:o-.3*e,"text-anchor":"middle"}).attr("style",`fill: ${n}`)}hasNoData(){return 0===this.dataModel.length}setAvailableWidth(t){if(this.pixelPerUnit<=0||t<=0)this.overflowConfig=null;else if(null==this.stackConfig){if(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig){const{cutWidth:t,overdriveZoneWidth:i,breakGap:s}=this.overflowConfig,h=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new ot(h,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new ot(-h,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new ot(h,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new ot(-h,this.smallestDataPointValue.scenario,1,this.smallestDataPointValue.variance))),this.updatePosition()}}else this.overflowConfig=null}calculateOverflowConfig(t){const i=this.variancesDataModel&&this.variancesDataModel.length>0;if(this.getVarianceType()===it.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,h=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,e=s.getScaledUnit(),n=null!=h.value?Math.abs(h.getScaledUnit()):0,r=Math.max(e,n);if(r<=0)return null;const o=this.styles.fontStyles.size,a=o*this.styles.scaleFactors.labelToBar,l=1.5*o,c=.3*o,u=.8*o,d=t-this.position.getAxisPositionX()-this.styles.padding.left-this.styles.padding.right-a-this.calculateTextBoxWidth(s.value||0)-l-c;if(d<=u)return null;const f=d-u;return r<=f?null:{cutWidth:d,overdriveZoneWidth:l,breakGap:c,maxOverflow:r-f,scenarioCutOffset:u}}}const yt=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.scenarios=[],this.variances=[],this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.i18n=new Map,this.order={hierarchy:[],direction:g.ASC},this.level=c.CATEGORY,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[],this.parentDimensions={width:0,height:0},U(this)}getDb(){return this.stores||(this.stores=Y(this.element)),this.stores.db.db}render(){var t,i,e,n;if(void 0===this.chart||void 0!==this.queryError)return s(h,null);if(this.chart.hasNoData()){const i=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return s(h,{class:"no-data"},s("div",{class:"empty-state"},i))}return s(h,null,s("div",{innerHTML:null===(i=this.pattern)||void 0===i?void 0:i.toString(),class:"hidePatternContainer",style:{width:"0",height:"0",overflow:"hidden"}}),s("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),s("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}syncQueryError(){var t,i;this.queryError=null!==(t=this.measureScaleError)&&void 0!==t?t:null===(i=this.chart)||void 0===i?void 0:i.getQueryError(),H(this.errors,this.queryError)}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),h=this.prepareStyle();this.chart=new Pt(new D(this.ruleSetConfig),i,this.tableName,s,h),this.chart.setI18n(this.i18n);const e=s.pixelPerUnit<=0;this.autoFitScaling(s,h),this.chart.setAvailableWidth(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new J(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}async componentWillUpdate(){var t;if(null==this.chart)return;const i=this.prepareConfig(),s=this.prepareStyle();this.chart.setI18n(this.i18n),this.chart.setStyles(s),this.chart.setRuleSet(new D(this.ruleSetConfig)),this.chart.setConfig(i);const h=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableWidth(h?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new J(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}autoFitScaling(t,i){var s;const h=t.pixelPerUnit<=0,e=t.pixelPerPercentage<=0;if(!h&&!e)return;const n=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:h?t.pixelPerUnit:void 0,percentage:e?t.pixelPerPercentage:void 0})},r=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,o=this.getDb(),a=()=>{this.chart=new Pt(new D(this.ruleSetConfig),o,this.tableName,t,i),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasWidth());if(!r||r<=0)return h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=50),a(),void n();h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=1),a();let c=l();if(c<=0)return void n();const u=Math.max(B,.9*r/c);let d=!1,f=!1,v=null;for(let i=0;i<=3;i++){const i=W({target:r,measured:c,unitExtent:h?this.chart.getUnitBarExtent():0,pctExtent:e?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(h&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,d=!0),e&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,f=!0),a(),c=l(),c<=r+.5&&(v={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*r))break}let p=!1;if(h&&!d&&(t.pixelPerUnit=u,p=!0),e&&!f&&(t.pixelPerPercentage=u,p=!0),c>r+.5){if(v)d&&(t.pixelPerUnit=v.ppu),f&&(t.pixelPerPercentage=v.ppp);else{const i=r/c;h&&(t.pixelPerUnit=Math.max(B,t.pixelPerUnit*i)),e&&(t.pixelPerPercentage=Math.max(B,t.pixelPerPercentage*i))}p=!0}p&&a(),n()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=G(t,this.tableName,this.filter);return this.measureScaleError=void 0,new rt(new lt,new p(new F),new F,new v,t,i,(t=>{this.measureScaleError=z(t)})).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideCategories:this.hideCategories,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,level:this.level,limit:this.limit,sortOrder:this.order,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,stackConfig:this.stackConfig,sums:this.sums,sumTitle:this.sumTitle,valueSuffix:this.valueSuffix,scenarioLabelTop:this.scenarioLabelTop,hideScenarioName:this.hideScenarioName,referenceLine:this.referenceLine,italicCategories:this.italicCategories})}prepareStyle(){var t,i;const s=new ut(new ft,new r,new o(new N),new I(new N),new a).adapt(this.styles);return s.locale=(null===(i=null===(t=Y(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return this}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"bn-chart-structure-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],scenarios:[16],variances:[16],hideCategories:[4,"hide-categories"],pixelPerUnit:[2,"pixel-per-unit"],pixelPerPercentage:[2,"pixel-per-percentage"],reportAutoScaling:[16],errors:[16],limit:[2],styles:[1040],i18n:[1040],order:[16],level:[1],filter:[1],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],dataFormatDigits:[16],stackConfig:[16],sums:[1],sumTitle:[1,"sum-title"],valueSuffix:[1,"value-suffix"],scenarioLabelTop:[4,"scenario-label-top"],hideScenarioName:[4,"hide-scenario-name"],referenceLine:[16],italicCategories:[16],parentDimensions:[16],ruleSetConfig:[16]}]);function xt(){"undefined"!=typeof customElements&&["bn-chart-structure-renderer"].forEach((t=>{"bn-chart-structure-renderer"===t&&(customElements.get(e(t))||customElements.define(e(t),yt))}))}export{yt as B,xt as d}
|
|
@@ -19186,6 +19186,28 @@ class StructureChart {
|
|
|
19186
19186
|
drawHeader(axisX + ((start + end) / 2) * seg.dataPoint.pixelPerUnit, this.i18n.get(seg.scenario) || seg.scenario);
|
|
19187
19187
|
});
|
|
19188
19188
|
}
|
|
19189
|
+
/** How far the header of a segment of the first row reaches right of the axis: a name can be wider than its segment. */
|
|
19190
|
+
stackHeaderExtent() {
|
|
19191
|
+
var _a;
|
|
19192
|
+
if (!this.stackConfig || this.dataModel.length === 0)
|
|
19193
|
+
return 0;
|
|
19194
|
+
const firstRow = (_a = this.dataModel.find((row) => !this.isTextSum(row))) !== null && _a !== void 0 ? _a : this.dataModel[0];
|
|
19195
|
+
const groups = this.stackGroups(firstRow);
|
|
19196
|
+
if (groups.length !== 1)
|
|
19197
|
+
return 0;
|
|
19198
|
+
const [group] = groups;
|
|
19199
|
+
let extent = 0;
|
|
19200
|
+
group.segments.forEach((seg, index) => {
|
|
19201
|
+
const { start, end } = group.layout.segments[index];
|
|
19202
|
+
const name = String(this.i18n.get(seg.scenario) || seg.scenario);
|
|
19203
|
+
const width = CalculateSize(name, {
|
|
19204
|
+
font: this.styles.fontStyles.font,
|
|
19205
|
+
fontSize: this.styles.fontStyles.size + "px",
|
|
19206
|
+
}).width;
|
|
19207
|
+
extent = Math.max(extent, ((start + end) / 2) * seg.dataPoint.pixelPerUnit + width / 2);
|
|
19208
|
+
});
|
|
19209
|
+
return extent;
|
|
19210
|
+
}
|
|
19189
19211
|
getVarianceType() {
|
|
19190
19212
|
if (this.variancesDataModel.length > 0) {
|
|
19191
19213
|
return this.variancesDataModel[0].type;
|
|
@@ -19193,14 +19215,15 @@ class StructureChart {
|
|
|
19193
19215
|
return VarianceType$1.NONE;
|
|
19194
19216
|
}
|
|
19195
19217
|
calculateLeftSideWidth(varianceType) {
|
|
19196
|
-
var _a, _b, _c;
|
|
19218
|
+
var _a, _b, _c, _d, _e;
|
|
19197
19219
|
let width = 0;
|
|
19198
19220
|
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
19199
19221
|
if (VarianceType$1.NONE === varianceType && this.isStacked()) {
|
|
19200
19222
|
// the negative side with the label of a negative total behind it
|
|
19201
19223
|
if (this.stackSides.negative > 0) {
|
|
19202
19224
|
width = this.stackSides.negative * this.pixelPerUnit;
|
|
19203
|
-
|
|
19225
|
+
const totalDrawn = ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) !== StackMode.RELATIVE || ((_b = this.stackConfig) === null || _b === void 0 ? void 0 : _b.labels) === "value";
|
|
19226
|
+
if (this.stackSides.minTotal < 0 && totalDrawn) {
|
|
19204
19227
|
width += labelToBar + this.calculateTotalLabelWidth(this.stackSides.minTotal);
|
|
19205
19228
|
}
|
|
19206
19229
|
}
|
|
@@ -19210,19 +19233,19 @@ class StructureChart {
|
|
|
19210
19233
|
}
|
|
19211
19234
|
}
|
|
19212
19235
|
else if (VarianceType$1.NONE === varianceType &&
|
|
19213
|
-
((
|
|
19236
|
+
((_c = this.smallestDataPointValue) === null || _c === void 0 ? void 0 : _c.value) != null &&
|
|
19214
19237
|
this.smallestDataPointValue.value < 0) {
|
|
19215
19238
|
const sizeLabelValue = this.calculateTextBoxWidth(this.smallestDataPointValue.value);
|
|
19216
19239
|
width = Math.abs(this.smallestDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
19217
19240
|
}
|
|
19218
19241
|
else if (VarianceType$1.RELATIVE === varianceType &&
|
|
19219
|
-
((
|
|
19242
|
+
((_d = this.smallestVarianceDataPointValue) === null || _d === void 0 ? void 0 : _d.value) != null &&
|
|
19220
19243
|
this.smallestVarianceDataPointValue.value < 0) {
|
|
19221
19244
|
const sizeLabelValue = this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);
|
|
19222
19245
|
width = Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit()) + labelToBar + sizeLabelValue;
|
|
19223
19246
|
}
|
|
19224
19247
|
else if (VarianceType$1.ABSOLUTE === varianceType &&
|
|
19225
|
-
((
|
|
19248
|
+
((_e = this.smallestVarianceDataPointValue) === null || _e === void 0 ? void 0 : _e.value) != null &&
|
|
19226
19249
|
this.smallestVarianceDataPointValue.value < 0) {
|
|
19227
19250
|
const sizeLabelValue = this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value, true);
|
|
19228
19251
|
width = Math.abs(this.smallestVarianceDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
@@ -19233,43 +19256,47 @@ class StructureChart {
|
|
|
19233
19256
|
return width;
|
|
19234
19257
|
}
|
|
19235
19258
|
calculateRightSideWidth(varianceType) {
|
|
19236
|
-
var _a, _b, _c, _d, _e, _f;
|
|
19259
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
19237
19260
|
// Stacked charts: width based on the positive side of the stacks, not individual max
|
|
19238
19261
|
if (this.isStacked()) {
|
|
19239
19262
|
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
19240
|
-
|
|
19241
|
-
|
|
19263
|
+
// a 100 % stack prints no total behind its bars: it needs room for half of the `100%` mark at most
|
|
19264
|
+
const totalDrawn = ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) !== StackMode.RELATIVE || ((_b = this.stackConfig) === null || _b === void 0 ? void 0 : _b.labels) === "value";
|
|
19265
|
+
let endRoom = labelToBar + this.calculateTextBoxWidth(this.stackSides.maxTotal);
|
|
19266
|
+
if (!totalDrawn)
|
|
19267
|
+
endRoom = this.hasPercentMark() ? this.boldWidth("100%") / 2 : 0;
|
|
19268
|
+
let width = Math.max(this.stackSides.positive * this.pixelPerUnit + endRoom, this.stackHeaderExtent());
|
|
19242
19269
|
// the category label of a row with a negative total sits right of the axis, behind its positive segments
|
|
19243
19270
|
if (this.stackSides.minTotal < 0) {
|
|
19244
19271
|
width = Math.max(width, this.stackLabelClearance.right * this.pixelPerUnit +
|
|
19245
19272
|
this.position.getCategoryToAxisSpaceing() +
|
|
19246
19273
|
this.calculateCategoryWidth());
|
|
19247
19274
|
}
|
|
19248
|
-
if ((
|
|
19275
|
+
if (((_c = this.stackConfig) === null || _c === void 0 ? void 0 : _c.totalTitle) && totalDrawn) {
|
|
19249
19276
|
const title = CalculateSize(this.stackConfig.totalTitle, {
|
|
19250
19277
|
font: this.styles.fontStyles.font,
|
|
19251
19278
|
fontSize: this.styles.fontStyles.size + "px",
|
|
19252
19279
|
}).width;
|
|
19253
19280
|
width = Math.max(width, this.stackSides.positive * this.pixelPerUnit + labelToBar + title);
|
|
19254
19281
|
}
|
|
19255
|
-
return Math.max(width, this.titleLength, (
|
|
19282
|
+
return Math.max(width, this.titleLength, (_e = (_d = this.sumColumns()) === null || _d === void 0 ? void 0 : _d.width) !== null && _e !== void 0 ? _e : 0, this.referenceLineExtent());
|
|
19256
19283
|
}
|
|
19257
19284
|
let width = 0;
|
|
19258
19285
|
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
19259
19286
|
if (VarianceType$1.NONE === varianceType &&
|
|
19260
|
-
((
|
|
19287
|
+
((_f = this.highestDataPointValue) === null || _f === void 0 ? void 0 : _f.value) != null &&
|
|
19261
19288
|
this.highestDataPointValue.value >= 0) {
|
|
19262
19289
|
const sizeLabelValue = this.calculateTextBoxWidth(this.highestDataPointValue.value);
|
|
19263
19290
|
width = Math.abs(this.highestDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
19264
19291
|
}
|
|
19265
19292
|
else if (VarianceType$1.RELATIVE === varianceType &&
|
|
19266
|
-
((
|
|
19293
|
+
((_g = this.highestVarianceDataPointValue) === null || _g === void 0 ? void 0 : _g.value) != null &&
|
|
19267
19294
|
this.highestVarianceDataPointValue.value >= 0) {
|
|
19268
19295
|
const sizeLabelValue = this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);
|
|
19269
19296
|
width = Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit()) + labelToBar + sizeLabelValue;
|
|
19270
19297
|
}
|
|
19271
19298
|
else if (VarianceType$1.ABSOLUTE === varianceType &&
|
|
19272
|
-
((
|
|
19299
|
+
((_h = this.highestVarianceDataPointValue) === null || _h === void 0 ? void 0 : _h.value) != null &&
|
|
19273
19300
|
this.highestVarianceDataPointValue.value >= 0) {
|
|
19274
19301
|
const sizeLabelValue = this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value, true);
|
|
19275
19302
|
width = Math.abs(this.highestVarianceDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
@@ -222,6 +222,8 @@ export declare class StructureChart {
|
|
|
222
222
|
* The headers take their place from the first row.
|
|
223
223
|
*/
|
|
224
224
|
private drawStackedHeaders;
|
|
225
|
+
/** How far the header of a segment of the first row reaches right of the axis: a name can be wider than its segment. */
|
|
226
|
+
private stackHeaderExtent;
|
|
225
227
|
private getVarianceType;
|
|
226
228
|
private calculateLeftSideWidth;
|
|
227
229
|
private calculateRightSideWidth;
|
package/package.json
CHANGED