apexcharts
Version:
A JavaScript Chart Library
6 lines (5 loc) • 35.7 kB
JavaScript
/*!
* ApexCharts v7.0.0
* (c) 2018-2026 ApexCharts
*/
"use strict";var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,l=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i,a=(e,t)=>{for(var s in t||(t={}))n.call(t,s)&&l(e,s,t[s]);if(i)for(var s of i(t))r.call(t,s)&&l(e,s,t[s]);return e},o=(e,i)=>t(e,s(i));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function c(e){if(e&&e.__esModule)return 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 d=c(require("apexcharts/core")),g=d.__apex_CoreUtils,h=d.__apex_dimensions_Dimensions,p=d.__apex_Graphics,u=d.__apex_Series,f=d.__apex_Utils,m=d.__apex_Environment_Environment;class x{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,n;const r=this.w;if(r.globals.axisCharts||"radialBar"===r.config.chart.type){r.globals.resized=!0;let l=null,a=null;if(r.globals.risingSeries=[],r.globals.axisCharts){if(l=null!=(s=Array.prototype.find.call(r.dom.baseEl.querySelectorAll(".apexcharts-series"),t=>t.getAttribute("data:realIndex")===String(e)))?s:null,!l)return;a=parseInt(null!=(i=l.getAttribute("data:realIndex"))?i:"",10)}else{if(l=r.dom.baseEl.querySelector(`.apexcharts-series[rel='${e+1}']`),!l)return;a=parseInt(null!=(n=l.getAttribute("rel"))?n:"",10)-1}if(t){[{cs:r.globals.collapsedSeries,csi:r.globals.collapsedSeriesIndices},{cs:r.globals.ancillaryCollapsedSeries,csi:r.globals.ancillaryCollapsedSeriesIndices}].forEach(e=>{const t=e.cs,s=e.csi;this.riseCollapsedSeries(t,s,a)})}else this.hideSeries({seriesEl:l,realIndex:a});if(r.config.chart.accessibility.enabled){const t=r.dom.baseEl.querySelector(`.apexcharts-legend-series[rel="${e+1}"]`);if(t){const s=r.globals.collapsedSeriesIndices.includes(a)||r.globals.ancillaryCollapsedSeriesIndices.includes(a);t.setAttribute("aria-pressed",s?"true":"false");const i=t.querySelector(".apexcharts-legend-text"),n=i?i.textContent:r.seriesData.seriesNames[e],l=s?"hidden":"visible";t.setAttribute("aria-label",`${n}, ${l}. Press Enter or Space to toggle.`)}}}else{if(r.globals.resized=!0,r.globals.risingSeries=[],t)this.riseCollapsedSeries(r.globals.collapsedSeries,r.globals.collapsedSeriesIndices,e);else{const t=this.getSeriesAfterCollapsing({realIndex:e});this.lgCtx.updateSeries(t,r.config.chart.animations.dynamicAnimation.enabled)}if(r.config.chart.accessibility.enabled){const t=r.dom.baseEl.querySelector(`.apexcharts-legend-series[rel="${e+1}"]`);if(t){const s=r.globals.collapsedSeriesIndices.includes(e);t.setAttribute("aria-pressed",s?"true":"false");const i=t.querySelector(".apexcharts-legend-text"),n=i?i.textContent:r.seriesData.seriesNames[e],l=s?"hidden":"visible";t.setAttribute("aria-label",`${n}, ${l}. Press Enter or Space to toggle.`)}}}}_nonAxisSliceContainer(e){const t=this.w.config.chart.type;return("pie"===t||"donut"===t||"polarArea"===t||"sunburst"===t)&&1===e.length&&e[0]&&"object"==typeof e[0]&&Array.isArray(e[0].data)?e[0].data:e}_readSliceValue(e){return"unit"===this.w.config.chart.type&&e&&Array.isArray(e.data)?e.data:e&&"object"==typeof e?e.y:e}_writeSliceValue(e,t,s){const i=e[t];"unit"===this.w.config.chart.type&&i&&Array.isArray(i.data)?i.data=Array.isArray(s)?s:[]:i&&"object"==typeof i?i.y=s:e[t]=s}getSeriesAfterCollapsing({realIndex:e}){var t,s;const i=this.w,n=i.globals,r=f.clone(i.config.series);if(n.axisCharts){const t=i.config.yaxis[n.seriesYAxisReverseMap[e]],s={index:e,data:r[e].data.slice(),type:r[e].type||i.config.chart.type,name:(n.seriesNames||[])[e]};if(t&&t.show&&t.showAlways)n.ancillaryCollapsedSeriesIndices.indexOf(e)<0&&(n.ancillaryCollapsedSeries.push(s),n.ancillaryCollapsedSeriesIndices.push(e));else if(n.collapsedSeriesIndices.indexOf(e)<0){n.collapsedSeries.push(s),n.collapsedSeriesIndices.push(e);const t=n.risingSeries.indexOf(e);n.risingSeries.splice(t,1)}}else if(n.collapsedSeriesIndices.indexOf(e)<0){const l=this._nonAxisSliceContainer(r);n.collapsedSeries.push({index:e,data:this._readSliceValue(l[e]),type:null!=(s=null==(t=i.config.series[e])?void 0:t.type)?s:"line",name:(n.seriesNames||[])[e]}),n.collapsedSeriesIndices.push(e)}const l=n.axisCharts?i.config.series.length:this._nonAxisSliceContainer(r).length;return n.allSeriesCollapsed=n.collapsedSeries.length+n.ancillaryCollapsedSeries.length===l,this._getSeriesBasedOnCollapsedState(r)}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"));const r=s.config.chart.animations.dynamicAnimation.enabled;r&&(s.globals.collapsingSeriesIndices=[t]);const l=()=>{s.globals.collapsingSeriesIndices=[]},a=this.lgCtx.updateSeries(i,r);l(),a&&"function"==typeof a.then&&a.then(l,l)}riseCollapsedSeries(e,t,s){const i=this.w;let n=f.clone(i.config.series);if(e.length>0){for(let r=0;r<e.length;r++)if(e[r].index===s){if(i.globals.axisCharts)n[s].data=e[r].data.slice(),n[s].hidden=!1;else{const t=this._nonAxisSliceContainer(n);this._writeSliceValue(t,s,e[r].data)}e.splice(r,1),t.splice(r,1),i.globals.risingSeries.push(s),r--}n=this._getSeriesBasedOnCollapsedState(n),this.lgCtx.updateSeries(n,i.config.chart.animations.dynamicAnimation.enabled)}}_getSeriesBasedOnCollapsedState(e){const t=this.w;let s=0;if(t.globals.axisCharts)e.forEach((i,n)=>{t.globals.collapsedSeriesIndices.indexOf(n)<0&&t.globals.ancillaryCollapsedSeriesIndices.indexOf(n)<0||(e[n].data=[],s++)});else{const i=this._nonAxisSliceContainer(e);i.forEach((e,n)=>{t.globals.collapsedSeriesIndices.indexOf(n)<0||(this._writeSliceValue(i,n,0),s++)})}const i=t.globals.axisCharts?e.length:this._nonAxisSliceContainer(e).length;return t.globals.allSeriesCollapsed=s===i,e}}const b=d.__apex_BrowserAPIs_BrowserAPIs,y=["#cf4d3f","#8f9499","#26a75b"],v=(e,t,s)=>e+(t-e)*s;function S(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")}function w(e,t,s){const i=f.parseHex(A(e)),n=f.parseHex(A(t));return i&&n?"#"+S(v(i[0],n[0],s))+S(v(i[1],n[1],s))+S(v(i[2],n[2],s)):e}function A(e){if("string"!=typeof e)return"#000000";if(f.isColorHex(e))return e;return f.rgb2hex(e)||"#000000"}function _(e,t,s,i){var n,r,l;if(!t||"object"!=typeof t)return null;const a=null==(l=null==(r=null==(n=e.config.plotOptions)?void 0:n.treemap)?void 0:r.colorScale)?void 0:l.colorValue;let o;if(o="function"==typeof a?a(t,{seriesIndex:s,dataPointIndex:i,w:e}):"string"==typeof a?t[a]:t.colorValue,null==o)return null;const c=Number(o);return Number.isFinite(c)?c:null}function L(e){var t,s,i;const n=null==(i=null==(s=null==(t=e.config)?void 0:t.plotOptions)?void 0:s.treemap)?void 0:i.colorScale,r=n&&n.gradient;if(!r)return null;if(!1===r.enabled)return null;const l=e.config.series||[];let a=1/0,o=-1/0,c=!1;for(let t=0;t<l.length;t++){const s=l[t]&&l[t].data;if(Array.isArray(s))for(let i=0;i<s.length;i++){const n=_(e,s[i],t,i);null!=n&&(c=!0,n<a&&(a=n),n>o&&(o=n))}}if(!c&&!0!==r.enabled)return null;Number.isFinite(a)||(a=0,o=0);let d=Number.isFinite(Number(r.min))?Number(r.min):a,g=Number.isFinite(Number(r.max))?Number(r.max):o,h=null;if(null===r.midpoint?h=null:Number.isFinite(Number(r.midpoint))?h=Number(r.midpoint):d<0&&g>0&&(h=0),null!=h&&!1!==r.symmetric&&!Number.isFinite(Number(r.min))&&!Number.isFinite(Number(r.max))){const e=Math.max(Math.abs(d-h),Math.abs(g-h));d=h-e,g=h+e}g===d&&(d-=.5,g+=.5);const p=function(e,t,s,i){if(Array.isArray(e.stops)&&e.stops.length>=2)return e.stops.filter(e=>e&&Number.isFinite(Number(e.value))).map(e=>({value:Number(e.value),color:A(e.color)})).sort((e,t)=>e.value-t.value);const n=(Array.isArray(e.colors)&&e.colors.length>=2?e.colors:y).map(A),r=n.length;if(null!=i&&r>=3){const e=Math.floor((r-1)/2),l=[];for(let s=0;s<=e;s++)l.push({value:v(t,i,s/e),color:n[s]});for(let t=e+1;t<r;t++)l.push({value:v(i,s,(t-e)/(r-1-e)),color:n[t]});return l}return n.map((e,i)=>({value:v(t,s,i/(r-1)),color:e}))}(r,d,g,h);if(p.length<2)return null;const u=g-d,f=p.map(e=>({percent:0===u?0:(e.value-d)/u,color:e.color}));return{min:d,max:g,midpoint:h,stops:p,at:e=>{if(!Number.isFinite(e))return p[Math.floor(p.length/2)].color;if(e<=p[0].value)return p[0].color;const t=p[p.length-1];if(e>=t.value)return t.color;for(let t=1;t<p.length;t++){const s=p[t];if(e<=s.value){const i=p[t-1],n=s.value-i.value,r=0===n?0:(e-i.value)/n;return w(i.color,s.color,r)}}return t.color},legendStops:f}}const C="http://www.w3.org/2000/svg";class E{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._targetEl=null,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._cfg();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 colorScaleOf(e){var t,s,i,n,r;const l=null==(s=null==(t=null==e?void 0:e.config)?void 0:t.chart)?void 0:s.type;return l&&(null==(r=null==(n=null==(i=null==e?void 0:e.config)?void 0:i.plotOptions)?void 0:n[l])?void 0:r.colorScale)||null}static configFor(e){const t=E.colorScaleOf(e);return t&&t.gradientLegend||null}_cfg(){return E.configFor(this.w)||{}}static isEnabled(e){if(!E.supports(e))return!1;const t=E.configFor(e);return!(!t||!t.enabled)}static supports(e){var t,s;const i=null==(s=null==(t=null==e?void 0:e.config)?void 0:t.chart)?void 0:s.type;return"heatmap"===i||"treemap"===i}draw(e=null){var t,s,i,n,r,l,a,o;const c=this.w;this._targetEl=e;const d=e||c.dom.elLegendWrap;if(!d)return;const g=this._cfg(),h=c.config.legend.position,p="left"===h||"right"===h,u=null!=(s=null==(t=g.arrow)?void 0:t.size)?s:8,f=u+4,m=g.showLabels?28:4,x=g.showLabels?20:4,y=g.showLabels?44:0,v=this._resolveStripLength(p?g.height:g.width,p),S=g.thickness,w=p?Math.max(S+f+4,y):v+2*m,A=p?v+2*x:S+f+4,_=(w-(S+f))/2,L=p?"left"===h?_:_+f:m,E=p?x:"top"===h?f:4,k=b.createElementNS(C,"svg");k.setAttribute("class","apexcharts-heatmap-gradient-legend apexcharts-gradient-legend"),k.setAttribute("width",String(w)),k.setAttribute("height",String(A)),k.setAttribute("overflow","visible");const I=b.createElementNS(C,"defs"),F=`apexcharts-heatmap-gradient-${c.globals.cuid}`,H=b.createElementNS(C,"linearGradient");H.setAttribute("id",F),p?(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:N,max:M,stops:O,bands:B}=this._computeStops();this._min=N,this._max=M,O.forEach(e=>{const t=b.createElementNS(C,"stop");t.setAttribute("offset",`${(100*e.percent).toFixed(2)}%`),t.setAttribute("stop-color",e.color),H.appendChild(t)}),I.appendChild(H),k.appendChild(I);const V=b.createElementNS(C,"rect");if(V.setAttribute("x",String(L)),V.setAttribute("y",String(E)),V.setAttribute("width",String(p?S:v)),V.setAttribute("height",String(p?v:S)),V.setAttribute("rx","2"),V.setAttribute("fill",`url(#${F})`),k.appendChild(V),g.showLabels){const e=(null==(i=g.labelStyle)?void 0:i.colors)||(Array.isArray(c.config.legend.labels.colors)?c.config.legend.labels.colors[0]:c.config.legend.labels.colors)||c.config.chart.foreColor,t=(null==(n=g.labelStyle)?void 0:n.fontSize)||"11px",s=(null==(r=g.labelStyle)?void 0:r.fontFamily)||c.config.chart.fontFamily,l=this._getFormatter(),a=(i,n,r,l)=>{const a=b.createElementNS(C,"text");return a.setAttribute("x",String(n)),a.setAttribute("y",String(r)),a.setAttribute("text-anchor",l),a.setAttribute("dominant-baseline","middle"),a.setAttribute("fill",e),a.setAttribute("font-size",t),s&&a.setAttribute("font-family",s),a.textContent=String(i),a};if(p){const e=L+S/2;k.appendChild(a(l(N),e,E+v+10,"middle")),k.appendChild(a(l(M),e,E-10,"middle"))}else{const e=E+S/2;k.appendChild(a(l(N),L-6,e,"end")),k.appendChild(a(l(M),L+v+6,e,"start"))}}const $=(null==(l=g.arrow)?void 0:l.color)||c.config.chart.foreColor,D=this._buildArrow(u,$,h);if(k.appendChild(D),this.arrowEl=D,this._bandHitEls=[],c.config.legend.onItemHover.highlightDataSeries&&B.length>0&&B.forEach(e=>{const t=b.createElementNS(C,"rect");if(p){const s=E+v-e.p2*v,i=E+v-e.p1*v;t.setAttribute("x",String(L)),t.setAttribute("y",String(s)),t.setAttribute("width",String(S)),t.setAttribute("height",String(Math.max(0,i-s)))}else t.setAttribute("x",String(L+e.p1*v)),t.setAttribute("y",String(E)),t.setAttribute("width",String(Math.max(0,(e.p2-e.p1)*v))),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",k.appendChild(t),this._bandHitEls.push(t)}),this._geom={isVertical:p,position:h,stripX:L,stripY:E,stripLength:v,stripThickness:S,arrowSize:u,svgWidth:w,svgHeight:A},g.showHoverValue){const e=b.createElement("div");e.classList.add("apexcharts-heatmap-gradient-legend-value"),e.style.position="absolute",e.style.fontSize=(null==(a=g.labelStyle)?void 0:a.fontSize)||"11px",e.style.fontFamily=(null==(o=g.labelStyle)?void 0:o.fontFamily)||c.config.chart.fontFamily||"",e.style.color=c.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}d.classList.add("apexcharts-heatmap-gradient-legend-wrap"),d.classList.add("apx-legend-position-"+h),d.appendChild(k),this.hoverValueEl&&d.appendChild(this.hoverValueEl),this.svgEl=k,e?(d.style.width=w+"px",d.style.height=A+"px",d.style.position="relative",d.style.overflow="visible"):this._applyWrapAlignment(d,h,p,w,A),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 r=this.w,l=this._cfg().align||"center",a=12,o=r.globals.svgWidth||r.config.chart.width||600,c=r.globals.svgHeight||r.config.chart.height||300,d=r.config.legend.offsetX||0,g=r.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 r;r="start"===l?a:"end"===l?a+Math.max(0,s):a+Math.max(0,s)/2,e.style.top=r+g+"px",e.style.left="left"===t?a+d+"px":o-i-a+d+"px"}else{const s=o-i-24;let r;r="start"===l?a:"end"===l?a+Math.max(0,s):a+Math.max(0,s)/2,e.style.left=r+d+"px",e.style.top="top"===t?a+g+"px":c-n-a+g+"px"}}repositionToPlot(){var e,t;if(!m.isBrowser())return;if(this._targetEl)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:r,position:l,svgWidth:a,svgHeight:o,stripX:c,stripY:d,stripThickness:g}=this._geom,h=this._cfg().align||"center",p=s.config.legend.offsetX||0,u=s.config.legend.offsetY||0,f=null==(t=null==(e=this.ctx)?void 0:e.dimensions)?void 0:t.dimHelpers,x=f?f.getTitleSubtitleCoords("title").height+f.getTitleSubtitleCoords("subtitle").height:0,y=s.layout.xAxisHeight||0,v=(e,t)=>{const s=Math.max(0,e-t);return"start"===h?0:"end"===h?s:s/2};if(r){n.style.top=i.translateY+v(i.gridHeight,o)+u+"px";const e=(("left"===l?0:i.translateX+i.gridWidth)+("left"===l?i.translateX:i.svgWidth))/2;n.style.left=e-c-g/2+p+"px"}else{n.style.left=i.translateX+v(i.gridWidth,a)+p+"px";const e=(("top"===l?x:i.translateY+i.gridHeight+y)+("top"===l?i.translateY:i.svgHeight))/2;n.style.top=e-d-g/2+u+"px"}b.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(),r=i.getBoundingClientRect();if(!(n.width&&n.height&&r.width&&r.height))return;const{isVertical:l,position:a}=this._geom;if(l){const e="left"===a?r.left-n.right:n.left-r.right;if(e<16){const s=parseFloat(t.style.left)||0,i=16-e;t.style.left=s+("left"===a?-i:i)+"px"}}else{const e="top"===a?r.top-n.bottom:n.top-r.bottom;if(e<16){const s=parseFloat(t.style.top)||0,i=16-e;t.style.top=s+("top"===a?-i:i)+"px"}}}destroy(){var e,t,s,i,n,r,l;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==(l=(r=this.ctx.events).removeEventListener)||l.call(r,"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 r=this.w,l=e.currentTarget,a=parseInt(null!=(t=l.getAttribute("data:range-index"))?t:"-1",10);a<0||a===this._activeBandIndex||(this._activeBandIndex=a,null==(n=null==(i=null==(s=this.ctx)?void 0:s.events)?void 0:i.fireEvent)||n.call(i,"legendHover",[this.ctx,a,r]),new u(r).highlightRangeInSeries(a,"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,i;const n=this.w;if(!this.arrowEl)return;const r=e[e.length-1];if(!r||"object"!=typeof r)return;const l=r.seriesIndex,a=r.dataPointIndex;if("number"!=typeof l||"number"!=typeof a)return;if(!E.supports(n))return;let o;o=this._continuous?function(e,t,s){const i=e.config.series[t];return _(e,i&&Array.isArray(i.data)?i.data[s]:null,t,s)}(n,l,a):null==(i=null==(s=null==(t=n.seriesData)?void 0:t.series)?void 0:s[l])?void 0:i[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:r,stripThickness:l,arrowSize:a}=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+r-d*r;let t,o;"left"===s?(t=i+l,o=t+a):(t=i,o=t-a);const c=[`${t},${e}`,`${o},${e-a/2}`,`${o},${e+a/2}`].join(" ");this.arrowEl.setAttribute("points",c)}else{const e=i+d*r;let t,o;"top"===s?(t=n+l,o=t+a):(t=n,o=t-a);const c=[`${e},${t}`,`${e-a/2},${o}`,`${e+a/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+r-d*r;"left"===s?this.hoverValueEl.style.left=`${i+l+a+8}px`:(this.hoverValueEl.style.left=i-a-8+"px",this.hoverValueEl.style.transform="translateX(-100%)"),this.hoverValueEl.style.top=e-9+"px"}else{const e=i+d*r;this.hoverValueEl.style.left=`${e}px`,this.hoverValueEl.style.transform="translateX(-50%)",this.hoverValueEl.style.top="top"===s?`${n+l+a+8}px`:n-a-18+"px"}this.hoverValueEl.style.opacity="1"}}_buildArrow(e,t,s){const i=b.createElementNS(C,"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=E.colorScaleOf(s)||{},n=this._cfg(),r=L(s);if(r)return this._continuous=!0,{min:r.min,max:r.max,stops:r.legendStops,bands:[]};this._continuous=!1;let l=1/0,c=-1/0;const d=(null==(e=s.seriesData)?void 0:e.series)||[];for(let e=0;e<d.length;e++){const t=d[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>c&&(c=s))}}Number.isFinite(l)||(l=0),Number.isFinite(c)||(c=0);let g=l,h=c;void 0!==i.min&&void 0!==i.max&&i.max>i.min?(g=i.min,h=i.max):(void 0!==i.min&&(g=i.min<l?i.min:l),void 0!==i.max&&(h=i.max>c?i.max:c));const p=[],u=[];if(i.ranges&&i.ranges.length>0){const e=i.ranges.map((e,t)=>o(a({},e),{_originalIndex:t})).sort((e,t)=>e.from-t.from),t=e[0].from,s=e[e.length-1].to;g=t,h=s;const n=s-t||1;e.forEach(e=>{const s=(e.from-t)/n,i=(e.to-t)/n;p.push({percent:(s+i)/2,color:e.color}),u.push({index:e._originalIndex,p1:s,p2:i})})}else{const e=s.globals.colors[0]||"#008FFB",i=new f,r=s.config.plotOptions[s.config.chart.type]||{},l=null!=(t=r.shadeIntensity)?t:.5,a=s.globals.hasNegs,o=Math.max(2,n.stops||16);for(let t=0;t<o;t++){const n=t/(o-1),c=g+n*(h-g),d=Math.abs(h)+Math.abs(g),u=0===d?0:100*c/d;let f;f=a?r.reverseNegativeShade?u<0?u/100*(1.25*l):1.25*l*(1-u/100):u<=0?1-(1+u/100)*l:(1-u/100)*l:1-u/100,f>1&&(f=1),f<-1&&(f=-1);const m=r.enableShades?i.shadeColor("dark"===s.config.theme.mode?-1*f:f,e):e;p.push({percent:n,color:m})}}return{min:g,max:h,stops:p,bands:u}}}const k=d.__apex_Markers;d.default.registerFeatures({legend:class{constructor(e,t){this.w=e,this.ctx=t,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 x(this)}init(){const e=this.w,t=e.globals,s=e.config;this.isBarsDistributed="bar"===s.chart.type&&s.plotOptions.bar.distributed&&1===s.series.length;const i=s.legend.showForSingleSeries&&1===this.w.seriesData.series.length||this.isBarsDistributed||"heatmap"===s.chart.type||E.isEnabled(e)||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),E.isEnabled(e)?(this.heatmapGradientLegend=new E(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=b.createElement("span");i.classList.add("apexcharts-legend-marker");const n=s.config.legend.markers.shape||s.config.markers.shape;let r=n;Array.isArray(n)&&(r=n[e]);const l=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*(l+g)+"px",h.width=2*(l+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 k(this.ctx.w,this.ctx).getMarkerConfig({cssClass:`apexcharts-legend-marker apexcharts-marker apexcharts-marker-${r}`,seriesIndex:e,strokeWidth:g,size:l}),c=(m.isBrowser()?window.SVG:global.SVG)().addTo(i).size("100%","100%"),d=new p(this.w).drawMarker(0,0,o(a({},n),{pointFillColor:Array.isArray(t)?t[e]:n.pointFillColor,shape:r}));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 r=s.seriesData.seriesNames,l=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;r=e.map(e=>e.name?e.name:e.from+" - "+e.to),l=e.map(e=>e.color)}else this.isBarsDistributed&&(r=s.labelData.labels.slice());s.config.legend.customLegendItems.length&&(r=s.config.legend.customLegendItems);const a=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]=b.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?r.length-1:0;o?t>=0:t<=r.length-1;o?t--:t++){const o=a(r[t],{seriesIndex:t,w:s});let d=!1,h=!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&&(h=!0);const u=this.createLegendMarker({i:t,fillcolor:l});p.setAttrs(u,{rel:t+1,"data:collapsed":d||h}),(d||h)&&u.classList.add("apexcharts-inactive-legend");const m=b.createElement("div");if(s.config.chart.accessibility.enabled&&s.config.chart.accessibility.keyboard.enabled){m.setAttribute("role","button"),m.setAttribute("tabindex","0");const e=Array.isArray(o)?o.join(" "):o,t=d||h,s=t?"hidden":"visible";m.setAttribute("aria-label",`${e}, ${s}. Press Enter or Space to toggle.`),m.setAttribute("aria-pressed",t?"true":"false")}const x=b.createElement("span");x.classList.add("apexcharts-legend-text"),x.innerHTML=Array.isArray(o)?o.join(" "):o;let y=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;y||(y=s.config.chart.foreColor),x.style.color=y,x.style.fontSize=s.config.legend.fontSize,x.style.fontWeight=s.config.legend.fontWeight,x.style.fontFamily=n||s.config.chart.fontFamily,p.setAttrs(x,{rel:t+1,i:t,"data:default-text":encodeURIComponent(o),"data:collapsed":d||h}),m.appendChild(u),m.appendChild(x);const v=new g(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)&&m.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)&&m.classList.add("apexcharts-hidden-null-series"),c.length?s.labelData.seriesGroups.forEach((e,n)=>{var r,l;e.includes(null!=(l=null==(r=s.config.series[t])?void 0:r.name)?l:"")&&(i.appendChild(c[n]),c[n].appendChild(m))}):i.appendChild(m),i.classList.add(`apexcharts-align-${s.config.legend.horizontalAlign}`),i.classList.add("apx-legend-position-"+s.config.legend.position),m.classList.add("apexcharts-legend-series"),m.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":"",p.setAttrs(m,{rel:t+1,seriesName:f.escapeString(r[t]),"data:collapsed":d||h}),(d||h)&&m.classList.add("apexcharts-inactive-legend"),s.config.legend.onItemClick.toggleDataSeries||m.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 r=0,l=0;if("bottom"===s.config.legend.position)l=s.globals.svgHeight-Math.min(n,s.globals.svgHeight/2)-5;else if("top"===s.config.legend.position){const e=new h(this.w,this.ctx),t=e.dimHelpers.getTitleSubtitleCoords("title").height,s=e.dimHelpers.getTitleSubtitleCoords("subtitle").height;l=(t>0?t-10:0)+(s>0?s-10:0)}i.style.position="absolute",r=r+e+s.config.legend.offsetX,l=l+t+s.config.legend.offsetY,i.style.left=r+"px",i.style.top=l+"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 h(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"),r=this.w.config.chart.events.legendClick;"function"==typeof r&&r(this.ctx,e,this.w),this.ctx.events.fireEvent("legendClick",[this.ctx,e,this.w]);const l=this.w.config.legend.markers.onClick;"function"==typeof l&&i.classList.contains("apexcharts-legend-marker")&&(l(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)}}}}),Object.defineProperty(exports,"default",{enumerable:!0,get:()=>d.default});