@bino-bi/bn-template-engine 1.0.0-next.37 → 1.0.0-next.39
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-f74760d7.entry.js → p-8c84d57e.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +271 -57
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +56 -6
- package/dist/collection/components/bn-table/bn-table.js +93 -5
- package/dist/collection/components/bn-table/utils/Table.js +33 -2
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +15 -7
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +2 -2
- package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +15 -7
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +24 -10
- package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +30 -6
- package/dist/collection/components/bn-table/utils/helper/WaterfallCalculator.js +9 -3
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +31 -8
- package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +5 -0
- package/dist/collection/utils/layoutState/baseline.js +6 -5
- package/dist/components/bn-chart-bubble-renderer.js +1 -1
- package/dist/components/bn-chart-bubble.js +1 -1
- package/dist/components/bn-chart-bullet-renderer.js +1 -1
- package/dist/components/bn-chart-bullet.js +1 -1
- package/dist/components/bn-chart-scatter-renderer.js +1 -1
- package/dist/components/bn-chart-scatter.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-table-renderer.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/{p-CQVAHG6w.js → p-B4Cf0cVi.js} +1 -1
- package/dist/components/{p-C-KX1_tw.js → p-BsJOvfIg.js} +1 -1
- package/dist/components/p-ChaSU4fh.js +1 -0
- package/dist/components/{p-BhEdmPjm.js → p-Cyf5ZEXs.js} +1 -1
- package/dist/components/{p-t4xPltK2.js → p-XFZYX7DZ.js} +1 -1
- package/dist/components/{p-C_6KHDYv.js → p-chnyMHJT.js} +1 -1
- package/dist/components/p-dRPJiQB6.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +271 -57
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/bn-table/bn-table-renderer/bn-table-renderer.d.ts +2 -0
- package/dist/types/components/bn-table/bn-table.d.ts +26 -0
- package/dist/types/components/bn-table/utils/Table.d.ts +11 -1
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +5 -2
- package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +7 -4
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +1 -0
- package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +7 -0
- package/dist/types/components/bn-table/utils/helper/WaterfallCalculator.d.ts +5 -2
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +15 -6
- package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +2 -0
- package/dist/types/components.d.ts +19 -4
- package/dist/types/utils/layoutState/baseline.d.ts +4 -2
- package/package.json +1 -1
- package/dist/components/p-CHQ67u2G.js +0 -1
- package/dist/components/p-sar8m7th.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as i,w as e,f as s,h as a,a as n,t as r}from"./p-D6YGOYV1.js";import{h as o,a as l}from"./p-DDvWTgk1.js";import{v as h,a as d,n as c,i as p,f as u,h as v,m,o as g,l as f}from"./p-DT04Cka0.js";import{w as y}from"./p-DJUffGeB.js";import{w as b}from"./p-Dq9dG0Kr.js";import{i as S,w,a as x}from"./p-BU_53KVT.js";import{w as O}from"./p-DQl2K2Xl.js";import{w as M}from"./p-Bo_R7f_T.js";import{w as A}from"./p-DjPWZfry.js";import{V as _,r as T,F as N}from"./p-CniN8ALm.js";import{w as L}from"./p-OquycEMA.js";import{w as k,r as W}from"./p-4vVbchX2.js";import{g as j}from"./p-DD1zlev_.js";import{r as U,f as C,p as D}from"./p-Xb6Ilq8u.js";import{o as I}from"./p-B6kka9sT.js";import{b as R,e as $,f as F,g as P,h as B}from"./p-B5tixDPM.js";import{D as E}from"./p-sLbQ7yZ1.js";import{LAYOUT_STATE_VERSION as z}from"./index.js";import{o as G,m as V}from"./p-DaOm9YwQ.js";import{r as H,a as q}from"./p-CckAR27O.js";import{a as X}from"./p-sar8m7th.js";import{a as Y}from"./p-t4xPltK2.js";import{s as J}from"./p-DakXa7Dp.js";import{d as K}from"./p-BmOWXYHF.js";const Q=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(S(t))return void this.errors.remove(i);const e=h(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(S(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="WARN_syncSpaceLeft";c(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+t+"' are not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";p(t)?this.errors.remove(i):"invalid"===U(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";p(t)?this.errors.remove(i):"invalid"===U(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateDateInterval(t){const i="WARN_dateInterval";p(t)||u(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateChartMode(t){const i="WARN_chartMode";["bar","line","auto"].includes(null==t?void 0:t.toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"chartMode: invalid value '"+(null==t?void 0:""+t)+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="WARN_maxBars";!v(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:""+t)+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="WARN_stack",e=m(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}validateAxisLabelsMode(t){const i="WARN_axisLabelsMode";p(t)||g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";f(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth=!0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.showOverlayAvg=!0,this.showOverlayMedian=!1,this.measureUnit="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,n,r,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),h=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=h/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(r=this.unitScaling)&&void 0!==r?r:"")+"").trim())}, auto-fitted to 1 em ≈ ${C(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*h/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${C(e)} percentage points.`}))}},M(this),b(this),y(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=k(this),O(this),this.componentStyle=A(this),this.ruleSetConfig=L(this),this.t=w(this).t,this.resolveInherited=x(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateMeasureScale(this.measureScale),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale)}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==n?n:"");Number.isNaN(r)||(e=Math.max(e,r),s=!0)})),s?Math.max(Math.floor(e),this.element.scrollWidth):this.element.scrollWidth}measureContentHeight(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("height"))&&void 0!==n?n:"");Number.isNaN(r)||(e+=r,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollHeight):this.element.scrollHeight}checkOverflow(){const t=j(this.element),i=this.measureContentWidth(),e=this.measureContentHeight(),s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void W(this.errors,null);const n=this.prepareVariances().some((t=>t.startsWith("dr"))),r="value"===U(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=n&&"value"===U(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=D(this.scale),h="auto"!==l&&"empty"!==l,d=[];a&&r&&d.push("unit-scaling"),a&&o&&d.push("percentage-scaling"),s&&h&&d.push("scale");const c=[];s&&c.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&c.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),W(this.errors,`Chart exceeds available ${c.join(" and ")}. `+(d.length>0?`Adjust ${d.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),d.length>0)}componentDidRender(){J(this.element,"bn-chart-time-renderer");const{mode:t}=D(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=j(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const a=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,r=this.appliedScaleFactor;if(n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,r*(s-1)/n);Math.abs(o-r)<.01||(i.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=I(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=j(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=j(this.element);this._lastObservedWidth=t,s(this)}))})),this.settleParentHeight()}settleParentHeight(){const t=[150,400,1e3,2500],i=()=>{if(this._settleTimer=null,!this.element.isConnected)return;const{height:e}=j(this.element);e>0&&Math.abs(e-this._lastAppliedHeight)>8&&!this._autoScaleGuard&&s(this);const a=t.shift();void 0!==a&&(this._settleTimer=setTimeout(i,a))};this._settleTimer=setTimeout(i,t.shift())}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}prepareDimension(){const t=j(this.element),i=this.prepareScenarios(),e=this.prepareVariances();this.canvasWidthSegmented=t.width/(i.length+e.length||1),this._lastAppliedHeight=t.height;const s=1+e.length,a=this.showMeasureScale?this.getEffectiveFontPx():0;return{width:this.canvasWidthSegmented,height:Math.max(0,t.height-a)/s}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));const n="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return p(a.value)||n?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(n||a.unresolved?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=a.value)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}prepareAvg(){return this.showOverlayAvg}prepareMedian(){return this.showOverlayMedian}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return p(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}checkVarianceScenarios(t){const i="WARN_variances_scenario",e=this.prepareScenarios(),s=[];for(const i of t){const t=new _(i);if(t.isValid)for(const a of[t.base,t.delta])e.includes(a)||s.push(`'${i}' needs '${a}'`)}e.length>0&&s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:`variances: ${s.join(", ")}, which is not in scenarios (${e.join(", ")}). The variance has no values.`}):this.errors.remove(i)}prepareHideAxisLabels(t){return t>=1||!this.showCategories}prepareI18n(){const t=l,i=new Map(["no-data"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...T(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=U(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=U(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:i["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:i["bn-chart-time"].scaleFactors.labelToColumn,labelToAxis:i["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:i["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:i["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-time"].scaleFactors.markerWidth,markerOffset:i["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${e}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-time"].axisStyles,barStyles:i["bn-chart-time"].barStyles,varianceStyles:i["bn-chart-time"].varianceStyles,stackColors:i["bn-chart-time"].stackColors,padding:i["bn-chart-time"].padding,pattern:null,locale:"de"}}))}prepareLeftSideOffset(t,i){return this.syncSpaceLeft>-1?this.syncSpaceLeft:N.getMaxWidthOfArrayItems([...this.prepareVariances(),...this.prepareScenarios(),this.chartTitle],t,i)}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareDateInterval(){var t,i,e;const s="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return p(this.dateInterval)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(s?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:"dateInterval: not set, auto-detected: "+this.datasetMeta.suggestedDateInterval}),E[this.datasetMeta.suggestedDateInterval.toUpperCase()]):s?E.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),E[null===(e=this.dateInterval)||void 0===e?void 0:e.toUpperCase()])}prepareIntervalSpanLimit(){const t=Number(this.intervalSpanLimit);return t>0?t:28}prepareAxisLabelsMode(){var t;return R[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase()]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return p(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(p(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,e="WARN_stack_dimensions_scenarios";if(i===$.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:e,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(e)}else this.errors.remove(e);return{by:i,mode:t.mode||P.ABSOLUTE,order:t.order||F.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareLineFullWidth(){return this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?B.LINE:"auto"===i?B.AUTO:B.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,i){const e=this.prepareI18n(),s=this.prepareStyle(),n=j(this.element).width,r=this.preparePixelPerUnit(),o=this.preparePixelPerPercentage(),l=this.prepareStackConfig(),h=this.prepareScenarios(),d=(null==l?void 0:l.by)===$.DIMENSIONS?h.slice(0,1):h;return a("bn-chart-time-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:d,variances:[t],hideAxisLabels:this.prepareHideAxisLabels(i),pixelPerUnit:r,pixelPerPercentage:o,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,s),styles:s,i18n:e,dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(i),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:l,lineFullWidth:this.prepareLineFullWidth(),containerWidth:n,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return Y(this.element,"bn-chart-time-renderer")}async getLayoutState(t){var i,e,s,a;const n=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",r=G(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,h=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,d=this.prepareVariances(),c=X(this.element,"bn-chart-time-renderer",["base",...d],r,n),p=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-time-renderer"),u={version:z,tag:this.element.localName,id:q(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:V(this.element,r),em:{fontSizePx:h,appliedScaleFactor:l},regions:c.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==p?void 0:p.scenarios)&&void 0!==a?a:[],variances:d,barCount:c.barCount,chartMode:this.chartMode||void 0,hasNoData:0===c.barCount},diagnostics:H(this.element),scaling:this.resolveScalingInfo(h),baseline:c.baseline};return c.elements&&(u.elements=c.elements),u}resolveScalingInfo(t){var i,e;const s={},a=U(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const n=U(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)s.percentageMode="fixed",s.percentagePointsPerEm=n.value,s.percentagePxPerPoint=t/n.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=D(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,n;const r=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":r*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(n=i.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const i=this.prepareVariances();this.checkVarianceScenarios(i),i.length>0&&(t=[...t,...i]);const e=this.getFontStyles();return a(n,{key:"37085b275bb92d716a31f79f15b9f2517f1c596b",style:e},a("div",{key:"93e9eacc22334da1deed871db640d6fd4aafb153",class:"container"},t.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],measureScale:[{validateMeasureScale:0}]}}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:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}'}},[1,"bn-chart-time",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],syncSpaceLeft:[2,"sync-space-left"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dateInterval:[1,"date-interval"],chartMode:[1,"chart-mode"],maxBars:[2,"max-bars"],stack:[1],scale:[1],intervalSpanLimit:[2,"interval-span-limit"],axisLabelsMode:[1,"axis-labels-mode"],lineFullWidth:[4,"line-full-width"],showCategories:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],showOverlayAvg:[4,"show-overlay-avg"],showOverlayMedian:[4,"show-overlay-median"],measureUnit:[1,"measure-unit"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],measureScale:[{validateMeasureScale:0}]}]),Z=Q,tt=function(){"undefined"!=typeof customElements&&["bn-chart-time","bn-chart-time-renderer"].forEach((t=>{switch(t){case"bn-chart-time":customElements.get(r(t))||customElements.define(r(t),Q);break;case"bn-chart-time-renderer":customElements.get(r(t))||K()}}))};export{Z as BnChartTime,tt as defineCustomElement}
|
|
1
|
+
import{p as t,H as i,w as e,f as s,h as a,a as n,t as r}from"./p-D6YGOYV1.js";import{h as o,a as l}from"./p-DDvWTgk1.js";import{v as h,a as d,n as c,i as p,f as u,h as v,m,o as g,l as f}from"./p-DT04Cka0.js";import{w as y}from"./p-DJUffGeB.js";import{w as b}from"./p-Dq9dG0Kr.js";import{i as S,w,a as x}from"./p-BU_53KVT.js";import{w as O}from"./p-DQl2K2Xl.js";import{w as M}from"./p-Bo_R7f_T.js";import{w as A}from"./p-DjPWZfry.js";import{V as _,r as T,F as N}from"./p-CniN8ALm.js";import{w as L}from"./p-OquycEMA.js";import{w as k,r as W}from"./p-4vVbchX2.js";import{g as U}from"./p-DD1zlev_.js";import{r as j,f as C,p as D}from"./p-Xb6Ilq8u.js";import{o as I}from"./p-B6kka9sT.js";import{b as R,e as $,f as F,g as B,h as P}from"./p-B5tixDPM.js";import{D as E}from"./p-sLbQ7yZ1.js";import{LAYOUT_STATE_VERSION as z}from"./index.js";import{o as G,m as V}from"./p-DaOm9YwQ.js";import{r as X,a as H}from"./p-CckAR27O.js";import{a as Y}from"./p-ChaSU4fh.js";import{a as q}from"./p-XFZYX7DZ.js";import{s as Z}from"./p-DakXa7Dp.js";import{d as J}from"./p-BmOWXYHF.js";const K=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(S(t))return void this.errors.remove(i);const e=h(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(S(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="WARN_syncSpaceLeft";c(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+t+"' are not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";p(t)?this.errors.remove(i):"invalid"===j(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";p(t)?this.errors.remove(i):"invalid"===j(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateDateInterval(t){const i="WARN_dateInterval";p(t)||u(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateChartMode(t){const i="WARN_chartMode";["bar","line","auto"].includes(null==t?void 0:t.toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"chartMode: invalid value '"+(null==t?void 0:""+t)+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="WARN_maxBars";!v(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:""+t)+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="WARN_stack",e=m(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}validateAxisLabelsMode(t){const i="WARN_axisLabelsMode";p(t)||g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";f(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth=!0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.showOverlayAvg=!0,this.showOverlayMedian=!1,this.measureUnit="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,n,r,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),h=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=h/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(r=this.unitScaling)&&void 0!==r?r:"")+"").trim())}, auto-fitted to 1 em ≈ ${C(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*h/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${C(e)} percentage points.`}))}},M(this),b(this),y(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=k(this),O(this),this.componentStyle=A(this),this.ruleSetConfig=L(this),this.t=w(this).t,this.resolveInherited=x(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateMeasureScale(this.measureScale),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale)}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==n?n:"");Number.isNaN(r)||(e=Math.max(e,r),s=!0)})),s?Math.max(Math.floor(e),this.element.scrollWidth):this.element.scrollWidth}measureContentHeight(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("height"))&&void 0!==n?n:"");Number.isNaN(r)||(e+=r,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollHeight):this.element.scrollHeight}checkOverflow(){const t=U(this.element),i=this.measureContentWidth(),e=this.measureContentHeight(),s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void W(this.errors,null);const n=this.prepareVariances().some((t=>t.startsWith("dr"))),r="value"===j(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=n&&"value"===j(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=D(this.scale),h="auto"!==l&&"empty"!==l,d=[];a&&r&&d.push("unit-scaling"),a&&o&&d.push("percentage-scaling"),s&&h&&d.push("scale");const c=[];s&&c.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&c.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),W(this.errors,`Chart exceeds available ${c.join(" and ")}. `+(d.length>0?`Adjust ${d.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),d.length>0)}componentDidRender(){Z(this.element,"bn-chart-time-renderer");const{mode:t}=D(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=U(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const a=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,r=this.appliedScaleFactor;if(n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,r*(s-1)/n);Math.abs(o-r)<.01||(i.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=I(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=U(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=U(this.element);this._lastObservedWidth=t,s(this)}))})),this.settleParentHeight()}settleParentHeight(){const t=[150,400,1e3,2500],i=()=>{if(this._settleTimer=null,!this.element.isConnected)return;const{height:e}=U(this.element);e>0&&Math.abs(e-this._lastAppliedHeight)>8&&!this._autoScaleGuard&&s(this);const a=t.shift();void 0!==a&&(this._settleTimer=setTimeout(i,a))};this._settleTimer=setTimeout(i,t.shift())}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}prepareDimension(){const t=U(this.element),i=this.prepareScenarios(),e=this.prepareVariances();this.canvasWidthSegmented=t.width/(i.length+e.length||1),this._lastAppliedHeight=t.height;const s=1+e.length,a=this.showMeasureScale?this.getEffectiveFontPx():0;return{width:this.canvasWidthSegmented,height:Math.max(0,t.height-a)/s}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));const n="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return p(a.value)||n?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(n||a.unresolved?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=a.value)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}prepareAvg(){return this.showOverlayAvg}prepareMedian(){return this.showOverlayMedian}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return p(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}checkVarianceScenarios(t){const i="WARN_variances_scenario",e=this.prepareScenarios(),s=[];for(const i of t){const t=new _(i);if(t.isValid)for(const a of[t.base,t.delta])e.includes(a)||s.push(`'${i}' needs '${a}'`)}e.length>0&&s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:`variances: ${s.join(", ")}, which is not in scenarios (${e.join(", ")}). The variance has no values.`}):this.errors.remove(i)}prepareHideAxisLabels(t){return t>=1||!this.showCategories}prepareI18n(){const t=l,i=new Map(["no-data"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...T(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=j(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=j(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:i["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:i["bn-chart-time"].scaleFactors.labelToColumn,labelToAxis:i["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:i["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:i["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-time"].scaleFactors.markerWidth,markerOffset:i["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${e}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-time"].axisStyles,barStyles:i["bn-chart-time"].barStyles,varianceStyles:i["bn-chart-time"].varianceStyles,stackColors:i["bn-chart-time"].stackColors,padding:i["bn-chart-time"].padding,pattern:null,locale:"de"}}))}prepareLeftSideOffset(t,i){return this.syncSpaceLeft>-1?this.syncSpaceLeft:N.getMaxWidthOfArrayItems([...this.prepareVariances(),...this.prepareScenarios(),this.chartTitle],t,i)}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareDateInterval(){var t,i,e;const s="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return p(this.dateInterval)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(s?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:"dateInterval: not set, auto-detected: "+this.datasetMeta.suggestedDateInterval}),E[this.datasetMeta.suggestedDateInterval.toUpperCase()]):s?E.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),E[null===(e=this.dateInterval)||void 0===e?void 0:e.toUpperCase()])}prepareIntervalSpanLimit(){const t=Number(this.intervalSpanLimit);return t>0?t:28}prepareAxisLabelsMode(){var t;return R[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase()]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return p(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(p(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,e="WARN_stack_dimensions_scenarios";if(i===$.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:e,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(e)}else this.errors.remove(e);return{by:i,mode:t.mode||B.ABSOLUTE,order:t.order||F.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareLineFullWidth(){return this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?P.LINE:"auto"===i?P.AUTO:P.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,i){const e=this.prepareI18n(),s=this.prepareStyle(),n=U(this.element).width,r=this.preparePixelPerUnit(),o=this.preparePixelPerPercentage(),l=this.prepareStackConfig(),h=this.prepareScenarios(),d=(null==l?void 0:l.by)===$.DIMENSIONS?h.slice(0,1):h;return a("bn-chart-time-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:d,variances:[t],hideAxisLabels:this.prepareHideAxisLabels(i),pixelPerUnit:r,pixelPerPercentage:o,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,s),styles:s,i18n:e,dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(i),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:l,lineFullWidth:this.prepareLineFullWidth(),containerWidth:n,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return q(this.element,"bn-chart-time-renderer")}async getLayoutState(t){var i,e,s,a;const n=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",r=G(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,h=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,d=this.prepareVariances(),c=Y(this.element,"bn-chart-time-renderer",["base",...d],r,n),p=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-time-renderer"),u={version:z,tag:this.element.localName,id:H(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:V(this.element,r),em:{fontSizePx:h,appliedScaleFactor:l},regions:c.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==p?void 0:p.scenarios)&&void 0!==a?a:[],variances:d,barCount:c.barCount,chartMode:this.chartMode||void 0,hasNoData:0===c.barCount},diagnostics:X(this.element),scaling:this.resolveScalingInfo(h),baseline:c.baseline};return c.elements&&(u.elements=c.elements),u}resolveScalingInfo(t){var i,e;const s={},a=j(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const n=j(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)s.percentageMode="fixed",s.percentagePointsPerEm=n.value,s.percentagePxPerPoint=t/n.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=D(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,n;const r=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":r*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(n=i.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const i=this.prepareVariances();this.checkVarianceScenarios(i),i.length>0&&(t=[...t,...i]);const e=this.getFontStyles();return a(n,{key:"37085b275bb92d716a31f79f15b9f2517f1c596b",style:e},a("div",{key:"93e9eacc22334da1deed871db640d6fd4aafb153",class:"container"},t.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],measureScale:[{validateMeasureScale:0}]}}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:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}'}},[1,"bn-chart-time",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],syncSpaceLeft:[2,"sync-space-left"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dateInterval:[1,"date-interval"],chartMode:[1,"chart-mode"],maxBars:[2,"max-bars"],stack:[1],scale:[1],intervalSpanLimit:[2,"interval-span-limit"],axisLabelsMode:[1,"axis-labels-mode"],lineFullWidth:[4,"line-full-width"],showCategories:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],showOverlayAvg:[4,"show-overlay-avg"],showOverlayMedian:[4,"show-overlay-median"],measureUnit:[1,"measure-unit"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],measureScale:[{validateMeasureScale:0}]}]),Q=K,tt=function(){"undefined"!=typeof customElements&&["bn-chart-time","bn-chart-time-renderer"].forEach((t=>{switch(t){case"bn-chart-time":customElements.get(r(t))||customElements.define(r(t),K);break;case"bn-chart-time-renderer":customElements.get(r(t))||J()}}))};export{Q as BnChartTime,tt as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as o,d as s}from"./p-
|
|
1
|
+
import{B as o,d as s}from"./p-dRPJiQB6.js";const p=o,r=s;export{p as BnTableRenderer,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as i,w as e,h as a,a as s,t as r,f as n}from"./p-D6YGOYV1.js";import{h as o,a as l}from"./p-DDvWTgk1.js";import{v as d,a as h,i as p,p as c,q as u,r as v,s as m,h as g,t as f,u as y,w as b,c as O,x as S,l as w,y as T,z as D,f as A,A as N}from"./p-DT04Cka0.js";import{w as _}from"./p-DJUffGeB.js";import{w as W}from"./p-Dq9dG0Kr.js";import{w as C}from"./p-DQl2K2Xl.js";import{w as M,a as F,i as R}from"./p-BU_53KVT.js";import{w as j}from"./p-Bo_R7f_T.js";import{w as x}from"./p-DjPWZfry.js";import{r as U}from"./p-CniN8ALm.js";import{w as P}from"./p-OquycEMA.js";import{w as k,r as G}from"./p-4vVbchX2.js";import{g as B}from"./p-DD1zlev_.js";import{f as I,r as L,p as E}from"./p-Xb6Ilq8u.js";import{o as $}from"./p-B6kka9sT.js";import{D as z,I as J,d as V,M as q,B as K,T as Q}from"./p-B5tixDPM.js";import{I as X,a as Y,T as Z,d as H}from"./p-CHQ67u2G.js";import{p as tt}from"./p-DCPLGEs_.js";import{a as it,n as et}from"./p-16rjcQ0t.js";import{LAYOUT_STATE_VERSION as at}from"./index.js";import{o as st,m as rt}from"./p-DaOm9YwQ.js";import{r as nt,a as ot}from"./p-CckAR27O.js";import{b as lt}from"./p-t4xPltK2.js";import{s as dt}from"./p-DakXa7Dp.js";const ht=t(class extends i{validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.hasBlankSetnames=!1,this.sumTitle="",this.filter="",this.measureUnit="",this.barColumnWidth="w10",this.unitScaling="100",this.percentageScaling="2",this.pixelPerUnitGroupMap=new Map,this.dataFormat="decimal",this.grouped=!1,this.showMeasureScale=!1,this.showGroupTitle=!0,this.type="list",this.limit=0,this.thereof="[]",this.partof="[]",this.order="category",this.orderDirection="asc",this.measureType="volume",this.measureScale="greatest",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.categoryWidth="w15",this.columnthereof=null,this.interval="none",this.tableAttributes="",this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,e,a,s;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.unit,percentage:null!==(a=t.percentage)&&void 0!==a?a:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage};const r=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t);if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=1/t.unit;r(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${this.unitScaling}" - auto-fitted to 1 em ≈ ${I(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=1/t.percentage;r(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${this.percentageScaling}" - auto-fitted to 1 em ≈ ${I(i)} percentage points.`}))}},j(this),W(this),this.errors=k(this),C(this),this.componentStyle=x(this),this.ruleSetConfig=P(this),_(this,((t,i)=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1,this.hasBlankSetnames=Array.isArray(i)&&i.some((t=>{var i;return p(null!==(i=null==t?void 0:t.setname)&&void 0!==i?i:null==t?void 0:t.setName)}))}),((t,i)=>{this.datasetMeta=i})),this.t=M(this).t,this.resolveInherited=F(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(R(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(R(t))return void this.errors.remove(i);const e=h(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="WARN_barColumns";if(p(t))return void this.errors.remove(i);const e=c(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="WARN_barColumnWidth";u(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";"invalid"===L(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";"invalid"===L(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateDataFormat(t){const i="WARN_dataFormat";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateType(t){const i="WARN_type";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateLimit(t){const i="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateThereOf(t){const i="WARN_thereof",e=f(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="WARN_partof",e=y(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="WARN_order";if(R(t))return void this.errors.remove(i);const e=b(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";R(t)||O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureType(t){const i="WARN_measureType";S(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";w(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="WARN_dataFormatDigitsDecimal";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsDecimal: invalid value(s) '"+t+"' are not supported."})}validateDateFormatDigitsPercent(t){const i="WARN_dataFormatDigitsPercent";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsPercent: invalid value(s) '"+t+"' are not supported."})}validateCategoryWidth(t){const i="WARN_categoryWidth";T(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryWidth: invalid value(s) '"+t+"' are not supported."})}validateColumnThereOf(t){const i=D(t),e="WARN_columnthereof";i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(e)}validateInterval(t){const i="WARN_interval",e=null==t?void 0:t.trim().toLowerCase();p(t)||e===X||e===Y||A(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="WARN_attributes",e=N(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),this.validateType(this.type),this.validateLimit(this.limit),this.validateThereOf(this.thereof),this.validatePartOf(this.partof),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDateFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateCategoryWidth(this.categoryWidth),this.validateMeasureType(this.measureType),this.validateMeasureScale(this.measureScale),this.validateColumnThereOf(this.columnthereof),this.validateInterval(this.interval),this.validateTableAttributes(this.tableAttributes),this.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=$(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=B(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,n(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){dt(this.element,"bn-table-renderer");const{mode:t}=E(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:a}=B(i);if(a<=0)return void this.checkOverflow();this._lastScaledParentWidth=a;const s=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,n=this.appliedScaleFactor;if(r<=a+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(a-1)/r);Math.abs(o-n)<.001||(i.style.setProperty("--bn-font-size",s*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled table by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){const t=B(this.element),i=this.element.scrollWidth,e=this.element.scrollHeight,a=t.width>0&&i>t.width+1,s=t.height>0&&e>t.height+1;if(!a&&!s)return void G(this.errors,null);const{mode:r}=E(this.scale),n="auto"!==r&&"empty"!==r,o=[];a&&o.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),s&&o.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),G(this.errors,`Table exceeds available ${o.join(" and ")}. Give the component more space, reduce rows (e.g. limit), or set a smaller scale.`,n)}prepareDataFormat(){var t;return z[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return this.grouped}prepareShowGroupTitle(){return this.showGroupTitle}prepareTableType(){var t;return Z[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){if(null==this.thereof||""===this.thereof.trim())return[];try{return JSON.parse(this.thereof)}catch(t){return[]}}preparePartOf(){if(null==this.partof||""===this.partof.trim())return[];try{return JSON.parse(this.partof)}catch(t){return[]}}prepareOrder(){var t;const i=this.resolveInherited("order",this.order,"category").value,e=this.resolveInherited("orderDirection",this.orderDirection,"asc").value,a="auto"===(null==i?void 0:i.trim().toLowerCase());let s=i;return a&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(s=this.datasetMeta.suggestedOrder),{hierarchy:s.split(",").map((t=>et(t))),direction:it[null==e?void 0:e.toUpperCase()]}}prepareI18nMode(){return J.META}prepareI18n(){const t=l,i=new Map(["in","category","operation","thereof","part_of","SUM_TOTAL","no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...U(this.ruleSetConfig("user"))])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,e,a,s,r,n,o,l,d,h;const c=this.resolveInherited("scenarios",this.scenarios),u=this.resolveInherited("variances",this.variances);if(c.inherited||u.inherited){this.errors.remove("AUTO_scenarios");let a=[];return p(c.value)?c.unresolved&&(a=a.concat(null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[])):a=a.concat(c.value.split(",")),(null===(e=u.value)||void 0===e?void 0:e.trim().length)>0&&(a=a.concat(u.value.split(","))),a.map((t=>t.trim()))}const v="auto"===(null===(a=c.value)||void 0===a?void 0:a.trim().toLowerCase()),m=v||c.unresolved;if((p(c.value)||v)&&p(u.value))return(null===(r=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===r?void 0:r.length)>0?(m?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[];let g=[];return v||p(c.value)?(null===(o=null===(n=this.datasetMeta)||void 0===n?void 0:n.availableScenarios)||void 0===o?void 0:o.length)>0&&(m?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),g=g.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),g=g.concat(null===(l=c.value)||void 0===l?void 0:l.split(","))),(null===(d=u.value)||void 0===d?void 0:d.trim().length)>0&&(g=g.concat(null===(h=u.value)||void 0===h?void 0:h.split(","))),g.map((t=>t.trim()))}prepareCategoryWidth(){var t;return p(this.categoryWidth)?V.INF:V[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return p(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareMeasureType(){var t;return p(this.measureType)?q.VOLUME:q[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=new Map;try{const i=JSON.parse(this.columnthereof);for(const[e,a]of Object.entries(i))!1===t.has(a.scenario)&&t.set(a.scenario,[]),t.get(a.scenario).push(a)}catch(t){return new Map}return t}prepareInterval(){var t;const i="WARN_intervalConflict",e="WARN_intervalNoDate",a="WARN_intervalSetname",s=p(this.interval)?X:this.interval.trim().toLowerCase();return s!==X&&s!==Y&&!A(s)||s===X?(this.errors.remove(i),this.errors.remove(e),this.errors.remove(a),X):null!=this.columnthereof&&""!==this.columnthereof.trim()?(this.errors.addOrReplace({id:i,type:"warning",message:"interval: cannot be combined with columnthereof, interval is ignored."}),this.errors.remove(e),this.errors.remove(a),X):(this.errors.remove(i),s===Y?(this.hasBlankSetnames?this.errors.addOrReplace({id:a,type:"warning",message:"interval: rows with blank setname found, they are grouped under '-'."}):this.errors.remove(a),this.errors.remove(e),Y):(this.errors.remove(a),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:e,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),X):(this.errors.remove(e),s)))}prepareAttributes(){if(null==this.tableAttributes||""===this.tableAttributes.trim())return[];try{const t=JSON.parse(this.tableAttributes);return null===t||"object"!=typeof t||t instanceof Array?[]:Object.entries(t).map((([t,i],e)=>"string"==typeof i?tt(t,"attr_"+e,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareBarColumnWidth(){var t;const i=null===(t=this.barColumnWidth)||void 0===t?void 0:t.toUpperCase(),e=Q[i];return e?K[e]:K[Q.W10]}prepareBarColumns(){return p(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=L(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${t.raw}" - auto-fitting to the bar column width.`}),0)}preparePercentageScaling(){const t=L(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${t.raw}" - auto-fitting to the pin area.`}),0)}getDataStructure(){return{ITableDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}async getBaseline(){return this.readBaseline()}readBaseline(){var t,i,e;const a=null===(e=null===(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector("bn-table-renderer"))||void 0===i?void 0:i.shadowRoot)||void 0===e?void 0:e.querySelector("table");return lt(a,this.element)}async getLayoutState(t){var i,e,a,s;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=st(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,d=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,h={version:at,tag:this.element.localName,id:ot(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:rt(this.element,n),em:{fontSizePx:d,appliedScaleFactor:l},regions:[],metadata:{},diagnostics:nt(this.element),scaling:this.resolveScalingInfo(d),baseline:this.readBaseline()},p=null===(a=this.element.shadowRoot)||void 0===a?void 0:a.querySelector("bn-table-renderer");if(p){const t=null!==(s=p.scenarios)&&void 0!==s?s:[];if(h.metadata.scenarios=t.filter((t=>!t.startsWith("d"))),h.metadata.variances=t.filter((t=>t.startsWith("d"))),"function"==typeof p.getLayoutDetail){const t=await p.getLayoutDetail(n,r);h.regions=t.regions,h.metadata=Object.assign(Object.assign({},h.metadata),t.metadata),h.diagnostics=[...h.diagnostics,...t.diagnostics],t.elements&&(h.elements=t.elements),t.table&&(h.table=t.table)}}return h}resolveScalingInfo(t){var i,e;const a={},s=L(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===s.kind)a.unitMode="fixed",a.unitsPerEm=s.value,a.unitPxPerUnit=t/s.value;else{a.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(a.unitsPerEm=1/e,a.unitPxPerUnit=e*t)}const r=L(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)a.percentageMode="fixed",a.percentagePointsPerEm=r.value,a.percentagePxPerPoint=t/r.value;else{a.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(a.percentagePointsPerEm=1/i,a.percentagePxPerPoint=i*t)}return a}getEffectiveScaleFactor(){const{mode:t,factor:i}=E(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,a,s,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(a=i.global)||void 0===a?void 0:a.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(s=i.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),i=this.getEffectiveScaleFactor();return a(s,{key:"2f24deddc4e58f57ef27443a27b4706b5f1b90db",style:t},a("div",{key:"b6368e143f868d9c2a7ad8ec753a14813b60e197"},a("bn-table-renderer",{key:"399b2dc8d5cf3e7a8093a9a486635ea4d1bb74b9",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),thereof:this.prepareThereOf(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),attributeColumns:this.prepareAttributes(),type:this.prepareTableType(),categoryWidth:this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),i18nMode:this.prepareI18nMode(),measureScale:this.prepareMeasureScale(),measureType:this.prepareMeasureType(),measureUnit:this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),interval:this.prepareInterval(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,scaleFactor:i,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return this}static get watchers(){return{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],tableAttributes:[{validateTableAttributes:0}]}}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)}'}},[1,"bn-table",{datasets:[513],i18nNamespace:[513,"i18n-namespace"],scale:[1],ruleset:[513],selectedStyle:[513,"selected-style"],sumTitle:[1,"sum-title"],filter:[1],measureUnit:[1,"measure-unit"],scenarios:[1],variances:[1],barColumns:[1,"bar-columns"],barColumnWidth:[1,"bar-column-width"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dataFormat:[1,"data-format"],grouped:[4],showMeasureScale:[4,"show-measure-scale"],showGroupTitle:[4,"show-group-title"],type:[1],limit:[2],thereof:[1],partof:[1],order:[1],orderDirection:[1,"order-direction"],measureType:[1,"measure-type"],measureScale:[1,"measure-scale"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],categoryWidth:[1,"category-width"],columnthereof:[1],interval:[1],tableAttributes:[1,"attributes"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],hasBlankSetnames:[32],getBaseline:[64],getLayoutState:[64]},void 0,{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],tableAttributes:[{validateTableAttributes:0}]}]),pt=ht,ct=function(){"undefined"!=typeof customElements&&["bn-table","bn-table-renderer"].forEach((t=>{switch(t){case"bn-table":customElements.get(r(t))||customElements.define(r(t),ht);break;case"bn-table-renderer":customElements.get(r(t))||H()}}))};export{pt as BnTable,ct as defineCustomElement}
|
|
1
|
+
import{p as t,H as i,w as e,h as a,a as s,t as r,f as n}from"./p-D6YGOYV1.js";import{h as o,a as l}from"./p-DDvWTgk1.js";import{v as d,a as h,i as p,p as c,q as u,r as v,s as m,h as g,t as f,u as y,w as b,c as S,x as O,l as w,y as A,z as D,f as T,A as N}from"./p-DT04Cka0.js";import{w as _}from"./p-DJUffGeB.js";import{w as W}from"./p-Dq9dG0Kr.js";import{w as C}from"./p-DQl2K2Xl.js";import{w as M,a as R,i as F}from"./p-BU_53KVT.js";import{w as x}from"./p-Bo_R7f_T.js";import{w as P}from"./p-DjPWZfry.js";import{r as j}from"./p-CniN8ALm.js";import{w as I}from"./p-OquycEMA.js";import{w as U,r as k}from"./p-4vVbchX2.js";import{g as B}from"./p-DD1zlev_.js";import{f as G,r as L,p as E}from"./p-Xb6Ilq8u.js";import{o as J}from"./p-B6kka9sT.js";import{D as $,I as z,d as V,M as X,B as Y,T as q}from"./p-B5tixDPM.js";import{I as Q,a as Z,T as K,d as H,c as tt}from"./p-dRPJiQB6.js";import{p as it}from"./p-DCPLGEs_.js";import{a as et,n as at}from"./p-16rjcQ0t.js";import{LAYOUT_STATE_VERSION as st}from"./index.js";import{o as rt,m as nt}from"./p-DaOm9YwQ.js";import{r as ot,a as lt}from"./p-CckAR27O.js";import{b as dt}from"./p-XFZYX7DZ.js";import{s as ht}from"./p-DakXa7Dp.js";const pt=t(class extends i{validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.hasBlankSetnames=!1,this.hasSetnameIndexWithoutSetname=!1,this.sumTitle="",this.filter="",this.measureUnit="",this.barColumnWidth="w10",this.unitScaling="100",this.percentageScaling="2",this.pixelPerUnitGroupMap=new Map,this.dataFormat="decimal",this.grouped=!1,this.showMeasureScale=!1,this.showGroupTitle=!0,this.type="list",this.limit=0,this.thereof="[]",this.partof="[]",this.order="category",this.orderDirection="asc",this.measureType="volume",this.measureScale="greatest",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.categoryWidth="w15",this.columnthereof=null,this.interval="none",this.categoryIntervalPosition=0,this.tableAttributes="",this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,e,a,s;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.unit,percentage:null!==(a=t.percentage)&&void 0!==a?a:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage};const r=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t);if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=1/t.unit;r(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${this.unitScaling}" - auto-fitted to 1 em ≈ ${G(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=1/t.percentage;r(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${this.percentageScaling}" - auto-fitted to 1 em ≈ ${G(i)} percentage points.`}))}},x(this),W(this),this.errors=U(this),C(this),this.componentStyle=P(this),this.ruleSetConfig=I(this),_(this,((t,i)=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1,this.hasBlankSetnames=Array.isArray(i)&&i.some((t=>{var i;return p(null!==(i=null==t?void 0:t.setname)&&void 0!==i?i:null==t?void 0:t.setName)})),this.hasSetnameIndexWithoutSetname=Array.isArray(i)&&i.some((t=>{var i,e;return void 0!==tt(null!==(i=null==t?void 0:t.setnameIndex)&&void 0!==i?i:null==t?void 0:t.setNameIndex)&&p(null!==(e=null==t?void 0:t.setname)&&void 0!==e?e:null==t?void 0:t.setName)}))}),((t,i)=>{this.datasetMeta=i})),this.t=M(this).t,this.resolveInherited=R(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(F(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(F(t))return void this.errors.remove(i);const e=h(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="WARN_barColumns";if(p(t))return void this.errors.remove(i);const e=c(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="WARN_barColumnWidth";u(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";"invalid"===L(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";"invalid"===L(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateDataFormat(t){const i="WARN_dataFormat";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateType(t){const i="WARN_type";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateLimit(t){const i="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateThereOf(t){const i="WARN_thereof",e=f(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="WARN_partof",e=y(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="WARN_order";if(F(t))return void this.errors.remove(i);const e=b(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";F(t)||S(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureType(t){const i="WARN_measureType";O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";w(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="WARN_dataFormatDigitsDecimal";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsDecimal: invalid value(s) '"+t+"' are not supported."})}validateDateFormatDigitsPercent(t){const i="WARN_dataFormatDigitsPercent";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsPercent: invalid value(s) '"+t+"' are not supported."})}validateCategoryWidth(t){const i="WARN_categoryWidth";A(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryWidth: invalid value(s) '"+t+"' are not supported."})}validateColumnThereOf(t){const i=D(t),e="WARN_columnthereof";i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(e)}validateInterval(t){const i="WARN_interval",e=null==t?void 0:t.trim().toLowerCase();p(t)||e===Q||e===Z||T(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateCategoryIntervalPosition(t){const i="WARN_categoryIntervalPosition";p(t)||g(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryIntervalPosition: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="WARN_attributes",e=N(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),this.validateType(this.type),this.validateLimit(this.limit),this.validateThereOf(this.thereof),this.validatePartOf(this.partof),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDateFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateCategoryWidth(this.categoryWidth),this.validateMeasureType(this.measureType),this.validateMeasureScale(this.measureScale),this.validateColumnThereOf(this.columnthereof),this.validateInterval(this.interval),this.validateCategoryIntervalPosition(this.categoryIntervalPosition),this.validateTableAttributes(this.tableAttributes),this.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=J(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=B(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,n(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){ht(this.element,"bn-table-renderer");const{mode:t}=E(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:a}=B(i);if(a<=0)return void this.checkOverflow();this._lastScaledParentWidth=a;const s=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,n=this.appliedScaleFactor;if(r<=a+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(a-1)/r);Math.abs(o-n)<.001||(i.style.setProperty("--bn-font-size",s*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled table by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){const t=B(this.element),i=this.element.scrollWidth,e=this.element.scrollHeight,a=t.width>0&&i>t.width+1,s=t.height>0&&e>t.height+1;if(!a&&!s)return void k(this.errors,null);const{mode:r}=E(this.scale),n="auto"!==r&&"empty"!==r,o=[];a&&o.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),s&&o.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),k(this.errors,`Table exceeds available ${o.join(" and ")}. Give the component more space, reduce rows (e.g. limit), or set a smaller scale.`,n)}prepareDataFormat(){var t;return $[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return this.grouped}prepareShowGroupTitle(){return this.showGroupTitle}prepareTableType(){var t;return K[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){if(null==this.thereof||""===this.thereof.trim())return[];try{return JSON.parse(this.thereof)}catch(t){return[]}}preparePartOf(){if(null==this.partof||""===this.partof.trim())return[];try{return JSON.parse(this.partof)}catch(t){return[]}}prepareOrder(){var t;const i=this.resolveInherited("order",this.order,"category").value,e=this.resolveInherited("orderDirection",this.orderDirection,"asc").value,a="auto"===(null==i?void 0:i.trim().toLowerCase());let s=i;return a&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(s=this.datasetMeta.suggestedOrder),{hierarchy:s.split(",").map((t=>at(t))),direction:et[null==e?void 0:e.toUpperCase()]}}prepareI18nMode(){return z.META}prepareI18n(){const t=l,i=new Map(["in","category","operation","thereof","part_of","SUM_TOTAL","no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...j(this.ruleSetConfig("user"))])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,e,a,s,r,n,o,l,d,h;const c=this.resolveInherited("scenarios",this.scenarios),u=this.resolveInherited("variances",this.variances);if(c.inherited||u.inherited){this.errors.remove("AUTO_scenarios");let a=[];return p(c.value)?c.unresolved&&(a=a.concat(null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[])):a=a.concat(c.value.split(",")),(null===(e=u.value)||void 0===e?void 0:e.trim().length)>0&&(a=a.concat(u.value.split(","))),a.map((t=>t.trim()))}const v="auto"===(null===(a=c.value)||void 0===a?void 0:a.trim().toLowerCase()),m=v||c.unresolved;if((p(c.value)||v)&&p(u.value))return(null===(r=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===r?void 0:r.length)>0?(m?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[];let g=[];return v||p(c.value)?(null===(o=null===(n=this.datasetMeta)||void 0===n?void 0:n.availableScenarios)||void 0===o?void 0:o.length)>0&&(m?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),g=g.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),g=g.concat(null===(l=c.value)||void 0===l?void 0:l.split(","))),(null===(d=u.value)||void 0===d?void 0:d.trim().length)>0&&(g=g.concat(null===(h=u.value)||void 0===h?void 0:h.split(","))),g.map((t=>t.trim()))}prepareCategoryWidth(){var t;return p(this.categoryWidth)?V.INF:V[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return p(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareMeasureType(){var t;return p(this.measureType)?X.VOLUME:X[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=new Map;try{const i=JSON.parse(this.columnthereof);for(const[e,a]of Object.entries(i))!1===t.has(a.scenario)&&t.set(a.scenario,[]),t.get(a.scenario).push(a)}catch(t){return new Map}return t}prepareInterval(){var t;const i="WARN_intervalConflict",e="WARN_intervalNoDate",a="WARN_intervalSetname",s="WARN_intervalSetnameIndex",r=p(this.interval)?Q:this.interval.trim().toLowerCase();return r!==Q&&r!==Z&&!T(r)||r===Q?(this.errors.remove(i),this.errors.remove(e),this.errors.remove(a),this.errors.remove(s),Q):null!=this.columnthereof&&""!==this.columnthereof.trim()?(this.errors.addOrReplace({id:i,type:"warning",message:"interval: cannot be combined with columnthereof, interval is ignored."}),this.errors.remove(e),this.errors.remove(a),this.errors.remove(s),Q):(this.errors.remove(i),r===Z?(this.hasBlankSetnames?this.errors.addOrReplace({id:a,type:"warning",message:"interval: rows with blank setname found, they are grouped under '-'."}):this.errors.remove(a),this.hasSetnameIndexWithoutSetname?this.errors.addOrReplace({id:s,type:"warning",message:"interval: rows with setnameIndex but blank setname found, setnameIndex needs setname."}):this.errors.remove(s),this.errors.remove(e),Z):(this.errors.remove(a),this.errors.remove(s),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:e,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),Q):(this.errors.remove(e),r)))}prepareCategoryIntervalPosition(){const t=Number(this.categoryIntervalPosition);return Number.isInteger(t)&&t>0?t:0}prepareAttributes(){if(null==this.tableAttributes||""===this.tableAttributes.trim())return[];try{const t=JSON.parse(this.tableAttributes);return null===t||"object"!=typeof t||t instanceof Array?[]:Object.entries(t).map((([t,i],e)=>"string"==typeof i?it(t,"attr_"+e,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareBarColumnWidth(){var t;const i=null===(t=this.barColumnWidth)||void 0===t?void 0:t.toUpperCase(),e=q[i];return e?Y[e]:Y[q.W10]}prepareBarColumns(){return p(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=L(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${t.raw}" - auto-fitting to the bar column width.`}),0)}preparePercentageScaling(){const t=L(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${t.raw}" - auto-fitting to the pin area.`}),0)}getDataStructure(){return{ITableDataRow:{setName:{type:"string",isOptional:!1,description:""},setNameIndex:{type:"number",isOptional:!0,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}async getBaseline(){return this.readBaseline()}readBaseline(){var t,i,e;const a=null===(e=null===(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector("bn-table-renderer"))||void 0===i?void 0:i.shadowRoot)||void 0===e?void 0:e.querySelector("table");return dt(a,this.element)}async getLayoutState(t){var i,e,a,s;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=rt(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,d=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,h={version:st,tag:this.element.localName,id:lt(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:nt(this.element,n),em:{fontSizePx:d,appliedScaleFactor:l},regions:[],metadata:{},diagnostics:ot(this.element),scaling:this.resolveScalingInfo(d),baseline:this.readBaseline()},p=null===(a=this.element.shadowRoot)||void 0===a?void 0:a.querySelector("bn-table-renderer");if(p){const t=null!==(s=p.scenarios)&&void 0!==s?s:[];if(h.metadata.scenarios=t.filter((t=>!t.startsWith("d"))),h.metadata.variances=t.filter((t=>t.startsWith("d"))),"function"==typeof p.getLayoutDetail){const t=await p.getLayoutDetail(n,r);h.regions=t.regions,h.metadata=Object.assign(Object.assign({},h.metadata),t.metadata),h.diagnostics=[...h.diagnostics,...t.diagnostics],t.elements&&(h.elements=t.elements),t.table&&(h.table=t.table)}}return h}resolveScalingInfo(t){var i,e;const a={},s=L(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===s.kind)a.unitMode="fixed",a.unitsPerEm=s.value,a.unitPxPerUnit=t/s.value;else{a.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(a.unitsPerEm=1/e,a.unitPxPerUnit=e*t)}const r=L(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)a.percentageMode="fixed",a.percentagePointsPerEm=r.value,a.percentagePxPerPoint=t/r.value;else{a.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(a.percentagePointsPerEm=1/i,a.percentagePxPerPoint=i*t)}return a}getEffectiveScaleFactor(){const{mode:t,factor:i}=E(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,a,s,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(a=i.global)||void 0===a?void 0:a.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(s=i.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),i=this.getEffectiveScaleFactor();return a(s,{key:"9c4b7d3df45c425ab5d6f1443a3a067220d3a451",style:t},a("div",{key:"b0332096da43ca9d5c139da7f18abdcb89356c37"},a("bn-table-renderer",{key:"f9ae1288c299bf3e5a5d1da5161fd9c663472e76",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),thereof:this.prepareThereOf(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),attributeColumns:this.prepareAttributes(),type:this.prepareTableType(),categoryWidth:this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),i18nMode:this.prepareI18nMode(),measureScale:this.prepareMeasureScale(),measureType:this.prepareMeasureType(),measureUnit:this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),interval:this.prepareInterval(),categoryIntervalPosition:this.prepareCategoryIntervalPosition(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,scaleFactor:i,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return this}static get watchers(){return{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],categoryIntervalPosition:[{validateCategoryIntervalPosition:0}],tableAttributes:[{validateTableAttributes:0}]}}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)}'}},[1,"bn-table",{datasets:[513],i18nNamespace:[513,"i18n-namespace"],scale:[1],ruleset:[513],selectedStyle:[513,"selected-style"],sumTitle:[1,"sum-title"],filter:[1],measureUnit:[1,"measure-unit"],scenarios:[1],variances:[1],barColumns:[1,"bar-columns"],barColumnWidth:[1,"bar-column-width"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dataFormat:[1,"data-format"],grouped:[4],showMeasureScale:[4,"show-measure-scale"],showGroupTitle:[4,"show-group-title"],type:[1],limit:[2],thereof:[1],partof:[1],order:[1],orderDirection:[1,"order-direction"],measureType:[1,"measure-type"],measureScale:[1,"measure-scale"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],categoryWidth:[1,"category-width"],columnthereof:[1],interval:[1],categoryIntervalPosition:[2,"category-interval-position"],tableAttributes:[1,"attributes"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],hasBlankSetnames:[32],hasSetnameIndexWithoutSetname:[32],getBaseline:[64],getLayoutState:[64]},void 0,{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],categoryIntervalPosition:[{validateCategoryIntervalPosition:0}],tableAttributes:[{validateTableAttributes:0}]}]),ct=pt,ut=function(){"undefined"!=typeof customElements&&["bn-table","bn-table-renderer"].forEach((t=>{switch(t){case"bn-table":customElements.get(r(t))||customElements.define(r(t),pt);break;case"bn-table-renderer":customElements.get(r(t))||H()}}))};export{ct as BnTable,ut as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as i,h as s,a as e,t as h}from"./p-D6YGOYV1.js";import{r as n,m as o,s as r,g as a,d as l}from"./p-DDvWTgk1.js";import{C as d,I as c}from"./p-CniN8ALm.js";import{w as u}from"./p-Dq9dG0Kr.js";import{e as v,r as m}from"./p-ClruFZD_.js";import{S as f,F as b,a as p,P as w}from"./p-eWxolPDU.js";import{d as g,S as y}from"./p-BzjGUtYh.js";import{X as x,r as M,a as $,x as z,f as j,b as L,P as S,c as P,F as W,d as D,S as k}from"./p-BhEdmPjm.js";import{g as C}from"./p-4q8nRcWC.js";import{N}from"./p-BJmwHV0a.js";import{a as E,r as F,i as T}from"./p-BXXjh6We.js";class A{constructor(t,i,s,e,h){this.mode=t,this.vMax=i,this.rMaxPx=s,this.rMinPx=e,this.areaPerUnitPx2=h}static local(t,i,s){return new A("local",t,i,s,0)}static grouped(t){return new A("grouped",0,0,0,t)}radius(t){return"grouped"===this.mode?t<=0?0:Math.sqrt(this.areaPerUnitPx2*t/Math.PI):this.vMax<=0||t<=0?this.rMinPx:Math.max(this.rMinPx,this.rMaxPx*Math.sqrt(t/this.vMax))}}class B{constructor(t,i,s,e,h,n){var o,r,a,l;this.ruleSet=t,this.config=e,this.styles=h,this.availableWidth=n,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map,this.hatchPatterns=new Set,this.scaleOverflowCount=0,this.svgRoot=null,this.config=Object.assign(Object.assign({},e),{x:E(e.x),y:E(e.y)});const d=new x;let c=[];try{""!==s&&(c=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=v(t)}const u=(null!=c?c:[]).map((t=>d.adapt(t)));this.data=M(u,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=F(e.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(r=F(e.y.measure))&&void 0!==r?r:{kind:"scenario",slot:"ac2"},size:null!==(a=F(e.size.measure))&&void 0!==a?a:{kind:"scenario",slot:"ac3"},share:null!==e.share&&null!==(l=F(e.share.measure))&&void 0!==l?l:void 0},compareFamily:e.compareFamily,domains:{x:{min:this.config.x.min,max:this.config.x.max},y:{min:this.config.y.min,max:this.config.y.max}},limit:e.limit,limitBy:"size"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}get xPercent(){return T(this.config.x.measure)}get yPercent(){return T(this.config.y.measure)}get sizePercent(){return T(this.config.size.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=d(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,h={}){var n,o;return t.text(i).font({size:this.styles.fontStyles.size,weight:h.bold?"bold":"normal",anchor:null!==(n=h.anchor)&&void 0!==n?n:"start"}).fill(null!==(o=h.color)&&void 0!==o?o:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}setI18n(t){this.i18nMap=t}addWarningOnce(t,i){this.warnings.some((i=>i.code===t))||this.warnings.push({code:t,data:i})}primaryColorIndex(){const t=F(this.config.size.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}compareColorIndex(){return this.ruleSet.getScenarioColorIndex(`${this.config.compareFamily}1`)}seriesHue(t){const{color:i,overflowed:s}=n(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),i}familyDisplayName(t){return this.ruleSet.getScenario(`${t}1`).group}legendModel(){var t,i;const s=[],e=null!==(i=null!==(t=this.config.size.label)&&void 0!==t?t:this.i18nMap.get("legend.size"))&&void 0!==i?i:"";""!==e&&(s.push(e),void 0!==this.config.size.unit&&""!==this.config.size.unit&&s.push(`${this.i18nMap.get("axis.in")||"in"} ${this.config.size.unit}`));const h=[];if(null!==this.config.compareFamily){const t=F(this.config.size.measure),i=null!==t&&"scenario"===t.kind?t.slot.replace(/\d+$/,""):"ac";h.push(this.legendEntry(this.familyDisplayName(this.config.compareFamily),this.compareColorIndex(),0)),h.push(this.legendEntry(this.familyDisplayName(i),this.primaryColorIndex(),0))}const n=this.data.series.map((t=>{var i;return this.legendEntry(""===t.key?null!==(i=this.ruleSet.getScenario("").name)&&void 0!==i?i:"Series":t.key,this.primaryColorIndex(),t.index)}));return{sizeCaption:s,title:this.i18nMap.get("legend.title")||null,compareEntries:h,entries:n}}legendEntry(t,i,s){const e=this.seriesHue(s),h=o(i,e,"bubble");return{label:t,treatment:h,fill:this.treatmentFill(h,s,e)}}toString(){const t=new f;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}axisTitle(t,i){var s;const e=null!==(s=t.label)&&void 0!==s?s:"";return""===e?"":void 0===t.unit||""===t.unit?e:`${e} ${i} ${t.unit}`}draw(t){var i,s,e,h,n,o,r,a,l,d,c;this.warnings=this.data.warnings.slice(),this.hatchPatterns.clear(),this.scaleOverflowCount=0,this.svgRoot=t;const u=this.em,v=this.styles.padding,m=this.i18nMap.get("axis.in")||"in",f=t.group(),b=new $(this.styles),p=this.legendModel(),w=this.config.legend.show&&(p.entries.length>0||p.sizeCaption.length>0),g=w?b.measure(p,this.config.legend.position):{width:0,height:0},y="right"===this.config.legend.position&&w?g.width+u:0,x=""!==this.config.chartTitle?1.6*u:0,M=this.axisTitle(this.config.y,m),L=this.axisTitle(this.config.x,m),S=""!==M?1.4*u:.4*u,P=1.4*u+(""!==L?1.3*u:0);let D,k=3*u,C={x:0,y:0,width:0,height:0},E=[];const F=Math.max(1,this.data.facets.length),T=null===(i=this.config.facet)||void 0===i?void 0:i.columns,B=N.domain(null!==(e=null===(s=this.data.extents)||void 0===s?void 0:s.xMin)&&void 0!==e?e:0,null!==(n=null===(h=this.data.extents)||void 0===h?void 0:h.xMax)&&void 0!==n?n:1,{min:this.config.x.min,max:this.config.x.max}),H=N.domain(null!==(r=null===(o=this.data.extents)||void 0===o?void 0:o.yMin)&&void 0!==r?r:0,null!==(l=null===(a=this.data.extents)||void 0===a?void 0:a.yMax)&&void 0!==l?l:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-v.left-v.right-k-y);C={x:v.left+k,y:v.top+x+S,width:t,height:t/this.config.aspect},D=new W(F,T,C,this.styles.scaleFactors.panelGap*u);const i=D.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*u)))),e=new N(H[0],H[1],i,0);E=e.ticks(s);const h=z(E,this.yPercent);k=Math.max(...E.map((t=>this.textWidth(j(t,h,this.styles.locale,this.yPercent)))),u)+this.styles.scaleFactors.axisTickLength*u+.4*u}this.canvasHeight=C.y+C.height+P+("bottom"===this.config.legend.position&&w?g.height+u:0)+v.bottom,""!==this.config.chartTitle&&this.drawText(f,this.config.chartTitle,v.left,v.top+u,{bold:!0}),""!==M&&this.drawAxisTitleText(f,this.config.y,m,v.left,C.y-.6*u,"start");const I=this.buildPanels(D,B,H),O=I[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(I[0].rect.width/(7*u))))),U=z(O,this.xPercent),X=z(E,this.yPercent),Y=this.config.sizeAreaPerUnit>0?A.grouped(this.config.sizeAreaPerUnit):A.local(null!==(c=null===(d=this.data.extents)||void 0===d?void 0:d.sizeMax)&&void 0!==c?c:0,this.styles.scaleFactors.bubbleMaxRadius*u,this.styles.scaleFactors.bubbleMinRadius*u);0===this.data.facets.length?this.drawPanel(f,I[0],{key:"",points:[]},Y,O,E,U,X,!0,!0):this.data.facets.forEach(((t,i)=>{this.drawPanel(f,I[i],t,Y,O,E,U,X,D.isOuterLeft(i),D.isOuterBottom(i),this.data.facets.length>1?t.key:"")})),""!==L&&this.drawAxisTitleText(f,this.config.x,m,C.x+C.width,C.y+C.height+2.6*u,"end"),w&&("right"===this.config.legend.position?b.draw(f,p,C.x+C.width+u,C.y,"right"):b.draw(f,p,C.x,C.y+C.height+P,"bottom")),this.scaleOverflowCount>0&&this.addWarningOnce("bubble-scale-overflow",{count:String(this.scaleOverflowCount)}),t.group().addClass("annotations")}drawAxisTitleText(t,i,s,e,h,n){var o;const r=null!==(o=i.label)&&void 0!==o?o:"",a=void 0!==i.unit&&""!==i.unit?`${s} ${i.unit}`:"",l=.3*this.em;"start"===n?(this.drawText(t,r,e,h,{bold:!0}),""!==a&&this.drawText(t,a,e+this.textWidth(r,!0)+l,h,{})):""!==a?(this.drawText(t,a,e,h,{anchor:"end"}),this.drawText(t,r,e-this.textWidth(a)-l,h,{anchor:"end",bold:!0})):this.drawText(t,r,e,h,{anchor:"end",bold:!0})}buildPanels(t,i,s){const e=[];for(let h=0;h<t.count;h++){const n=t.panelRect(h),o=new N(i[0],i[1],n.x,n.x+n.width),r=new N(s[0],s[1],n.y+n.height,n.y);e.push({rect:n,xScale:o,yScale:r,frame:new L(o,r,n,this.styles)})}return e}treatmentFill(t,i,s){return!0!==t.hatch?t.fill:(this.ensureHatchPattern(i,s),`url(#xy-fc-${i})`)}ensureHatchPattern(t,i){this.hatchPatterns.has(t)||null===this.svgRoot||(this.hatchPatterns.add(t),this.svgRoot.defs().pattern(10,10,(t=>{t.rect(10,10).fill("#ffffff"),t.line(0,10,10,0).stroke({color:i,width:2}),t.line(-2.5,2.5,2.5,-2.5).stroke({color:i,width:2}),t.line(7.5,12.5,12.5,7.5).stroke({color:i,width:2})})).id(`xy-fc-${t}`))}drawPanel(t,i,s,e,h,n,a,l,d,c,u=""){var v,m,f,b,p,w;const y=t.group(),x=this.em;i.frame.drawBands(y,this.config.x.highlight,this.config.y.highlight),i.frame.drawGrid(y,n,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&i.rect.width>30*x?h:void 0),i.frame.drawRefLines(y,this.config.x.refLine,this.config.y.refLine),i.frame.drawFrame(y);const M=y.group().id("compare"),$=y.group().id("primary"),z=new S(i.rect,this.styles.scaleFactors.labelToMark*x),j=[...s.points].sort(((t,i)=>{var s,e;return(null!==(s=i.size)&&void 0!==s?s:0)-(null!==(e=t.size)&&void 0!==e?e:0)})),L=[];for(const t of j){const h=null!==(m=null===(v=this.data.series.find((i=>i.key===t.seriesKey)))||void 0===v?void 0:v.index)&&void 0!==m?m:0,n=this.seriesHue(h),a=o(this.primaryColorIndex(),n,"bubble"),l=i.xScale.scale(t.x),d=i.yScale.scale(t.y),c=e.radius(null!==(f=t.size)&&void 0!==f?f:0);if(this.config.sizeAreaPerUnit>0&&this.bubbleExceedsPanel(i.rect,l,d,c)&&this.scaleOverflowCount++,null!=t.compare){const s=o(this.compareColorIndex(),n,"bubble"),r=i.xScale.scale(t.compare.x),a=i.yScale.scale(t.compare.y),l=e.radius(null!==(b=t.compare.size)&&void 0!==b?b:0);this.drawBubble(M,r,a,l,s,h,n),z.registerMark(r,a,l),this.config.labels.values&&void 0!==t.compare.size&&l>=1.2*x&&this.drawValueLabel(M,r,a,l,t.compare.size,s.fill)}const u=P(t,s.key,this.config);null===(p=this.drawBubble($,l,d,c,a,h,n))||void 0===p||p.attr(g(u,"element")),z.registerMark(l,d,c),void 0!==t.share&&c>0&&(null===(w=this.drawShareSlice($,l,d,c,t.share,r(n)))||void 0===w||w.attr(g(u))),this.config.labels.values&&void 0!==t.size&&this.drawValueLabel($,l,d,c,t.size,!0===a.hatch?"#ffffff":a.fill),L.push({point:t,cx:l,cy:d,r:c,seriesIndex:h,hue:n,treatment:a})}this.drawNameLabels(y,z,L,s.key),i.frame.drawTickLabels(y,{ticksX:h,ticksY:n,xDecimals:a,yDecimals:l,xPercent:this.xPercent,yPercent:this.yPercent,showXLabels:c,showYLabels:d}),""!==u&&i.frame.drawPanelTitle(y,u)}bubbleExceedsPanel(t,i,s,e){return i-e<t.x||i+e>t.x+t.width||s-e<t.y||s+e>t.y+t.height}drawBubble(t,i,s,e,h,n,o){if(!(e<=0))return t.circle(2*e).center(i,s).fill(this.treatmentFill(h,n,o)).stroke({color:h.stroke,width:h.strokeWidth})}drawShareSlice(t,i,s,e,h,n){if(h<=0)return;if(h>=1)return t.circle(2*e).center(i,s).fill(n);const o=2*h*Math.PI,r=i+e*Math.sin(o),a=s-e*Math.cos(o),l=o>Math.PI?1:0;return t.path(`M ${i} ${s} L ${i} ${s-e} A ${e} ${e} 0 ${l} 1 ${r} ${a} Z`).fill(n).stroke("none")}drawValueLabel(t,i,s,e,h,n){const o=j(h,this.valueDecimals(),this.styles.locale,this.sizePercent);this.textWidth(o)+.4*this.em>2*e||this.drawText(t,o,i,s+.35*this.em,{anchor:"middle",color:C(n)})}drawNameLabels(t,i,s,e){const h=[...s].sort(((t,i)=>{var s,e;return(null!==(s=i.point.size)&&void 0!==s?s:0)-(null!==(e=t.point.size)&&void 0!==e?e:0)})),{selected:n,unknownNames:o}=i.selectCandidates(h,this.config.labels.points,this.config.labels.max,(t=>t.point.name));o.length>0&&this.addWarningOnce("xy-label-unknown",{names:o.join(", ")});const r=new Map,a=n.map((t=>{const i={name:t.point.name,cx:t.cx,cy:t.cy,r:t.r,width:this.textWidth(t.point.name),height:1.1*this.em};return r.set(i,t.point),i}));for(const s of i.place(a))this.drawText(t,s.candidate.name,s.x,s.y+.9*s.candidate.height,{}).attr(g(P(r.get(s.candidate),e,this.config),"label"))}valueDecimals(){var t,i,s;let e=0;for(const h of this.data.facets)for(const n of h.points)e=Math.max(e,Math.abs(null!==(t=n.size)&&void 0!==t?t:0),Math.abs(null!==(s=null===(i=n.compare)||void 0===i?void 0:i.size)&&void 0!==s?s:0));return e>0&&Number.isFinite(e)?(this.sizePercent&&(e*=100),N.stepDecimals(Math.pow(10,Math.floor(Math.log10(e))-2))):1}}const H=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-label-unknown","xy-series-overflow","xy-point-budget","bubble-size-negative","bubble-share-range","bubble-scale-overflow"],I=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.share=null,this.compareFamily=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.sizeAreaPerUnit=0,this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",u(this)}getDb(){return this.stores||(this.stores=a(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=l(this.getDb(),this.tableName,this.filter);this.chart=new B(new c(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,x:this.x,y:this.y,size:this.size,share:this.share,compareFamily:this.compareFamily,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit,sizeAreaPerUnit:this.sizeAreaPerUnit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),m(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of H){const s=`WARN_${t.replace(/-/g,"_")}`;if(i.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){var t,i;const s=new D(new k,new b,new p(new y),new w).adapt(this.styles);return s.locale=(null===(i=null===(t=a(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return s(e,null);if(this.chart.hasNoData()){const i=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return s(e,{class:"no-data"},s("div",{class:"empty-state"},i))}return s(e,null,s("div",{innerHTML:this.svgMarkup}))}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{position:relative;display:inline-block}'}},[1,"bn-chart-bubble-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],x:[16],y:[16],size:[16],share:[16],compareFamily:[1,"compare-family"],labels:[16],legend:[16],facet:[16],pointLevel:[1,"point-level"],seriesLevel:[1,"series-level"],aspect:[2],limit:[2],filter:[1],sizeAreaPerUnit:[2,"size-area-per-unit"],styles:[16],i18n:[16],containerWidth:[2,"container-width"],ruleSetConfig:[16],errors:[16],translator:[16]}]);function O(){"undefined"!=typeof customElements&&["bn-chart-bubble-renderer"].forEach((t=>{"bn-chart-bubble-renderer"===t&&(customElements.get(h(t))||customElements.define(h(t),I))}))}export{I as B,O as d}
|
|
1
|
+
import{p as t,H as i,h as s,a as e,t as h}from"./p-D6YGOYV1.js";import{r as n,m as o,s as r,g as a,d as l}from"./p-DDvWTgk1.js";import{C as d,I as c}from"./p-CniN8ALm.js";import{w as u}from"./p-Dq9dG0Kr.js";import{e as v,r as m}from"./p-ClruFZD_.js";import{S as f,F as b,a as p,P as w}from"./p-eWxolPDU.js";import{d as g,S as y}from"./p-BzjGUtYh.js";import{X as x,r as M,a as $,x as z,f as j,b as L,P as S,c as P,F as W,d as C,S as D}from"./p-Cyf5ZEXs.js";import{g as k}from"./p-4q8nRcWC.js";import{N}from"./p-BJmwHV0a.js";import{a as E,r as F,i as T}from"./p-BXXjh6We.js";class A{constructor(t,i,s,e,h){this.mode=t,this.vMax=i,this.rMaxPx=s,this.rMinPx=e,this.areaPerUnitPx2=h}static local(t,i,s){return new A("local",t,i,s,0)}static grouped(t){return new A("grouped",0,0,0,t)}radius(t){return"grouped"===this.mode?t<=0?0:Math.sqrt(this.areaPerUnitPx2*t/Math.PI):this.vMax<=0||t<=0?this.rMinPx:Math.max(this.rMinPx,this.rMaxPx*Math.sqrt(t/this.vMax))}}class B{constructor(t,i,s,e,h,n){var o,r,a,l;this.ruleSet=t,this.config=e,this.styles=h,this.availableWidth=n,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map,this.hatchPatterns=new Set,this.scaleOverflowCount=0,this.svgRoot=null,this.config=Object.assign(Object.assign({},e),{x:E(e.x),y:E(e.y)});const d=new x;let c=[];try{""!==s&&(c=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=v(t)}const u=(null!=c?c:[]).map((t=>d.adapt(t)));this.data=M(u,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=F(e.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(r=F(e.y.measure))&&void 0!==r?r:{kind:"scenario",slot:"ac2"},size:null!==(a=F(e.size.measure))&&void 0!==a?a:{kind:"scenario",slot:"ac3"},share:null!==e.share&&null!==(l=F(e.share.measure))&&void 0!==l?l:void 0},compareFamily:e.compareFamily,domains:{x:{min:this.config.x.min,max:this.config.x.max},y:{min:this.config.y.min,max:this.config.y.max}},limit:e.limit,limitBy:"size"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}get xPercent(){return T(this.config.x.measure)}get yPercent(){return T(this.config.y.measure)}get sizePercent(){return T(this.config.size.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=d(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,h={}){var n,o;return t.text(i).font({size:this.styles.fontStyles.size,weight:h.bold?"bold":"normal",anchor:null!==(n=h.anchor)&&void 0!==n?n:"start"}).fill(null!==(o=h.color)&&void 0!==o?o:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}setI18n(t){this.i18nMap=t}addWarningOnce(t,i){this.warnings.some((i=>i.code===t))||this.warnings.push({code:t,data:i})}primaryColorIndex(){const t=F(this.config.size.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}compareColorIndex(){return this.ruleSet.getScenarioColorIndex(`${this.config.compareFamily}1`)}seriesHue(t){const{color:i,overflowed:s}=n(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),i}familyDisplayName(t){return this.ruleSet.getScenario(`${t}1`).group}legendModel(){var t,i;const s=[],e=null!==(i=null!==(t=this.config.size.label)&&void 0!==t?t:this.i18nMap.get("legend.size"))&&void 0!==i?i:"";""!==e&&(s.push(e),void 0!==this.config.size.unit&&""!==this.config.size.unit&&s.push(`${this.i18nMap.get("axis.in")||"in"} ${this.config.size.unit}`));const h=[];if(null!==this.config.compareFamily){const t=F(this.config.size.measure),i=null!==t&&"scenario"===t.kind?t.slot.replace(/\d+$/,""):"ac";h.push(this.legendEntry(this.familyDisplayName(this.config.compareFamily),this.compareColorIndex(),0)),h.push(this.legendEntry(this.familyDisplayName(i),this.primaryColorIndex(),0))}const n=this.data.series.map((t=>{var i;return this.legendEntry(""===t.key?null!==(i=this.ruleSet.getScenario("").name)&&void 0!==i?i:"Series":t.key,this.primaryColorIndex(),t.index)}));return{sizeCaption:s,title:this.i18nMap.get("legend.title")||null,compareEntries:h,entries:n}}legendEntry(t,i,s){const e=this.seriesHue(s),h=o(i,e,"bubble");return{label:t,treatment:h,fill:this.treatmentFill(h,s,e)}}toString(){const t=new f;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}axisTitle(t,i){var s;const e=null!==(s=t.label)&&void 0!==s?s:"";return""===e?"":void 0===t.unit||""===t.unit?e:`${e} ${i} ${t.unit}`}draw(t){var i,s,e,h,n,o,r,a,l,d,c;this.warnings=this.data.warnings.slice(),this.hatchPatterns.clear(),this.scaleOverflowCount=0,this.svgRoot=t;const u=this.em,v=this.styles.padding,m=this.i18nMap.get("axis.in")||"in",f=t.group(),b=new $(this.styles),p=this.legendModel(),w=this.config.legend.show&&(p.entries.length>0||p.sizeCaption.length>0),g=w?b.measure(p,this.config.legend.position):{width:0,height:0},y="right"===this.config.legend.position&&w?g.width+u:0,x=""!==this.config.chartTitle?1.6*u:0,M=this.axisTitle(this.config.y,m),L=this.axisTitle(this.config.x,m),S=""!==M?1.4*u:.4*u,P=1.4*u+(""!==L?1.3*u:0);let C,D=3*u,k={x:0,y:0,width:0,height:0},E=[];const F=Math.max(1,this.data.facets.length),T=null===(i=this.config.facet)||void 0===i?void 0:i.columns,B=N.domain(null!==(e=null===(s=this.data.extents)||void 0===s?void 0:s.xMin)&&void 0!==e?e:0,null!==(n=null===(h=this.data.extents)||void 0===h?void 0:h.xMax)&&void 0!==n?n:1,{min:this.config.x.min,max:this.config.x.max}),X=N.domain(null!==(r=null===(o=this.data.extents)||void 0===o?void 0:o.yMin)&&void 0!==r?r:0,null!==(l=null===(a=this.data.extents)||void 0===a?void 0:a.yMax)&&void 0!==l?l:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-v.left-v.right-D-y);k={x:v.left+D,y:v.top+x+S,width:t,height:t/this.config.aspect},C=new W(F,T,k,this.styles.scaleFactors.panelGap*u);const i=C.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*u)))),e=new N(X[0],X[1],i,0);E=e.ticks(s);const h=z(E,this.yPercent);D=Math.max(...E.map((t=>this.textWidth(j(t,h,this.styles.locale,this.yPercent)))),u)+this.styles.scaleFactors.axisTickLength*u+.4*u}this.canvasHeight=k.y+k.height+P+("bottom"===this.config.legend.position&&w?g.height+u:0)+v.bottom,""!==this.config.chartTitle&&this.drawText(f,this.config.chartTitle,v.left,v.top+u,{bold:!0}),""!==M&&this.drawAxisTitleText(f,this.config.y,m,v.left,k.y-.6*u,"start");const H=this.buildPanels(C,B,X),I=H[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(H[0].rect.width/(7*u))))),O=z(I,this.xPercent),U=z(E,this.yPercent),Y=this.config.sizeAreaPerUnit>0?A.grouped(this.config.sizeAreaPerUnit):A.local(null!==(c=null===(d=this.data.extents)||void 0===d?void 0:d.sizeMax)&&void 0!==c?c:0,this.styles.scaleFactors.bubbleMaxRadius*u,this.styles.scaleFactors.bubbleMinRadius*u);0===this.data.facets.length?this.drawPanel(f,H[0],{key:"",points:[]},Y,I,E,O,U,!0,!0):this.data.facets.forEach(((t,i)=>{this.drawPanel(f,H[i],t,Y,I,E,O,U,C.isOuterLeft(i),C.isOuterBottom(i),this.data.facets.length>1?t.key:"")})),""!==L&&this.drawAxisTitleText(f,this.config.x,m,k.x+k.width,k.y+k.height+2.6*u,"end"),w&&("right"===this.config.legend.position?b.draw(f,p,k.x+k.width+u,k.y,"right"):b.draw(f,p,k.x,k.y+k.height+P,"bottom")),this.scaleOverflowCount>0&&this.addWarningOnce("bubble-scale-overflow",{count:String(this.scaleOverflowCount)}),t.group().addClass("annotations")}drawAxisTitleText(t,i,s,e,h,n){var o;const r=null!==(o=i.label)&&void 0!==o?o:"",a=void 0!==i.unit&&""!==i.unit?`${s} ${i.unit}`:"",l=.3*this.em;"start"===n?(this.drawText(t,r,e,h,{bold:!0}),""!==a&&this.drawText(t,a,e+this.textWidth(r,!0)+l,h,{})):""!==a?(this.drawText(t,a,e,h,{anchor:"end"}),this.drawText(t,r,e-this.textWidth(a)-l,h,{anchor:"end",bold:!0})):this.drawText(t,r,e,h,{anchor:"end",bold:!0})}buildPanels(t,i,s){const e=[];for(let h=0;h<t.count;h++){const n=t.panelRect(h),o=new N(i[0],i[1],n.x,n.x+n.width),r=new N(s[0],s[1],n.y+n.height,n.y);e.push({rect:n,xScale:o,yScale:r,frame:new L(o,r,n,this.styles)})}return e}treatmentFill(t,i,s){return!0!==t.hatch?t.fill:(this.ensureHatchPattern(i,s),`url(#xy-fc-${i})`)}ensureHatchPattern(t,i){this.hatchPatterns.has(t)||null===this.svgRoot||(this.hatchPatterns.add(t),this.svgRoot.defs().pattern(10,10,(t=>{t.rect(10,10).fill("#ffffff"),t.line(0,10,10,0).stroke({color:i,width:2}),t.line(-2.5,2.5,2.5,-2.5).stroke({color:i,width:2}),t.line(7.5,12.5,12.5,7.5).stroke({color:i,width:2})})).id(`xy-fc-${t}`))}drawPanel(t,i,s,e,h,n,a,l,d,c,u=""){var v,m,f,b,p,w;const y=t.group(),x=this.em;i.frame.drawBands(y,this.config.x.highlight,this.config.y.highlight),i.frame.drawGrid(y,n,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&i.rect.width>30*x?h:void 0),i.frame.drawRefLines(y,this.config.x.refLine,this.config.y.refLine),i.frame.drawFrame(y);const M=y.group().id("compare"),$=y.group().id("primary"),z=new S(i.rect,this.styles.scaleFactors.labelToMark*x),j=[...s.points].sort(((t,i)=>{var s,e;return(null!==(s=i.size)&&void 0!==s?s:0)-(null!==(e=t.size)&&void 0!==e?e:0)})),L=[];for(const t of j){const h=null!==(m=null===(v=this.data.series.find((i=>i.key===t.seriesKey)))||void 0===v?void 0:v.index)&&void 0!==m?m:0,n=this.seriesHue(h),a=o(this.primaryColorIndex(),n,"bubble"),l=i.xScale.scale(t.x),d=i.yScale.scale(t.y),c=e.radius(null!==(f=t.size)&&void 0!==f?f:0);if(this.config.sizeAreaPerUnit>0&&this.bubbleExceedsPanel(i.rect,l,d,c)&&this.scaleOverflowCount++,null!=t.compare){const s=o(this.compareColorIndex(),n,"bubble"),r=i.xScale.scale(t.compare.x),a=i.yScale.scale(t.compare.y),l=e.radius(null!==(b=t.compare.size)&&void 0!==b?b:0);this.drawBubble(M,r,a,l,s,h,n),z.registerMark(r,a,l),this.config.labels.values&&void 0!==t.compare.size&&l>=1.2*x&&this.drawValueLabel(M,r,a,l,t.compare.size,s.fill)}const u=P(t,s.key,this.config);null===(p=this.drawBubble($,l,d,c,a,h,n))||void 0===p||p.attr(g(u,"element")),z.registerMark(l,d,c),void 0!==t.share&&c>0&&(null===(w=this.drawShareSlice($,l,d,c,t.share,r(n)))||void 0===w||w.attr(g(u))),this.config.labels.values&&void 0!==t.size&&this.drawValueLabel($,l,d,c,t.size,!0===a.hatch?"#ffffff":a.fill),L.push({point:t,cx:l,cy:d,r:c,seriesIndex:h,hue:n,treatment:a})}this.drawNameLabels(y,z,L,s.key),i.frame.drawTickLabels(y,{ticksX:h,ticksY:n,xDecimals:a,yDecimals:l,xPercent:this.xPercent,yPercent:this.yPercent,showXLabels:c,showYLabels:d}),""!==u&&i.frame.drawPanelTitle(y,u)}bubbleExceedsPanel(t,i,s,e){return i-e<t.x||i+e>t.x+t.width||s-e<t.y||s+e>t.y+t.height}drawBubble(t,i,s,e,h,n,o){if(!(e<=0))return t.circle(2*e).center(i,s).fill(this.treatmentFill(h,n,o)).stroke({color:h.stroke,width:h.strokeWidth})}drawShareSlice(t,i,s,e,h,n){if(h<=0)return;if(h>=1)return t.circle(2*e).center(i,s).fill(n);const o=2*h*Math.PI,r=i+e*Math.sin(o),a=s-e*Math.cos(o),l=o>Math.PI?1:0;return t.path(`M ${i} ${s} L ${i} ${s-e} A ${e} ${e} 0 ${l} 1 ${r} ${a} Z`).fill(n).stroke("none")}drawValueLabel(t,i,s,e,h,n){const o=j(h,this.valueDecimals(),this.styles.locale,this.sizePercent);this.textWidth(o)+.4*this.em>2*e||this.drawText(t,o,i,s+.35*this.em,{anchor:"middle",color:k(n)})}drawNameLabels(t,i,s,e){const h=[...s].sort(((t,i)=>{var s,e;return(null!==(s=i.point.size)&&void 0!==s?s:0)-(null!==(e=t.point.size)&&void 0!==e?e:0)})),{selected:n,unknownNames:o}=i.selectCandidates(h,this.config.labels.points,this.config.labels.max,(t=>t.point.name));o.length>0&&this.addWarningOnce("xy-label-unknown",{names:o.join(", ")});const r=new Map,a=n.map((t=>{const i={name:t.point.name,cx:t.cx,cy:t.cy,r:t.r,width:this.textWidth(t.point.name),height:1.1*this.em};return r.set(i,t.point),i}));for(const s of i.place(a))this.drawText(t,s.candidate.name,s.x,s.y+.9*s.candidate.height,{}).attr(g(P(r.get(s.candidate),e,this.config),"label"))}valueDecimals(){var t,i,s;let e=0;for(const h of this.data.facets)for(const n of h.points)e=Math.max(e,Math.abs(null!==(t=n.size)&&void 0!==t?t:0),Math.abs(null!==(s=null===(i=n.compare)||void 0===i?void 0:i.size)&&void 0!==s?s:0));return e>0&&Number.isFinite(e)?(this.sizePercent&&(e*=100),N.stepDecimals(Math.pow(10,Math.floor(Math.log10(e))-2))):1}}const X=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-label-unknown","xy-series-overflow","xy-point-budget","bubble-size-negative","bubble-share-range","bubble-scale-overflow"],H=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.share=null,this.compareFamily=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.sizeAreaPerUnit=0,this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",u(this)}getDb(){return this.stores||(this.stores=a(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=l(this.getDb(),this.tableName,this.filter);this.chart=new B(new c(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,x:this.x,y:this.y,size:this.size,share:this.share,compareFamily:this.compareFamily,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit,sizeAreaPerUnit:this.sizeAreaPerUnit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),m(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of X){const s=`WARN_${t.replace(/-/g,"_")}`;if(i.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){var t,i;const s=new C(new D,new b,new p(new y),new w).adapt(this.styles);return s.locale=(null===(i=null===(t=a(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return s(e,null);if(this.chart.hasNoData()){const i=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return s(e,{class:"no-data"},s("div",{class:"empty-state"},i))}return s(e,null,s("div",{innerHTML:this.svgMarkup}))}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{position:relative;display:inline-block}'}},[1,"bn-chart-bubble-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],x:[16],y:[16],size:[16],share:[16],compareFamily:[1,"compare-family"],labels:[16],legend:[16],facet:[16],pointLevel:[1,"point-level"],seriesLevel:[1,"series-level"],aspect:[2],limit:[2],filter:[1],sizeAreaPerUnit:[2,"size-area-per-unit"],styles:[16],i18n:[16],containerWidth:[2,"container-width"],ruleSetConfig:[16],errors:[16],translator:[16]}]);function I(){"undefined"!=typeof customElements&&["bn-chart-bubble-renderer"].forEach((t=>{"bn-chart-bubble-renderer"===t&&(customElements.get(h(t))||customElements.define(h(t),H))}))}export{H as B,I as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as i,h as s,a as e,t as n}from"./p-D6YGOYV1.js";import{r as h,m as o,g as r,d as a}from"./p-DDvWTgk1.js";import{C as l,I as d}from"./p-CniN8ALm.js";import{w as c}from"./p-Dq9dG0Kr.js";import{e as u,r as m}from"./p-ClruFZD_.js";import{S as v,F as f,a as p,P as w}from"./p-eWxolPDU.js";import{d as g,S as x}from"./p-BzjGUtYh.js";import{X as y,r as b,a as M,x as $,f as L,b as j,c as P,P as S,F as W,d as k,S as D}from"./p-BhEdmPjm.js";import{N as C}from"./p-BJmwHV0a.js";import{a as T,r as N,i as z}from"./p-BXXjh6We.js";import{s as E}from"./p-Xb6Ilq8u.js";class B{constructor(t,i){this.xScale=t,this.yScale=i}isPositiveDomain(){return this.xScale.domainMin>0&&this.yScale.domainMin>0}static autoK(t){const i=t.filter((t=>t>0)).sort(((t,i)=>t-i));if(0===i.length)return[];const s=t=>i[Math.min(i.length-1,Math.floor(t*i.length))];let e=B.ladderValues(s(.25),s(.75));if(e.length<2&&(e=B.ladderValues(i[0],i[i.length-1])),0===e.length)return[];if(1===e.length)return e;if(e.length<=4)return e;const n=[];for(let t=0;t<4;t++)n.push(e[Math.round(t*(e.length-1)/3)]);return[...new Set(n)]}static ladderValues(t,i){if(t<=0||i<t)return[];const s=[];for(let e=Math.floor(Math.log10(t))-1;e<=Math.ceil(Math.log10(i));e++)for(const n of[1,2,5]){const h=n*Math.pow(10,e);h>=t&&h<=i&&s.push(h)}return s}visibleRange(t){if(!this.isPositiveDomain()||t<=0)return null;const i=Math.max(this.xScale.domainMin,t/this.yScale.domainMax),s=Math.min(this.xScale.domainMax,t/this.yScale.domainMin);return i>=s?null:[i,s]}samples(t){const i=this.visibleRange(t);if(null===i)return null;const[s,e]=i,n=[];for(let i=0;i<64;i++){const h=s*Math.pow(e/s,i/63);n.push({x:this.xScale.scale(h),y:this.yScale.scale(t/h)})}return n}path(t){const i=this.samples(t);return null===i?null:i.map(((t,i)=>`${0===i?"M":"L"} ${t.x} ${t.y}`)).join(" ")}exitPoint(t){const i=this.visibleRange(t);if(null===i)return null;const s=i[1],e=s>=this.xScale.domainMax-1e-9*Math.abs(this.xScale.domainMax);return{x:this.xScale.scale(s),y:this.yScale.scale(t/s),edge:e?"right":"bottom"}}regionPath(t){if(!this.isPositiveDomain()||t<=0)return null;const i=this.xScale.domainMin,s=this.xScale.domainMax,e=this.yScale.domainMin,n=this.yScale.domainMax,h=this.xScale.scale(i),o=this.xScale.scale(s),r=this.yScale.scale(n),a=this.yScale.scale(e);if(t>=s*n)return null;if(t<=i*e)return`M ${h} ${r} L ${o} ${r} L ${o} ${a} L ${h} ${a} Z`;const l=this.samples(t),[d,c]=this.visibleRange(t),u=d>i,m=c>=s-1e-9*Math.abs(s),v=l.map(((t,i)=>`${0===i?"M":"L"} ${t.x} ${t.y}`));return m||v.push(`L ${o} ${a}`),v.push(`L ${o} ${r}`),u||v.push(`L ${h} ${r}`),v.push("Z"),v.join(" ")}}class V{constructor(t,i,s,e,n,h){var o,r;this.ruleSet=t,this.config=e,this.styles=n,this.availableWidth=h,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map,this.config=Object.assign(Object.assign({},e),{x:T(e.x),y:T(e.y)});const a=new y;let l=[];try{""!==s&&(l=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=u(t)}const d=(null!=l?l:[]).map((t=>a.adapt(t)));this.data=b(d,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=N(e.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(r=N(e.y.measure))&&void 0!==r?r:{kind:"scenario",slot:"ac2"}},domains:{x:{min:this.config.x.min,max:this.config.x.max},y:{min:this.config.y.min,max:this.config.y.max}},limit:e.limit,limitBy:"order"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}get xPercent(){return z(this.config.x.measure)}get yPercent(){return z(this.config.y.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=l(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,n={}){var h,o,r;return t.text(i).font({size:null!==(h=n.size)&&void 0!==h?h:this.styles.fontStyles.size,weight:n.bold?"bold":"normal",anchor:null!==(o=n.anchor)&&void 0!==o?o:"start"}).fill(null!==(r=n.color)&&void 0!==r?r:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}axisTitle(t,i){var s;const e=null!==(s=t.label)&&void 0!==s?s:"";return""===e?"":void 0===t.unit||""===t.unit?e:`${e} ${i} ${t.unit}`}setI18n(t){this.i18nMap=t}legendModel(){const t=this.data.series.map((t=>{var i;return{label:""===t.key?null!==(i=this.ruleSet.getScenario("").name)&&void 0!==i?i:"Series":t.key,treatment:this.seriesTreatment(t.index)}}));return{sizeCaption:[],title:this.i18nMap.get("legend.title")||null,compareEntries:[],entries:t}}primaryColorIndex(){const t=N(this.config.x.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}seriesTreatment(t){const{color:i,overflowed:s}=h(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),o(this.primaryColorIndex(),i,"dot")}addWarningOnce(t,i){this.warnings.some((i=>i.code===t))||this.warnings.push({code:t,data:i})}toString(){const t=new v;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){var i,s,e,n,h,o,r,a,l,d;this.warnings=this.data.warnings.slice();const c=this.em,u=this.styles.padding,m=this.i18nMap.get("axis.in")||"in",v=t.group(),f=new M(this.styles),p=this.legendModel(),w=this.config.legend.show&&p.entries.length>0,g=w?f.measure(p,this.config.legend.position):{width:0,height:0},x=null!==this.config.iso,y=x?Math.max(3*c,...this.isoValueLabels().map((t=>this.textWidth(t)+c)),this.textWidth(null!==(i=this.config.iso.label)&&void 0!==i?i:"",!0)+c,this.textWidth(void 0!==this.config.iso.unit&&""!==this.config.iso.unit?`${m} ${this.config.iso.unit}`:"")+c):0,b="right"===this.config.legend.position?Math.max(w?g.width+c:0,y):y,j=""!==this.config.chartTitle?1.6*c:0,P=this.axisTitle(this.config.y,m),S=this.axisTitle(this.config.x,m),k=""!==P?1.4*c:.4*c,D=1.4*c+(""!==S?1.3*c:0);let T,N=3*c,z={x:0,y:0,width:0,height:0},E=[];const B=Math.max(1,this.data.facets.length),V=null===(s=this.config.facet)||void 0===s?void 0:s.columns,X=C.domain(null!==(n=null===(e=this.data.extents)||void 0===e?void 0:e.xMin)&&void 0!==n?n:0,null!==(o=null===(h=this.data.extents)||void 0===h?void 0:h.xMax)&&void 0!==o?o:1,{min:this.config.x.min,max:this.config.x.max}),A=C.domain(null!==(a=null===(r=this.data.extents)||void 0===r?void 0:r.yMin)&&void 0!==a?a:0,null!==(d=null===(l=this.data.extents)||void 0===l?void 0:l.yMax)&&void 0!==d?d:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-u.left-u.right-N-b);z={x:u.left+N,y:u.top+j+k,width:t,height:t/this.config.aspect},T=new W(B,V,z,this.styles.scaleFactors.panelGap*c);const i=T.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*c)))),e=new C(A[0],A[1],i,0);E=e.ticks(s);const n=$(E,this.yPercent);N=Math.max(...E.map((t=>this.textWidth(L(t,n,this.styles.locale,this.yPercent)))),c)+this.styles.scaleFactors.axisTickLength*c+.4*c}this.canvasHeight=z.y+z.height+D+("bottom"===this.config.legend.position&&w?g.height+c:0)+u.bottom,""!==this.config.chartTitle&&this.drawText(v,this.config.chartTitle,u.left,u.top+c,{bold:!0}),""!==P&&this.drawAxisTitleText(v,this.config.y,m,u.left,z.y-.6*c,"start");const F=this.buildPanels(T,X,A),I=F[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(F[0].rect.width/(7*c))))),O=$(I,this.xPercent),Y=$(E,this.yPercent);let G=!1;x&&(X[0]>0&&A[0]>0?G=!0:this.addWarningOnce("xy-iso-domain",{})),0===this.data.facets.length?this.drawPanel(v,F[0],{key:"",points:[]},I,E,O,Y,!0,!0,G):this.data.facets.forEach(((t,i)=>{this.drawPanel(v,F[i],t,I,E,O,Y,T.isOuterLeft(i),T.isOuterBottom(i),G,this.data.facets.length>1?t.key:"")})),""!==S&&this.drawAxisTitleText(v,this.config.x,m,z.x+z.width,z.y+z.height+2.6*c,"end"),w&&("right"===this.config.legend.position?f.draw(v,p,z.x+z.width+c,z.y,"right"):f.draw(v,p,z.x,z.y+z.height+D,"bottom")),t.group().addClass("annotations")}drawAxisTitleText(t,i,s,e,n,h){var o;const r=null!==(o=i.label)&&void 0!==o?o:"",a=void 0!==i.unit&&""!==i.unit?`${s} ${i.unit}`:"",l=.3*this.em;"start"===h?(this.drawText(t,r,e,n,{bold:!0}),""!==a&&this.drawText(t,a,e+this.textWidth(r,!0)+l,n,{})):""!==a?(this.drawText(t,a,e,n,{anchor:"end"}),this.drawText(t,r,e-this.textWidth(a)-l,n,{anchor:"end",bold:!0})):this.drawText(t,r,e,n,{anchor:"end",bold:!0})}buildPanels(t,i,s){const e=[];for(let n=0;n<t.count;n++){const h=t.panelRect(n),o=new C(i[0],i[1],h.x,h.x+h.width),r=new C(s[0],s[1],h.y+h.height,h.y);e.push({rect:h,xScale:o,yScale:r,frame:new j(o,r,h,this.styles)})}return e}drawPanel(t,i,s,e,n,h,o,r,a,l,d=""){var c,u;const m=t.group(),v=this.em;i.frame.drawBands(m,this.config.x.highlight,this.config.y.highlight),i.frame.drawGrid(m,n,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&i.rect.width>30*v?e:void 0),l&&null!==this.config.iso&&this.drawIso(m,i),i.frame.drawRefLines(m,this.config.x.refLine,this.config.y.refLine),i.frame.drawFrame(m);const f=this.styles.scaleFactors.pointRadius*v,p=new S(i.rect,this.styles.scaleFactors.labelToMark*v),w=[];for(const t of s.points){const e=null!==(u=null===(c=this.data.series.find((i=>i.key===t.seriesKey)))||void 0===c?void 0:c.index)&&void 0!==u?u:0,n=this.seriesTreatment(e),h=i.xScale.scale(t.x),o=i.yScale.scale(t.y);w.push({point:t,cx:h,cy:o,treatment:n});const r=m.circle(2*f).center(h,o).fill(n.fill).stroke({color:n.stroke,width:n.strokeWidth}).attr(g(P(t,s.key,this.config),"element"));void 0!==n.dasharray&&r.attr("stroke-dasharray",n.dasharray),p.registerMark(h,o,f)}this.drawPointLabels(m,p,w,f,s.key),i.frame.drawTickLabels(m,{ticksX:e,ticksY:n,xDecimals:h,yDecimals:o,xPercent:this.xPercent,yPercent:this.yPercent,showXLabels:a,showYLabels:r}),""!==d&&i.frame.drawPanelTitle(m,d)}drawPointLabels(t,i,s,e,n){const h=s.reduce(((t,i)=>t+i.cx),0)/Math.max(1,s.length),o=s.reduce(((t,i)=>t+i.cy),0)/Math.max(1,s.length),r=[...s].sort(((t,i)=>Math.hypot(i.cx-h,i.cy-o)-Math.hypot(t.cx-h,t.cy-o))),{selected:a,unknownNames:l}=i.selectCandidates(r,this.config.labels.points,this.config.labels.max,(t=>t.point.name));l.length>0&&this.addWarningOnce("xy-label-unknown",{names:l.join(", ")});const d=new Map,c=a.map((t=>{const i={name:t.point.name,cx:t.cx,cy:t.cy,r:e,width:this.textWidth(t.point.name),height:1.1*this.em};return d.set(i,t.point),i}));for(const s of i.place(c))this.drawText(t,s.candidate.name,s.x,s.y+.9*s.candidate.height,{}).attr(g(P(d.get(s.candidate),n,this.config),"label"))}drawIso(t,i){const s=this.config.iso,e=new B(i.xScale,i.yScale),n=this.i18nMap.get("axis.in")||"in",h=this.isoValues(),o=this.isoValueLabels();if(void 0!==s.highlight){const i=e.regionPath(s.highlight.from);null!==i&&t.path(i).fill(this.styles.axisStyles.pl.fill).stroke("none")}const r={color:this.styles.axisStyles.fc.stroke,width:E(this.styles.scaleFactors.gridLineWidth,this.em)};let a=null;for(const[i,s]of h.entries()){const n=e.path(s);if(null===n)continue;t.path(n).fill("none").stroke(r);const h=e.exitPoint(s);null!==h&&(this.drawText(t,o[i],h.x+.4*this.em,"right"===h.edge?h.y+.35*this.em:h.y-.5*this.em,{}),(null===a||h.y<a.y)&&(a=h))}if(null!==a&&void 0!==s.label&&""!==s.label){const i=void 0!==s.unit&&""!==s.unit?`${n} ${s.unit}`:"";this.drawText(t,s.label,a.x+.4*this.em,a.y-1.6*this.em,{bold:!0}),""!==i&&this.drawText(t,i,a.x+.4*this.em,a.y-.5*this.em,{})}}isoValues(){const t=this.config.iso;return"auto"!==t.values?t.values:B.autoK(this.data.facets.flatMap((t=>t.points.map((t=>t.x*t.y)))))}isoValueLabels(){const t=this.isoValues(),i=Math.max(0,...t.map((t=>C.stepDecimals(Math.abs(t)))));return t.map((t=>L(t,i,this.styles.locale)))}}const X=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-iso-domain","xy-label-unknown","xy-series-overflow","xy-point-budget"],A=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.iso=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",c(this)}getDb(){return this.stores||(this.stores=r(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=a(this.getDb(),this.tableName,this.filter);this.chart=new V(new d(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,x:this.x,y:this.y,iso:this.iso,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),m(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of X){const s=`WARN_${t.replace(/-/g,"_")}`;if(i.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){var t,i;const s=new k(new D,new f,new p(new x),new w).adapt(this.styles);return s.locale=(null===(i=null===(t=r(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return s(e,null);if(this.chart.hasNoData()){const i=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return s(e,{class:"no-data"},s("div",{class:"empty-state"},i))}return s(e,null,s("div",{innerHTML:this.svgMarkup}))}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{position:relative;display:inline-block}'}},[1,"bn-chart-scatter-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],x:[16],y:[16],iso:[16],labels:[16],legend:[16],facet:[16],pointLevel:[1,"point-level"],seriesLevel:[1,"series-level"],aspect:[2],limit:[2],filter:[1],styles:[16],i18n:[16],containerWidth:[2,"container-width"],ruleSetConfig:[16],errors:[16],translator:[16]}]);function F(){"undefined"!=typeof customElements&&["bn-chart-scatter-renderer"].forEach((t=>{"bn-chart-scatter-renderer"===t&&(customElements.get(n(t))||customElements.define(n(t),A))}))}export{A as B,F as d}
|
|
1
|
+
import{p as t,H as s,h as i,a as e,t as n}from"./p-D6YGOYV1.js";import{r as h,m as o,g as r,d as a}from"./p-DDvWTgk1.js";import{C as l,I as d}from"./p-CniN8ALm.js";import{w as c}from"./p-Dq9dG0Kr.js";import{e as u,r as m}from"./p-ClruFZD_.js";import{S as v,F as f,a as p,P as w}from"./p-eWxolPDU.js";import{d as g,S as y}from"./p-BzjGUtYh.js";import{X as x,r as b,a as M,x as $,f as L,b as j,c as P,P as S,F as W,d as k,S as D}from"./p-Cyf5ZEXs.js";import{N as C}from"./p-BJmwHV0a.js";import{a as T,r as N,i as z}from"./p-BXXjh6We.js";import{s as E}from"./p-Xb6Ilq8u.js";class X{constructor(t,s){this.xScale=t,this.yScale=s}isPositiveDomain(){return this.xScale.domainMin>0&&this.yScale.domainMin>0}static autoK(t){const s=t.filter((t=>t>0)).sort(((t,s)=>t-s));if(0===s.length)return[];const i=t=>s[Math.min(s.length-1,Math.floor(t*s.length))];let e=X.ladderValues(i(.25),i(.75));if(e.length<2&&(e=X.ladderValues(s[0],s[s.length-1])),0===e.length)return[];if(1===e.length)return e;if(e.length<=4)return e;const n=[];for(let t=0;t<4;t++)n.push(e[Math.round(t*(e.length-1)/3)]);return[...new Set(n)]}static ladderValues(t,s){if(t<=0||s<t)return[];const i=[];for(let e=Math.floor(Math.log10(t))-1;e<=Math.ceil(Math.log10(s));e++)for(const n of[1,2,5]){const h=n*Math.pow(10,e);h>=t&&h<=s&&i.push(h)}return i}visibleRange(t){if(!this.isPositiveDomain()||t<=0)return null;const s=Math.max(this.xScale.domainMin,t/this.yScale.domainMax),i=Math.min(this.xScale.domainMax,t/this.yScale.domainMin);return s>=i?null:[s,i]}samples(t){const s=this.visibleRange(t);if(null===s)return null;const[i,e]=s,n=[];for(let s=0;s<64;s++){const h=i*Math.pow(e/i,s/63);n.push({x:this.xScale.scale(h),y:this.yScale.scale(t/h)})}return n}path(t){const s=this.samples(t);return null===s?null:s.map(((t,s)=>`${0===s?"M":"L"} ${t.x} ${t.y}`)).join(" ")}exitPoint(t){const s=this.visibleRange(t);if(null===s)return null;const i=s[1],e=i>=this.xScale.domainMax-1e-9*Math.abs(this.xScale.domainMax);return{x:this.xScale.scale(i),y:this.yScale.scale(t/i),edge:e?"right":"bottom"}}regionPath(t){if(!this.isPositiveDomain()||t<=0)return null;const s=this.xScale.domainMin,i=this.xScale.domainMax,e=this.yScale.domainMin,n=this.yScale.domainMax,h=this.xScale.scale(s),o=this.xScale.scale(i),r=this.yScale.scale(n),a=this.yScale.scale(e);if(t>=i*n)return null;if(t<=s*e)return`M ${h} ${r} L ${o} ${r} L ${o} ${a} L ${h} ${a} Z`;const l=this.samples(t),[d,c]=this.visibleRange(t),u=d>s,m=c>=i-1e-9*Math.abs(i),v=l.map(((t,s)=>`${0===s?"M":"L"} ${t.x} ${t.y}`));return m||v.push(`L ${o} ${a}`),v.push(`L ${o} ${r}`),u||v.push(`L ${h} ${r}`),v.push("Z"),v.join(" ")}}class V{constructor(t,s,i,e,n,h){var o,r;this.ruleSet=t,this.config=e,this.styles=n,this.availableWidth=h,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map,this.config=Object.assign(Object.assign({},e),{x:T(e.x),y:T(e.y)});const a=new x;let l=[];try{""!==i&&(l=s.exec(`SELECT * FROM ${i}`))}catch(t){this.queryError=u(t)}const d=(null!=l?l:[]).map((t=>a.adapt(t)));this.data=b(d,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=N(e.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(r=N(e.y.measure))&&void 0!==r?r:{kind:"scenario",slot:"ac2"}},domains:{x:{min:this.config.x.min,max:this.config.x.max},y:{min:this.config.y.min,max:this.config.y.max}},limit:e.limit,limitBy:"order"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}get xPercent(){return z(this.config.x.measure)}get yPercent(){return z(this.config.y.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,s=!1){const i=l(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:s?"bold":"normal"}).width;return Number.isFinite(i)&&i>0?i:.6*t.length*this.em}drawText(t,s,i,e,n={}){var h,o,r;return t.text(s).font({size:null!==(h=n.size)&&void 0!==h?h:this.styles.fontStyles.size,weight:n.bold?"bold":"normal",anchor:null!==(o=n.anchor)&&void 0!==o?o:"start"}).fill(null!==(r=n.color)&&void 0!==r?r:this.styles.fontStyles.color).attr({x:i,y:e,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}axisTitle(t,s){var i;const e=null!==(i=t.label)&&void 0!==i?i:"";return""===e?"":void 0===t.unit||""===t.unit?e:`${e} ${s} ${t.unit}`}setI18n(t){this.i18nMap=t}legendModel(){const t=this.data.series.map((t=>{var s;return{label:""===t.key?null!==(s=this.ruleSet.getScenario("").name)&&void 0!==s?s:"Series":t.key,treatment:this.seriesTreatment(t.index)}}));return{sizeCaption:[],title:this.i18nMap.get("legend.title")||null,compareEntries:[],entries:t}}primaryColorIndex(){const t=N(this.config.x.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}seriesTreatment(t){const{color:s,overflowed:i}=h(t,this.styles.seriesColors);return i&&this.addWarningOnce("xy-series-overflow",{}),o(this.primaryColorIndex(),s,"dot")}addWarningOnce(t,s){this.warnings.some((s=>s.code===t))||this.warnings.push({code:t,data:s})}toString(){const t=new v;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){var s,i,e,n,h,o,r,a,l,d;this.warnings=this.data.warnings.slice();const c=this.em,u=this.styles.padding,m=this.i18nMap.get("axis.in")||"in",v=t.group(),f=new M(this.styles),p=this.legendModel(),w=this.config.legend.show&&p.entries.length>0,g=w?f.measure(p,this.config.legend.position):{width:0,height:0},y=null!==this.config.iso,x=y?Math.max(3*c,...this.isoValueLabels().map((t=>this.textWidth(t)+c)),this.textWidth(null!==(s=this.config.iso.label)&&void 0!==s?s:"",!0)+c,this.textWidth(void 0!==this.config.iso.unit&&""!==this.config.iso.unit?`${m} ${this.config.iso.unit}`:"")+c):0,b="right"===this.config.legend.position?Math.max(w?g.width+c:0,x):x,j=""!==this.config.chartTitle?1.6*c:0,P=this.axisTitle(this.config.y,m),S=this.axisTitle(this.config.x,m),k=""!==P?1.4*c:.4*c,D=1.4*c+(""!==S?1.3*c:0);let T,N=3*c,z={x:0,y:0,width:0,height:0},E=[];const X=Math.max(1,this.data.facets.length),V=null===(i=this.config.facet)||void 0===i?void 0:i.columns,A=C.domain(null!==(n=null===(e=this.data.extents)||void 0===e?void 0:e.xMin)&&void 0!==n?n:0,null!==(o=null===(h=this.data.extents)||void 0===h?void 0:h.xMax)&&void 0!==o?o:1,{min:this.config.x.min,max:this.config.x.max}),B=C.domain(null!==(a=null===(r=this.data.extents)||void 0===r?void 0:r.yMin)&&void 0!==a?a:0,null!==(d=null===(l=this.data.extents)||void 0===l?void 0:l.yMax)&&void 0!==d?d:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-u.left-u.right-N-b);z={x:u.left+N,y:u.top+j+k,width:t,height:t/this.config.aspect},T=new W(X,V,z,this.styles.scaleFactors.panelGap*c);const s=T.panelRect(0).height,i=Math.max(4,Math.min(8,Math.round(s/(4*c)))),e=new C(B[0],B[1],s,0);E=e.ticks(i);const n=$(E,this.yPercent);N=Math.max(...E.map((t=>this.textWidth(L(t,n,this.styles.locale,this.yPercent)))),c)+this.styles.scaleFactors.axisTickLength*c+.4*c}this.canvasHeight=z.y+z.height+D+("bottom"===this.config.legend.position&&w?g.height+c:0)+u.bottom,""!==this.config.chartTitle&&this.drawText(v,this.config.chartTitle,u.left,u.top+c,{bold:!0}),""!==P&&this.drawAxisTitleText(v,this.config.y,m,u.left,z.y-.6*c,"start");const F=this.buildPanels(T,A,B),I=F[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(F[0].rect.width/(7*c))))),O=$(I,this.xPercent),Y=$(E,this.yPercent);let G=!1;y&&(A[0]>0&&B[0]>0?G=!0:this.addWarningOnce("xy-iso-domain",{})),0===this.data.facets.length?this.drawPanel(v,F[0],{key:"",points:[]},I,E,O,Y,!0,!0,G):this.data.facets.forEach(((t,s)=>{this.drawPanel(v,F[s],t,I,E,O,Y,T.isOuterLeft(s),T.isOuterBottom(s),G,this.data.facets.length>1?t.key:"")})),""!==S&&this.drawAxisTitleText(v,this.config.x,m,z.x+z.width,z.y+z.height+2.6*c,"end"),w&&("right"===this.config.legend.position?f.draw(v,p,z.x+z.width+c,z.y,"right"):f.draw(v,p,z.x,z.y+z.height+D,"bottom")),t.group().addClass("annotations")}drawAxisTitleText(t,s,i,e,n,h){var o;const r=null!==(o=s.label)&&void 0!==o?o:"",a=void 0!==s.unit&&""!==s.unit?`${i} ${s.unit}`:"",l=.3*this.em;"start"===h?(this.drawText(t,r,e,n,{bold:!0}),""!==a&&this.drawText(t,a,e+this.textWidth(r,!0)+l,n,{})):""!==a?(this.drawText(t,a,e,n,{anchor:"end"}),this.drawText(t,r,e-this.textWidth(a)-l,n,{anchor:"end",bold:!0})):this.drawText(t,r,e,n,{anchor:"end",bold:!0})}buildPanels(t,s,i){const e=[];for(let n=0;n<t.count;n++){const h=t.panelRect(n),o=new C(s[0],s[1],h.x,h.x+h.width),r=new C(i[0],i[1],h.y+h.height,h.y);e.push({rect:h,xScale:o,yScale:r,frame:new j(o,r,h,this.styles)})}return e}drawPanel(t,s,i,e,n,h,o,r,a,l,d=""){var c,u;const m=t.group(),v=this.em;s.frame.drawBands(m,this.config.x.highlight,this.config.y.highlight),s.frame.drawGrid(m,n,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&s.rect.width>30*v?e:void 0),l&&null!==this.config.iso&&this.drawIso(m,s),s.frame.drawRefLines(m,this.config.x.refLine,this.config.y.refLine),s.frame.drawFrame(m);const f=this.styles.scaleFactors.pointRadius*v,p=new S(s.rect,this.styles.scaleFactors.labelToMark*v),w=[];for(const t of i.points){const e=null!==(u=null===(c=this.data.series.find((s=>s.key===t.seriesKey)))||void 0===c?void 0:c.index)&&void 0!==u?u:0,n=this.seriesTreatment(e),h=s.xScale.scale(t.x),o=s.yScale.scale(t.y);w.push({point:t,cx:h,cy:o,treatment:n});const r=m.circle(2*f).center(h,o).fill(n.fill).stroke({color:n.stroke,width:n.strokeWidth}).attr(g(P(t,i.key,this.config),"element"));void 0!==n.dasharray&&r.attr("stroke-dasharray",n.dasharray),p.registerMark(h,o,f)}this.drawPointLabels(m,p,w,f,i.key),s.frame.drawTickLabels(m,{ticksX:e,ticksY:n,xDecimals:h,yDecimals:o,xPercent:this.xPercent,yPercent:this.yPercent,showXLabels:a,showYLabels:r}),""!==d&&s.frame.drawPanelTitle(m,d)}drawPointLabels(t,s,i,e,n){const h=i.reduce(((t,s)=>t+s.cx),0)/Math.max(1,i.length),o=i.reduce(((t,s)=>t+s.cy),0)/Math.max(1,i.length),r=[...i].sort(((t,s)=>Math.hypot(s.cx-h,s.cy-o)-Math.hypot(t.cx-h,t.cy-o))),{selected:a,unknownNames:l}=s.selectCandidates(r,this.config.labels.points,this.config.labels.max,(t=>t.point.name));l.length>0&&this.addWarningOnce("xy-label-unknown",{names:l.join(", ")});const d=new Map,c=a.map((t=>{const s={name:t.point.name,cx:t.cx,cy:t.cy,r:e,width:this.textWidth(t.point.name),height:1.1*this.em};return d.set(s,t.point),s}));for(const i of s.place(c))this.drawText(t,i.candidate.name,i.x,i.y+.9*i.candidate.height,{}).attr(g(P(d.get(i.candidate),n,this.config),"label"))}drawIso(t,s){const i=this.config.iso,e=new X(s.xScale,s.yScale),n=this.i18nMap.get("axis.in")||"in",h=this.isoValues(),o=this.isoValueLabels();if(void 0!==i.highlight){const s=e.regionPath(i.highlight.from);null!==s&&t.path(s).fill(this.styles.axisStyles.pl.fill).stroke("none")}const r={color:this.styles.axisStyles.fc.stroke,width:E(this.styles.scaleFactors.gridLineWidth,this.em)};let a=null;for(const[s,i]of h.entries()){const n=e.path(i);if(null===n)continue;t.path(n).fill("none").stroke(r);const h=e.exitPoint(i);null!==h&&(this.drawText(t,o[s],h.x+.4*this.em,"right"===h.edge?h.y+.35*this.em:h.y-.5*this.em,{}),(null===a||h.y<a.y)&&(a=h))}if(null!==a&&void 0!==i.label&&""!==i.label){const s=void 0!==i.unit&&""!==i.unit?`${n} ${i.unit}`:"";this.drawText(t,i.label,a.x+.4*this.em,a.y-1.6*this.em,{bold:!0}),""!==s&&this.drawText(t,s,a.x+.4*this.em,a.y-.5*this.em,{})}}isoValues(){const t=this.config.iso;return"auto"!==t.values?t.values:X.autoK(this.data.facets.flatMap((t=>t.points.map((t=>t.x*t.y)))))}isoValueLabels(){const t=this.isoValues(),s=Math.max(0,...t.map((t=>C.stepDecimals(Math.abs(t)))));return t.map((t=>L(t,s,this.styles.locale)))}}const A=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-iso-domain","xy-label-unknown","xy-series-overflow","xy-point-budget"],B=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.iso=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",c(this)}getDb(){return this.stores||(this.stores=r(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),s=a(this.getDb(),this.tableName,this.filter);this.chart=new V(new d(this.ruleSetConfig),this.getDb(),s,{chartTitle:this.chartTitle,x:this.x,y:this.y,iso:this.iso,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),m(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const s=new Map(t.map((t=>[t.code,t.data])));for(const t of A){const i=`WARN_${t.replace(/-/g,"_")}`;if(s.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,s.get(t)):t;this.errors.addOrReplace({id:i,type:"warning",message:e})}else this.errors.remove(i)}}prepareStyle(){var t,s;const i=new k(new D,new f,new p(new y),new w).adapt(this.styles);return i.locale=(null===(s=null===(t=r(this.element).context)||void 0===t?void 0:t.state)||void 0===s?void 0:s.locale)||"de",i}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return i(e,null);if(this.chart.hasNoData()){const s=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(e,{class:"no-data"},i("div",{class:"empty-state"},s))}return i(e,null,i("div",{innerHTML:this.svgMarkup}))}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{position:relative;display:inline-block}'}},[1,"bn-chart-scatter-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],x:[16],y:[16],iso:[16],labels:[16],legend:[16],facet:[16],pointLevel:[1,"point-level"],seriesLevel:[1,"series-level"],aspect:[2],limit:[2],filter:[1],styles:[16],i18n:[16],containerWidth:[2,"container-width"],ruleSetConfig:[16],errors:[16],translator:[16]}]);function F(){"undefined"!=typeof customElements&&["bn-chart-scatter-renderer"].forEach((t=>{"bn-chart-scatter-renderer"===t&&(customElements.get(n(t))||customElements.define(n(t),B))}))}export{B,F as d}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as n}from"./p-XFZYX7DZ.js";import{r as i}from"./p-BzjGUtYh.js";import{r as t,a as e}from"./p-CckAR27O.js";import{m as o}from"./p-DaOm9YwQ.js";import{LAYOUT_STATE_VERSION as r}from"./index.js";const l=/^Scenario([1-4])$/,d=/^stacked_(?:col|bar)_(\d+)_seg_\d+$/,a='g[id^="stacked_col_"], g[id^="stacked_bar_"]';function s(n,i){var t;let e=n.parentElement;for(;e&&e!==i;){const n=l.exec(null!==(t=e.id)&&void 0!==t?t:"");if(n)return`scenario${n[1]}`;e=e.parentElement}}function c(n){if(""===n)return;const i=Number(n.split("_")[0]);return Number.isFinite(i)?i:void 0}function u(n){const i=n.getAttribute("data-bn-index");return null===i?void 0:Number(i)}function v(n,i){var t;return(null!==(t=n.getAttribute("class"))&&void 0!==t?t:"").split(/\s+/).includes(i)}function f(t,e,r,l,f){var m,g;const b={regions:[],barCount:0,baseline:{}},p=[];return Array.from(null!==(g=null===(m=t.shadowRoot)||void 0===m?void 0:m.querySelectorAll(e))&&void 0!==g?g:[]).forEach(((e,m)=>{var g,x,k,_;const A=null!==(g=r[m])&&void 0!==g?g:`segment${m}`,$=null===(x=e.shadowRoot)||void 0===x?void 0:x.querySelector("svg#drawCanvas");if($&&(b.regions.push({id:`canvas:${A}`,rect:o($,l)}),0===m&&(b.barCount=function(n){const i=n.querySelector('g[id="Scenario1"]');if(i)return Array.from(i.children).filter((n=>{var i;return/^\d+$/.test(null!==(i=n.id)&&void 0!==i?i:"")})).length;const t=new Set;return n.querySelectorAll(a).forEach((n=>{const i=d.exec(n.id);i&&n.querySelector("rect")&&t.add(i[1])})),t.size}($),b.baseline=n($,t)),"full"===f&&p.push(...function(n,t,e){const r=[],l=new Set;return n.querySelectorAll('g[id$="_RECT"]').forEach(((d,a)=>{var u;l.add(d);const v={kind:"bar",id:d.id,segment:t,scenario:s(d,n),index:null!==(u=c(d.id))&&void 0!==u?u:a,rect:o(d,e),point:i(d)};r.push(v)})),n.querySelectorAll(a).forEach((n=>{var a,s,c;const u=d.exec(n.id);if(!u||!n.querySelector("rect"))return;l.add(n);const v=i(n),f={kind:"bar",id:n.id,segment:t,scenario:`stack:${null!==(c=null!==(s=null!==(a=null==v?void 0:v.scenario)&&void 0!==a?a:null==v?void 0:v.subCategory)&&void 0!==s?s:null==v?void 0:v.category)&&void 0!==c?c:""}`,index:Number(u[1]),rect:o(n,e),point:v};r.push(f)})),["DATA","SCENARIO"].forEach((d=>{n.querySelectorAll(`g[id$="_${d}_Label"]`).forEach(((n,a)=>{var s,u,f;if(v(n,"hide"))return;const m=null!==(u=null===(s=n.textContent)||void 0===s?void 0:s.trim())&&void 0!==u?u:"";if(!m)return;l.add(n);const g={kind:"label",id:n.id,role:"DATA"===d?"data":"scenario",text:m,segment:t,index:null!==(f=c(n.id))&&void 0!==f?f:a,rect:o(n,e),point:i(n)};r.push(g)}))})),n.querySelectorAll("[data-bn-part]").forEach(((d,a)=>{var s,v,f;if(l.has(d))return;const m=i(d),g=null!==(s=u(d))&&void 0!==s?s:function(n,i){var t;for(let e=n;e&&e!==i;e=e.parentElement){const n=c(null!==(t=e.id)&&void 0!==t?t:"");if(void 0!==n)return n}}(d,n);if("element"===m.part){const n={kind:"point",series:m.scenario,index:null!=g?g:a,rect:o(d,e),point:m};return void r.push(n)}const b={kind:"label",id:d.id||void 0,role:"data",text:null!==(f=null===(v=d.textContent)||void 0===v?void 0:v.trim())&&void 0!==f?f:"",segment:t,index:g,rect:o(d,e),point:m};r.push(b)})),n.querySelectorAll('g[id="axis"] line').forEach((n=>{var i;const l=(null!==(i=n.getAttribute("class"))&&void 0!==i?i:"").split(/\s+/).find((n=>n.startsWith("axis-"))),d=o(n,e),a={kind:"axis",style:null==l?void 0:l.slice(5),orientation:d.context.width>=d.context.height?"horizontal":"vertical",segment:t,rect:d};r.push(a)})),n.querySelectorAll('g[id="AxisAndDateLables"] text, g[id="AxisAndDateLabelsLine"] text').forEach((i=>{var l,d;if(v(i,"hide")||function(n,i){var t;let e=n.parentElement;for(;e&&e!==i;){if((null!==(t=e.id)&&void 0!==t?t:"").endsWith("_Label"))return!0;e=e.parentElement}return!1}(i,n))return;const a=null!==(d=null===(l=i.textContent)||void 0===l?void 0:l.trim())&&void 0!==d?d:"";if(!a)return;const s={kind:"label",role:v(i,"categories")?"title":"category",text:a,segment:t,rect:o(i,e)};r.push(s)})),r}($,A,l))),"full"===f){const n=null===(k=e.shadowRoot)||void 0===k?void 0:k.querySelector(".footer"),i=null===(_=null==n?void 0:n.textContent)||void 0===_?void 0:_.trim();i&&p.push({kind:"label",role:"footer",text:i,segment:A,rect:o(n,l)})}})),"full"===f&&(b.elements=p),b}function m(l,d,a,s,c,v){var f,m,g,b;const p={version:r,tag:l.localName,id:e(l),slot:null!==(f=l.getAttribute("slot"))&&void 0!==f?f:void 0,rect:o(l,c),em:s,regions:[],metadata:{title:a},diagnostics:t(l)},x=null===(b=null===(g=null===(m=l.shadowRoot)||void 0===m?void 0:m.querySelector(d))||void 0===g?void 0:g.shadowRoot)||void 0===b?void 0:b.querySelector("svg#drawCanvas");return x&&(p.regions.push({id:"canvas",rect:o(x,c)}),p.metadata.pointCount=x.querySelectorAll("circle, ellipse").length,p.baseline=n(x,l),"full"===v&&(p.elements=function(n,t){const e=[];return n.querySelectorAll("circle, ellipse").forEach(((n,r)=>{const l={kind:"point",index:r,rect:o(n,t),point:i(n)};e.push(l)})),n.querySelectorAll('rect[data-bn-part="element"]').forEach(((n,r)=>{var l;const d=i(n),a={kind:"bar",segment:"base",scenario:null==d?void 0:d.scenario,index:null!==(l=u(n))&&void 0!==l?l:r,rect:o(n,t),point:d};e.push(a)})),n.querySelectorAll("text").forEach((n=>{var r,l;const d=null!==(l=null===(r=n.textContent)||void 0===r?void 0:r.trim())&&void 0!==l?l:"";if(!d)return;const a={kind:"label",role:"data",text:d,rect:o(n,t),point:i(n)};e.push(a)})),e}(x,c))),p}export{f as a,m as c}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as t}from"./p-B5tixDPM.js";import{X as s}from"./p-DDvWTgk1.js";import{L as i,H as n}from"./p-Dm6EAaJ9.js";import{F as o,C as e}from"./p-CniN8ALm.js";import{N as r}from"./p-BJmwHV0a.js";import{s as h}from"./p-Xb6Ilq8u.js";import{B as l}from"./p-t4xPltK2.js";import{D as a}from"./p-Dq9dG0Kr.js";import{b as c}from"./p-BXXjh6We.js";class u{constructor(t,i,n,o){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=n,this.padding=o,this.seriesColors=[...s],this.locale="de"}}class f{constructor(t,s,i,n){this.scaleFactorsXYChartAdapter=t,this.fontStyleAdapter=s,this.svgStyleGroupAdapter=i,this.paddingAdapter=n}adapt(s){const i=this.default();return t.isExisting(s)&&(t.isExisting(s.scaleFactors)&&(i.scaleFactors=this.scaleFactorsXYChartAdapter.adapt(s.scaleFactors)),t.isExisting(s.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(s.fontStyles)),t.isExisting(s.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(s.axisStyles)),t.isExisting(s.padding)&&(i.padding=this.paddingAdapter.adapt(s.padding)),Array.isArray(s.seriesColors)&&s.seriesColors.length>0&&(i.seriesColors=s.seriesColors)),i}default(){return new u(this.scaleFactorsXYChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.paddingAdapter.default())}}class d{constructor(){this.pointRadius=.4,this.bubbleMaxRadius=3.2,this.bubbleMinRadius=.35,this.axisTickLength=.35,this.labelToMark=.3,this.legendSwatch=.9,this.panelGap=1.6,this.refLineWidth=.075,this.gridLineWidth=.075}}class v{adapt(s){const i=new d;return t.isNumber(s.pointRadius)&&(i.pointRadius=s.pointRadius),t.isNumber(s.bubbleMaxRadius)&&(i.bubbleMaxRadius=s.bubbleMaxRadius),t.isNumber(s.bubbleMinRadius)&&(i.bubbleMinRadius=s.bubbleMinRadius),t.isNumber(s.axisTickLength)&&(i.axisTickLength=s.axisTickLength),t.isNumber(s.labelToMark)&&(i.labelToMark=s.labelToMark),t.isNumber(s.legendSwatch)&&(i.legendSwatch=s.legendSwatch),t.isNumber(s.panelGap)&&(i.panelGap=s.panelGap),t.isNumber(s.refLineWidth)&&(i.refLineWidth=s.refLineWidth),t.isNumber(s.gridLineWidth)&&(i.gridLineWidth=s.gridLineWidth),i}default(){return new d}}function m(t,s,i){const n={[i.pointLevel]:t.name};return null!==i.seriesLevel&&""!==t.seriesKey&&(n[i.seriesLevel]=t.seriesKey),null!==i.facet&&""!==s&&(n["rowgroup"===i.facet.level?"rowGroup":"category"]=s),n}class p{constructor(t,s,i,n){this.count=t,this.drawingRect=i,this.panelGapPx=n,this.columns=Math.max(1,Math.min(null!=s?s:t,t)),this.rows=Math.max(1,Math.ceil(t/this.columns))}panelRect(t){const s=t%this.columns,i=Math.floor(t/this.columns),n=(this.drawingRect.width-(this.columns-1)*this.panelGapPx)/this.columns,o=(this.drawingRect.height-(this.rows-1)*this.panelGapPx)/this.rows;return{x:this.drawingRect.x+s*(n+this.panelGapPx),y:this.drawingRect.y+i*(o+this.panelGapPx),width:n,height:o}}isOuterLeft(t){return t%this.columns==0}isOuterBottom(t){return t+this.columns>=this.count}}function w(t,s,i,n=!1){return o.number(t,n?"percent":"decimal",s,s,1,i)}function x(t,s){return r.tickDecimals(s?t.map((t=>100*t)):t)}const y=["n","ne","e","se","s","sw","w","nw"],b=Math.SQRT1_2;class g{constructor(t,s,n=new i){this.frame=t,this.gapPx=s,this.manager=n}registerMark(t,s,i){this.manager.register(this.bounds(t-i,s-i,2*i,2*i))}selectCandidates(t,s,i,n){if("none"===s)return{selected:[],unknownNames:[]};if("all"===s)return{selected:[...t],unknownNames:[]};if("auto"===s)return{selected:t.slice(0,i),unknownNames:[]};const o=new Set(s),e=t.filter((t=>o.has(n(t)))),r=new Set(e.map((t=>n(t))));return{selected:e,unknownNames:s.filter((t=>!r.has(t)))}}place(t){const s=[];for(const i of t)for(const t of y){const n=this.anchorBox(i,t);if(!this.insideFrame(n.x,n.y,i.width,i.height))continue;const o=this.bounds(n.x,n.y,i.width,i.height);if(!this.manager.hasCollision(o)){this.manager.register(o),s.push({candidate:i,x:n.x,y:n.y,anchor:t});break}}return s}anchorBox(t,s){const i=t.r+this.gapPx,n=t.r*b+.5*this.gapPx;switch(s){case"n":return{x:t.cx-t.width/2,y:t.cy-i-t.height};case"ne":return{x:t.cx+n,y:t.cy-n-t.height};case"e":return{x:t.cx+i,y:t.cy-t.height/2};case"se":return{x:t.cx+n,y:t.cy+n};case"s":return{x:t.cx-t.width/2,y:t.cy+i};case"sw":return{x:t.cx-n-t.width,y:t.cy+n};case"w":return{x:t.cx-i-t.width,y:t.cy-t.height/2};case"nw":return{x:t.cx-n-t.width,y:t.cy-n-t.height}}}insideFrame(t,s,i,n){return t>=this.frame.x&&s>=this.frame.y&&t+i<=this.frame.x+this.frame.width&&s+n<=this.frame.y+this.frame.height}bounds(t,s,i,o){return{x:t,y:s,width:i,height:o,pointIndex:0,preferredHook:n.Center}}}class M{constructor(t,s,i,n){this.xScale=t,this.yScale=s,this.rect=i,this.styles=n}get em(){return this.styles.fontStyles.size}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}drawBands(t,s,i){var n,o,e,r;const h=this.styles.axisStyles.pl.fill;if(void 0!==s&&(void 0!==s.from||void 0!==s.to)){const i=this.xScale.scale(null!==(n=s.from)&&void 0!==n?n:this.xScale.domainMin),e=this.xScale.scale(null!==(o=s.to)&&void 0!==o?o:this.xScale.domainMax);t.rect(Math.abs(e-i),this.rect.height).move(Math.min(i,e),this.rect.y).fill(h)}if(void 0!==i&&(void 0!==i.from||void 0!==i.to)){const s=this.yScale.scale(null!==(e=i.from)&&void 0!==e?e:this.yScale.domainMin),n=this.yScale.scale(null!==(r=i.to)&&void 0!==r?r:this.yScale.domainMax);t.rect(this.rect.width,Math.abs(s-n)).move(this.rect.x,Math.min(s,n)).fill(h)}}drawGrid(t,s,i){const n={color:this.styles.axisStyles.pp.stroke,width:h(this.styles.scaleFactors.gridLineWidth,this.em)};for(const i of s){const s=this.yScale.scale(i);t.line(this.rect.x,s,this.rect.x+this.rect.width,s).stroke(n)}if(void 0!==i)for(const s of i){const i=this.xScale.scale(s);t.line(i,this.rect.y,i,this.rect.y+this.rect.height).stroke(n)}}drawRefLines(t,s,i){const n={color:this.styles.axisStyles.fc.stroke,width:h(this.styles.scaleFactors.refLineWidth,this.em)};if(void 0!==s){const i=this.xScale.scale(s);t.line(i,this.rect.y,i,this.rect.y+this.rect.height).stroke(n)}if(void 0!==i){const s=this.yScale.scale(i);t.line(this.rect.x,s,this.rect.x+this.rect.width,s).stroke(n)}}drawFrame(t){t.rect(this.rect.width,this.rect.height).move(this.rect.x,this.rect.y).fill("none").stroke({color:this.styles.axisStyles.ac.stroke,width:h(this.styles.scaleFactors.gridLineWidth,this.em)}).attr(l,"frame")}drawTickLabels(t,s){const i=this.styles.scaleFactors.axisTickLength*this.em,n={size:this.styles.fontStyles.size,anchor:"start"},o=this.fontFamily(),e=this.styles.fontStyles.color;if(s.showXLabels)for(const r of s.ticksX){const h=this.xScale.scale(r);t.text(w(r,s.xDecimals,this.styles.locale,s.xPercent)).font(Object.assign(Object.assign({},n),{anchor:"middle"})).fill(e).attr({x:h,y:this.rect.y+this.rect.height+i+.8*this.em,"font-family":o})}if(s.showYLabels)for(const r of s.ticksY){const h=this.yScale.scale(r);t.text(w(r,s.yDecimals,this.styles.locale,s.yPercent)).font(Object.assign(Object.assign({},n),{anchor:"end"})).fill(e).attr({x:this.rect.x-i,y:h+.35*this.em,"font-family":o})}}drawPanelTitle(t,s){""!==s&&t.text(s).font({size:this.styles.fontStyles.size,weight:"bold",anchor:"start"}).fill(this.styles.fontStyles.color).attr({x:this.rect.x+.5*this.em,y:this.rect.y+1.2*this.em,"font-family":this.fontFamily()})}}class N{constructor(t){this.styles=t}get em(){return this.styles.fontStyles.size}get rowHeight(){return 1.5*this.em}get swatchSize(){return this.styles.scaleFactors.legendSwatch*this.em}textWidth(t,s=!1){const i=e(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:s?"bold":"normal"}).width;return Number.isFinite(i)&&i>0?i:.6*t.length*this.em}rows(t){const s=[];t.sizeCaption.forEach(((t,i)=>{s.push({text:t,bold:0===i,treatment:null})})),null!==t.title&&""!==t.title&&s.push({text:t.title,bold:!0,treatment:null});for(const i of[...t.compareEntries,...t.entries])s.push({text:i.label,bold:!1,treatment:i.treatment,fill:i.fill});return s}measure(t,s){const i=this.rows(t);if(0===i.length)return{width:0,height:0};const n=this.swatchSize+.4*this.em;if("bottom"===s){let t=0;for(const s of i)t+=(null!==s.treatment?n:0)+this.textWidth(s.text,s.bold)+1.5*this.em;return{width:t,height:this.rowHeight}}let o=0;for(const t of i)o=Math.max(o,(null!==t.treatment?n:0)+this.textWidth(t.text,t.bold));return{width:o,height:i.length*this.rowHeight}}draw(t,s,i,n,o){var e;const r=this.rows(s),h=this.swatchSize+.4*this.em;let l=i,a=n;for(const s of r){let i=l;if(null!==s.treatment){const n=t.circle(this.swatchSize).move(l,a+(this.rowHeight-this.swatchSize)/2).fill(null!==(e=s.fill)&&void 0!==e?e:s.treatment.hatch?"#ffffff":s.treatment.fill).stroke({color:"#ffffff"===s.treatment.stroke?s.treatment.fill:s.treatment.stroke,width:s.treatment.strokeWidth});void 0!==s.treatment.dasharray&&n.attr("stroke-dasharray",s.treatment.dasharray),i+=h}t.text(s.text).font({size:this.styles.fontStyles.size,weight:s.bold?"bold":"normal",anchor:"start"}).fill(this.styles.fontStyles.color).attr({x:i,y:a+this.rowHeight/2+.35*this.em,"font-family":this.fontFamily()}),"bottom"===o?l=i+this.textWidth(s.text,s.bold)+1.5*this.em:a+=this.rowHeight}}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}}class j{constructor(){this.operation="+",this.custom={},this.counts={}}slotValue(s){const i=this[s];return t.isNumber(i)?i:null}slotHasNoData(t){return 0===this.counts[t]}}const S=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"];class k{adapt(s){const i=new j;if(t.isOperator(s.operation)&&(i.operation=s.operation),t.isString(s.date)){const t=a.fromISO(s.date);i.date=t.isValid?t:void 0}t.isString(s.rowGroup)&&t.isNumber(s.rowGroupIndex)&&(i.rowGroup=s.rowGroup,i.rowGroupIndex=s.rowGroupIndex),t.isString(s.category)&&t.isNumber(s.categoryIndex)&&(i.category=s.category,i.categoryIndex=s.categoryIndex),t.isString(s.subCategory)&&t.isNumber(s.subCategoryIndex)&&(i.subCategory=s.subCategory,i.subCategoryIndex=s.subCategoryIndex),t.isString(s.columnGroup)&&t.isNumber(s.columnGroupIndex)&&(i.columnGroup=s.columnGroup,i.columnGroupIndex=s.columnGroupIndex),t.isString(s.columnSubGroup)&&t.isNumber(s.columnSubGroupIndex)&&(i.columnSubGroup=s.columnSubGroup,i.columnSubGroupIndex=s.columnSubGroupIndex);for(const n of S){t.isNumber(s[n])&&(i[n]=s[n]);const o=s[`${n}_cnt`];t.isNumber(o)&&(i.counts[n]=o)}for(const t of Object.keys(s))t.startsWith("_")&&(i.custom[t]=s[t]);return i}default(){return new j}}const D={rowGroup:"rowGroupIndex",category:"categoryIndex",subCategory:"subCategoryIndex"};function z(t,s){if("scenario"===s.kind)return{value:t.slotValue(s.slot),varianceNoData:!1};if(t.slotHasNoData(s.measure.base)||t.slotHasNoData(s.measure.delta))return{value:null,varianceNoData:!0};const i=s.measure.compute(t.slotValue(s.measure.base),t.slotValue(s.measure.delta));return{value:i,varianceNoData:null===i}}function B(t,s){return void 0!==s&&(void 0!==s.min&&t<s.min||void 0!==s.max&&t>s.max)}function O(t,s){return"scenario"!==t.kind?null:s+c(t.slot)}function C(t,s){var i,n,o,e,r,h,l,a,c;const u=[],f=new Set,d=[];let v=0,m=0,p=0,w=0,x=0;const y=new Map,b=new Map,g=new Map,M=null!==(i=s.compareFamily)&&void 0!==i?i:null,N=null!==M?O(s.measures.x,M):null,j=null!==M?O(s.measures.y,M):null,S=null!==M&&void 0!==s.measures.size?O(s.measures.size,M):null;for(const i of t){const t=i[s.pointLevel];if(null==t||""===t)continue;const u=null!==(n=null!==s.facetLevel?i[s.facetLevel]:"")&&void 0!==n?n:"",M=null!==(o=null!==s.seriesLevel?i[s.seriesLevel]:"")&&void 0!==o?o:"",k=`${u}\0${M}\0${t}`;if(f.has(k)){v++,d.length<5&&!d.includes(t)&&d.push(t);continue}const O=z(i,s.measures.x),C=z(i,s.measures.y);if(null===O.value||null===C.value){(O.varianceNoData||C.varianceNoData)&&m++;continue}if(B(O.value,null===(e=s.domains)||void 0===e?void 0:e.x)||B(C.value,null===(r=s.domains)||void 0===r?void 0:r.y)){p++;continue}const F={name:t,seriesKey:M,facetKey:u,x:O.value,y:C.value,row:i};if(void 0!==s.measures.size){const t=z(i,s.measures.size).value;if(null===t)continue;if(t<0){w++;continue}F.size=t}if(void 0!==s.measures.share){const t=z(i,s.measures.share).value;null!==t&&(t<0||t>1?(x++,F.share=Math.min(1,Math.max(0,t))):F.share=t)}if(null!==N&&null!==j){const t=i.slotValue(N),n=i.slotValue(j),o=null!==S?i.slotValue(S):null;null===t||null===n||null!==S&&null===o?F.compare=null:B(t,null===(h=s.domains)||void 0===h?void 0:h.x)||B(n,null===(l=s.domains)||void 0===l?void 0:l.y)?(p++,F.compare=null):(F.compare={x:t,y:n},null!==o&&(F.compare.size=o))}if(f.add(k),g.has(u)||g.set(u,[]),g.get(u).push(F),null!==s.facetLevel){const t=i[D[s.facetLevel]];null!=t&&t<(null!==(a=y.get(u))&&void 0!==a?a:Number.POSITIVE_INFINITY)&&y.set(u,t)}if(null!==s.seriesLevel){const t=i[D[s.seriesLevel]];null!=t&&t<(null!==(c=b.get(M))&&void 0!==c?c:Number.POSITIVE_INFINITY)&&b.set(M,t)}}const k=[...g.keys()].sort(((t,s)=>{var i,n;return(null!==(i=y.get(t))&&void 0!==i?i:Number.MAX_SAFE_INTEGER)-(null!==(n=y.get(s))&&void 0!==n?n:Number.MAX_SAFE_INTEGER)})),C=k.map((t=>{let i=g.get(t);return s.limit>0&&i.length>s.limit&&(i="size"===s.limitBy?[...i].sort(((t,s)=>{var i,n;return(null!==(i=s.size)&&void 0!==i?i:0)-(null!==(n=t.size)&&void 0!==n?n:0)})).slice(0,s.limit):i.slice(0,s.limit)),{key:t,points:i}})),F=new Set;for(const t of C)for(const s of t.points)F.add(s.seriesKey);const H=[...F].sort(((t,s)=>{var i,n;return(null!==(i=b.get(t))&&void 0!==i?i:Number.MAX_SAFE_INTEGER)-(null!==(n=b.get(s))&&void 0!==n?n:Number.MAX_SAFE_INTEGER)})).map(((t,s)=>({key:t,index:s})));let I=null,L=0;for(const t of C)for(const s of t.points){L++;const t=[s.x],i=[s.y],n=void 0!==s.size?[s.size]:[];null!=s.compare&&(t.push(s.compare.x),i.push(s.compare.y),void 0!==s.compare.size&&n.push(s.compare.size)),null===I&&(I={xMin:t[0],xMax:t[0],yMin:i[0],yMax:i[0],sizeMax:0});for(const s of t)I.xMin=Math.min(I.xMin,s),I.xMax=Math.max(I.xMax,s);for(const t of i)I.yMin=Math.min(I.yMin,t),I.yMax=Math.max(I.yMax,t);for(const t of n)I.sizeMax=Math.max(I.sizeMax,t)}return v>0&&u.push({code:"xy-duplicate-point",data:{count:String(v),names:d.join(", ")}}),m>0&&u.push({code:"xy-variance-nodata",data:{count:String(m)}}),p>0&&u.push({code:"xy-point-clipped",data:{count:String(p)}}),w>0&&u.push({code:"bubble-size-negative",data:{count:String(w)}}),x>0&&u.push({code:"bubble-share-range",data:{count:String(x)}}),L>5e3&&u.push({code:"xy-point-budget",data:{count:String(L)}}),{facets:C,series:H,extents:I,warnings:u,totalPoints:L}}export{p as F,g as P,v as S,k as X,N as a,M as b,m as c,f as d,w as f,C as r,x}
|
|
1
|
+
import{C as t}from"./p-B5tixDPM.js";import{X as s}from"./p-DDvWTgk1.js";import{L as i,H as n}from"./p-Dm6EAaJ9.js";import{F as o,C as e}from"./p-CniN8ALm.js";import{N as r}from"./p-BJmwHV0a.js";import{s as h}from"./p-Xb6Ilq8u.js";import{B as l}from"./p-XFZYX7DZ.js";import{D as a}from"./p-Dq9dG0Kr.js";import{b as c}from"./p-BXXjh6We.js";class u{constructor(t,i,n,o){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=n,this.padding=o,this.seriesColors=[...s],this.locale="de"}}class f{constructor(t,s,i,n){this.scaleFactorsXYChartAdapter=t,this.fontStyleAdapter=s,this.svgStyleGroupAdapter=i,this.paddingAdapter=n}adapt(s){const i=this.default();return t.isExisting(s)&&(t.isExisting(s.scaleFactors)&&(i.scaleFactors=this.scaleFactorsXYChartAdapter.adapt(s.scaleFactors)),t.isExisting(s.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(s.fontStyles)),t.isExisting(s.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(s.axisStyles)),t.isExisting(s.padding)&&(i.padding=this.paddingAdapter.adapt(s.padding)),Array.isArray(s.seriesColors)&&s.seriesColors.length>0&&(i.seriesColors=s.seriesColors)),i}default(){return new u(this.scaleFactorsXYChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.paddingAdapter.default())}}class d{constructor(){this.pointRadius=.4,this.bubbleMaxRadius=3.2,this.bubbleMinRadius=.35,this.axisTickLength=.35,this.labelToMark=.3,this.legendSwatch=.9,this.panelGap=1.6,this.refLineWidth=.075,this.gridLineWidth=.075}}class v{adapt(s){const i=new d;return t.isNumber(s.pointRadius)&&(i.pointRadius=s.pointRadius),t.isNumber(s.bubbleMaxRadius)&&(i.bubbleMaxRadius=s.bubbleMaxRadius),t.isNumber(s.bubbleMinRadius)&&(i.bubbleMinRadius=s.bubbleMinRadius),t.isNumber(s.axisTickLength)&&(i.axisTickLength=s.axisTickLength),t.isNumber(s.labelToMark)&&(i.labelToMark=s.labelToMark),t.isNumber(s.legendSwatch)&&(i.legendSwatch=s.legendSwatch),t.isNumber(s.panelGap)&&(i.panelGap=s.panelGap),t.isNumber(s.refLineWidth)&&(i.refLineWidth=s.refLineWidth),t.isNumber(s.gridLineWidth)&&(i.gridLineWidth=s.gridLineWidth),i}default(){return new d}}function m(t,s,i){const n={[i.pointLevel]:t.name};return null!==i.seriesLevel&&""!==t.seriesKey&&(n[i.seriesLevel]=t.seriesKey),null!==i.facet&&""!==s&&(n["rowgroup"===i.facet.level?"rowGroup":"category"]=s),n}class p{constructor(t,s,i,n){this.count=t,this.drawingRect=i,this.panelGapPx=n,this.columns=Math.max(1,Math.min(null!=s?s:t,t)),this.rows=Math.max(1,Math.ceil(t/this.columns))}panelRect(t){const s=t%this.columns,i=Math.floor(t/this.columns),n=(this.drawingRect.width-(this.columns-1)*this.panelGapPx)/this.columns,o=(this.drawingRect.height-(this.rows-1)*this.panelGapPx)/this.rows;return{x:this.drawingRect.x+s*(n+this.panelGapPx),y:this.drawingRect.y+i*(o+this.panelGapPx),width:n,height:o}}isOuterLeft(t){return t%this.columns==0}isOuterBottom(t){return t+this.columns>=this.count}}function w(t,s,i,n=!1){return o.number(t,n?"percent":"decimal",s,s,1,i)}function x(t,s){return r.tickDecimals(s?t.map((t=>100*t)):t)}const y=["n","ne","e","se","s","sw","w","nw"],b=Math.SQRT1_2;class g{constructor(t,s,n=new i){this.frame=t,this.gapPx=s,this.manager=n}registerMark(t,s,i){this.manager.register(this.bounds(t-i,s-i,2*i,2*i))}selectCandidates(t,s,i,n){if("none"===s)return{selected:[],unknownNames:[]};if("all"===s)return{selected:[...t],unknownNames:[]};if("auto"===s)return{selected:t.slice(0,i),unknownNames:[]};const o=new Set(s),e=t.filter((t=>o.has(n(t)))),r=new Set(e.map((t=>n(t))));return{selected:e,unknownNames:s.filter((t=>!r.has(t)))}}place(t){const s=[];for(const i of t)for(const t of y){const n=this.anchorBox(i,t);if(!this.insideFrame(n.x,n.y,i.width,i.height))continue;const o=this.bounds(n.x,n.y,i.width,i.height);if(!this.manager.hasCollision(o)){this.manager.register(o),s.push({candidate:i,x:n.x,y:n.y,anchor:t});break}}return s}anchorBox(t,s){const i=t.r+this.gapPx,n=t.r*b+.5*this.gapPx;switch(s){case"n":return{x:t.cx-t.width/2,y:t.cy-i-t.height};case"ne":return{x:t.cx+n,y:t.cy-n-t.height};case"e":return{x:t.cx+i,y:t.cy-t.height/2};case"se":return{x:t.cx+n,y:t.cy+n};case"s":return{x:t.cx-t.width/2,y:t.cy+i};case"sw":return{x:t.cx-n-t.width,y:t.cy+n};case"w":return{x:t.cx-i-t.width,y:t.cy-t.height/2};case"nw":return{x:t.cx-n-t.width,y:t.cy-n-t.height}}}insideFrame(t,s,i,n){return t>=this.frame.x&&s>=this.frame.y&&t+i<=this.frame.x+this.frame.width&&s+n<=this.frame.y+this.frame.height}bounds(t,s,i,o){return{x:t,y:s,width:i,height:o,pointIndex:0,preferredHook:n.Center}}}class M{constructor(t,s,i,n){this.xScale=t,this.yScale=s,this.rect=i,this.styles=n}get em(){return this.styles.fontStyles.size}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}drawBands(t,s,i){var n,o,e,r;const h=this.styles.axisStyles.pl.fill;if(void 0!==s&&(void 0!==s.from||void 0!==s.to)){const i=this.xScale.scale(null!==(n=s.from)&&void 0!==n?n:this.xScale.domainMin),e=this.xScale.scale(null!==(o=s.to)&&void 0!==o?o:this.xScale.domainMax);t.rect(Math.abs(e-i),this.rect.height).move(Math.min(i,e),this.rect.y).fill(h)}if(void 0!==i&&(void 0!==i.from||void 0!==i.to)){const s=this.yScale.scale(null!==(e=i.from)&&void 0!==e?e:this.yScale.domainMin),n=this.yScale.scale(null!==(r=i.to)&&void 0!==r?r:this.yScale.domainMax);t.rect(this.rect.width,Math.abs(s-n)).move(this.rect.x,Math.min(s,n)).fill(h)}}drawGrid(t,s,i){const n={color:this.styles.axisStyles.pp.stroke,width:h(this.styles.scaleFactors.gridLineWidth,this.em)};for(const i of s){const s=this.yScale.scale(i);t.line(this.rect.x,s,this.rect.x+this.rect.width,s).stroke(n)}if(void 0!==i)for(const s of i){const i=this.xScale.scale(s);t.line(i,this.rect.y,i,this.rect.y+this.rect.height).stroke(n)}}drawRefLines(t,s,i){const n={color:this.styles.axisStyles.fc.stroke,width:h(this.styles.scaleFactors.refLineWidth,this.em)};if(void 0!==s){const i=this.xScale.scale(s);t.line(i,this.rect.y,i,this.rect.y+this.rect.height).stroke(n)}if(void 0!==i){const s=this.yScale.scale(i);t.line(this.rect.x,s,this.rect.x+this.rect.width,s).stroke(n)}}drawFrame(t){t.rect(this.rect.width,this.rect.height).move(this.rect.x,this.rect.y).fill("none").stroke({color:this.styles.axisStyles.ac.stroke,width:h(this.styles.scaleFactors.gridLineWidth,this.em)}).attr(l,"frame")}drawTickLabels(t,s){const i=this.styles.scaleFactors.axisTickLength*this.em,n={size:this.styles.fontStyles.size,anchor:"start"},o=this.fontFamily(),e=this.styles.fontStyles.color;if(s.showXLabels)for(const r of s.ticksX){const h=this.xScale.scale(r);t.text(w(r,s.xDecimals,this.styles.locale,s.xPercent)).font(Object.assign(Object.assign({},n),{anchor:"middle"})).fill(e).attr({x:h,y:this.rect.y+this.rect.height+i+.8*this.em,"font-family":o})}if(s.showYLabels)for(const r of s.ticksY){const h=this.yScale.scale(r);t.text(w(r,s.yDecimals,this.styles.locale,s.yPercent)).font(Object.assign(Object.assign({},n),{anchor:"end"})).fill(e).attr({x:this.rect.x-i,y:h+.35*this.em,"font-family":o})}}drawPanelTitle(t,s){""!==s&&t.text(s).font({size:this.styles.fontStyles.size,weight:"bold",anchor:"start"}).fill(this.styles.fontStyles.color).attr({x:this.rect.x+.5*this.em,y:this.rect.y+1.2*this.em,"font-family":this.fontFamily()})}}class N{constructor(t){this.styles=t}get em(){return this.styles.fontStyles.size}get rowHeight(){return 1.5*this.em}get swatchSize(){return this.styles.scaleFactors.legendSwatch*this.em}textWidth(t,s=!1){const i=e(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:s?"bold":"normal"}).width;return Number.isFinite(i)&&i>0?i:.6*t.length*this.em}rows(t){const s=[];t.sizeCaption.forEach(((t,i)=>{s.push({text:t,bold:0===i,treatment:null})})),null!==t.title&&""!==t.title&&s.push({text:t.title,bold:!0,treatment:null});for(const i of[...t.compareEntries,...t.entries])s.push({text:i.label,bold:!1,treatment:i.treatment,fill:i.fill});return s}measure(t,s){const i=this.rows(t);if(0===i.length)return{width:0,height:0};const n=this.swatchSize+.4*this.em;if("bottom"===s){let t=0;for(const s of i)t+=(null!==s.treatment?n:0)+this.textWidth(s.text,s.bold)+1.5*this.em;return{width:t,height:this.rowHeight}}let o=0;for(const t of i)o=Math.max(o,(null!==t.treatment?n:0)+this.textWidth(t.text,t.bold));return{width:o,height:i.length*this.rowHeight}}draw(t,s,i,n,o){var e;const r=this.rows(s),h=this.swatchSize+.4*this.em;let l=i,a=n;for(const s of r){let i=l;if(null!==s.treatment){const n=t.circle(this.swatchSize).move(l,a+(this.rowHeight-this.swatchSize)/2).fill(null!==(e=s.fill)&&void 0!==e?e:s.treatment.hatch?"#ffffff":s.treatment.fill).stroke({color:"#ffffff"===s.treatment.stroke?s.treatment.fill:s.treatment.stroke,width:s.treatment.strokeWidth});void 0!==s.treatment.dasharray&&n.attr("stroke-dasharray",s.treatment.dasharray),i+=h}t.text(s.text).font({size:this.styles.fontStyles.size,weight:s.bold?"bold":"normal",anchor:"start"}).fill(this.styles.fontStyles.color).attr({x:i,y:a+this.rowHeight/2+.35*this.em,"font-family":this.fontFamily()}),"bottom"===o?l=i+this.textWidth(s.text,s.bold)+1.5*this.em:a+=this.rowHeight}}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}}class j{constructor(){this.operation="+",this.custom={},this.counts={}}slotValue(s){const i=this[s];return t.isNumber(i)?i:null}slotHasNoData(t){return 0===this.counts[t]}}const S=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"];class k{adapt(s){const i=new j;if(t.isOperator(s.operation)&&(i.operation=s.operation),t.isString(s.date)){const t=a.fromISO(s.date);i.date=t.isValid?t:void 0}t.isString(s.rowGroup)&&t.isNumber(s.rowGroupIndex)&&(i.rowGroup=s.rowGroup,i.rowGroupIndex=s.rowGroupIndex),t.isString(s.category)&&t.isNumber(s.categoryIndex)&&(i.category=s.category,i.categoryIndex=s.categoryIndex),t.isString(s.subCategory)&&t.isNumber(s.subCategoryIndex)&&(i.subCategory=s.subCategory,i.subCategoryIndex=s.subCategoryIndex),t.isString(s.columnGroup)&&t.isNumber(s.columnGroupIndex)&&(i.columnGroup=s.columnGroup,i.columnGroupIndex=s.columnGroupIndex),t.isString(s.columnSubGroup)&&t.isNumber(s.columnSubGroupIndex)&&(i.columnSubGroup=s.columnSubGroup,i.columnSubGroupIndex=s.columnSubGroupIndex);for(const n of S){t.isNumber(s[n])&&(i[n]=s[n]);const o=s[`${n}_cnt`];t.isNumber(o)&&(i.counts[n]=o)}for(const t of Object.keys(s))t.startsWith("_")&&(i.custom[t]=s[t]);return i}default(){return new j}}const D={rowGroup:"rowGroupIndex",category:"categoryIndex",subCategory:"subCategoryIndex"};function z(t,s){if("scenario"===s.kind)return{value:t.slotValue(s.slot),varianceNoData:!1};if(t.slotHasNoData(s.measure.base)||t.slotHasNoData(s.measure.delta))return{value:null,varianceNoData:!0};const i=s.measure.compute(t.slotValue(s.measure.base),t.slotValue(s.measure.delta));return{value:i,varianceNoData:null===i}}function B(t,s){return void 0!==s&&(void 0!==s.min&&t<s.min||void 0!==s.max&&t>s.max)}function F(t,s){return"scenario"!==t.kind?null:s+c(t.slot)}function O(t,s){var i,n,o,e,r,h,l,a,c;const u=[],f=new Set,d=[];let v=0,m=0,p=0,w=0,x=0;const y=new Map,b=new Map,g=new Map,M=null!==(i=s.compareFamily)&&void 0!==i?i:null,N=null!==M?F(s.measures.x,M):null,j=null!==M?F(s.measures.y,M):null,S=null!==M&&void 0!==s.measures.size?F(s.measures.size,M):null;for(const i of t){const t=i[s.pointLevel];if(null==t||""===t)continue;const u=null!==(n=null!==s.facetLevel?i[s.facetLevel]:"")&&void 0!==n?n:"",M=null!==(o=null!==s.seriesLevel?i[s.seriesLevel]:"")&&void 0!==o?o:"",k=`${u}\0${M}\0${t}`;if(f.has(k)){v++,d.length<5&&!d.includes(t)&&d.push(t);continue}const F=z(i,s.measures.x),O=z(i,s.measures.y);if(null===F.value||null===O.value){(F.varianceNoData||O.varianceNoData)&&m++;continue}if(B(F.value,null===(e=s.domains)||void 0===e?void 0:e.x)||B(O.value,null===(r=s.domains)||void 0===r?void 0:r.y)){p++;continue}const X={name:t,seriesKey:M,facetKey:u,x:F.value,y:O.value,row:i};if(void 0!==s.measures.size){const t=z(i,s.measures.size).value;if(null===t)continue;if(t<0){w++;continue}X.size=t}if(void 0!==s.measures.share){const t=z(i,s.measures.share).value;null!==t&&(t<0||t>1?(x++,X.share=Math.min(1,Math.max(0,t))):X.share=t)}if(null!==N&&null!==j){const t=i.slotValue(N),n=i.slotValue(j),o=null!==S?i.slotValue(S):null;null===t||null===n||null!==S&&null===o?X.compare=null:B(t,null===(h=s.domains)||void 0===h?void 0:h.x)||B(n,null===(l=s.domains)||void 0===l?void 0:l.y)?(p++,X.compare=null):(X.compare={x:t,y:n},null!==o&&(X.compare.size=o))}if(f.add(k),g.has(u)||g.set(u,[]),g.get(u).push(X),null!==s.facetLevel){const t=i[D[s.facetLevel]];null!=t&&t<(null!==(a=y.get(u))&&void 0!==a?a:Number.POSITIVE_INFINITY)&&y.set(u,t)}if(null!==s.seriesLevel){const t=i[D[s.seriesLevel]];null!=t&&t<(null!==(c=b.get(M))&&void 0!==c?c:Number.POSITIVE_INFINITY)&&b.set(M,t)}}const k=[...g.keys()].sort(((t,s)=>{var i,n;return(null!==(i=y.get(t))&&void 0!==i?i:Number.MAX_SAFE_INTEGER)-(null!==(n=y.get(s))&&void 0!==n?n:Number.MAX_SAFE_INTEGER)})),O=k.map((t=>{let i=g.get(t);return s.limit>0&&i.length>s.limit&&(i="size"===s.limitBy?[...i].sort(((t,s)=>{var i,n;return(null!==(i=s.size)&&void 0!==i?i:0)-(null!==(n=t.size)&&void 0!==n?n:0)})).slice(0,s.limit):i.slice(0,s.limit)),{key:t,points:i}})),X=new Set;for(const t of O)for(const s of t.points)X.add(s.seriesKey);const C=[...X].sort(((t,s)=>{var i,n;return(null!==(i=b.get(t))&&void 0!==i?i:Number.MAX_SAFE_INTEGER)-(null!==(n=b.get(s))&&void 0!==n?n:Number.MAX_SAFE_INTEGER)})).map(((t,s)=>({key:t,index:s})));let H=null,I=0;for(const t of O)for(const s of t.points){I++;const t=[s.x],i=[s.y],n=void 0!==s.size?[s.size]:[];null!=s.compare&&(t.push(s.compare.x),i.push(s.compare.y),void 0!==s.compare.size&&n.push(s.compare.size)),null===H&&(H={xMin:t[0],xMax:t[0],yMin:i[0],yMax:i[0],sizeMax:0});for(const s of t)H.xMin=Math.min(H.xMin,s),H.xMax=Math.max(H.xMax,s);for(const t of i)H.yMin=Math.min(H.yMin,t),H.yMax=Math.max(H.yMax,t);for(const t of n)H.sizeMax=Math.max(H.sizeMax,t)}return v>0&&u.push({code:"xy-duplicate-point",data:{count:String(v),names:d.join(", ")}}),m>0&&u.push({code:"xy-variance-nodata",data:{count:String(m)}}),p>0&&u.push({code:"xy-point-clipped",data:{count:String(p)}}),w>0&&u.push({code:"bubble-size-negative",data:{count:String(w)}}),x>0&&u.push({code:"bubble-share-range",data:{count:String(x)}}),I>5e3&&u.push({code:"xy-point-budget",data:{count:String(I)}}),{facets:O,series:C,extents:H,warnings:u,totalPoints:I}}export{p as F,g as P,v as S,k as X,N as a,M as b,m as c,f as d,w as f,O as r,x}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as n}from"./p-CMCnX0iM.js";const t="data-bn-baseline",r=n=>Math.round(100*n)/100;function o(o,a){const i=o.querySelector(`[${t}]`),s=null!=i?i:o.querySelector('g[id="axis"] line');if(!s)return{};const u=n(a);return"frame"===s.getAttribute(t)?function(n,t){const o=t.toLocal(n.getBoundingClientRect());return{x:r(o.x),y:r(o.y+o.height)}}(s,u):function(n,t){const o=t.toLocal(n.getBoundingClientRect());return o.width>=o.height?{x:r(o.x),y:r(o.y+o.height/2)}:{x:r(o.x+o.width/2),y:r(o.y)}}(s,u)}function a(n,t){var r,a,i;const s=null===(i=null===(a=null===(r=n.shadowRoot)||void 0===r?void 0:r.querySelector(t))||void 0===a?void 0:a.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas");return s?o(s,n):{}}function i(t,o){var a;if(!t)return{};const i=n(o),s={},u=t.querySelector("thead");if(u){const n=i.toLocal(u.getBoundingClientRect());s.y=r(n.y+n.height)}const c=n=>n?Array.from(n.children).filter((n=>"tr"===n.localName)):[],e=c(u),l=null!==(a=e[e.length-1])&&void 0!==a?a:c(t.querySelector("tbody"))[0],d=l?Array.from(l.children):[],v=
|
|
1
|
+
import{l as n}from"./p-CMCnX0iM.js";const t="data-bn-baseline",r=n=>Math.round(100*n)/100;function o(o,a){const i=o.querySelector(`[${t}]`),s=null!=i?i:o.querySelector('g[id="axis"] line');if(!s)return{};const u=n(a);return"frame"===s.getAttribute(t)?function(n,t){const o=t.toLocal(n.getBoundingClientRect());return{x:r(o.x),y:r(o.y+o.height)}}(s,u):function(n,t){const o=t.toLocal(n.getBoundingClientRect());return o.width>=o.height?{x:r(o.x),y:r(o.y+o.height/2)}:{x:r(o.x+o.width/2),y:r(o.y)}}(s,u)}function a(n,t){var r,a,i;const s=null===(i=null===(a=null===(r=n.shadowRoot)||void 0===r?void 0:r.querySelector(t))||void 0===a?void 0:a.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas");return s?o(s,n):{}}function i(t,o){var a;if(!t)return{};const i=n(o),s={},u=t.querySelector("thead");if(u){const n=i.toLocal(u.getBoundingClientRect());s.y=r(n.y+n.height)}const c=n=>n?Array.from(n.children).filter((n=>"tr"===n.localName)):[],e=c(u),l=null!==(a=e[e.length-1])&&void 0!==a?a:c(t.querySelector("tbody"))[0],d=l?Array.from(l.children):[],v=n=>n.classList.contains("category")||n.classList.contains("operation"),f=d.some(v)?d.find((n=>!v(n))):d[1];return f&&(s.x=r(i.toLocal(f.getBoundingClientRect()).x)),s}export{t as B,a,i as b,o as r}
|