apexcharts
Version:
A JavaScript Chart Library
6 lines (5 loc) • 31.2 kB
JavaScript
/*!
* ApexCharts v7.0.0
* (c) 2018-2026 ApexCharts
*/
"use strict";var t=Object.defineProperty,e=Object.defineProperties,r=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,i=(e,r,o)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o,s=(t,e)=>{for(var r in e||(e={}))n.call(e,r)&&i(t,r,e[r]);if(o)for(var r of o(e))a.call(e,r)&&i(t,r,e[r]);return t},l=(t,o)=>e(t,r(o));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function c(t){if(t&&t.__esModule)return t;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t)for(const r in t)if("default"!==r){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}return e.default=t,Object.freeze(e)}const h=c(require("apexcharts/core"));function d(t,e){let r=0;for(let e=0;e<t.length;e++)r+=t[e];const o=e/r,n=new Array(t.length);for(let e=0;e<t.length;e++)n[e]=t[e]*o;return n}function u(t,e,r,o){const n=o*o,a=r*r;return Math.max(n*e/a,a/(n*t))}function f(t,e,r,o,n,a){if(0===t)return!0;return u(e,r,o,a)>=u(Math.min(e,n),Math.max(r,n),o+n,a)}function p(t,e,r,o,n,a,i,s){if(i>=s){const i=o/s;let l=a;for(let o=0;o<r;o++){const r=e[o]/i;t.push([n,l,n+i,l+r]),l+=r}}else{const s=o/i;let l=n;for(let o=0;o<r;o++){const r=e[o]/s;t.push([l,a,l+r,a+s]),l+=r}}}function g(t,e,r,o,n){const a=[],i=t.length;if(0===i)return a;const s=new Array(i);let l=0,c=0,h=1/0,d=-1/0,u=0;for(;u<i;){const i=Math.min(o,n),g=t[u];if(f(l,h,d,c,g,i))s[l]=g,l++,c+=g,g<h&&(h=g),g>d&&(d=g),u++;else{if(p(a,s,l,c,e,r,o,n),o>=n){const t=c/n;e+=t,o-=t}else{const t=c/o;r+=t,n-=t}l=0,c=0,h=1/0,d=-1/0}}return l>0&&p(a,s,l,c,e,r,o,n),a}function m(t){const e=t.children;if(e&&e.length){let r=0;for(let t=0;t<e.length;t++)r+=m(e[t]);return t._area=r,r}const r=Number(t.value),o=isNaN(r)?0:Math.abs(r);return t._area=o,o}function b(t,e,r,o,n,a,i,s){const l=t.length;if(0===l||o<=0||n<=0)return;const c=new Array(l);let h=0;for(let e=0;e<l;e++)c[e]=t[e]._area,h+=c[e];if(h<=0)return;const u=g(d(c,o*n),e,r,o,n);for(let e=0;e<l;e++){const r=t[e],o=u[e];if(!o)continue;r.rect=o,r.depth=a;const n=r.children;if(!n||!n.length)continue;const l=o[2]-o[0],c=o[3]-o[1];let h=Math.max(0,i(r,a,l,c)||0);(2*h>=l||2*h>=c)&&(h=0);let d=Math.max(0,s(r,a,l,c)||0);d>0&&c-2*h-d<d&&(d=0),r.headerHeight=d,b(n,o[0]+h,o[1]+d+h,l-2*h,c-d-2*h,a+1,i,s)}}const y={generate:function(t,e,r){const o=t.length,n=new Array(o);for(let e=0;e<o;e++){let r=0;const o=t[e];for(let t=0;t<o.length;t++)r+=o[t];n[e]=r}const a=g(d(n,e*r),0,0,e,r),i=new Array(o);for(let e=0;e<o;e++){const r=a[e],o=r[0],n=r[1],s=r[2]-o,l=r[3]-n;i[e]=g(d(t[e],s*l),o,n,s,l)}return i},generateNested:function(t,e,r,o={}){if(!Array.isArray(t)||0===t.length)return t||[];const n=o.padding||(()=>0),a=o.header||(()=>0);for(let e=0;e<t.length;e++)m(t[e]);return b(t,0,0,e,r,0,n,a),t}},x=h.__apex_Graphics,_=h.__apex_Animations,v=h.__apex_Fill,w=h.__apex_Utils,S=h.__apex_DataLabels,C=(t,e,r,o)=>{if("function"!=typeof t)return t;const n=t({series:e.seriesData.series,seriesIndex:r,dataPointIndex:o,w:e});return Number.isFinite(n)?n:0};class A{constructor(t,e){this.ctx=e,this.w=t}checkColorRange(){const t=this.w;let e=!1;const r=t.config.plotOptions[t.config.chart.type];return r.colorScale.ranges.length>0&&r.colorScale.ranges.map(t=>{t.from<=0&&(e=!0)}),e}getShadeColor(t,e,r,o){const n=this.w;let a=1;const i=n.config.plotOptions[t].shadeIntensity,s=this.determineColor(t,e,r);n.globals.hasNegs||o?a=n.config.plotOptions[t].reverseNegativeShade?s.percent<0?s.percent/100*(1.25*i):(1-s.percent/100)*(1.25*i):s.percent<=0?1-(1+s.percent/100)*i:(1-s.percent/100)*i:(a=1-s.percent/100,"treemap"===t&&(a=(1-s.percent/100)*(1.25*i)));let l=s.color;const c=new w;if(n.config.plotOptions[t].enableShades)if("dark"===this.w.config.theme.mode){const t=c.shadeColor(-1*a,s.color);l=w.hexToRgba(w.isColorHex(t)?t:w.rgb2hex(t),n.config.fill.opacity)}else{const t=c.shadeColor(a,s.color);l=w.hexToRgba(w.isColorHex(t)?t:w.rgb2hex(t),n.config.fill.opacity)}return{color:l,colorProps:s}}determineColor(t,e,r){const o=this.w,n=o.seriesData.series[e][r],a=o.config.plotOptions[t];let i=a.colorScale.inverse?r:e;a.distributed&&"treemap"===o.config.chart.type&&(i=r);let s,l,c=o.globals.colors[i],h=null;if(a.distributed||"heatmap"!==t){const t=o.seriesData.series[e];s=t.length?t[0]:0,l=s;for(let e=1;e<t.length;e++)t[e]<s&&(s=t[e]),t[e]>l&&(l=t[e])}else s=o.globals.minY,l=o.globals.maxY;const d=a.colorScale.min,u=a.colorScale.max;void 0!==d&&void 0!==u&&u>d?(s=d,l=u):void 0!==d&&(s=d<o.globals.minY?d:o.globals.minY,l=u>o.globals.maxY?u:o.globals.maxY);const f=Math.abs(l)+Math.abs(s),p=Math.min(Math.max(n,s),l);let g=0===f?0:100*p/f;if(a.colorScale.ranges.length>0){a.colorScale.ranges.map(t=>{if(n>=t.from&&n<=t.to){c=t.color,h=t.foreColor?t.foreColor:null,s=t.from,l=t.to;const e=Math.abs(l)+Math.abs(s);g=0===e?0:100*n/e}})}return{color:c,foreColor:h,percent:g}}calculateDataLabels({text:t,x:e,y:r,i:o,j:n,colorProps:a,fontSize:i}){const s=this.w,l=s.config.dataLabels,c=new x(this.w),h=new S(this.w,this.ctx);let d=null;if(l.enabled){d=c.group({class:"apexcharts-data-labels"});const u=C(l.offsetX,s,o,n),f=C(l.offsetY,s,o,n),p=e+u,g=r+parseFloat(l.style.fontSize)/3+f;h.plotDataLabelsText({x:p,y:g,text:t,i:o,j:n,color:a.foreColor,parent:d,fontSize:i,dataLabelsConfig:l})}return d}}const M=h.__apex_Filters,L=h.__apex_Environment_Environment;function P(t,e,r,o,n,a=null,i={}){var s,l,c;const h=e&&"object"==typeof e,d=h&&null!=(l=null!=(s=e.x)?s:e.name)?l:"",u=Number(h?null!=(c=e.y)?c:e.value:e),f={name:String(d),value:isNaN(u)?null:u,color:h&&e.color?e.color:void 0,_key:`${n}/${r}:${d}`};if(o&&!f.color&&(f.color=o[r%o.length]),i.keepDatum&&(f._datum=e),h&&Array.isArray(e.children)&&e.children.length)f.children=e.children.map((e,r)=>P(t,e,r,null,f._key,a,i));else if(h&&null!=e.drilldown&&!1!==i.expandDrilldown){const r=a||new Set;if(!r.has(e.drilldown)){const o=function(t,e){const r=t.config.drilldown;return(r&&Array.isArray(r.series)?r.series:[]).find(t=>t&&t.id===e)}(t,e.drilldown);if(o&&Array.isArray(o.data)&&o.data.length){const n=new Set(r);n.add(e.drilldown);const a=Array.isArray(o.colors)?o.colors:null;f.children=o.data.map((e,r)=>P(t,e,r,a,f._key,n,i))}}}return f}function N(t){t.children&&t.children.length&&(t.children.forEach(t=>N(t)),(null==t.value||isNaN(t.value))&&(t.value=t.children.reduce((t,e)=>t+Math.max(0,e.value||0),0))),(null==t.value||isNaN(t.value))&&(t.value=0)}function k(t){if("string"!=typeof t)return"";const e=t.indexOf("/");return-1===e?"":t.slice(e)}function E(t){const e=t.globals.treemapRoots;if(e&&e.length)return{roots:e,maxDepth:t.globals.treemapMaxDepth||1,nested:!0};const r=function(t,e,r={}){const o=e||t.config.series;return Array.isArray(o)?o.map((e,o)=>{var n,a;const i=e&&Array.isArray(e.data)?e.data:[],s=`${o}:${null!=(n=null==e?void 0:e.name)?n:""}`;return{name:String(null!=(a=null==e?void 0:e.name)?a:""),value:null,color:(null==e?void 0:e.color)||void 0,_key:s,_seriesIndex:o,children:i.map((e,o)=>P(t,e,o,null,s,null,r))}}):[]}(t,t.config.series,{keepDatum:!0,expandDrilldown:!1});r.forEach(N);const{maxDepth:o}=function(t){const e=[];let r=0;return t.forEach((t,o)=>{const n=[],a=(t,e,i)=>{t._parent=i,t._depth=e,t._si=o,t._leaf=!(t.children&&t.children.length),e>r&&(r=e),t._leaf?(t._di=n.length,n.push(t)):(t._di=-1,t.children.forEach(r=>a(r,e+1,t)))};a(t,0,null),e.push(n)}),{leaves:e,maxDepth:r}}(r);return{roots:r,maxDepth:o,nested:!1}}const F=["#cf4d3f","#8f9499","#26a75b"],O=(t,e,r)=>t+(e-t)*r;function T(t){return Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0")}function $(t,e,r){const o=w.parseHex(z(t)),n=w.parseHex(z(e));return o&&n?"#"+T(O(o[0],n[0],r))+T(O(o[1],n[1],r))+T(O(o[2],n[2],r)):t}function z(t){if("string"!=typeof t)return"#000000";if(w.isColorHex(t))return t;return w.rgb2hex(t)||"#000000"}function W(t,e,r,o){var n,a,i;if(!e||"object"!=typeof e)return null;const s=null==(i=null==(a=null==(n=t.config.plotOptions)?void 0:n.treemap)?void 0:a.colorScale)?void 0:i.colorValue;let l;if(l="function"==typeof s?s(e,{seriesIndex:r,dataPointIndex:o,w:t}):"string"==typeof s?e[s]:e.colorValue,null==l)return null;const c=Number(l);return Number.isFinite(c)?c:null}function R(t){var e,r,o;const n=null==(o=null==(r=null==(e=t.config)?void 0:e.plotOptions)?void 0:r.treemap)?void 0:o.colorScale,a=n&&n.gradient;if(!a)return null;if(!1===a.enabled)return null;const i=t.config.series||[];let s=1/0,l=-1/0,c=!1;for(let e=0;e<i.length;e++){const r=i[e]&&i[e].data;if(Array.isArray(r))for(let o=0;o<r.length;o++){const n=W(t,r[o],e,o);null!=n&&(c=!0,n<s&&(s=n),n>l&&(l=n))}}if(!c&&!0!==a.enabled)return null;Number.isFinite(s)||(s=0,l=0);let h=Number.isFinite(Number(a.min))?Number(a.min):s,d=Number.isFinite(Number(a.max))?Number(a.max):l,u=null;if(null===a.midpoint?u=null:Number.isFinite(Number(a.midpoint))?u=Number(a.midpoint):h<0&&d>0&&(u=0),null!=u&&!1!==a.symmetric&&!Number.isFinite(Number(a.min))&&!Number.isFinite(Number(a.max))){const t=Math.max(Math.abs(h-u),Math.abs(d-u));h=u-t,d=u+t}d===h&&(h-=.5,d+=.5);const f=function(t,e,r,o){if(Array.isArray(t.stops)&&t.stops.length>=2)return t.stops.filter(t=>t&&Number.isFinite(Number(t.value))).map(t=>({value:Number(t.value),color:z(t.color)})).sort((t,e)=>t.value-e.value);const n=(Array.isArray(t.colors)&&t.colors.length>=2?t.colors:F).map(z),a=n.length;if(null!=o&&a>=3){const t=Math.floor((a-1)/2),i=[];for(let r=0;r<=t;r++)i.push({value:O(e,o,r/t),color:n[r]});for(let e=t+1;e<a;e++)i.push({value:O(o,r,(e-t)/(a-1-t)),color:n[e]});return i}return n.map((t,o)=>({value:O(e,r,o/(a-1)),color:t}))}(a,h,d,u);if(f.length<2)return null;const p=d-h,g=f.map(t=>({percent:0===p?0:(t.value-h)/p,color:t.color}));return{min:h,max:d,midpoint:u,stops:f,at:t=>{if(!Number.isFinite(t))return f[Math.floor(f.length/2)].color;if(t<=f[0].value)return f[0].color;const e=f[f.length-1];if(t>=e.value)return e.color;for(let e=1;e<f.length;e++){const r=f[e];if(t<=r.value){const o=f[e-1],n=r.value-o.value,a=0===n?0:(t-o.value)/n;return $(o.color,r.color,a)}}return e.color},legendStops:g}}function B(t){const e=z(t);return w.getContrastRatio(e,"#ffffff")>=w.getContrastRatio(e,"#000000")?"#ffffff":"#000000"}const I=h.__apex_BrowserAPIs_BrowserAPIs,D="http://www.w3.org/1999/xhtml";function j(t,e){const r=t.config.drilldown&&t.config.drilldown.breadcrumb||{};return s(s({show:!0,position:"top-left",separator:" / ",rootLabel:"All",offsetX:0,offsetY:0,formatter:void 0},r),e||{})}function Y(t){const e=t.dom.elWrap;if(!e)return;const r=e.querySelector(".apexcharts-breadcrumb");r&&r.parentNode&&r.parentNode.removeChild(r)}h.default.use({treemap:class{constructor(t,e){this.ctx=e,this.w=t,this.strokeWidth=this.w.config.stroke.width,this.helpers=new A(t,e),this.dynamicAnim=this.w.config.chart.animations.dynamicAnimation,this.labels=[],this.roots=[],this.drawn=[],this.nested=!1,this.showParents=!1,this.scale=null,this._levelCache=null,this._total=null,this._avgLabelSize=null,this._tooltipEl=null,this._tipOwned=!1,this._morphLeafIndex=0}draw(t){var e;const r=this.w,o=new x(this.w,this.ctx),n=new v(this.w),a=o.group({class:"apexcharts-treemap"});if(r.globals.noData)return a;t.forEach(t=>{t.map(t=>Math.abs(t))}),this.negRange=this.helpers.checkColorRange(),r.config.series.forEach((t,e)=>{t.data.forEach(t=>{Array.isArray(this.labels[e])||(this.labels[e]=[]),this.labels[e].push(t.x)})});const i=E(r);this.nested=i.nested,this.roots=i.roots,this.scale=R(r);const s=1===i.roots.length?i.roots[0].children||[]:i.roots;this.drawn=s;const l=r.config.plotOptions.treemap.parents;this.showParents=!0===l.show||!1!==l.show&&this.nested;const c=this._resolveFocus(s),h=c?[c]:s;y.generateNested(h,r.layout.gridWidth,r.layout.gridHeight,{padding:(t,e,r,o)=>this.showParents?this._levelPadding(e,r,o):0,header:(t,e,r,o)=>this.showParents?this._levelHeader(t,e,r,o):0});const d=null==(e=this.ctx)?void 0:e.morphTypeChange,u=!!d&&"function"==typeof d.isActive&&d.isActive()&&"function"==typeof d.getInitialPathAt;this._morphLeafIndex=0;const f=this._leavesBySeries(h,r.config.series.length),p=this.showParents?this._parentsBySeries(h,r.config.series.length):[];return f.forEach((e,i)=>{var s;const l=o.group({class:"apexcharts-series apexcharts-treemap-series",seriesName:w.escapeString(r.seriesData.seriesNames[i]),rel:i+1,"data:realIndex":i});if(o.setupEventDelegation(l,".apexcharts-treemap-rect"),r.config.chart.dropShadow.enabled){const t=r.config.chart.dropShadow;new M(this.w).dropShadow(a,t,i)}const c=o.group({class:"apexcharts-data-labels"}),h={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0};this.showParents&&(p[i]||[]).forEach(t=>{this._drawParent(l,t,i)});const d=r.config.chart.animations,f=d.animateGradually,g=f&&!1!==f.enabled,m=new Array(e.length).fill(0);if(g){const t=e.length||1,r=Math.min(f.delay||0,.5*d.speed/t);e.map((t,e)=>{return{j:e,area:t.rect?(r=t.rect,(r[2]-r[0])*(r[3]-r[1])):0};var r}).sort((t,e)=>e.area-t.area).forEach((t,e)=>{m[t.j]=e*r})}e.forEach((e,a)=>{const s=e.rect;if(!s)return;const c=e._di,d=s[0],f=s[1],p=s[2],g=s[3];h.xMin=Math.min(h.xMin,d),h.yMin=Math.min(h.yMin,f),h.xMax=Math.max(h.xMax,p),h.yMax=Math.max(h.yMax,g);const b=this._leafColor(i,c),y=b.color,x=n.fillPath({color:y,seriesNumber:i,dataPointIndex:c}),_=u?this._morphSourceForLeaf(e):null,v=_?o.drawPath({d:this._tilePath(d,f,p,g),fill:"#fff",stroke:r.config.plotOptions.treemap.useFillColorAsStroke?y:r.globals.stroke.colors[i],strokeWidth:this.strokeWidth,fillOpacity:1}):o.drawRect(d,f,p-d,g-f,r.config.plotOptions.treemap.borderRadius,"#fff",1,this.strokeWidth,r.config.plotOptions.treemap.useFillColorAsStroke?y:r.globals.stroke.colors[i]);v.attr({cx:d,cy:f,index:i,i:i,j:c,width:p-d,height:g-f,fill:x}),v.node.classList.add("apexcharts-treemap-rect"),v.node.setAttribute("data:key",k(e._key));let w={x:d+(p-d)/2,y:f+(g-f)/2,width:0,height:0};const S={x:d,y:f,width:p-d,height:g-f};if(_)this._morphTile(v,_,this._tilePath(d,f,p,g),this.ctx.morphTypeChange.getSpeed(),i,c);else if(r.config.chart.animations.enabled&&!r.globals.dataChanged){let t=1;r.globals.resized||(t=r.config.chart.animations.speed),this.animateTreemap(v,w,S,t,m[a]||0)}if(r.globals.dataChanged){let t=1;this.dynamicAnim.enabled&&r.globals.shouldAnimate&&(t=this.dynamicAnim.speed,r.globals.previousPaths[i]&&r.globals.previousPaths[i][c]&&r.globals.previousPaths[i][c].rect&&(w=r.globals.previousPaths[i][c].rect),this.animateTreemap(v,w,S,t))}let C=this.getFontSize(s);"truncate"===r.config.plotOptions.treemap.dataLabels.format&&(C=parseInt(String(r.config.dataLabels.style.fontSize),10));let A=null;if(r.config.dataLabels.enabled&&this._labelCanShow(C,p-d,g-f)){let e=r.config.dataLabels.formatter(this.labels[i][c],{value:r.seriesData.series[i][c],seriesIndex:i,dataPointIndex:c,w:r});"truncate"===r.config.plotOptions.treemap.dataLabels.format&&(e=this.truncateLabels(String(e),C,d,f,p,g)),r.seriesData.series[i][c]&&(A=this.helpers.calculateDataLabels({text:e,x:(d+p)/2,y:(f+g)/2+this.strokeWidth/2+C/3,i:i,j:c,colorProps:b,fontSize:C,series:t})),r.config.dataLabels.enabled&&A&&this.rotateToFitLabel(A,C,e,d,f,p,g)}l.add(v),null!==A&&l.add(A)});const b=r.config.plotOptions.treemap.seriesTitle;if(!this.showParents&&r.config.series.length>1&&b&&b.show){const t=r.config.series[i].name||"";if(t&&h.xMin<1/0&&h.yMin<1/0){const{offsetX:e,offsetY:n,borderColor:a,borderWidth:i,borderRadius:c,style:d}=b,u=d.color||r.config.chart.foreColor,f={left:d.padding.left,right:d.padding.right,top:d.padding.top,bottom:d.padding.bottom},p=o.getTextRects(t,d.fontSize,d.fontFamily),g=p.width+f.left+f.right,m=p.height+f.top+f.bottom,y=h.xMin+(e||0),x=h.yMin+(n||0),_=o.drawRect(y,x,g,m,c,d.background,1,i,a),v=o.drawText({x:y+f.left,y:x+f.top+.75*(null!=(s=null==p?void 0:p.height)?s:0),text:t,fontSize:d.fontSize,fontFamily:d.fontFamily,fontWeight:d.fontWeight,foreColor:u,cssClass:d.cssClass||""});l.add(_),l.add(v)}}l.add(c),a.add(l)}),this._renderBreadcrumb(),a}_levelCfg(t){if(this._levelCache||(this._levelCache=[]),this._levelCache[t])return this._levelCache[t];const e=this.w.config.plotOptions.treemap,r=e.parents||{},o=(e.levels||[])[t]||{},n=l(s(s({},r),o),{header:l(s(s({},r.header||{}),o.header||{}),{style:s(s({},(r.header||{}).style||{}),(o.header||{}).style||{})}),hover:s(s({},r.hover||{}),o.hover||{})});return this._levelCache[t]=n,n}_levelPadding(t,e,r){const o=this._levelCfg(t);return Number(o.padding)||0}_levelHeader(t,e,r,o){const n=this._levelCfg(e).header||{};if(!1===n.show)return 0;const a=Number(n.height);if(!Number.isFinite(a)||a<=0)return 0;return r<(Number(n.minWidth)||40)||o<2*a?0:a}_leavesBySeries(t,e){const r=new Array(Math.max(1,e));for(let t=0;t<r.length;t++)r[t]=[];const o=t=>{if(t.children&&t.children.length)t.children.forEach(o);else{const e=t._si||0;r[e]&&r[e].push(t)}};return t.forEach(o),r}_parentsBySeries(t,e){const r=new Array(Math.max(1,e));for(let t=0;t<r.length;t++)r[t]=[];const o=t=>{if(!t.children||!t.children.length)return;const e=t._si||0;r[e]&&r[e].push(t),t.children.forEach(o)};return t.forEach(o),r.forEach(t=>t.sort((t,e)=>(t.depth||0)-(e.depth||0))),r}_leafColor(t,e){const r=this.w;if(this.scale){const o=function(t,e,r){const o=t.config.series[e];return W(t,o&&Array.isArray(o.data)?o.data[r]:null,e,r)}(r,t,e);if(null!=o){const t=this.scale.at(o);return{color:t,foreColor:B(t),colorProps:{color:t,foreColor:B(t),percent:0}}}}return this.helpers.getShadeColor(r.config.chart.type,t,e,this.negRange)}_parentChrome(t){const e=this.w,r=this._levelCfg(t),o="dark"===e.config.theme.mode,n=(r.header||{}).style||{},a=Math.min(t,3),i=o?255:0,s=`${i},${i},${i}`;return{fill:r.fill||`rgba(${s},${(o?.04:.03)+.02*a})`,fillOpacity:null==r.fillOpacity?1:r.fillOpacity,borderColor:r.borderColor||`rgba(${s},${o?.18:.14})`,borderWidth:null==r.borderWidth?1:r.borderWidth,borderRadius:null==r.borderRadius?e.config.plotOptions.treemap.borderRadius:r.borderRadius,headerBg:n.background||`rgba(${s},${o?.1:.07})`,headerColor:n.color||(o?"#e8e8e8":e.config.chart.foreColor),headerFontSize:n.fontSize||"12px",headerFontFamily:n.fontFamily||e.config.chart.fontFamily,headerFontWeight:null==n.fontWeight?600:n.fontWeight,hoverColor:r.hover&&r.hover.color||(o?"rgba(255,255,255,0.85)":"rgba(0,0,0,0.7)"),hoverWidth:r.hover&&r.hover.width||2,hoverShow:!(r.hover&&!1===r.hover.show)}}_drawParent(t,e,r){var o;const n=e.rect;if(!n)return;const a=this.w,i=new x(this.w,this.ctx),s=e.depth||0,l=this._levelCfg(s),c=this._parentChrome(s),h=n[0],d=n[1],u=n[2]-n[0],f=n[3]-n[1];if(u<=0||f<=0)return;const p=i.group({class:"apexcharts-treemap-parent","data:depth":s,"data:name":w.escapeString(e.name)}),g=k(e._key),m=this._morphKeyed()?this.ctx.morphTypeChange.getInitialPathForKey(g):null,b=m?i.drawPath({d:this._tilePath(h,d,h+u,d+f),fill:c.fill,stroke:c.borderColor,strokeWidth:c.borderWidth,fillOpacity:c.fillOpacity}):i.drawRect(h,d,u,f,c.borderRadius,c.fill,c.fillOpacity,c.borderWidth,c.borderColor);b.node.classList.add("apexcharts-treemap-parent-rect"),b.node.setAttribute("data:key",g),b.node.setAttribute("data:depth",String(s)),m&&this._morphTile(b,m,this._tilePath(h,d,h+u,d+f),this.ctx.morphTypeChange.getSpeed(),r,s),p.add(b);const y=e.headerHeight||0;let _="";if(y>0){const t=l.header||{},n=i.drawRect(h,d,u,y,0,c.headerBg,1,0,"transparent");n.node.classList.add("apexcharts-treemap-parent-header"),p.add(n);let f=String(null!=(o=e.name)?o:"");"function"==typeof t.formatter?f=String(t.formatter(e.name,{value:e.value,depth:s,seriesIndex:r,node:e,w:a})):t.showValue&&(f=`${f} ${this._formatValue(e.value)}`),_=f;const g=Number(t.offsetX)||0,m=t.align||"left",x=6,v=Math.max(0,u-2*x-Math.abs(g)),w=parseFloat(String(c.headerFontSize))||12,S=i.getTextBasedOnMaxWidth({text:f,maxWidth:v,fontSize:w});if(S){let e=h+x+g,r="start";"center"===m?(e=h+u/2+g,r="middle"):"right"===m&&(e=h+u-x+g,r="end");const o=i.drawText({x:e,y:d+y/2+w/3+(Number(t.offsetY)||0),text:S,textAnchor:r,fontSize:c.headerFontSize,fontFamily:c.headerFontFamily,fontWeight:c.headerFontWeight,foreColor:c.headerColor,cssClass:`apexcharts-treemap-parent-label ${t.style&&t.style.cssClass||""}`});o.node.setAttribute("pointer-events","none"),p.add(o)}this._attachParentEvents(n.node,e,c,b),this._makeParentAccessible(n.node,e,c,b,_)}this._attachParentEvents(b.node,e,c,b),p.node.setAttribute("role","group"),p.node.setAttribute("aria-label",this._parentLabel(e,_)),t.add(p)}_parentLabel(t,e){const r=this._drawnTotal(),o=r>0?(t._area/r*100).toFixed(1):"0",n=this._countLeaves(t);return`${e&&String(e).trim()?String(e).replace(/\s+/g," ").trim():`${t.name}, ${this._formatValue(t._area)}`}, ${n} ${1===n?"item":"items"}, ${o}% of total`}_makeParentAccessible(t,e,r,o,n){t&&t.setAttribute&&this._zoomEnabled()&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.setAttribute("aria-label",`${this._parentLabel(e,n)}. Zoom in`),t.setAttribute("aria-expanded","false"),L.isBrowser()&&t.addEventListener&&(t.addEventListener("focus",()=>{o.node.setAttribute("stroke",r.hoverColor),o.node.setAttribute("stroke-width",String(r.hoverWidth+1))}),t.addEventListener("blur",()=>{o.node.setAttribute("stroke",r.borderColor),o.node.setAttribute("stroke-width",String(r.borderWidth))}),t.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key&&"Spacebar"!==t.key||(t.preventDefault(),this._zoomTo(e,!0))})))}_attachParentEvents(t,e,r,o){if(!L.isBrowser()||!t||!t.addEventListener)return;const n=this.w;r.hoverShow&&(t.addEventListener("mouseenter",()=>{o.node.setAttribute("stroke",r.hoverColor),o.node.setAttribute("stroke-width",String(r.hoverWidth))}),t.addEventListener("mouseleave",()=>{o.node.setAttribute("stroke",r.borderColor),o.node.setAttribute("stroke-width",String(r.borderWidth))})),n.config.tooltip.enabled&&(t.addEventListener("mouseenter",t=>this._showParentTooltip(t,e)),t.addEventListener("mousemove",t=>this._positionTooltip(t)),t.addEventListener("mouseleave",()=>this._hideParentTooltip())),this._zoomEnabled()&&(t.style.cursor="pointer",t.addEventListener("click",()=>this._zoomTo(e)))}_zoomEnabled(){const t=this.w,e=t.config.plotOptions.treemap.zoom;if(!e||!e.enabled||!this.showParents)return!1;const r=t.config.drilldown;return!(r&&r.enabled&&Array.isArray(r.series)&&r.series.length)||(this._warnedZoomConflict||(this._warnedZoomConflict=!0),!1)}_resolveFocus(t){const e=this.w.globals.treemapFocusKey;if(!e||!this._zoomEnabled())return null;let r=null;const o=t=>{r||(t._key!==e?t.children&&t.children.forEach(o):r=t)};return t.forEach(o),r&&r.children&&r.children.length?r:null}_zoomTo(t,e=!1){const r=this.w;if(!t||!t.children||!t.children.length)return;const o=r.globals.treemapFocusKey===t._key?null:t._key;r.globals.treemapFocusKey=o,this._hideParentTooltip();const n=this.ctx.update();e&&n&&"function"==typeof n.then&&n.then(()=>{if(!L.isBrowser())return;const t=r.dom.baseEl.querySelector(".apexcharts-breadcrumb .apexcharts-breadcrumb-item");if(t&&t.focus)return void t.focus();const e=r.dom.baseEl.querySelector(".apexcharts-treemap-parent-header[tabindex]");e&&e.focus&&e.focus()})}_focusChain(){const t=[],e=new Set(this.drawn||[]);let r=this._resolveFocus(this.drawn||[]);for(;r&&(t.unshift(r),!e.has(r));)r=r._parent;return t}_breadcrumbCfg(){const t=this.w.config.plotOptions.treemap.zoom;return j(this.w,t&&t.breadcrumb)}_renderBreadcrumb(){if(!L.isBrowser())return;const t=this.w;if(!t.dom.elWrap)return;if(Y(t),!this._zoomEnabled())return;const e=this._focusChain();if(!e.length)return;const r=function(t,e){if(!L.isBrowser())return null;const r=t.dom.elWrap;if(!r)return null;Y(t);const o=e.config||j(t);if(!1===o.show)return null;const n=e.crumbs||[];if(n.length<2)return null;const a=I.createElementNS(D,"nav");a.setAttribute("class","apexcharts-breadcrumb"),a.setAttribute("aria-label",e.ariaLabel||"Breadcrumb"),function(t,e){const r=e.offsetX||0,o=e.offsetY||0;t.style.position="absolute",t.style.top=o+"px","top-right"===e.position?t.style.right=3-r+"px":t.style.left=r+"px"}(a,o),e.compact&&(a.style.fontSize="11px",a.style.padding="0 2px");const i=null!=o.separator?o.separator:" / ";return n.forEach((t,r)=>{var s;if(r>0){const t=I.createElementNS(D,"span");t.setAttribute("class","apexcharts-breadcrumb-separator"),t.setAttribute("aria-hidden","true"),t.textContent=i,a.appendChild(t)}let l=0===r?null!=(s=o.rootLabel)?s:"All":t.label;if("function"==typeof o.formatter&&(l=o.formatter(l,{index:r,depth:n.length-1,data:t.data})),r===n.length-1){const t=I.createElementNS(D,"span");return t.setAttribute("class","apexcharts-breadcrumb-item apexcharts-breadcrumb-current"),t.setAttribute("aria-current","page"),t.textContent=String(l),void a.appendChild(t)}const c=I.createElementNS(D,"button");if(c.setAttribute("type","button"),c.setAttribute("class","apexcharts-breadcrumb-item"),0===r){const t=I.createElementNS(D,"span");t.setAttribute("class","apexcharts-breadcrumb-arrow"),t.setAttribute("aria-hidden","true"),t.textContent="\u2190",c.appendChild(t)}const h=I.createElementNS(D,"span");h.setAttribute("class","apexcharts-breadcrumb-label"),h.textContent=String(l),c.appendChild(h),c.addEventListener("click",()=>e.onNavigate(r,t)),a.appendChild(c)}),r.appendChild(a),a}(t,{ariaLabel:"Treemap breadcrumb",config:this._breadcrumbCfg(),compact:!0,crumbs:[{label:"All",data:null}].concat(e.map(t=>({label:t.name,data:t}))),onNavigate:(e,r)=>{t.globals.treemapFocusKey=r.data?r.data._key:null,this._hideParentTooltip(),this.ctx.update()}});r&&(this._placeBreadcrumb(r),function(t,e){const r=[".apexcharts-title-text",".apexcharts-subtitle-text"].map(e=>t.dom.baseEl.querySelector(e)).filter(t=>null!==t);if(!r.length)return;const o=t.dom.elWrap.getBoundingClientRect().top;for(let t=0;t<r.length+1;t++){const t=e.getBoundingClientRect(),n=r.find(e=>{const r=e.getBoundingClientRect();return t.left<r.right&&t.right>r.left&&t.top<r.bottom&&t.bottom>r.top});if(!n)break;e.style.top=n.getBoundingClientRect().bottom-o+4+"px"}}(t,r))}_placeBreadcrumb(t){var e,r;const o=this.w,n=o.layout.translateY||0,a=null==(r=null==(e=this.ctx)?void 0:e.dimensions)?void 0:r.dimHelpers,i=a?a.getTitleSubtitleCoords("title").height+a.getTitleSubtitleCoords("subtitle").height:0,s=t.getBoundingClientRect().height||18;if(n-i>=s+1)return void(t.style.top=n-s-1+"px");t.style.top=`${i}px`;const l="dark"===o.config.theme.mode;t.style.background=l?"rgba(20,24,30,0.82)":"rgba(255,255,255,0.86)",t.style.borderRadius="4px"}_showParentTooltip(t,e){const r=this.w,o=this._tip();if(!o)return;const n=this._drawnTotal(),a=e._parent?e._parent._area:n,i=n>0?(e._area/n*100).toFixed(1):"0.0",s=a>0?(e._area/a*100).toFixed(1):i,l=this.w.config.plotOptions.treemap.parents,c=l&&l.tooltip&&l.tooltip.formatter,h=this._countLeaves(e);let d;if("function"==typeof c)d=c({name:e.name,value:e._area,depth:e.depth||0,leafCount:h,percentOfParent:Number(s),percentOfTotal:Number(i),node:e,w:r});else{const t=this._parentChrome(e.depth||0).headerBg;d=`<div class="apexcharts-tooltip-series-group apexcharts-active" style="display:flex;${r.config.tooltip.fillSeriesColor?`background-color:${t};`:""}"><div class="apexcharts-tooltip-text"><div class="apexcharts-tooltip-y-group"><span class="apexcharts-tooltip-text-y-label">${w.escapeString(e.name)}: </span><span class="apexcharts-tooltip-text-y-value">${this._formatValue(e._area)}</span></div><div class="apexcharts-tooltip-y-group"><span class="apexcharts-tooltip-text-y-label">${h} items, </span><span class="apexcharts-tooltip-text-y-value">${s}% of parent, ${i}% of total</span></div></div></div>`}o.innerHTML=d,o.classList.add("apexcharts-active"),o.style.opacity="1",this._tipOwned=!0,this._positionTooltip(t)}_tip(){return this._tooltipEl||(this._tooltipEl=this.w.dom.baseEl.querySelector(".apexcharts-tooltip")),this._tooltipEl}_positionTooltip(t){const e=this._tip();if(!e||!this._tipOwned)return;const r=this.w.dom.elWrap.getBoundingClientRect(),o=e.offsetWidth,n=e.offsetHeight;let a=t.clientX-r.left+12;a+o>r.width&&(a=t.clientX-r.left-o-12),a=Math.max(0,Math.min(a,r.width-o));let i=t.clientY-r.top+12;i+n>r.height&&(i=t.clientY-r.top-n-12),i=Math.max(0,Math.min(i,r.height-n)),e.style.left=a+"px",e.style.top=i+"px"}_hideParentTooltip(){const t=this._tip();t&&this._tipOwned&&(this._tipOwned=!1,t.classList.remove("apexcharts-active"),t.style.opacity="0")}_drawnTotal(){return null==this._total&&(this._total=(this.drawn||[]).reduce((t,e)=>t+this._subtreeArea(e),0)),this._total||0}_subtreeArea(t){if(null!=t._area)return t._area;const e=t.children;if(e&&e.length){let t=0;for(let r=0;r<e.length;r++)t+=this._subtreeArea(e[r]);return t}const r=Number(t.value);return isNaN(r)?0:Math.abs(r)}_countLeaves(t){return t.children&&t.children.length?t.children.reduce((t,e)=>t+this._countLeaves(e),0):1}_formatValue(t){var e,r,o,n,a;const i=this.w,s=(null==(r=null==(e=i.config.tooltip)?void 0:e.y)?void 0:r.formatter)||(null==(a=null==(n=null==(o=i.config.yaxis)?void 0:o[0])?void 0:n.labels)?void 0:a.formatter);if("function"==typeof s)try{return String(s(t,{seriesIndex:0,dataPointIndex:0,w:i}))}catch(t){}return String(t)}_labelCanShow(t,e,r){if(!Number.isFinite(t)||t<=0)return!1;const o=this.w.config.plotOptions.treemap.dataLabels;return!(t<(o&&null!=o.minFontSize?Number(o.minFontSize):0))&&Math.max(e,r)>=t}_averageLabelSize(){if(null!=this._avgLabelSize)return this._avgLabelSize;return this._avgLabelSize=function t(e){let r,o=0;if(Array.isArray(e[0]))for(r=0;r<e.length;r++)o+=t(e[r]);else for(r=0;r<e.length;r++)o+=e[r].length;return o}(this.labels)/function t(e){let r,o=0;if(Array.isArray(e[0]))for(r=0;r<e.length;r++)o+=t(e[r]);else for(r=0;r<e.length;r++)o+=1;return o}(this.labels),this._avgLabelSize}getFontSize(t){const e=this.w,r=this._averageLabelSize();return function(t,o){const n=t*o,a=Math.pow(n,.5);return Math.min(a/r,parseInt(e.config.dataLabels.style.fontSize,10))}(t[2]-t[0],t[3]-t[1])}rotateToFitLabel(t,e,r,o,n,a,i){const s=new x(this.w),l=s.getTextRects(r,String(e));if(l.width+this.w.config.stroke.width+5>a-o&&l.width<=i-n){const e=s.rotateAroundCenter(t.node);t.node.setAttribute("transform",`rotate(-90 ${e.x} ${e.y}) translate(${l.height/3})`)}}truncateLabels(t,e,r,o,n,a){const i=new x(this.w),s=i.getTextRects(t,String(e)).width+this.w.config.stroke.width+5>n-r&&a-o>n-r?a-o:n-r,l=i.getTextBasedOnMaxWidth({text:t,maxWidth:s,fontSize:e});return t.length!==l.length&&s/e<5?"":l}_morphKeyed(){var t;const e=null==(t=this.ctx)?void 0:t.morphTypeChange;return!(!e||"function"!=typeof e.hasKeyedMarks||!e.hasKeyedMarks()||"function"!=typeof e.getInitialPathForKey)}_morphSourceForLeaf(t){var e;const r=null==(e=this.ctx)?void 0:e.morphTypeChange;if(!r||"function"!=typeof r.getInitialPathAt)return null;if(this._morphKeyed()){const e=r.getInitialPathForKey(k(t._key));if(e)return e}return r.getInitialPathAt(this._morphLeafIndex++)}_tilePath(t,e,r,o){return`M ${t} ${e} L ${r} ${e} L ${r} ${o} L ${t} ${o} Z`}_morphTile(t,e,r,o,n,a){new _(this.w,this.ctx).morphSVG(t,n,a,"none",e,r,o,0)}animateTreemap(t,e,r,o,n=0){const a=new _(this.w);a.animateRect(t,e,r,o,()=>{a.animationCompleted(t)},n)}}}),Object.defineProperty(exports,"default",{enumerable:!0,get:()=>h.default});