UNPKG

apexcharts

Version:

A JavaScript Chart Library

6 lines (5 loc) 31.2 kB
/*! * ApexCharts v5.15.0 * (c) 2018-2026 ApexCharts */ "use strict";var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,a=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i,r=(e,t)=>{for(var s in t||(t={}))n.call(t,s)&&a(e,s,t[s]);if(i)for(var s of i(t))l.call(t,s)&&a(e,s,t[s]);return e},o=(e,i)=>t(e,s(i));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("apexcharts/core");function d(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const s in e)if("default"!==s){const i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>e[s]})}return t.default=e,Object.freeze(t)}const g=d(c),h=g.__apex_CoreUtils,p=g.__apex_dimensions_Dimensions,f=g.__apex_Graphics,u=g.__apex_Series,x=g.__apex_Utils,m=g.__apex_Environment_Environment;class b{constructor(e){this.w=e.w,this.lgCtx=e}getLegendStyles(){if(m.isSSR())return null;const e=document.createElement("style");e.setAttribute("type","text/css");const t=this.w.config.chart.nonce;t&&e.setAttribute("nonce",t);const s=document.createTextNode(".apexcharts-flip-y {\n transform: scaleY(-1) translateY(-100%);\n transform-origin: top;\n transform-box: fill-box;\n}\n.apexcharts-flip-x {\n transform: scaleX(-1);\n transform-origin: center;\n transform-box: fill-box;\n}\n.apexcharts-legend {\n display: flex;\n overflow: auto;\n padding: 0 10px;\n}\n.apexcharts-legend.apexcharts-legend-group-horizontal {\n flex-direction: column;\n}\n.apexcharts-legend-group {\n display: flex;\n}\n.apexcharts-legend-group-vertical {\n flex-direction: column-reverse;\n}\n.apexcharts-legend.apx-legend-position-bottom, .apexcharts-legend.apx-legend-position-top {\n flex-wrap: wrap\n}\n.apexcharts-legend.apx-legend-position-right, .apexcharts-legend.apx-legend-position-left {\n flex-direction: column;\n bottom: 0;\n}\n.apexcharts-legend.apx-legend-position-bottom.apexcharts-align-left, .apexcharts-legend.apx-legend-position-top.apexcharts-align-left, .apexcharts-legend.apx-legend-position-right, .apexcharts-legend.apx-legend-position-left {\n justify-content: flex-start;\n align-items: flex-start;\n}\n.apexcharts-legend.apx-legend-position-bottom.apexcharts-align-center, .apexcharts-legend.apx-legend-position-top.apexcharts-align-center {\n justify-content: center;\n align-items: center;\n}\n.apexcharts-legend.apx-legend-position-bottom.apexcharts-align-right, .apexcharts-legend.apx-legend-position-top.apexcharts-align-right {\n justify-content: flex-end;\n align-items: flex-end;\n}\n.apexcharts-legend-series {\n cursor: pointer;\n line-height: normal;\n display: flex;\n align-items: center;\n}\n.apexcharts-legend-text {\n position: relative;\n font-size: 14px;\n}\n.apexcharts-legend-text *, .apexcharts-legend-marker * {\n pointer-events: none;\n}\n.apexcharts-legend-marker {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n margin-right: 1px;\n}\n\n.apexcharts-legend-series.apexcharts-no-click {\n cursor: auto;\n}\n.apexcharts-legend .apexcharts-hidden-zero-series, .apexcharts-legend .apexcharts-hidden-null-series {\n display: none !important;\n}\n.apexcharts-inactive-legend {\n opacity: 0.45;\n} ");return e.appendChild(s),e}getLegendDimensions(){const e=this.w.dom.baseEl.querySelector(".apexcharts-legend");if(!e)return{clwh:0,clww:0};const{width:t,height:s}=e.getBoundingClientRect();return{clwh:s,clww:t}}appendToForeignObject(){var e;const t=this.getLegendStyles();!1!==this.w.config.chart.injectStyleSheet&&t&&(null==(e=this.w.dom.elLegendForeign)||e.appendChild(t))}toggleDataSeries(e,t){var s,i;const n=this.w;if(n.globals.axisCharts||"radialBar"===n.config.chart.type){n.globals.resized=!0;let l=null,a=null;if(n.globals.risingSeries=[],n.globals.axisCharts){if(l=n.dom.baseEl.querySelector(`.apexcharts-series[data\\:realIndex='${e}']`),!l)return;a=parseInt(null!=(s=l.getAttribute("data:realIndex"))?s:"",10)}else{if(l=n.dom.baseEl.querySelector(`.apexcharts-series[rel='${e+1}']`),!l)return;a=parseInt(null!=(i=l.getAttribute("rel"))?i:"",10)-1}if(t){[{cs:n.globals.collapsedSeries,csi:n.globals.collapsedSeriesIndices},{cs:n.globals.ancillaryCollapsedSeries,csi:n.globals.ancillaryCollapsedSeriesIndices}].forEach(e=>{const t=e.cs,s=e.csi;this.riseCollapsedSeries(t,s,a)})}else this.hideSeries({seriesEl:l,realIndex:a});if(n.config.chart.accessibility.enabled){const t=n.dom.baseEl.querySelector(`.apexcharts-legend-series[rel="${e+1}"]`);if(t){const s=n.globals.collapsedSeriesIndices.includes(a)||n.globals.ancillaryCollapsedSeriesIndices.includes(a);t.setAttribute("aria-pressed",s?"true":"false");const i=t.querySelector(".apexcharts-legend-text"),l=i?i.textContent:n.seriesData.seriesNames[e],r=s?"hidden":"visible";t.setAttribute("aria-label",`${l}, ${r}. Press Enter or Space to toggle.`)}}}else{const t=n.dom.Paper.findOne(` .apexcharts-series[rel='${e+1}'] path`),s=n.config.chart.type;if("pie"===s||"polarArea"===s||"donut"===s){const e=n.config.plotOptions.pie.donut.labels;new f(this.w).pathMouseDown(t,null),this.lgCtx.printDataLabelsInner(t.node,e)}if(n.config.chart.accessibility.enabled){const t=n.dom.baseEl.querySelector(`.apexcharts-legend-series[rel="${e+1}"]`);if(t){const s=n.globals.collapsedSeriesIndices.includes(e);t.setAttribute("aria-pressed",s?"true":"false");const i=t.querySelector(".apexcharts-legend-text"),l=i?i.textContent:n.seriesData.seriesNames[e],a=s?"hidden":"visible";t.setAttribute("aria-label",`${l}, ${a}. Press Enter or Space to toggle.`)}}}}getSeriesAfterCollapsing({realIndex:e}){var t;const s=this.w,i=s.globals,n=x.clone(s.config.series);if(i.axisCharts){const t=s.config.yaxis[i.seriesYAxisReverseMap[e]],l={index:e,data:n[e].data.slice(),type:n[e].type||s.config.chart.type};if(t&&t.show&&t.showAlways)i.ancillaryCollapsedSeriesIndices.indexOf(e)<0&&(i.ancillaryCollapsedSeries.push(l),i.ancillaryCollapsedSeriesIndices.push(e));else if(i.collapsedSeriesIndices.indexOf(e)<0){i.collapsedSeries.push(l),i.collapsedSeriesIndices.push(e);const t=i.risingSeries.indexOf(e);i.risingSeries.splice(t,1)}}else i.collapsedSeries.push({index:e,data:n[e],type:null!=(t=s.config.series[e].type)?t:"line"}),i.collapsedSeriesIndices.push(e);return i.allSeriesCollapsed=i.collapsedSeries.length+i.ancillaryCollapsedSeries.length===s.config.series.length,this._getSeriesBasedOnCollapsedState(n)}hideSeries({seriesEl:e,realIndex:t}){const s=this.w,i=this.getSeriesAfterCollapsing({realIndex:t}),n=e.childNodes;for(let e=0;e<n.length;e++)n[e].classList.contains("apexcharts-series-markers-wrap")&&(n[e].classList.contains("apexcharts-hide")?n[e].classList.remove("apexcharts-hide"):n[e].classList.add("apexcharts-hide"));this.lgCtx.updateSeries(i,s.config.chart.animations.dynamicAnimation.enabled)}riseCollapsedSeries(e,t,s){const i=this.w;let n=x.clone(i.config.series);if(e.length>0){for(let l=0;l<e.length;l++)e[l].index===s&&(i.globals.axisCharts?n[s].data=e[l].data.slice():n[s]=e[l].data,"number"!=typeof n[s]&&(n[s].hidden=!1),e.splice(l,1),t.splice(l,1),i.globals.risingSeries.push(s),l--);n=this._getSeriesBasedOnCollapsedState(n),this.lgCtx.updateSeries(n,i.config.chart.animations.dynamicAnimation.enabled)}}_getSeriesBasedOnCollapsedState(e){const t=this.w;let s=0;return t.globals.axisCharts?e.forEach((i,n)=>{t.globals.collapsedSeriesIndices.indexOf(n)<0&&t.globals.ancillaryCollapsedSeriesIndices.indexOf(n)<0||(e[n].data=[],s++)}):e.forEach((i,n)=>{t.globals.collapsedSeriesIndices.indexOf(n)<0||(e[n]=0,s++)}),t.globals.allSeriesCollapsed=s===e.length,e}}const y=g.__apex_BrowserAPIs_BrowserAPIs,v="http://www.w3.org/2000/svg";class S{constructor(e,t){this.w=e,this.ctx=t,this.svgEl=null,this.arrowEl=null,this.hoverValueEl=null,this._min=0,this._max=0,this._geom=null,this._bandHitEls=[],this._activeBandIndex=-1,this._onCellEnter=this._onCellEnter.bind(this),this._onCellLeave=this._onCellLeave.bind(this),this._onBandEnter=this._onBandEnter.bind(this),this._onBandLeave=this._onBandLeave.bind(this)}_getFormatter(){const e=this.w.config.plotOptions.heatmap.colorScale.gradientLegend;return"function"==typeof e.formatter?e.formatter:e=>{if(!Number.isFinite(e))return String(e);const t=Math.abs(e);return t>=1e3?e.toFixed(0):t>=10?e.toFixed(1):e.toFixed(2)}}static isEnabled(e){var t,s,i,n;const l=null==(n=null==(i=null==(s=null==(t=null==e?void 0:e.config)?void 0:t.plotOptions)?void 0:s.heatmap)?void 0:i.colorScale)?void 0:n.gradientLegend;return!(!l||!l.enabled)}draw(){var e,t,s,i,n,l,a,r;const o=this.w,c=o.dom.elLegendWrap;if(!c)return;const d=o.config.plotOptions.heatmap.colorScale.gradientLegend,g=o.config.legend.position,h="left"===g||"right"===g,p=null!=(t=null==(e=d.arrow)?void 0:e.size)?t:8,f=p+4,u=d.showLabels?28:4,x=d.showLabels?20:4,m=d.showLabels?44:0,b=this._resolveStripLength(h?d.height:d.width,h),S=d.thickness,w=h?Math.max(S+f+4,m):b+2*u,L=h?b+2*x:S+f+4,A=(w-(S+f))/2,E=h?"left"===g?A:A+f:u,C=h?x:"top"===g?f:4,_=y.createElementNS(v,"svg");_.setAttribute("class","apexcharts-heatmap-gradient-legend"),_.setAttribute("width",String(w)),_.setAttribute("height",String(L)),_.setAttribute("overflow","visible");const k=y.createElementNS(v,"defs"),I=`apexcharts-heatmap-gradient-${o.globals.cuid}`,H=y.createElementNS(v,"linearGradient");H.setAttribute("id",I),h?(H.setAttribute("x1","0"),H.setAttribute("y1","1"),H.setAttribute("x2","0"),H.setAttribute("y2","0")):(H.setAttribute("x1","0"),H.setAttribute("y1","0"),H.setAttribute("x2","1"),H.setAttribute("y2","0"));const{min:F,max:O,stops:M,bands:B}=this._computeStops();this._min=F,this._max=O,M.forEach(e=>{const t=y.createElementNS(v,"stop");t.setAttribute("offset",`${(100*e.percent).toFixed(2)}%`),t.setAttribute("stop-color",e.color),H.appendChild(t)}),k.appendChild(H),_.appendChild(k);const D=y.createElementNS(v,"rect");if(D.setAttribute("x",String(E)),D.setAttribute("y",String(C)),D.setAttribute("width",String(h?S:b)),D.setAttribute("height",String(h?b:S)),D.setAttribute("rx","2"),D.setAttribute("fill",`url(#${I})`),_.appendChild(D),d.showLabels){const e=(null==(s=d.labelStyle)?void 0:s.colors)||(Array.isArray(o.config.legend.labels.colors)?o.config.legend.labels.colors[0]:o.config.legend.labels.colors)||o.config.chart.foreColor,t=(null==(i=d.labelStyle)?void 0:i.fontSize)||"11px",l=(null==(n=d.labelStyle)?void 0:n.fontFamily)||o.config.chart.fontFamily,a=this._getFormatter(),r=(s,i,n,a)=>{const r=y.createElementNS(v,"text");return r.setAttribute("x",String(i)),r.setAttribute("y",String(n)),r.setAttribute("text-anchor",a),r.setAttribute("dominant-baseline","middle"),r.setAttribute("fill",e),r.setAttribute("font-size",t),l&&r.setAttribute("font-family",l),r.textContent=String(s),r};if(h){const e=E+S/2;_.appendChild(r(a(F),e,C+b+10,"middle")),_.appendChild(r(a(O),e,C-10,"middle"))}else{const e=C+S/2;_.appendChild(r(a(F),E-6,e,"end")),_.appendChild(r(a(O),E+b+6,e,"start"))}}const $=(null==(l=d.arrow)?void 0:l.color)||o.config.chart.foreColor,N=this._buildArrow(p,$,g);if(_.appendChild(N),this.arrowEl=N,this._bandHitEls=[],o.config.legend.onItemHover.highlightDataSeries&&B.length>0&&B.forEach(e=>{const t=y.createElementNS(v,"rect");if(h){const s=C+b-e.p2*b,i=C+b-e.p1*b;t.setAttribute("x",String(E)),t.setAttribute("y",String(s)),t.setAttribute("width",String(S)),t.setAttribute("height",String(Math.max(0,i-s)))}else t.setAttribute("x",String(E+e.p1*b)),t.setAttribute("y",String(C)),t.setAttribute("width",String(Math.max(0,(e.p2-e.p1)*b))),t.setAttribute("height",String(S));t.setAttribute("fill","transparent"),t.setAttribute("class","apexcharts-heatmap-gradient-band"),t.setAttribute("data:range-index",String(e.index)),t.style.cursor="pointer",_.appendChild(t),this._bandHitEls.push(t)}),this._geom={isVertical:h,position:g,stripX:E,stripY:C,stripLength:b,stripThickness:S,arrowSize:p,svgWidth:w,svgHeight:L},d.showHoverValue){const e=y.createElement("div");e.classList.add("apexcharts-heatmap-gradient-legend-value"),e.style.position="absolute",e.style.fontSize=(null==(a=d.labelStyle)?void 0:a.fontSize)||"11px",e.style.fontFamily=(null==(r=d.labelStyle)?void 0:r.fontFamily)||o.config.chart.fontFamily||"",e.style.color=o.config.chart.foreColor,e.style.background="rgba(0,0,0,0.65)",e.style.color="#fff",e.style.padding="2px 6px",e.style.borderRadius="3px",e.style.pointerEvents="none",e.style.whiteSpace="nowrap",e.style.opacity="0",e.style.transition="opacity 120ms ease",this.hoverValueEl=e}c.classList.add("apexcharts-heatmap-gradient-legend-wrap"),c.classList.add("apx-legend-position-"+g),c.appendChild(_),this.hoverValueEl&&c.appendChild(this.hoverValueEl),this.svgEl=_,this._applyWrapAlignment(c,g,h,w,L),this._attachHoverListeners(),this._attachBandHoverListeners()}_resolveStripLength(e,t){const s=this.w,i=t?s.globals.svgHeight||s.config.chart.height||300:s.globals.svgWidth||s.config.chart.width||600;if("string"==typeof e){const t=e.trim();if(t.endsWith("%")){const e=parseFloat(t)||0;return Math.max(20,i*e/100)}const s=parseFloat(t);return Number.isFinite(s)?s:200}return"number"==typeof e&&Number.isFinite(e)?e:200}_applyWrapAlignment(e,t,s,i,n){const l=this.w,a=l.config.plotOptions.heatmap.colorScale.gradientLegend.align||"center",r=12,o=l.globals.svgWidth||l.config.chart.width||600,c=l.globals.svgHeight||l.config.chart.height||300,d=l.config.legend.offsetX||0,g=l.config.legend.offsetY||0;if(e.style.position="absolute",e.style.display="block",e.style.overflow="visible",e.style.padding="0",e.style.width=i+"px",e.style.height=n+"px",e.style.right="auto",e.style.bottom="auto",s){const s=c-n-24;let l;l="start"===a?r:"end"===a?r+Math.max(0,s):r+Math.max(0,s)/2,e.style.top=l+g+"px",e.style.left="left"===t?r+d+"px":o-i-r+d+"px"}else{const s=o-i-24;let l;l="start"===a?r:"end"===a?r+Math.max(0,s):r+Math.max(0,s)/2,e.style.left=l+d+"px",e.style.top="top"===t?r+g+"px":c-n-r+g+"px"}}repositionToPlot(){var e,t;if(!m.isBrowser())return;const s=this.w,i=s.globals,n=s.dom.elLegendWrap;if(!n||!this._geom)return;if(!Number.isFinite(i.gridWidth)||!Number.isFinite(i.gridHeight))return;const{isVertical:l,position:a,svgWidth:r,svgHeight:o,stripX:c,stripY:d,stripThickness:g}=this._geom,h=s.config.plotOptions.heatmap.colorScale.gradientLegend.align||"center",p=s.config.legend.offsetX||0,f=s.config.legend.offsetY||0,u=null==(t=null==(e=this.ctx)?void 0:e.dimensions)?void 0:t.dimHelpers,x=u?u.getTitleSubtitleCoords("title").height+u.getTitleSubtitleCoords("subtitle").height:0,b=s.layout.xAxisHeight||0,v=(e,t)=>{const s=Math.max(0,e-t);return"start"===h?0:"end"===h?s:s/2};if(l){n.style.top=i.translateY+v(i.gridHeight,o)+f+"px";const e=(("left"===a?0:i.translateX+i.gridWidth)+("left"===a?i.translateX:i.svgWidth))/2;n.style.left=e-c-g/2+p+"px"}else{n.style.left=i.translateX+v(i.gridWidth,r)+p+"px";const e=(("top"===a?x:i.translateY+i.gridHeight+b)+("top"===a?i.translateY:i.svgHeight))/2;n.style.top=e-d-g/2+f+"px"}y.requestAnimationFrame(()=>this._enforceMinPlotGap())}_enforceMinPlotGap(){const e=this.w,t=e.dom.elLegendWrap,s=this.svgEl&&this.svgEl.querySelector("rect"),i=e.dom.baseEl.querySelector(".apexcharts-grid");if(!(t&&s&&i&&this._geom))return;const n=s.getBoundingClientRect(),l=i.getBoundingClientRect();if(!(n.width&&n.height&&l.width&&l.height))return;const{isVertical:a,position:r}=this._geom;if(a){const e="left"===r?l.left-n.right:n.left-l.right;if(e<16){const s=parseFloat(t.style.left)||0,i=16-e;t.style.left=s+("left"===r?-i:i)+"px"}}else{const e="top"===r?l.top-n.bottom:n.top-l.bottom;if(e<16){const s=parseFloat(t.style.top)||0,i=16-e;t.style.top=s+("top"===r?-i:i)+"px"}}}destroy(){var e,t,s,i,n,l,a;for(let s=0;s<this._bandHitEls.length;s++){const i=this._bandHitEls[s];null==(e=i.removeEventListener)||e.call(i,"mousemove",this._onBandEnter),null==(t=i.removeEventListener)||t.call(i,"mouseout",this._onBandLeave)}if(this._bandHitEls=[],this._activeBandIndex=-1,null==(s=this.ctx)?void 0:s.events)try{null==(n=(i=this.ctx.events).removeEventListener)||n.call(i,"dataPointMouseEnter",this._onCellEnter),null==(a=(l=this.ctx.events).removeEventListener)||a.call(l,"dataPointMouseLeave",this._onCellLeave)}catch(e){}}_attachBandHoverListeners(){if(m.isBrowser())for(let e=0;e<this._bandHitEls.length;e++){const t=this._bandHitEls[e];t.addEventListener("mousemove",this._onBandEnter),t.addEventListener("mouseout",this._onBandLeave)}}_onBandEnter(e){var t,s,i,n;const l=this.w,a=e.currentTarget,r=parseInt(null!=(t=a.getAttribute("data:range-index"))?t:"-1",10);r<0||r===this._activeBandIndex||(this._activeBandIndex=r,null==(n=null==(i=null==(s=this.ctx)?void 0:s.events)?void 0:i.fireEvent)||n.call(i,"legendHover",[this.ctx,r,l]),new u(l).highlightRangeInSeries(r,"highlight"))}_onBandLeave(){if(this._activeBandIndex<0)return;const e=this._activeBandIndex;this._activeBandIndex=-1,new u(this.w).highlightRangeInSeries(e,"reset")}_attachHoverListeners(){var e,t;m.isBrowser()&&(null==(t=null==(e=this.ctx)?void 0:e.events)?void 0:t.addEventListener)&&(this.ctx.events.addEventListener("dataPointMouseEnter",this._onCellEnter),this.ctx.events.addEventListener("dataPointMouseLeave",this._onCellLeave))}_onCellEnter(...e){var t,s;const i=this.w;if(!this.arrowEl)return;const n=e[e.length-1];if(!n||"object"!=typeof n)return;const l=n.seriesIndex,a=n.dataPointIndex;if("number"!=typeof l||"number"!=typeof a)return;if("heatmap"!==i.config.chart.type)return;const r=null==(s=null==(t=i.seriesData)?void 0:t.series)?void 0:s[l],o=null==r?void 0:r[a];null==o||Number.isNaN(o)||this._positionArrow(o)}_onCellLeave(){this.arrowEl&&(this.arrowEl.setAttribute("opacity","0"),this.hoverValueEl&&(this.hoverValueEl.style.opacity="0"))}_positionArrow(e){if(!this.arrowEl||!this._geom)return;const{isVertical:t,position:s,stripX:i,stripY:n,stripLength:l,stripThickness:a,arrowSize:r}=this._geom,o=this._min,c=this._max-o;let d;if(d=0===c?.5:(e-o)/c,d<0&&(d=0),d>1&&(d=1),t){const e=n+l-d*l;let t,o;"left"===s?(t=i+a,o=t+r):(t=i,o=t-r);const c=[`${t},${e}`,`${o},${e-r/2}`,`${o},${e+r/2}`].join(" ");this.arrowEl.setAttribute("points",c)}else{const e=i+d*l;let t,o;"top"===s?(t=n+a,o=t+r):(t=n,o=t-r);const c=[`${e},${t}`,`${e-r/2},${o}`,`${e+r/2},${o}`].join(" ");this.arrowEl.setAttribute("points",c)}if(this.arrowEl.setAttribute("opacity","1"),this.hoverValueEl){const o=this._getFormatter();if(this.hoverValueEl.textContent=o(e),t){const e=n+l-d*l;"left"===s?this.hoverValueEl.style.left=`${i+a+r+8}px`:(this.hoverValueEl.style.left=i-r-8+"px",this.hoverValueEl.style.transform="translateX(-100%)"),this.hoverValueEl.style.top=e-9+"px"}else{const e=i+d*l;this.hoverValueEl.style.left=`${e}px`,this.hoverValueEl.style.transform="translateX(-50%)",this.hoverValueEl.style.top="top"===s?`${n+a+r+8}px`:n-r-18+"px"}this.hoverValueEl.style.opacity="1"}}_buildArrow(e,t,s){const i=y.createElementNS(v,"polygon");return i.setAttribute("fill",t),i.setAttribute("opacity","0"),i.setAttribute("class","apexcharts-heatmap-gradient-arrow"),i.setAttribute("points","0,0 0,0 0,0"),i.setAttribute("pointer-events","none"),i}_computeStops(){var e,t;const s=this.w,i=s.config.plotOptions.heatmap.colorScale,n=i.gradientLegend;let l=1/0,a=-1/0;const c=(null==(e=s.seriesData)?void 0:e.series)||[];for(let e=0;e<c.length;e++){const t=c[e];if(t)for(let e=0;e<t.length;e++){const s=t[e];null==s||Number.isNaN(s)||(s<l&&(l=s),s>a&&(a=s))}}Number.isFinite(l)||(l=0),Number.isFinite(a)||(a=0);let d=l,g=a;void 0!==i.min&&(d=i.min<l?i.min:l),void 0!==i.max&&(g=i.max>a?i.max:a);const h=[],p=[];if(i.ranges&&i.ranges.length>0){const e=i.ranges.map((e,t)=>o(r({},e),{_originalIndex:t})).sort((e,t)=>e.from-t.from),t=e[0].from,s=e[e.length-1].to;d=t,g=s;const n=s-t||1;e.forEach(e=>{const s=(e.from-t)/n,i=(e.to-t)/n;h.push({percent:(s+i)/2,color:e.color}),p.push({index:e._originalIndex,p1:s,p2:i})})}else{const e=s.globals.colors[0]||"#008FFB",i=new x,l=null!=(t=s.config.plotOptions.heatmap.shadeIntensity)?t:.5,a=s.globals.hasNegs,r=Math.max(2,n.stops||16);for(let t=0;t<r;t++){const n=t/(r-1),o=d+n*(g-d),c=Math.abs(g)+Math.abs(d),p=0===c?0:100*o/c;let f;f=a?s.config.plotOptions.heatmap.reverseNegativeShade?p<0?p/100*(1.25*l):1.25*l*(1-p/100):p<=0?1-(1+p/100)*l:(1-p/100)*l:1-p/100,f>1&&(f=1),f<-1&&(f=-1);const u=s.config.plotOptions.heatmap.enableShades?i.shadeColor("dark"===s.config.theme.mode?-1*f:f,e):e;h.push({percent:n,color:u})}}return{min:d,max:g,stops:h,bands:p}}}const w=g.__apex_Markers;c.registerFeatures({legend:class{constructor(e,t){this.w=e,this.ctx=t,this.printDataLabelsInner=(...e)=>{var s;return null==(s=t.pie)?void 0:s.printDataLabelsInner(...e)},this.updateSeries=(...e)=>t.updateHelpers._updateSeries(...e),this.onLegendClick=this.onLegendClick.bind(this),this.onLegendHovered=this.onLegendHovered.bind(this),this.isBarsDistributed="bar"===this.w.config.chart.type&&this.w.config.plotOptions.bar.distributed&&1===this.w.config.series.length,this.legendHelpers=new b(this)}init(){const e=this.w,t=e.globals,s=e.config,i=s.legend.showForSingleSeries&&1===this.w.seriesData.series.length||this.isBarsDistributed||"heatmap"===s.chart.type||this.w.seriesData.series.length>1;if(this.legendHelpers.appendToForeignObject(),(i||!t.axisCharts)&&s.legend.show){const t=e.dom.elLegendWrap;for(;t.firstChild;)t.removeChild(t.firstChild);this.heatmapGradientLegend&&(this.heatmapGradientLegend.destroy(),this.heatmapGradientLegend=null),"heatmap"===s.chart.type&&S.isEnabled(e)?(this.heatmapGradientLegend=new S(e,this.ctx),this.heatmapGradientLegend.draw()):(this.drawLegends(),"bottom"===s.legend.position||"top"===s.legend.position?this.legendAlignHorizontal():"right"!==s.legend.position&&"left"!==s.legend.position||this.legendAlignVertical())}}createLegendMarker({i:e,fillcolor:t}){const s=this.w,i=y.createElement("span");i.classList.add("apexcharts-legend-marker");const n=s.config.legend.markers.shape||s.config.markers.shape;let l=n;Array.isArray(n)&&(l=n[e]);const a=Array.isArray(s.config.legend.markers.size)?parseFloat(s.config.legend.markers.size[e]):parseFloat(s.config.legend.markers.size),c=Array.isArray(s.config.legend.markers.offsetX)?parseFloat(s.config.legend.markers.offsetX[e]):parseFloat(s.config.legend.markers.offsetX),d=Array.isArray(s.config.legend.markers.offsetY)?parseFloat(s.config.legend.markers.offsetY[e]):parseFloat(s.config.legend.markers.offsetY),g=Array.isArray(s.config.legend.markers.strokeWidth)?parseFloat(s.config.legend.markers.strokeWidth[e]):parseFloat(s.config.legend.markers.strokeWidth),h=i.style;if(h.height=2*(a+g)+"px",h.width=2*(a+g)+"px",h.left=c+"px",h.top=d+"px",s.config.legend.markers.customHTML)h.background="transparent",h.color=t[e],Array.isArray(s.config.legend.markers.customHTML)?s.config.legend.markers.customHTML[e]&&(i.innerHTML=s.config.legend.markers.customHTML[e]()):i.innerHTML=s.config.legend.markers.customHTML();else{const n=new w(this.ctx.w,this.ctx).getMarkerConfig({cssClass:`apexcharts-legend-marker apexcharts-marker apexcharts-marker-${l}`,seriesIndex:e,strokeWidth:g,size:a}),c=(m.isBrowser()?window.SVG:global.SVG)().addTo(i).size("100%","100%"),d=new f(this.w).drawMarker(0,0,o(r({},n),{pointFillColor:Array.isArray(t)?t[e]:n.pointFillColor,shape:l}));s.dom.Paper.find(".apexcharts-legend-marker.apexcharts-marker").forEach(e=>{e.node.classList.contains("apexcharts-marker-triangle")?e.node.style.transform="translate(50%, 45%)":e.node.style.transform="translate(50%, 50%)"}),c.add(d)}return i}drawLegends(){var e;const t=this,s=this.w,i=s.dom.elLegendWrap,n=s.config.legend.fontFamily;let l=s.seriesData.seriesNames,a=s.config.legend.markers.fillColors?s.config.legend.markers.fillColors.slice():s.globals.colors.slice();if("heatmap"===s.config.chart.type){const e=s.config.plotOptions.heatmap.colorScale.ranges;l=e.map(e=>e.name?e.name:e.from+" - "+e.to),a=e.map(e=>e.color)}else this.isBarsDistributed&&(l=s.labelData.labels.slice());s.config.legend.customLegendItems.length&&(l=s.config.legend.customLegendItems);const r=s.formatters.legendFormatter,o=s.config.legend.inverseOrder,c=[];s.labelData.seriesGroups.length>1&&s.config.legend.clusterGroupedSeries&&s.labelData.seriesGroups.forEach((e,t)=>{c[t]=y.createElement("div"),c[t].classList.add("apexcharts-legend-group",`apexcharts-legend-group-${t}`),"horizontal"===s.config.legend.clusterGroupedSeriesOrientation?i.classList.add("apexcharts-legend-group-horizontal"):c[t].classList.add("apexcharts-legend-group-vertical")});for(let t=o?l.length-1:0;o?t>=0:t<=l.length-1;o?t--:t++){const o=r(l[t],{seriesIndex:t,w:s});let d=!1,g=!1;if(s.globals.collapsedSeries.length>0)for(let e=0;e<s.globals.collapsedSeries.length;e++)s.globals.collapsedSeries[e].index===t&&(d=!0);if(s.globals.ancillaryCollapsedSeriesIndices.length>0)for(let e=0;e<s.globals.ancillaryCollapsedSeriesIndices.length;e++)s.globals.ancillaryCollapsedSeriesIndices[e]===t&&(g=!0);const p=this.createLegendMarker({i:t,fillcolor:a});f.setAttrs(p,{rel:t+1,"data:collapsed":d||g}),(d||g)&&p.classList.add("apexcharts-inactive-legend");const u=y.createElement("div");if(s.config.chart.accessibility.enabled&&s.config.chart.accessibility.keyboard.enabled){u.setAttribute("role","button"),u.setAttribute("tabindex","0");const e=Array.isArray(o)?o.join(" "):o,t=d||g,s=t?"hidden":"visible";u.setAttribute("aria-label",`${e}, ${s}. Press Enter or Space to toggle.`),u.setAttribute("aria-pressed",t?"true":"false")}const m=y.createElement("span");m.classList.add("apexcharts-legend-text"),m.innerHTML=Array.isArray(o)?o.join(" "):o;let b=s.config.legend.labels.useSeriesColors?s.globals.colors[t]:Array.isArray(s.config.legend.labels.colors)?null==(e=s.config.legend.labels.colors)?void 0:e[t]:s.config.legend.labels.colors;b||(b=s.config.chart.foreColor),m.style.color=b,m.style.fontSize=s.config.legend.fontSize,m.style.fontWeight=s.config.legend.fontWeight,m.style.fontFamily=n||s.config.chart.fontFamily,f.setAttrs(m,{rel:t+1,i:t,"data:default-text":encodeURIComponent(o),"data:collapsed":d||g}),u.appendChild(p),u.appendChild(m);const v=new h(this.w);if(!s.config.legend.showForZeroSeries){0===v.getSeriesTotalByIndex(t)&&v.seriesHaveSameValues(t)&&!v.isSeriesNull(t)&&-1===s.globals.collapsedSeriesIndices.indexOf(t)&&-1===s.globals.ancillaryCollapsedSeriesIndices.indexOf(t)&&u.classList.add("apexcharts-hidden-zero-series")}s.config.legend.showForNullSeries||v.isSeriesNull(t)&&-1===s.globals.collapsedSeriesIndices.indexOf(t)&&-1===s.globals.ancillaryCollapsedSeriesIndices.indexOf(t)&&u.classList.add("apexcharts-hidden-null-series"),c.length?s.labelData.seriesGroups.forEach((e,n)=>{var l,a;e.includes(null!=(a=null==(l=s.config.series[t])?void 0:l.name)?a:"")&&(i.appendChild(c[n]),c[n].appendChild(u))}):i.appendChild(u),i.classList.add(`apexcharts-align-${s.config.legend.horizontalAlign}`),i.classList.add("apx-legend-position-"+s.config.legend.position),u.classList.add("apexcharts-legend-series"),u.style.margin=`${s.config.legend.itemMargin.vertical}px ${s.config.legend.itemMargin.horizontal}px`,i.style.width=s.config.legend.width?s.config.legend.width+"px":"",i.style.height=s.config.legend.height?s.config.legend.height+"px":"",f.setAttrs(u,{rel:t+1,seriesName:x.escapeString(l[t]),"data:collapsed":d||g}),(d||g)&&u.classList.add("apexcharts-inactive-legend"),s.config.legend.onItemClick.toggleDataSeries||u.classList.add("apexcharts-no-click")}s.dom.elWrap.addEventListener("click",t.onLegendClick,!0),s.config.legend.onItemHover.highlightDataSeries&&0===s.config.legend.customLegendItems.length&&(s.dom.elWrap.addEventListener("mousemove",t.onLegendHovered,!0),s.dom.elWrap.addEventListener("mouseout",t.onLegendHovered,!0)),s.config.chart.accessibility.enabled&&s.config.chart.accessibility.keyboard.enabled&&s.dom.elWrap.addEventListener("keydown",t.onLegendKeyDown.bind(t),!0)}setLegendWrapXY(e,t){const s=this.w,i=s.dom.elLegendWrap,n=i.clientHeight;let l=0,a=0;if("bottom"===s.config.legend.position)a=s.globals.svgHeight-Math.min(n,s.globals.svgHeight/2)-5;else if("top"===s.config.legend.position){const e=new p(this.w,this.ctx),t=e.dimHelpers.getTitleSubtitleCoords("title").height,s=e.dimHelpers.getTitleSubtitleCoords("subtitle").height;a=(t>0?t-10:0)+(s>0?s-10:0)}i.style.position="absolute",l=l+e+s.config.legend.offsetX,a=a+t+s.config.legend.offsetY,i.style.left=l+"px",i.style.top=a+"px","right"===s.config.legend.position&&(i.style.left="auto",i.style.right=25+s.config.legend.offsetX+"px");["width","height"].forEach(e=>{i&&i.style[e]&&(i.style[e]=parseInt(String(s.config.legend[e]),10)+"px")})}legendAlignHorizontal(){const e=this.w;e.dom.elLegendWrap.style.right="0";const t=new p(this.w,this.ctx),s=t.dimHelpers.getTitleSubtitleCoords("title"),i=t.dimHelpers.getTitleSubtitleCoords("subtitle");let n=0;"top"===e.config.legend.position&&(n=s.height+i.height+e.config.title.margin+e.config.subtitle.margin-10),this.setLegendWrapXY(20,n)}legendAlignVertical(){const e=this.w,t=this.legendHelpers.getLegendDimensions();let s=0;"left"===e.config.legend.position&&(s=20),"right"===e.config.legend.position&&(s=e.globals.svgWidth-t.clww-10),this.setLegendWrapXY(s,20)}onLegendHovered(e){var t;const s=this.w,i=e.target,n=i.classList.contains("apexcharts-legend-series")||i.classList.contains("apexcharts-legend-text")||i.classList.contains("apexcharts-legend-marker");if("heatmap"===s.config.chart.type||this.isBarsDistributed){if(n){const s=parseInt(null!=(t=i.getAttribute("rel"))?t:"0",10)-1;this.ctx.events.fireEvent("legendHover",[this.ctx,s,this.w]);const n=new u(this.ctx.w);"mousemove"===e.type?n.highlightRangeInSeries(s,"highlight"):"mouseout"===e.type&&n.highlightRangeInSeries(s,"reset")}}else if(!i.classList.contains("apexcharts-inactive-legend")&&n){new u(this.ctx.w).toggleSeriesOnHover(e,i)}}onLegendKeyDown(e){const t=this,s=this.w,i=e.target;if((i.classList.contains("apexcharts-legend-series")||i.classList.contains("apexcharts-legend-text")||i.classList.contains("apexcharts-legend-marker"))&&("Enter"===e.key||" "===e.key)){e.preventDefault();const n=i.getAttribute("rel");t.onLegendClick(e),null!==n&&s.config.legend.onItemClick.toggleDataSeries&&requestAnimationFrame(()=>{const e=s.dom.baseEl.querySelector(`.apexcharts-legend-series[rel="${n}"]`);e&&e.focus()})}}onLegendClick(e){var t;const s=this.w,i=e.target;if(!s.config.legend.customLegendItems.length&&(i.classList.contains("apexcharts-legend-series")||i.classList.contains("apexcharts-legend-text")||i.classList.contains("apexcharts-legend-marker"))){const e=parseInt(null!=(t=i.getAttribute("rel"))?t:"0",10)-1,n="true"===i.getAttribute("data:collapsed"),l=this.w.config.chart.events.legendClick;"function"==typeof l&&l(this.ctx,e,this.w),this.ctx.events.fireEvent("legendClick",[this.ctx,e,this.w]);const a=this.w.config.legend.markers.onClick;"function"==typeof a&&i.classList.contains("apexcharts-legend-marker")&&(a(this.ctx,e,this.w),this.ctx.events.fireEvent("legendMarkerClick",[this.ctx,e,this.w]));"treemap"!==s.config.chart.type&&"heatmap"!==s.config.chart.type&&!this.isBarsDistributed&&s.config.legend.onItemClick.toggleDataSeries&&this.legendHelpers.toggleDataSeries(e,n)}}}}),exports.default=c;