UNPKG

@eclipse-scout/chart

Version:
1 lines 136 kB
import*as R from"@eclipse-scout/core";import*as ve from"chart.js";import"chart.js/auto";import*as We from"chartjs-plugin-datalabels";var E={};E.n=l=>{var e=l&&l.__esModule?()=>l.default:()=>l;return E.d(e,{a:e}),e},E.d=(l,e)=>{for(var t in e)E.o(e,t)&&!E.o(l,t)&&Object.defineProperty(l,t,{enumerable:!0,get:e[t]})},E.o=(l,e)=>Object.prototype.hasOwnProperty.call(l,e),E.r=l=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(l,"__esModule",{value:!0})};var L={};E.r(L),E.d(L,{AbstractChartRenderer:()=>pe,AbstractSvgChartRenderer:()=>M,Chart:()=>d,ChartAdapter:()=>Me,ChartColorMode:()=>se,ChartField:()=>He,ChartFieldAdapter:()=>Ne,ChartFieldTile:()=>Fe,ChartFieldTileAdapter:()=>Ve,ChartJsRenderer:()=>J,ChartLayout:()=>Ae,ChartTableControl:()=>oe,ChartTableControlAdapter:()=>je,ChartTableControlLayout:()=>Ee,ChartTableUserFilter:()=>Q,FulfillmentChartRenderer:()=>Be,SalesfunnelChartRenderer:()=>Se,SpeedoChartRenderer:()=>k,VennAsync3Calculator:()=>Oe,VennChartRenderer:()=>De,VennCircle:()=>Z,VennCircleHelper:()=>Pe,chartJsDateAdapter:()=>ke,default:()=>Ge});var ce={};E.r(ce),E.d(ce,{AbstractChartRenderer:()=>pe,AbstractSvgChartRenderer:()=>M,Chart:()=>d,ChartAdapter:()=>Me,ChartColorMode:()=>se,ChartField:()=>He,ChartFieldAdapter:()=>Ne,ChartFieldTile:()=>Fe,ChartFieldTileAdapter:()=>Ve,ChartJsRenderer:()=>J,ChartLayout:()=>Ae,ChartTableControl:()=>oe,ChartTableControlAdapter:()=>je,ChartTableControlLayout:()=>Ee,ChartTableUserFilter:()=>Q,FulfillmentChartRenderer:()=>Be,SalesfunnelChartRenderer:()=>Se,SpeedoChartRenderer:()=>k,VennAsync3Calculator:()=>Oe,VennChartRenderer:()=>De,VennCircle:()=>Z,VennCircleHelper:()=>Pe,chartJsDateAdapter:()=>ke,default:()=>Ge});var ze=l=>{var e={};return E.d(e,l),e},lr=l=>()=>l;const o=ze({AbstractLayout:()=>R.AbstractLayout,DateColumn:()=>R.DateColumn,DateFormat:()=>R.DateFormat,FormField:()=>R.FormField,FormFieldAdapter:()=>R.FormFieldAdapter,FormFieldTile:()=>R.FormFieldTile,FormFieldTileAdapter:()=>R.FormFieldTileAdapter,HtmlComponent:()=>R.HtmlComponent,Icon:()=>R.Icon,ModelAdapter:()=>R.ModelAdapter,NumberColumn:()=>R.NumberColumn,ObjectFactory:()=>R.ObjectFactory,Point:()=>R.Point,PropertyEventEmitter:()=>R.PropertyEventEmitter,RoundingMode:()=>R.RoundingMode,TableControl:()=>R.TableControl,TableControlAdapter:()=>R.TableControlAdapter,TableMatrix:()=>R.TableMatrix,TableUserFilter:()=>R.TableUserFilter,Tile:()=>R.Tile,Tooltip:()=>R.Tooltip,Widget:()=>R.Widget,aria:()=>R.aria,arrays:()=>R.arrays,colorSchemes:()=>R.colorSchemes,dates:()=>R.dates,graphics:()=>R.graphics,icons:()=>R.icons,numbers:()=>R.numbers,objects:()=>R.objects,scout:()=>R.scout,scrollbars:()=>R.scrollbars,strings:()=>R.strings,styles:()=>R.styles,tooltips:()=>R.tooltips}),Xe=require("jquery");var g=E.n(Xe);function N(l,e,t){return(e=Ye(e))in l?Object.defineProperty(l,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):l[e]=t,l}function Ye(l){var e=Je(l,"string");return typeof e=="symbol"?e:e+""}function Je(l,e){if(typeof l!="object"||!l)return l;var t=l[Symbol.toPrimitive];if(t!==void 0){var r=t.call(l,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(l)}class d extends o.Widget{constructor(){super(),N(this,"data",void 0),N(this,"config",void 0),N(this,"checkedItems",void 0),N(this,"chartRenderer",void 0),N(this,"_updatedOnce",void 0),N(this,"_updateChartTimeoutId",void 0),N(this,"_updateChartOpts",void 0),N(this,"_updateChartOptsWhileNotAttached",void 0),this.$container=null,this.data=null,this.config=null,this.checkedItems=[],this.chartRenderer=null,this._updateChartTimeoutId=null,this._updateChartOpts=null,this._updateChartOptsWhileNotAttached=[],this._updatedOnce=!1}_init(e){super._init(e),this.setConfig(this.config),this._setData(this.data)}_render(){this.$container=this.$parent.appendDiv("chart"),o.aria.role(this.$container,"none"),this.htmlComp=o.HtmlComponent.install(this.$container,this.session),this.htmlComp.setLayout(new Ae(this))}_renderProperties(){super._renderProperties(),this._renderClickable(),this._renderCheckable(),this._renderChartType(),this._renderColorScheme(),this.updateChart({requestAnimation:!0,debounce:d.DEFAULT_DEBOUNCE_TIMEOUT})}_renderOnAttach(){var e;super._renderOnAttach();const t=this._updateChartOptsWhileNotAttached.splice(0);(e=this.chartRenderer)!==null&&e!==void 0&&e.isDetachSupported()||(this._updateChartRenderer(),t.forEach(r=>delete r.requestAnimation),t.push({requestAnimation:!1})),t.forEach(r=>this.updateChart(g().extend(!0,{},r,{debounce:!0})))}_remove(){this.chartRenderer&&this.chartRenderer.remove(!1),this.$container.remove(),this.$container=null}setData(e){this.setProperty("data",e),this.setCheckedItems(this.checkedItems)}_setData(e){e&&(e=g().extend({axes:[]},e)),this._setProperty("data",e)}_renderData(){this.updateChart({requestAnimation:!0,debounce:d.DEFAULT_DEBOUNCE_TIMEOUT,onlyUpdateData:!0})}setConfig(e){let t={type:d.Type.PIE,options:{autoColor:!0,colorMode:se.AUTO,colorScheme:o.colorSchemes.ColorSchemeId.DEFAULT,transparent:!1,maxSegments:5,adjustGridMaxMin:!0,clickable:!1,checkable:!1,animation:{duration:d.DEFAULT_ANIMATION_DURATION},plugins:{datalabels:{display:!1},tooltip:{enabled:!0},legend:{display:!0,clickable:!1,position:d.Position.RIGHT,pointsVisible:!0}}}};if(e=g().extend(!0,{},t,e),e.options.colorScheme=o.colorSchemes.ensureColorScheme(e.options.colorScheme),o.objects.equalsRecursive(this.config,e))return;let r=g().extend(!0,{},this.config);e.data?r.data=e.data:delete r.data;let a=(i,s,n)=>{if(!(!i||!s||!n)){if(!i.options||!i.options[n]){s.options&&delete s.options[n],s.options&&o.objects.isEmpty(s.options.scales)&&!(i.options&&i.options.scales)&&delete s.options.scales,o.objects.isEmpty(s.options)&&!i.options&&delete s.options;return}s.options[n]=i.options[n]}};if(a(e,r,"xLabelMap"),a(e,r,"yLabelMap"),o.objects.equalsRecursive(r,e)){this._setProperty("config",e),this.rendered&&this._renderConfig(!0),this.setCheckedItems(this.checkedItems);return}this.rendered&&this.config&&this.config.type&&this.$container.removeClass(this.config.type+"-chart"),this.setProperty("config",e),this.setCheckedItems(this.checkedItems),this._updateChartRenderer()}_renderConfig(e){this._renderClickable(),this._renderCheckable(),this._renderChartType(),this._renderColorScheme(),this.updateChart({requestAnimation:!0,debounce:d.DEFAULT_DEBOUNCE_TIMEOUT,onlyUpdateData:e})}setCheckedItems(e){this.setProperty("checkedItems",o.arrays.ensure(this._filterCheckedItems(e)))}_filterCheckedItems(e){if(!Array.isArray(e))return e;let t=[];this.data&&this.data.chartValueGroups?this.data.chartValueGroups.forEach(a=>t.push(a.values.length)):this.config&&this.config.data&&this.config.data.datasets.forEach(a=>t.push(a.data.length));let r=e.filter(a=>t[a.datasetIndex]&&a.dataIndex<t[a.datasetIndex]);return r.length<e.length?r:e}_renderCheckedItems(){this.chartRenderer&&this.chartRenderer.renderCheckedItems()}_renderEnabled(){this.updateChart()}_renderClickable(){this.$container.toggleClass("clickable",this.config.options.clickable)}_renderCheckable(){this.$container.toggleClass("checkable",this.config.options.checkable)}_renderChartType(){this.$container.addClass(this.config.type+"-chart")}_renderColorScheme(){o.colorSchemes.toggleColorSchemeClasses(this.$container,this.config.options.colorScheme)}updateChart(e){e=e||{},e.onlyUpdateData=e.onlyUpdateData&&this.chartRenderer&&this.chartRenderer.isDataUpdatable(),e.enforceRerender=!e.onlyUpdateData&&!e.onlyRefresh,this._updateChartTimeoutId&&(clearTimeout(this._updateChartTimeoutId),this._updateChartOpts&&(e.requestAnimation=e.requestAnimation||this._updateChartOpts.requestAnimation,e.onlyUpdateData=e.onlyUpdateData||this._updateChartOpts.onlyUpdateData,e.onlyRefresh=e.onlyRefresh||this._updateChartOpts.onlyRefresh,e.enforceRerender=e.enforceRerender||this._updateChartOpts.enforceRerender),this._updateChartTimeoutId=null,this._updateChartOpts=null);let t=a.bind(this);e.debounce===!0||typeof e.debounce=="number"?(this._updateChartOpts=e,typeof e.debounce=="number"?this._updateChartTimeoutId=setTimeout(t,e.debounce):this._updateChartTimeoutId=setTimeout(t)):t();function a(){if(this._updateChartTimeoutId=null,this._updateChartOpts=null,!this.$container||!this.$container.isAttached()){this._updateChartOptsWhileNotAttached.push(e);return}this._updatedOnce=!0,this.chartRenderer&&(e.enforceRerender?this.chartRenderer.remove(this.chartRenderer.shouldAnimateRemoveOnUpdate(e),i=>{this.removing||i||(this.chartRenderer.render(e.requestAnimation),this.trigger("chartRender"))}):e.onlyUpdateData?this.chartRenderer.updateData(e.requestAnimation):e.onlyRefresh&&this.chartRenderer.refresh())}}_resolveChartRenderer(){switch(this.config.type){case d.Type.FULFILLMENT:return new Be(this);case d.Type.SPEEDO:return new k(this);case d.Type.SALESFUNNEL:return new Se(this);case d.Type.VENN:return new De(this);case d.Type.BAR:case d.Type.BAR_HORIZONTAL:case d.Type.LINE:case d.Type.COMBO_BAR_LINE:case d.Type.PIE:case d.Type.DOUGHNUT:case d.Type.POLAR_AREA:case d.Type.RADAR:case d.Type.BUBBLE:case d.Type.SCATTER:return new J(this)}return null}_updateChartRenderer(){this.chartRenderer&&this.chartRenderer.remove(),this.setProperty("chartRenderer",this._resolveChartRenderer())}handleValueClick(e,t){if(this.config.options.checkable){let r=[...this.checkedItems],a=r.filter(i=>i.datasetIndex===e.datasetIndex&&i.dataIndex===e.dataIndex)[0];a?o.arrays.remove(r,a):r.push(e),this.setCheckedItems(r)}this.trigger("valueClick",{data:e,originalEvent:t})}}N(d,"Type",{PIE:"pie",LINE:"line",BAR:"bar",BAR_HORIZONTAL:"horizontalBar",COMBO_BAR_LINE:"comboBarLine",FULFILLMENT:"fulfillment",SPEEDO:"speedo",SALESFUNNEL:"salesfunnel",VENN:"venn",DOUGHNUT:"doughnut",POLAR_AREA:"polarArea",RADAR:"radar",BUBBLE:"bubble",SCATTER:"scatter"}),N(d,"Position",{TOP:"top",BOTTOM:"bottom",LEFT:"left",RIGHT:"right",CENTER:"center"}),N(d,"DEFAULT_ANIMATION_DURATION",600),N(d,"DEFAULT_DEBOUNCE_TIMEOUT",100);var se;(function(l){l.AUTO="auto",l.DATASET="dataset",l.DATA="data"})(se||(se={}));class Me extends o.ModelAdapter{_onWidgetValueClick(e){this._send("valueClick",e.data)}_onWidgetEvent(e){e.type==="valueClick"?this._onWidgetValueClick(e):super._onWidgetEvent(e)}}function qe(l,e,t){return(e=Ke(e))in l?Object.defineProperty(l,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):l[e]=t,l}function Ke(l){var e=Ze(l,"string");return typeof e=="symbol"?e:e+""}function Ze(l,e){if(typeof l!="object"||!l)return l;var t=l[Symbol.toPrimitive];if(t!==void 0){var r=t.call(l,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(l)}class Ae extends o.AbstractLayout{constructor(e){super(),qe(this,"chart",void 0),this.chart=e}layout(e){var t;let r={requestAnimation:!0,debounce:d.DEFAULT_DEBOUNCE_TIMEOUT,onlyUpdateData:!0};if((!this.chart.session.ready||this.chart._updatedOnce)&&(r.requestAnimation=!1),this.chart.session.ready||(r.debounce=!1),(t=this.chart.findParent(o.Tile))!==null&&t!==void 0&&t.$container.hasClass("dragged")&&(r.debounce=!1),this.chart.chartRenderer instanceof J){var a;(a=this.chart.chartRenderer.chartJs)===null||a===void 0||a.resize()}this.chart.updateChart(r)}}function he(l,e,t){return(e=Qe(e))in l?Object.defineProperty(l,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):l[e]=t,l}function Qe(l){var e=et(l,"string");return typeof e=="symbol"?e:e+""}function et(l,e){if(typeof l!="object"||!l)return l;var t=l[Symbol.toPrimitive];if(t!==void 0){var r=t.call(l,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(l)}class pe extends o.PropertyEventEmitter{constructor(e){super(),he(this,"chart",void 0),he(this,"session",void 0),he(this,"rendering",void 0),he(this,"rendered",void 0),he(this,"animationDuration",void 0),he(this,"firstOpaqueBackgroundColor",void 0),this.chart=e,this.session=e.session,this.rendering=!1,this.rendered=!1,this.animationDuration=0,this.firstOpaqueBackgroundColor=""}validate(){return this._validateChartData()?this._validate():!1}_validateChartData(){let e=this.chart&&this.chart.data;if(!e||!e.chartValueGroups||e.chartValueGroups.length===0)return!1;let t,r=0;for(t=0;t<e.chartValueGroups.length;t++){let a=e.chartValueGroups[t];if(!a.values)return!1;if(t===0)r=a.values.length;else if(a.values.length!==r)return!1;if(!this.chart.config.options.autoColor&&!o.arrays.ensure(a.colorHexValue).length&&!a.cssClass)return!1}for(t=0;t<e.axes.length;t++)if(e.axes[t].length!==r)return!1;return!0}_validate(){return!0}render(e){if(!this.validate()||!this.chart.rendered)return;const t=this.chart.config.options.animation.duration;this.setAnimationDuration(e?t:0),this.rendering=!0,this._render(),this.rendering=!1,this.rendered=!0,this.setAnimationDuration(t)}_render(){}renderCheckedItems(){this.rendered&&this._renderCheckedItems()}_renderCheckedItems(){}updateData(e){if(!this.rendered){this.render(e);return}if(!this.validate()||!this.isDataUpdatable())return;const t=this.chart.config.options.animation.duration;this.setAnimationDuration(e?t:0),this._updateData(),this.setAnimationDuration(t)}_updateData(){}isDataUpdatable(){return!1}isDetachSupported(){return!0}refresh(){this.rendered&&this.remove(!1),this.render(!1)}setAnimationDuration(e){this.setProperty("animationDuration",e)&&this.rendered&&this._renderAnimationDuration()}_setAnimationDuration(e){this._setProperty("animationDuration",e)}_renderAnimationDuration(){}remove(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=arguments.length>1?arguments[1]:void 0;const r=this.chart.config.options.animation.duration;this.setAnimationDuration(e&&r),this.animationDuration&&this.rendered?this._removeAnimated(t):this._remove(t),this.setAnimationDuration(r)}_remove(e){this.rendered=!1,e&&e()}_removeAnimated(e){this._remove(e)}shouldAnimateRemoveOnUpdate(e){return e.requestAnimation}}function F(l,e,t){return(e=tt(e))in l?Object.defineProperty(l,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):l[e]=t,l}function tt(l){var e=rt(l,"string");return typeof e=="symbol"?e:e+""}function rt(l,e){if(typeof l!="object"||!l)return l;var t=l[Symbol.toPrimitive];if(t!==void 0){var r=t.call(l,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(l)}class M extends pe{constructor(e){super(e),F(this,"chartBox",void 0),F(this,"clipId",void 0),F(this,"maskId",void 0),F(this,"suppressLegendBox",void 0),F(this,"height",void 0),F(this,"width",void 0),F(this,"chartAnimationStopping",void 0),F(this,"$svg",void 0),this.chartBox=null,this.clipId="Clip-"+o.ObjectFactory.get().createUniqueId(),this.maskId="Mask-"+o.ObjectFactory.get().createUniqueId(),this.suppressLegendBox=!1}_render(){this.$svg||(this.$svg=this.chart.$container.appendSVG("svg","chart-svg"),o.aria.role(this.$svg,"img"),this.linkChartWithFieldLabel(this.$svg)),this.firstOpaqueBackgroundColor=o.styles.getFirstOpaqueBackgroundColor(this.$svg),this.height=this.$svg.height(),this.width=this.$svg.width(),this._initChartBox(),this._useFontSizeBig()?this.$svg.addClass(M.FONT_SIZE_BIG):this._useFontSizeMiddle()?this.$svg.addClass(M.FONT_SIZE_MIDDLE):this._useFontSizeSmall()?this.$svg.addClass(M.FONT_SIZE_SMALL):this._useFontSizeSmallest()&&this.$svg.addClass(M.FONT_SIZE_SMALLEST),this.$svg.isAttached()&&this._renderInternal()}linkChartWithFieldLabel(e){if(!e)return;let t=e.parents(".chart-field");if(t.length>0){let r=t.eq(0).children("label");r.length>0&&o.aria.linkElementWithLabel(e,r.eq(0))}}_renderInternal(){}_useFontSizeBig(){return!1}_useFontSizeMiddle(){return!1}_useFontSizeSmall(){return!1}_useFontSizeSmallest(){return!1}remove(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=arguments.length>1?arguments[1]:void 0;this.rendered&&!this.chartAnimationStopping&&(this.chartAnimationStopping=!0,this.$svg.children().stop(!0,!1),this.chartAnimationStopping=!1),super.remove(e,t)}_remove(e){this.rendered&&(this.$svg.children().stop(!0,!1),this.rendered&&(this.$svg.remove(),this.$svg=null)),this.rendered=!1,e&&e(this.chartAnimationStopping)}_createClickObject(e,t){return{xIndex:e,dataIndex:e,datasetIndex:t}}_measureText(e,t){let r=this.$svg.appendSVG("text",t).attr("x",0).attr("y",0).attr("visibility","hidden").text(e),a;try{a=r[0].getBBox()}catch{return{height:0,width:0}}return r.remove(),a}_renderLine(e,t,r,a,i){let s=this.$svg.appendSVG("line",i).attr("x1",e).attr("y1",t).attr("x2",r).attr("y2",a);return this.animationDuration&&s.attr("opacity",0).animateSVG("opacity",1,this.animationDuration,null,!0),s}_renderLineLabel(e,t,r,a,i){let s=this.$svg.appendSVG("text",a||"line-label").attr("x",e).attr("y",t).text(r);if(i){s.attr("mask","url(#"+this.maskId+")");let n=this.$svg.appendSVG("text",a?a+" background":"line-label-background").attr("x",e).attr("y",t).attr("clip-path","url(#"+this.clipId+")").text(r);s.data("$background",n),this.animationDuration&&n.attr("opacity",0).animateSVG("opacity",1,this.animationDuration,null,!0)}return this.animationDuration&&s.attr("opacity",0).animateSVG("opacity",1,this.animationDuration,null,!0),s}_initChartBox(){this.chartBox={width:this.width,height:this.height,xOffset:0,yOffset:0,mX:function(){return this.xOffset+this.width/2},mY:function(){return this.yOffset+this.height/2}}}_createAnimationObjectWithTabIndexRemoval(e,t){return{step:function(r,a){try{e.bind(this)(r,a)}catch(i){throw g()(this).stop(!0,!1),i}},duration:t||d.DEFAULT_ANIMATION_DURATION,complete:function(){g()(this).removeAttr("tabindex")}}}_addClipping(e){let t=this.$svg.appendSVG("clipPath");t[0].id=this.clipId;let r=this.$svg.appendSVG("mask");r.appendSVG("rect").attr("x",0).attr("y",0).attr("width","100%").attr("height","100%").attr("fill","white"),r[0].id=this.maskId,this.chart.$container.find("."+e).each(function(a){this.id="ClipMask-"+o.ObjectFactory.get().createUniqueId(),t.appendSVG("use").attrXLINK("href","#"+this.id),r.appendSVG("use").attrXLINK("href","#"+this.id)})}_renderWireLegend(e,t,r,a){if(!this.chart.config.options.plugins.tooltip.enabled)return{detachFunc:()=>{},attachFunc:()=>{},removeFunc:()=>{}};let i={},s=5,n,u=0,h=17,p=h;a&&(n=this.$svg.appendSVG("rect","wire-legend-background-box").attr("opacity","1"));let c=t,f,m=0,y=0;if(c.h===-1?y=c.x2-2*s:y=this.width-c.x2-2*s,Array.isArray(e))for(let _=0;_<e.length;_++){let x=e.length-_-1,v=c.y2+c.v*s-h*x-s*x,T=this._renderLineLabel(c.x2+s,v,o.strings.truncateText(e[_],y,this._measureText.bind(this)),"",a);T.addClass(r),m=Math.max(m,T[0].getComputedTextLength()),_===0?f=T:f.data("lines")?f.data("lines").push(T):f.data("lines",[T])}else f=this._renderLineLabel(c.x2+s,c.y2+c.v*s,o.strings.truncateText(e,y,this._measureText.bind(this)),"",a),f.addClass(r),m=f[0].getComputedTextLength();if(u=m+2*s,t.autoPosition&&(c=t.posFunc.call(this,u,p),f.attr("x",c.x2+s),f.attr("y",c.y2+c.v*s)),c.h===-1?(f.attr("x",c.x2-s-m),f.css("text-anchor","left"),f.data("lines")&&f.data("lines").forEach(_=>{_.attr("x",c.x2-s-m),_.css("text-anchor","left")})):(f.attr("x",c.x2+s),f.css("text-anchor","right"),f.data("lines")&&f.data("lines").forEach(_=>{_.attr("x",c.x2+s),_.css("text-anchor","right")})),c.v===1)f.data("lines")&&f.data("lines").forEach((_,x)=>{_.attr("y",c.x2-s-m);let v=1+x;_.attr("y",c.y2+c.v*s+h*v+s*(v+1))}),f.attr("dy","0.7em");else if(f.data("lines")){let _=f.data("lines").length;f.attr("y",c.y2+c.v*s-h*_-s*_),f.data("lines").forEach((x,v)=>{_=f.data("lines").length-1-v,x.attr("y",c.y2+c.v*s-h*_-s*_)})}f.add(f.data("lines")).each((_,x)=>{let v=g()(x),T=v.data("$background");T&&(T.attr("x",v.attr("x")),T.attr("y",v.attr("y")),T.css("text-anchor",v.css("text-anchor")),T.attr("dy",v.attr("dy")))});let b=[];c.x1>0&&c.y1>0&&(b.push(this._renderLine(c.x1,c.y1,c.x2,c.y2,"label-line")),b.push(this._renderLine(c.x2,c.y2,c.x2+c.h*(m+2*s),c.y2,"label-line"))),f.data("wires",b);let C=this.$svg;return i.detachFunc=()=>{f.data("wires").forEach(_=>{_.detach()}),f.data("lines")&&f.data("lines").forEach(_=>{_.data("$background")&&C.append(_.data("$background")),_.detach()}),f.data("$background")&&f.data("$background").remove(),f.detach()},i.attachFunc=()=>{C.append(f),f.data("$background")&&C.append(f.data("$background")),C.append(f.data("wires")),f.data("lines")&&f.data("lines").forEach(_=>{C.append(_),_.data("$background")&&C.append(_.data("$background"))})},i.removeFunc=()=>{f.data("wires").forEach(_=>{_.remove()}),f.data("lines")&&f.data("lines").forEach(_=>{_.data("$background")&&_.data("$background").remove(),_().remove()}),f.data("$background")&&f.data("$background").remove(),f.remove()},i.$field=f,i}}F(M,"FONT_SIZE_SMALLEST","smallestFont"),F(M,"FONT_SIZE_SMALL","smallFont"),F(M,"FONT_SIZE_MIDDLE","middleFont"),F(M,"FONT_SIZE_BIG","bigFont");const ke={getAdapter(l){return{formats:()=>at(l.locale),parse:(e,t)=>o.objects.isNullOrUndefined(e)?null:e instanceof Date?e.getTime():o.objects.isString(e)?o.objects.isString(t)&&o.strings.hasText(t)?(e=new o.DateFormat(l.locale,t).parse(e),e instanceof Date?e.getTime():null):(e=o.dates.parseJsonDate(e),e instanceof Date?e.getTime():null):null,format:(e,t)=>{if(t==="quarter")throw new Error('The time unit "quarter" is not supported for formatting.');return o.dates.format(new Date(e),l.locale,t)},add:(e,t,r)=>{let a=new Date(e);switch(r){case"millisecond":return o.dates.shiftTime(a,0,0,0,t).getTime();case"second":return o.dates.shiftTime(a,0,0,t,0).getTime();case"minute":return o.dates.shiftTime(a,0,t,0,0).getTime();case"hour":return o.dates.shiftTime(a,t,0,0,0).getTime();case"day":return o.dates.shift(a,0,0,t).getTime();case"week":return o.dates.shift(a,0,0,t*7).getTime();case"month":return o.dates.shift(a,0,t,0).getTime();case"quarter":return o.dates.shift(a,0,t*3,0).getTime();case"year":return o.dates.shift(a,t,0,0).getTime();default:return e}},diff:(e,t,r)=>{switch(r){case"millisecond":return e-t;case"second":return(e-t)/1e3;case"minute":return(e-t)/1e3/60;case"hour":return(e-t)/1e3/60/60;case"day":return o.dates.compareDays(new Date(e),new Date(t));case"week":return o.dates.compareDays(new Date(e),new Date(t))/7;case"month":return o.dates.compareMonths(new Date(e),new Date(t));case"quarter":return o.dates.compareMonths(new Date(e),new Date(t))/3;case"year":return new Date(e).getFullYear()-new Date(t).getFullYear();default:return 0}},startOf:(e,t,r)=>{let a=new Date(e);switch(t){case"second":return a.setMilliseconds(0);case"minute":return a.setSeconds(0,0);case"hour":return a.setMinutes(0,0,0);case"day":return a.setHours(0,0,0,0);case"week":return o.dates.firstDayOfWeek(a,0).getTime();case"isoWeek":return o.dates.firstDayOfWeek(a,r).getTime();case"month":return o.dates.trunc(a).setDate(0);case"quarter":return o.dates.trunc(a).setMonth(a.getMonth()%4,1);case"year":return o.dates.trunc(a).setMonth(0,1);default:return e}},endOf:(e,t)=>{let r=new Date(e);switch(t){case"second":return r.setMilliseconds(999);case"minute":return r.setSeconds(59,999);case"hour":return r.setMinutes(59,59,999);case"day":return r.setHours(23,59,59,999);case"week":{r.setHours(23,59,59,999);let a=o.dates.firstDayOfWeek(r,0);return a.setDate(a.getDate()+7)}case"month":return r.setHours(23,59,59,999),r.setDate(Ie(r.getMonth(),r.getFullYear()));case"quarter":{r.setHours(23,59,59,999);let a=r.getMonth()%4+2;return r.setMonth(a,Ie(a,r.getFullYear()))}case"year":return r.setHours(23,59,59,999),r.setMonth(11,31);default:return e}}}}};function at(l){return{datetime:l.dateFormatPatternDefault+" "+l.timeFormatPatternDefault,millisecond:"HH:mm:ss.SSS",second:"HH:mm:ss",minute:l.timeFormatPatternDefault,hour:l.timeFormatPatternDefault,day:l.dateFormatPatternDefault,week:"ww",month:"MMM yyyy",quarter:"qqq - yyyy",year:"yyyy"}}function Ie(l,e){return l in[3,5,8,10]?30:l===1?o.dates.isLeapYear(e)?29:28:31}var it=l=>{var e={};return E.d(e,l),e},hr=l=>()=>l;const B=it({CategoryScale:()=>ve.CategoryScale,Chart:()=>ve.Chart,_adapters:()=>ve._adapters});var st=l=>{var e={};return E.d(e,l),e},dr=l=>()=>l;const ur=st({});var nt=l=>{var e={};return E.d(e,l),e},cr=l=>()=>l;const Re=nt({default:()=>We.default});function A(l,e,t){return(e=ot(e))in l?Object.defineProperty(l,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):l[e]=t,l}function ot(l){var e=lt(l,"string");return typeof e=="symbol"?e:e+""}function lt(l,e){if(typeof l!="object"||!l)return l;var t=l[Symbol.toPrimitive];if(t!==void 0){var r=t.call(l,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(l)}B.Chart.register(Re.default),g().extend(!0,B.Chart.defaults,{maintainAspectRatio:!1,elements:{line:{borderWidth:2},point:{radius:0,hitRadius:10,hoverRadius:7,hoverBorderWidth:2},arc:{borderWidth:1},bar:{borderWidth:1,borderSkipped:""}},plugins:{legend:{labels:{usePointStyle:!0,boxHeight:7}}}}),g().extend(!0,B.Chart.overrides,{line:{elements:{point:{borderWidth:2}}},scatter:{elements:{point:{radius:3}}},bubble:{layout:{autoPadding:!1}}});let we=!1;const ht=(1+Math.sqrt(5))/2;class J extends pe{constructor(e){super(e),A(this,"chartJs",void 0),A(this,"onlyIntegers",void 0),A(this,"maxXAxesTicksHeight",void 0),A(this,"numSupportedColors",void 0),A(this,"colorSchemeCssClass",void 0),A(this,"minRadialChartDatalabelSpace",void 0),A(this,"resetDatasetAfterHover",void 0),A(this,"legendHoverDatasets",void 0),A(this,"removing",void 0),A(this,"$canvas",void 0),A(this,"_labelFormatter",void 0),A(this,"_xLabelFormatter",void 0),A(this,"_yLabelFormatter",void 0),A(this,"_xAxisFitter",void 0),A(this,"_yAxisFitter",void 0),A(this,"_radialChartDatalabelsDisplayHandler",void 0),A(this,"_radialChartDatalabelsFormatter",void 0),A(this,"_datalabelsFormatter",void 0),A(this,"_datalabelBackgroundColorHandler",void 0),A(this,"_legendLabelGenerator",void 0),A(this,"_clickHandler",void 0),A(this,"_hoverHandler",void 0),A(this,"_pointerHoverHandler",void 0),A(this,"_legendClickHandler",void 0),A(this,"_legendHoverHandler",void 0),A(this,"_legendPointerHoverHandler",void 0),A(this,"_legendLeaveHandler",void 0),A(this,"_legendPointerLeaveHandler",void 0),A(this,"_resizeHandler",void 0),A(this,"_tooltipTitleGenerator",void 0),A(this,"_tooltipItemsGenerator",void 0),A(this,"_tooltipLabelGenerator",void 0),A(this,"_tooltipLabelValueGenerator",void 0),A(this,"_tooltipLabelColorGenerator",void 0),A(this,"_tooltipRenderer",void 0),A(this,"_tooltip",void 0),A(this,"_tooltipTimeoutId",void 0),A(this,"_updatingDatalabels",void 0),this.chartJs=null,this.onlyIntegers=!0,this.maxXAxesTicksHeight=75,this.numSupportedColors=6,this.colorSchemeCssClass="",this.minRadialChartDatalabelSpace=25,this._labelFormatter=this._createLabelFormatter(this._formatLabel),this._xLabelFormatter=this._createLabelFormatter(this._formatXLabel),this._yLabelFormatter=this._createLabelFormatter(this._formatYLabel),this._xAxisFitter=this._fitXAxis.bind(this),this._yAxisFitter=this._fitYAxis.bind(this),this._radialChartDatalabelsDisplayHandler=this._displayDatalabelsOnRadialChart.bind(this),this._radialChartDatalabelsFormatter=this._formatDatalabelsOnRadialChart.bind(this),this._datalabelsFormatter=this._formatDatalabels.bind(this),this._datalabelBackgroundColorHandler=this._getBackgroundColorOfDataset.bind(this),this._legendLabelGenerator=this._generateLegendLabels.bind(this),this.resetDatasetAfterHover=!1,this._clickHandler=this._onClick.bind(this),this._hoverHandler=this._onHover.bind(this),this._pointerHoverHandler=this._onHoverPointer.bind(this),this.legendHoverDatasets=[],this._legendClickHandler=this._onLegendClick.bind(this),this._legendHoverHandler=this._onLegendHover.bind(this),this._legendPointerHoverHandler=this._onLegendHoverPointer.bind(this),this._legendLeaveHandler=this._onLegendLeave.bind(this),this._legendPointerLeaveHandler=this._onLegendLeavePointer.bind(this),this._resizeHandler=this._onResize.bind(this),this._tooltipTitleGenerator=this._generateTooltipTitle.bind(this),this._tooltipItemsGenerator=this._generateTooltipItems.bind(this),this._tooltipLabelGenerator=this._generateTooltipLabel.bind(this),this._tooltipLabelValueGenerator=this._generateTooltipLabelValue.bind(this),this._tooltipLabelColorGenerator=this._generateTooltipLabelColor.bind(this),this._tooltipRenderer=this._renderTooltip.bind(this),this._tooltip=null,this._tooltipTimeoutId=null}_validateChartData(){let e=!0,t=this.chart&&this.chart.data;if((!t||!t.chartValueGroups||t.chartValueGroups.length===0||!t.axes)&&(e=!1),e&&o.scout.isOneOf(this.chart.config.type,d.Type.POLAR_AREA,d.Type.RADAR)){let i,s=0;for(i=0;i<t.chartValueGroups.length;i++){let n=t.chartValueGroups[i];n.values||(e=!1),i===0?s=n.values.length:n.values.length!==s&&(e=!1)}for(i=0;i<t.axes.length;i++)t.axes[i].length!==s&&(e=!1)}if(e)return!0;let r=!0,a=this.chart&&this.chart.config;if((!a||!a.data||!a.data.datasets||a.data.datasets.length===0)&&(r=!1),r&&o.scout.isOneOf(a.type,d.Type.POLAR_AREA,d.Type.RADAR)){let i,s=0;for(i=0;i<a.data.datasets.length;i++){let n=a.data.datasets[i];n.data||(r=!1),i===0?s=n.data.length:n.data.length!==s&&(r=!1)}}return r}_render(){this.$canvas||(this.$canvas=this.chart.$container.appendElement("<canvas>"),o.aria.hidden(this.$canvas,!0)),this.firstOpaqueBackgroundColor=o.styles.getFirstOpaqueBackgroundColor(this.$canvas),we||(B.Chart.defaults.font.family=this.$canvas.css("font-family"),B._adapters._date.override(ke.getAdapter(this.chart.session)),we=!0);let e=g().extend(!0,{},this.chart.config);this._adjustConfig(e),this._renderChart(e)}_renderChart(e){this.chartJs&&this.chartJs.destroy(),e=g().extend(!0,{},e,{options:{animation:{}}},e),e.options.animation.duration=this.animationDuration,this.chartJs=new B.Chart(this.$canvas[0].getContext("2d"),e),this._adjustSize(this.chartJs.config,this.chartJs.chartArea,{isDatasetVisible:t=>this.chartJs.getDatasetMeta(t).visible}),this.refresh()}_updateData(){if(!this.chartJs)return;let e=g().extend(!0,{},this.chart.config);this._adjustConfig(e);let t=this.chartJs.config.data,r=e.data,a=(h,p,c,f)=>{if(!h||!p||!c)return;if(!p[c]){let b=h[c];(b||f)&&(p[c]=b);return}if(!h[c]){if(f){p[c]=void 0;return}if(Array.isArray(p[c])){p[c].splice(0,p[c].length);return}p[c]=void 0;return}if(!Array.isArray(h[c])||!Array.isArray(p[c])){p[c]=h[c];return}for(let b=0;b<Math.min(h[c].length,p[c].length);b++)p[c][b]=h[c][b];let m=p[c].length,y=h[c].length;m>y?p[c].splice(y,m-y):m<y&&p[c].push(...h[c].splice(m))},i=(h,p)=>o.arrays.find(h,c=>c.datasetId===p),s=(h,p)=>o.arrays.findIndex(h,c=>c.datasetId===p);if(t&&r){a(r,t,"labels"),t.datasets||(t.datasets=[]),r.datasets||(r.datasets=[]),r.datasets.every(h=>o.objects.isNullOrUndefined(h.datasetId))&&(r.datasets.forEach((h,p)=>{h.datasetId=""+p}),t.datasets.forEach((h,p)=>{h.datasetId=""+p})),t.datasets.forEach(h=>{let p=i(r.datasets,h.datasetId);p&&(h.label=p.label,h.type=p.type,a(p,h,"data"),a(p,h,"backgroundColor",!0),a(p,h,"borderColor",!0),a(p,h,"hoverBackgroundColor",!0),a(p,h,"hoverBorderColor",!0),a(p,h,"legendColor",!0),a(p,h,"pointBackgroundColor",!0),a(p,h,"pointHoverBackgroundColor",!0),a(p,h,"pointBorderColor",!0),a(p,h,"pointHoverBorderColor",!0),a(p,h,"uncheckedBackgroundColor",!0),a(p,h,"uncheckedHoverBackgroundColor",!0),a(p,h,"checkedBackgroundColor",!0),a(p,h,"checkedHoverBackgroundColor",!0),a(p,h,"uncheckedPointBackgroundColor",!0),a(p,h,"uncheckedPointHoverBackgroundColor",!0),a(p,h,"checkedPointBackgroundColor",!0),a(p,h,"checkedPointHoverBackgroundColor",!0),a(p,h,"lineTension",!0),a(p,h,"pointRadius",!0),a(p,h,"uncheckedPointRadius",!0),a(p,h,"checkedPointRadius",!0),this._adjustDatasetBorderWidths(h))});for(let h=t.datasets.length-1;h>=0;h--){let p=t.datasets[h].datasetId;(o.objects.isNullOrUndefined(p)||s(r.datasets,p)===-1)&&t.datasets.splice(h,1)}t.datasets.sort((h,p)=>s(r.datasets,h.datasetId)-s(r.datasets,p.datasetId)),r.datasets.forEach((h,p)=>{let c=t.datasets[p];c&&c.datasetId&&h.datasetId===c.datasetId||t.datasets.splice(p,0,h)})}else this.chartJs.config.data=r;a(e.options,this.chartJs.config.options,"xLabelMap",!0),a(e.options,this.chartJs.config.options,"yLabelMap",!0),g().extend(!0,this.chartJs.config,{options:{animation:{duration:this.animationDuration}}});let n=this.chartJs.config.options.scales||{};[n.x||{},n.y||{},n.yDiffType||{},n.r||{}].forEach(h=>{(h.ticks||{}).stepSize=void 0}),this.refresh(),this._adjustSize(this.chartJs.config,this.chartJs.chartArea,{isDatasetVisible:h=>this.chartJs.getDatasetMeta(h).visible}),this.refresh()}isDataUpdatable(){return!0}isDetachSupported(){return!1}refresh(){this.chartJs?this.chartJs.update():super.refresh()}_renderAnimationDuration(){this.chartJs&&(g().extend(!0,this.chartJs.config,{options:{animation:{duration:this.animationDuration}}}),this.refresh())}_renderCheckedItems(){this.chartJs&&this._checkItems(this.chartJs.config)&&this.refresh()}_checkItems(e){if(!e||!e.data)return!1;let t=(a,i,s)=>{if(Array.isArray(a)&&Array.isArray(i)){let n=0;return o.arrays.ensure(s).filter(u=>!isNaN(u)&&u<Math.min(a.length,i.length)).forEach(u=>{a[u]!==i[u]&&(a[u]=i[u],n++)}),n}return 0},r=0;return e.data.datasets.forEach((a,i)=>{let s=this.chart.checkedItems.filter(u=>u.datasetIndex===i).map(u=>u.dataIndex),n=o.arrays.init(a.data.length,null).map((u,h)=>h);o.arrays.removeAll(n,s),r=r+t(a.backgroundColor,a.checkedBackgroundColor,s)+t(a.hoverBackgroundColor,a.checkedHoverBackgroundColor,s)+t(a.pointBackgroundColor,a.checkedPointBackgroundColor,s)+t(a.pointHoverBackgroundColor,a.checkedPointHoverBackgroundColor,s)+t(a.pointRadius,a.checkedPointRadius,s)+t(a.backgroundColor,a.uncheckedBackgroundColor,n)+t(a.hoverBackgroundColor,a.uncheckedHoverBackgroundColor,n)+t(a.pointBackgroundColor,a.uncheckedPointBackgroundColor,n)+t(a.pointHoverBackgroundColor,a.uncheckedPointHoverBackgroundColor,n)+t(a.pointRadius,a.uncheckedPointRadius,n),this._adjustDatasetBorderWidths(a)}),0<r}stopAnimations(){this.chartJs&&this.chartJs.stop()}_adjustConfig(e){!e||!e.type||(this._adjustType(e),this.chart.data&&this._computeDatasets(this.chart.data,e),this._adjustData(e),this._adjustLegend(e),this._adjustTooltip(e),this._adjustGrid(e),this._adjustPlugins(e),this._adjustColors(e),this._adjustClickHandler(e),this._adjustResizeHandler(e))}_adjustType(e){if(e.type===d.Type.COMBO_BAR_LINE){e.type=d.Type.BAR;let t=(e.options||{}).scaleLabelByTypeMap;t&&(t[d.Type.BAR]=t[d.Type.COMBO_BAR_LINE])}else this._isHorizontalBar(e)&&(e.type=d.Type.BAR,e.options=g().extend(!0,{},e.options,{indexAxis:"y"}))}_computeDatasets(e,t){let r=[],a=[],i=(n,u)=>{g().isEmptyObject(u)||(t.options[n]=u)};(e.axes[0]||[]).forEach(n=>r.push(n.label));let s=this._isHorizontalBar(t);i(s?"yLabelMap":"xLabelMap",this._computeLabelMap(e.axes[0])),i(s?"xLabelMap":"yLabelMap",this._computeLabelMap(e.axes[1])),e.chartValueGroups.forEach(n=>a.push({type:n.type,label:n.groupName,data:g().extend(!0,[],n.values)})),t.data={labels:r,datasets:a}}_isHorizontalBar(e){return e&&(e.type===d.Type.BAR_HORIZONTAL||e.type===d.Type.BAR&&e.options&&e.options.indexAxis==="y")}_computeLabelMap(e){let t={};return(e||[]).forEach((r,a)=>{t[a]=r.label}),t}_adjustData(e){!e||!e.data||!e.type||(this._adjustBarBorderWidth(e),this._adjustMaxSegments(e),this._adjustBubbleRadii(e),this._adjustOnlyIntegers(e))}_adjustBarBorderWidth(e){!e||!e.data||!e.type||!o.scout.isOneOf(e.type,d.Type.BAR)||e.data.datasets.forEach(t=>{(t.type||d.Type.BAR)===d.Type.BAR&&(t.borderWidth=t.borderWidth||1,t.hoverBorderWidth=t.hoverBorderWidth||2,this._adjustDatasetBorderWidths(t))})}_adjustDatasetBorderWidths(e){this._adjustDatasetBorderWidth(e),this._adjustDatasetBorderWidth(e,!0)}_adjustDatasetBorderWidth(e,t){if(!e)return;let r=t?"hoverBorderWidth":"borderWidth",a=t?"hoverBorderWidthBackup":"borderWidthBackup",i=t?"hoverBackgroundColor":"backgroundColor",s=t?"hoverBorderColor":"borderColor";if(e[a]&&(e[r]=e[a],delete e[a]),!e[r]||o.objects.isFunction(e[r]))return;let n=Array.isArray(e[r]),u=Array.isArray(e[i]),h=Array.isArray(e[s]);if(!(n||u||h)&&e[i]===e[s]){e[a]=e[r],e[r]=0;return}let c=(e.data||[]).length;n?e[r].length<c&&e[r].push(...o.arrays.init(c-e[r].length,e[r][0])):e[r]=o.arrays.init(c,e[r]);let f=e[r],m=f.length,y=o.arrays.init(m,null);for(let b=0;b<m;b++){let C=u?e[i][b]:e[i],_=h?e[s][b]:e[s];y[b]=f[b],C===_&&(f[b]=0)}o.arrays.equals(f,y)||(e[a]=y)}_adjustMaxSegments(e){if(!e||!e.data||!e.type||!o.scout.isOneOf(e.type,d.Type.PIE,d.Type.DOUGHNUT,d.Type.POLAR_AREA,d.Type.RADAR))return;let t=e.options.maxSegments;if(!(t&&e.data.datasets.length&&t<e.data.datasets[0].data.length))return;e.data.datasets.forEach(a=>{let i=a.data.slice(0,t);i[t-1]=a.data.slice(t-1,a.data.length).reduce((s,n)=>s+n,0),a.data=i});let r=e.data.labels.slice(0,t);r[t-1]=this.chart.session.text("ui.OtherValues"),e.data.labels=r,e.data.maxSegmentsExceeded=!0}_isMaxSegmentsExceeded(e,t){return!o.scout.isOneOf(e.type,d.Type.PIE,d.Type.DOUGHNUT,d.Type.POLAR_AREA,d.Type.RADAR)||e.options.otherSegmentClickable||!e.data.maxSegmentsExceeded||!e.options.maxSegments?!1:e.options.maxSegments-1<=t}_adjustBubbleRadii(e){!e||!e.data||!e.type||e.type!==d.Type.BUBBLE||e.data.datasets.forEach(t=>t.data.forEach(r=>{isNaN(r.r)||(r.z=Math.pow(r.r,2)),r.r=1}))}_adjustOnlyIntegers(e){this.onlyIntegers=!0,!(!e||!e.data||!e.type)&&(o.scout.isOneOf(e.type,d.Type.BUBBLE,d.Type.SCATTER)?this.onlyIntegers=e.data.datasets.every(t=>t.data.every(r=>o.numbers.isInteger(r.x)&&o.numbers.isInteger(r.y))):this.onlyIntegers=e.data.datasets.every(t=>t.data.every(r=>o.numbers.isInteger(r))))}_adjustLegend(e){!e||!e.type||!e.options||(e.options=g().extend(!0,{},e.options,{plugins:{legend:{labels:{generateLabels:this._legendLabelGenerator}}}}),e.options.plugins.legend.pointsVisible||(e.options.plugins.legend.labels.boxWidth=0))}_adjustTooltip(e){if(!e)return;e.options=g().extend(!0,{},{plugins:{tooltip:{callbacks:{title:this._tooltipTitleGenerator,items:this._tooltipItemsGenerator,label:this._tooltipLabelGenerator,labelValue:this._tooltipLabelValueGenerator,labelColor:this._tooltipLabelColorGenerator}}}},e.options);let t=e.options.plugins.tooltip;t.enabled&&(t.enabled=!1,t.external=this._tooltipRenderer)}_generateTooltipTitle(e){if(!e||!e.length)return"";let t=e[0],r=t.chart,a=r.config,i=t.dataset,s=[];if(o.scout.isOneOf(a.type,d.Type.BUBBLE)){let n=a.options.scales.x,u=a.options.scales.y,h=this._getAxisLabels(a),p=n.ticks.callback(i.data[t.dataIndex].x,null,null);p&&s.push(this._createTooltipAttribute(h.x,o.strings.encode(p),!0));let c=u.ticks.callback(i.data[t.dataIndex].y,null,null);c&&s.push(this._createTooltipAttribute(h.y,o.strings.encode(c),!0))}else if(!o.scout.isOneOf(a.type,d.Type.SCATTER)){let n=r.data.labels[t.dataIndex];s.push(this._createTooltipAttribute(a.options.reformatLabels?this._formatLabel(n):n,"",!0))}return s}_getAxisLabels(e){let t=e.options.scales.x.title.text,r=e.options.scales.y.title.text;return t=this._resolveAxisLabel(t,J.ARROW_LEFT_RIGHT),r=this._resolveAxisLabel(r,"&nbsp;"+J.ARROW_UP_DOWN+"&nbsp;"),{x:t,y:r}}_resolveAxisLabel(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return o.objects.isFunction(e)&&(e=e(),e=o.objects.isString(e)?e:""),e?o.strings.encode(e):t}_generateTooltipItems(e,t,r,a){if(!e||!e.length)return"";let i=e[0],s=i.chart,n=s.config,u=!1,h=!1,p="";if(e.forEach(c=>{let{label:f,labelValue:m,labelColor:y}=this._getItemDetails(c,t,r,a);if(o.scout.isOneOf(n.type,d.Type.SCATTER)){let{x:b,y:C}=m;u||(u=o.objects.isString(b)),h||(h=o.objects.isString(C)),p+=this._createTooltipScatterAttribute(f,b,C,!1,y)}else p+=this._createTooltipAttribute(f,m,!1,y)}),o.scout.isOneOf(n.type,d.Type.SCATTER)){let c="<table><tbody>",f=this._getAxisLabels(n);c+=this._createTooltipScatterAttribute("",u?f.x:"",h?f.y:"",!0),p=o.strings.box(c,p,"</tbody></table>")}return p}_getItemDetails(e,t,r,a){let i,s,n;return o.objects.isFunction(t)&&(i=t(e),i=o.objects.isString(i)?i:""),o.objects.isFunction(r)&&(s=r(e),s=o.objects.isString(s)||o.objects.isObject(s)?s:""),o.objects.isFunction(a)&&(n=a(e),n=o.objects.isObject(n)&&n.backgroundColor||""),{label:i,labelValue:s,labelColor:n}}_generateTooltipLabel(e){return o.strings.encode(e.dataset.label)}_generateTooltipLabelValue(e){let t=e.chart.config,r=e.dataset;return t.type===d.Type.BUBBLE?o.strings.encode(this._formatLabel(r.data[e.dataIndex].z)):t.type===d.Type.SCATTER?{x:o.strings.encode(this._formatXLabel(r.data[e.dataIndex].x)),y:o.strings.encode(this._formatYLabel(r.data[e.dataIndex].y))}:o.strings.encode(this._formatLabel(r.data[e.dataIndex]))}_generateTooltipLabelColor(e){let t=e.chart.config,r=e.dataset,a,i,s,n;o.scout.isOneOf(r.type||t.type,d.Type.LINE,d.Type.BAR,d.Type.BAR_HORIZONTAL,d.Type.RADAR,d.Type.BUBBLE,d.Type.SCATTER)&&(s=r.borderColor,a=Array.isArray(r.legendColor)?r.legendColor[e.dataIndex]:r.legendColor,n=e.datasetIndex),o.scout.isOneOf(t.type,d.Type.PIE,d.Type.DOUGHNUT,d.Type.POLAR_AREA)&&(a=Array.isArray(r.legendColor)?r.legendColor[e.dataIndex]:r.legendColor,i=Array.isArray(r.backgroundColor)?r.backgroundColor[e.dataIndex]:r.backgroundColor,i=this._adjustColorOpacity(i,1),n=e.dataIndex),o.objects.isFunction(a)&&(a=a.call(e.chart,n));let u=a||i||s;if(!u||o.objects.isFunction(u)){let h;B.Chart.overrides[t.type]&&B.Chart.overrides[t.type].plugins&&B.Chart.overrides[t.type].plugins.tooltip&&B.Chart.overrides[t.type].plugins.tooltip.callbacks&&(h=B.Chart.overrides[t.type].plugins.tooltip.callbacks.labelColor),u=(h||B.Chart.defaults.plugins.tooltip.callbacks.labelColor).call(e.chart,e).backgroundColor}return{backgroundColor:u}}_createTooltipAttribute(e,t,r,a){return'<div class="'+(r?"attribute title":"attribute")+'">'+(a?'<div class="color" style="background-color:'+a+'"></div>':"")+(e?"<label>"+e+"</label>":"")+(t?'<div class="value">'+t+"</div>":"")+"</div>"}_createTooltipScatterAttribute(e,t,r,a,i){return'<tr class="'+(a?"attribute title":"attribute")+'"><td class="color-cell">'+(i?'<div class="color" style="background-color:'+i+'"></div>':"")+'</td><td class="label">'+e+"</td>"+(t?'<td class="value">'+t+"</td>":"")+(r?'<td class="value">'+r+"</td>":"")+"</tr>"}_renderTooltip(e){if(e.tooltip.opacity===0||e.tooltip.dataPoints.length<1){this._tooltipTimeoutId&&(clearTimeout(this._tooltipTimeoutId),this._tooltipTimeoutId=void 0),this._tooltip&&(this._tooltip.destroy(),this._tooltip=null);return}!!this._tooltip?this._renderTooltipLater(e):(clearTimeout(this._tooltipTimeoutId),this._tooltipTimeoutId=setTimeout(()=>this._renderTooltipLater(e),o.tooltips.DEFAULT_TOOLTIP_DELAY))}_renderTooltipLater(e){if(!this.rendered||this.removing)return;let t=e.tooltip,r=t.dataPoints;if(r.length<1)return;let a=r[0];if(!a.chart.getDatasetMeta(a.datasetIndex).data[a.dataIndex])return;this._tooltip&&(this._tooltip.destroy(),this._tooltip=null);let s=t.options||{},n=s.callbacks||{},u=n.title,h=n.items,p=n.label,c=n.labelValue,f=n.labelColor,m="";o.objects.isFunction(u)&&(m+=o.arrays.ensure(u(r)).join("")),o.objects.isFunction(h)&&(m+=o.arrays.ensure(h(r,p,c,f)).join(""));let y=this._computeTooltipPositionAndOffset(a),b=new o.Point(t.caretX+y.offsetX,t.caretY+y.offsetY);this._tooltip=o.scout.create({objectType:o.Tooltip,parent:this.chart,$anchor:this.$canvas,text:m,htmlEnabled:!0,cssClass:o.strings.join(" ","chart-tooltip",s.cssClass),tooltipPosition:y.tooltipPosition,tooltipDirection:y.tooltipDirection,originProducer:v=>{const T=o.graphics.offsetBounds(v);return T.height=y.height,T},offsetProducer:v=>b}),this._tooltip.render(),this._tooltip.$container.css("pointer-events","none");let C=!1,_=(s.titleFont||{}).family;_&&(this._tooltip.$container.css("--chart-tooltip-font-family",_),C=!0);let x=0;this._tooltip.$container.find("label").each((v,T)=>{x=Math.max(x,o.graphics.prefSize(g()(T)).width)}),x>0&&(this._tooltip.$container.css("--chart-tooltip-label-width",Math.min(x,120)+"px"),C=!0),C&&this._tooltip.position()}_computeTooltipPositionAndOffset(e){let t="top",r="right",a=0,i=0,s=0,n=e.chart,u=e.datasetIndex,h=e.dataIndex,p=n.config,c=p.data.datasets,f=c[u],m=f.data[h];if(this._isHorizontalBar(p))o.objects.isObject(m)&&o.objects.isArray(m.x)&&m.x.length===2?r=(m.x[0]+m.x[1])/2<0?"left":"right":r=m<0?"left":"right";else if((f.type||p.type)===d.Type.BAR)t=m<0?"bottom":"top";else if(o.scout.isOneOf(p.type,d.Type.PIE,d.Type.DOUGHNUT,d.Type.POLAR_AREA)){let y=n.getDatasetMeta(u).data[h].getProps(["startAngle","endAngle"]),b=y.startAngle,C=y.endAngle,_=(b+C)/2;t=0<=_&&_<Math.PI?"bottom":"top",r=-Math.PI/2<=_&&_<Math.PI/2?"right":"left"}else if(p.type===d.Type.RADAR){let b=n.getDatasetMeta(u).data[h].getProps(["angle"]).angle;t=0<=b&&b<Math.PI?"bottom":"top",r=-Math.PI/2<=b&&b<Math.PI/2?"right":"left"}else if(o.scout.isOneOf(p.type,d.Type.BUBBLE,d.Type.SCATTER)){let y=n.getDatasetMeta(u).data[h],b=n.chartArea,C=b.left+b.width/2;r=y.x<C?"left":"right"}if(this._isHorizontalBar(p)){let y=n.getDatasetMeta(u).data[h].getProps(["height","width"]);s=y.height;let b=y.width,C=b/(ht+1);i=-s/2,a=r==="left"?C:-C}else if(o.scout.isOneOf(p.type,d.Type.LINE,d.Type.BUBBLE,d.Type.SCATTER,d.Type.RADAR)||f.type===d.Type.LINE){let b=n.getDatasetMeta(u).data[h].options,C=b.hoverRadius+b.hoverBorderWidth;p.type===d.Type.BUBBLE&&(C+=m.r),s=2*C,i=-C}else if(o.scout.isOneOf(p.type,d.Type.PIE,d.Type.DOUGHNUT,d.Type.POLAR_AREA)){let y=n.getDatasetMeta(u).data[h].getProps(["startAngle","endAngle","innerRadius","outerRadius"]),b=y.startAngle,C=y.endAngle,_=(b+C)/2,x=y.innerRadius,v=y.outerRadius,T=(v-x)/2;a=T*Math.cos(_),i=T*Math.sin(_)}return{tooltipPosition:t,tooltipDirection:r,offsetX:a,offsetY:i,height:s}}_adjustGrid(e){e&&(e.options=g().extend(!0,{},e.options),this._adjustScalesR(e),this._adjustScalesXY(e))}_adjustScalesR(e){if(!e||!e.type||!e.options)return;o.scout.isOneOf(e.type,d.Type.POLAR_AREA,d.Type.RADAR)&&(e.options=g().extend(!0,{},{scales:{r:{}}},e.options));let t=e.options,r=t?t.scales:{};r&&r.r&&(r.r=g().extend(!0,{},{minSpaceBetweenTicks:35,beginAtZero:!0,angleLines:{display:!1},ticks:{callback:this._labelFormatter},pointLabels:{callback:this._labelFormatter,font:{size:B.Chart.defaults.font.size}}},r.r))}_adjustScalesXY(e){!e||!e.type||!e.options||(o.scout.isOneOf(e.type,d.Type.BAR,d.Type.LINE,d.Type.BUBBLE)?e.options=g().extend(!0,{},{scales:{x:{minSpaceBetweenTicks:150},y:{minSpaceBetweenTicks:35}}},e.options):o.scout.isOneOf(e.type,d.Type.SCATTER)&&(e.options=g().extend(!0,{},{scales:{x:{minSpaceBetweenTicks:35,ticks:{padding:10}},y:{minSpaceBetweenTicks:35,ticks:{padding:10}}}},e.options)),this._adjustXAxis(e),this._adjustYAxis(e))}_adjustXAxis(e){if(!e||!e.type||!e.options||!e.options.scales||!e.options.scales.x)return;let t=e.type,r=e.options.scales;this._isHorizontalBar(e)||o.scout.isOneOf(t,d.Type.BUBBLE,d.Type.SCATTER)?r.x=g().extend(!0,{},{beginAtZero:this._isHorizontalBar(e),offset:t===d.Type.BUBBLE,grid:{drawTicks:!1},border:{display:!1},ticks:{padding:5}},r.x):r.x=g().extend(!0,{},{offset:!0,grid:{display:!1},border:{display:!1}},r.x),(this._isHorizontalBar(e)||o.scout.isOneOf(t,d.Type.BUBBLE,d.Type.SCATTER)||e.options.reformatLabels)&&(r.x=g().extend(!0,{},{ticks:{callback:this._xLabelFormatter}},r.x)),r.x.afterCalculateLabelRotation=this._xAxisFitter}_adjustYAxis(e){if(!e||!e.type||!e.options||!e.options.scales||!e.options.scales.y)return;let t=e.type,r=e.options.scales;this._isHorizontalBar(e)?r.y=g().extend(!0,{},{grid:{display:!1},border:{display:!1}},r.y):r.y=g().extend(!0,{},{beginAtZero:!o.scout.isOneOf(t,d.Type.BUBBLE,d.Type.SCATTER),grid:{drawTicks:!1},border:{display:!1},ticks:{padding:5}},r.y),(!this._isHorizontalBar(e)||e.options.reformatLabels)&&(r.y=g().extend(!0,{},{ticks:{callback:this._yLabelFormatter}},r.y)),r.y.afterFit=this._yAxisFitter}_adjustPlugins(e){this._adjustPluginsDatalabels(e)}_adjustPluginsDatalabels(e){if(!e||!e.type||!e.options||!e.options.plugins||!e.options.plugins.datalabels||!e.options.plugins.datalabels.display)return;let t=e.options.plugins;if(o.scout.isOneOf(e.type,d.Type.PIE,d.Type.DOUGHNUT)){t.datalabels=g().extend(!0,{},{formatter:this._radialChartDatalabelsFormatter},t.datalabels),t.datalabels.display=this._radialChartDatalabelsDisplayHandler,this._updatingDatalabels=!1;let r=e.options.animation||{},a=r.onProgress,i=r.onComplete,s=u=>{if(this._updatingDatalabels)return;this._updatingDatalabels=!0;let h=u.chart,p=h.getSortedVisibleDatasetMetas(),c=[...h.getActiveElements()],f=[];p.forEach((m,y)=>{m.data.forEach((b,C)=>{let _=o.arrays.findIndex(c,x=>x.datasetIndex===y&&x.index===C);_>0?c.splice(_,1):f.push({datasetIndex:y,index:C,element:b})})}),h["$"+Re.default.id]._actives=f,Re.default.afterEvent(h,null,null),this._updatingDatalabels=!1},n=(u,h)=>{s(u),h&&h(u)};e.options.animation=g().extend(!0,{},e.options.animation,{onProgress:u=>n(u,a),onComplete:u=>n(u,i)})}else o.scout.isOneOf(e.type,d.Type.BAR,d.Type.LINE,d.Type.POLAR_AREA,d.Type.RADAR,d.Type.BUBBLE)?(t.datalabels=g().extend(!0,{},{backgroundColor:this._datalabelBackgroundColorHandler,borderRadius:3},t.datalabels),t.datalabels.display="auto"):o.scout.isOneOf(e.type,d.Type.SCATTER)&&(t.datalabels=g().extend(!0,{},{backgroundColor:this._datalabelBackgroundColorHandler,borderRadius:3,anchor:"end",align:"top",offset:3},t.datalabels),t.datalabels.display="auto");if(e.options.reformatLabels){let r=a=>(i,s)=>{let n=a.call(s.chart,i,s);return this._formatLabel(n)};e.data&&e.data.datasets.forEach(i=>{i.datalabels&&i.datalabels.formatter&&(i.datalabels.formatter=r(i.datalabels.formatter))}),t.datalabels.formatter&&(t.datalabels.formatter=r(t.datalabels.formatter))}t.datalabels=g().extend(!0,{},{formatter:this._datalabelsFormatter},t.datalabels)}_getNumberFormatter(){var e;return(e=this.chartJs)===null||e===void 0||(e=e.config)===null||e===void 0||(e=e.options)===null||e===void 0?void 0:e.numberFormatter}_createLabelFormatter(e){const t=this;return function(r){return e.call(t,r,this)}}_formatLabel(e,t){return e=this._formatCategory(e,t),this._forma