@malinconico/nmcharts 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(t){"use strict";var e=t.NMCharts;if(!e)throw new Error("NMCharts-Categories: NMCharts must be loaded first.");var i=window.devicePixelRatio||1,s=600,o=400,a={top:50,right:24,bottom:60,left:60},r='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',l=["#6366f1","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#14b8a6"];function n(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}function d(t){return{bg:n(t,"--mc-bg")||"#f5f7fa",card:n(t,"--mc-card")||"#fff",text:n(t,"--mc-text")||"#1e293b",text2:n(t,"--mc-text2")||"#475569",muted:n(t,"--mc-muted")||"#94a3b8",grid:n(t,"--mc-grid")||"#e2e8f0",border:n(t,"--mc-border")||"#e2e8f0",hover:n(t,"--mc-hover")||"rgba(0,0,0,.04)",ttBg:n(t,"--mc-tt-bg")||"#1e293b",ttFg:n(t,"--mc-tt-fg")||"#fff",btn:n(t,"--mc-btn")||"#6366f1",btnH:n(t,"--mc-btn-h")||"#4f46e5"}}function c(t,e,i){return Math.max(e,Math.min(i,t))}function _(t){if(t<=0)return 10;var e=Math.pow(10,Math.floor(Math.log10(t))),i=t/e;return i<=1?e:i<=2?2*e:i<=5?5*e:10*e}function p(t,e){var i=t/e,s=Math.pow(10,Math.floor(Math.log10(i))),o=i/s;return o<=1?s:o<=2?2*s:o<=5?5*s:10*s}function v(t){return Math.abs(t)>=1e6?(t/1e6).toFixed(1)+"M":Math.abs(t)>=1e3?(t/1e3).toFixed(1)+"k":t%1==0?String(t):t.toFixed(1)}function g(t){return 1-Math.pow(1-t,3)}function f(t){var e=1.70158;return 1+2.70158*Math.pow(t-1,3)+e*Math.pow(t-1,2)}function u(t,e,i){var s=document.createElement(t);return e&&(s.className=e),i&&i.appendChild(s),s}function b(t){var e=t.replace("#","");return 3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),[parseInt(e.substr(0,2),16),parseInt(e.substr(2,2),16),parseInt(e.substr(4,2),16)]}function m(t,e){var i=b(t);return"rgb("+Math.round(i[0]+(255-i[0])*e)+","+Math.round(i[1]+(255-i[1])*e)+","+Math.round(i[2]+(255-i[2])*e)+")"}function x(t,e,i){return null!=t[e]?t[e]:i}var y='<svg viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 1 1 11.21 3a7 7 0 0 0 9.79 9.79z"/></svg>',M='<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>';function S(t,e,i){if(this.type=i,this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts-Categories: container not found");this.opts=e||{},this.categories=e.categories||[];var r=this.opts;this._height=x(r,"height",o),this._opacity=x(r,"opacity",x(r,"fillOpacity",.85)),this._hoverOpacity=x(r,"hoverOpacity",1),this._borderRadius=x(r,"borderRadius",4),this._showValues=x(r,"showValues",!0),this._valueSize=x(r,"valueSize",10),this._valueColor=x(r,"valueColor",null),this._gridLines=x(r,"gridLines",!0),this._gridColor=x(r,"gridColor",null),this._gridDashed=x(r,"gridDashed",!1),this._animDuration=x(r,"animDuration",s),this._toolbar=Object.assign({dark:!0,export:!0},r.toolbar||{}),this._padding=Object.assign({},a,r.padding||{}),this._legendPosition=x(r,"legendPosition","bottom"),this._legendHidden=x(r,"legendHidden",!1),this._userColors=r.colors||null,this._gradient=x(r,"gradient",!0),this._gradientOpacity=r.gradientOpacity||[.9,.4],this._tooltipEnabled=x(r,"tooltip",!0),this._responsive=x(r,"responsive",!0),this._barWidth=x(r,"barWidth",null),this._barGap=x(r,"barGap",4),this._groupPadding=x(r,"groupPadding",.25),this._stacked=x(r,"stacked",!1),this._borderWidth=x(r,"borderWidth",0),this._borderColor=x(r,"borderColor","transparent"),this._stackLabels=x(r,"stackLabels",!0),this._showTotal=x(r,"showTotal",!1),this.series=(e.series||[]).map(function(t,e){var i=r.colors||l;return{name:t.name||"Series "+(e+1),data:t.data||[],color:t.color||i[e%i.length],type:t.type||null,visible:!0}}),this._hoverCat=-1,this._hoverSeries=-1,this._animProgress=0,this._animStart=0,this._rafId=0,this._buildDOM(),this._initSize(),this._startAnimation(),this._bindEvents()}function C(t,e){S.call(this,t,e,"column")}function w(t,e){S.call(this,t,e,"bar")}function k(t,e){S.call(this,t,e,"barStacked")}function T(t,e){S.call(this,t,e,"lollipop")}function P(t,e){S.call(this,t,e,"combo")}function A(t,e){if(this.type="donut",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts-Categories: container not found");this.opts=e||{},this._innerRadius=x(e,"innerRadius",.6),this._padAngle=x(e,"padAngle",.02),this._cornerRadius=x(e,"cornerRadius",0),this._centerLabel=x(e,"centerLabel",null),this._centerSubLabel=x(e,"centerSubLabel",null),this._hoverScale=x(e,"hoverScale",1.06),this._strokeWidth=x(e,"strokeWidth",2),this._strokeColor=x(e,"strokeColor","auto"),this._height=x(e,"height",o),this._opacity=x(e,"opacity",x(e,"fillOpacity",.88)),this._hoverOpacity=x(e,"hoverOpacity",1),this._animDuration=x(e,"animDuration",s),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._legendPosition=x(e,"legendPosition","bottom"),this._legendHidden=x(e,"legendHidden",!1),this._tooltipEnabled=x(e,"tooltip",!0),this._responsive=x(e,"responsive",!0),this._gradient=x(e,"gradient",!1),this._gradientOpacity=e.gradientOpacity||[.9,.4],this.segments=(e.segments||[]).map(function(t,i){var s=e.colors||l;return{label:t.label||"Segment "+(i+1),value:t.value||0,color:t.color||s[i%s.length],visible:!0}}),this._hoverIndex=-1,this._selectedIndex=-1,this._animProgress=0,this._animStart=0,this._rafId=0,this._buildDonutDOM(),this._initSize(),this._startAnimation(),this._bindDonutEvents()}function E(t,e){if(this.type="gauge",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts-Categories: container not found");this.opts=e||{},this.value=e.value||0,this.min=null!=e.min?e.min:0,this.max=null!=e.max?e.max:100,this.zones=e.zones||[{from:0,to:40,color:"#10b981"},{from:40,to:70,color:"#f59e0b"},{from:70,to:100,color:"#ef4444"}],this._needleColor=x(e,"needleColor",null),this._needleWidth=x(e,"needleWidth",2.5),this._arcWidth=x(e,"arcWidth",.22),this._showTicks=x(e,"showTicks",!0),this._unit=x(e,"unit",e.unit||""),this._height=x(e,"height",o),this._animDuration=x(e,"animDuration",s),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._responsive=x(e,"responsive",!0),this._animProgress=0,this._animStart=0,this._rafId=0,this._buildGaugeDOM(),this._initSize(),this._startAnimation(),this._bindGaugeEvents()}function L(t,e){if(this.type="heatmap",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts-Categories: container not found");this.opts=e||{},this.xLabels=e.xLabels||e.xCategories||[],this.yLabels=e.yLabels||e.yCategories||[],this.data=e.data||[];var i=e.colorRange;i&&i.min&&i.max?this.colorRange=[i.min,i.max]:this.colorRange=(Array.isArray(i)?i:null)||["#dbeafe","#1e40af"],this._cellRadius=x(e,"cellRadius",3),this._cellGap=x(e,"cellGap",2),this._showCellValues=x(e,"showCellValues",!0),this._cellFontSize=x(e,"cellFontSize",11),this._height=x(e,"height",o),this._animDuration=x(e,"animDuration",s),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._tooltipEnabled=x(e,"tooltip",!0),this._responsive=x(e,"responsive",!0),this._padding=Object.assign({},a,e.padding||{}),this._hoverCell=null,this._animProgress=0,this._animStart=0,this._rafId=0,this._buildHeatmapDOM(),this._initSize(),this._computeMinMax(),this._startAnimation(),this._bindHeatmapEvents()}function B(t,e){if(this.type="radar",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts-Categories: container not found");if(this.opts=e||{},this.categories=e.categories||[],this._levels=x(e,"levels",5),this._fillOpacity=x(e,"fillOpacity",.2),this._lineWidth=x(e,"lineWidth",2),this._dotRadius=x(e,"dotRadius",4),this._showValues=x(e,"showValues",!1),this._gridStyle=x(e,"gridStyle","polygon"),this._axisLabels=x(e,"axisLabels",!0),this._max=x(e,"max",null),this._height=x(e,"height",o),this._animDuration=x(e,"animDuration",s),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._legendPosition=x(e,"legendPosition","bottom"),this._legendHidden=x(e,"legendHidden",!1),this._tooltipEnabled=x(e,"tooltip",!0),this._responsive=x(e,"responsive",!0),this.series=(e.series||[]).map(function(t,i){var s=e.colors||l;return{name:t.name||"Series "+(i+1),data:t.data||[],color:t.color||s[i%s.length],visible:!0}}),null==this._max){var i=0;this.series.forEach(function(t){t.data.forEach(function(t){t>i&&(i=t)})}),this._max=_(1.1*i)}this._hoverAxis=-1,this._animProgress=0,this._animStart=0,this._rafId=0,this._buildRadarDOM(),this._initSize(),this._startAnimation(),this._bindRadarEvents()}function H(t,e){this._barWidth=x(e,"barWidth",32),this._barOpacity=x(e,"barOpacity",.7),this._lineWidth=x(e,"lineWidth",2.5),this._lineTension=x(e,"lineTension",.4),this._dualAxis=x(e,"dualAxis",!1),S.call(this,t,e,"lineBar")}function W(t,e){this._showTotal=x(e,"showTotal",!0),this._showConnectors=x(e,"showConnectors",!0),this._positiveColor=x(e,"positiveColor","#10b981"),this._negativeColor=x(e,"negativeColor","#ef4444"),this._totalColor=x(e,"totalColor","#6366f1"),S.call(this,t,e,"waterfall")}function R(t,e){this._items=e.items||[],this._rangeColors=x(e,"rangeColors",["#94a3b8","#cbd5e1","#e2e8f0"]),this._markerColor=x(e,"markerColor","#1e293b"),this._barColor=x(e,"barColor","#1e293b"),this._barHeightRatio=x(e,"barHeight",.4),e.categories=this._items.map(function(t){return t.label}),e.series=[{name:"Actual",data:this._items.map(function(t){return t.actual}),color:"#1e293b"}],S.call(this,t,e,"bullet")}function D(t,e){this._segments=e.segments||[],this._barHeight=x(e,"height",60),this._showPercent=x(e,"showPercent",!0),this._showSegValues=x(e,"showValues",!0),this._rounded=x(e,"rounded",!0),this._segGap=x(e,"gap",2),e.height=Math.max(this._barHeight+120,180),e.series=[{name:"Timeline",data:this._segments.map(function(t){return t.value}),color:"#6366f1"}],e.categories=this._segments.map(function(t){return t.label}),e.legendHidden=!0,S.call(this,t,e,"timeline")}!function(){if(!document.getElementById("mc-cat-enhanced-styles")){var t=document.createElement("style");t.id="mc-cat-enhanced-styles",t.textContent=[".mc-root { box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.03); border-radius: 12px; overflow: hidden; }",".mc-tooltip { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 10px; overflow: hidden; }",'.mc-tooltip::before { content: ""; display: block; height: 3px; background: var(--mc-tt-accent, #6366f1); }',".mc-legend-swatch { width: 10px !important; height: 10px !important; border-radius: 50% !important; transition: transform .15s ease; }",".mc-legend-item:hover .mc-legend-swatch { transform: scale(1.25); }",".mc-legend-item { transition: opacity .15s ease; }"].join("\n"),document.head.appendChild(t)}}(),S.prototype._buildDOM=function(){this._root=u("div","mc-root",this.el);var t=u("div","mc-header",this._root),e=u("div","mc-titles",t);this.opts.title&&(u("div","mc-title",e).textContent=this.opts.title);this.opts.subtitle&&(u("div","mc-subtitle",e).textContent=this.opts.subtitle);var i=u("div","mc-toolbar",t),s=this;if(this._toolbar.dark&&(this._darkBtn=u("button","",i),this._darkBtn.innerHTML=y,this._darkBtn.title="Toggle dark mode",this._darkBtn.addEventListener("click",function(){s.el.classList.toggle("mc-dark"),s._darkBtn.classList.toggle("active",s.el.classList.contains("mc-dark")),s.render()})),this._toolbar.export){var o=u("button","",i);o.innerHTML=M,o.title="Export PNG",o.addEventListener("click",function(){s.exportPNG()})}"top"!==this._legendPosition||this._legendHidden||(this._legendEl=u("div","mc-legend",this._root),this._buildLegend()),this._wrap=u("div","mc-wrap",this._root),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this._wrap.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this._tooltipEl=u("div","mc-tooltip",this._wrap),this.series.length>0&&this._tooltipEl.style.setProperty("--mc-tt-accent",this.series[0].color),"bottom"!==this._legendPosition||this._legendHidden||(this._legendEl=u("div","mc-legend",this._root),this._buildLegend()),this._legendEl||(this._legendEl=u("div","mc-legend",null),this._legendEl.style.display="none")},S.prototype._buildLegend=function(){this._legendEl.innerHTML="";var t=this;this.series.forEach(function(e,i){var s=u("div","mc-legend-item",t._legendEl);e.visible||s.classList.add("disabled"),u("div","mc-legend-swatch",s).style.background=e.color,u("span","",s).textContent=e.name,s.addEventListener("click",function(){e.visible=!e.visible,s.classList.toggle("disabled",!e.visible),t.render()})})},S.prototype._initSize=function(){var t=this._wrap.getBoundingClientRect().width,e=this._height;this.W=t,this.H=e,this.canvas.width=Math.round(t*i),this.canvas.height=Math.round(e*i),this.canvas.style.height=e+"px",this.ctx.setTransform(i,0,0,i,0,0)},S.prototype._startAnimation=function(){var t=this;this._animStart=performance.now(),this._animProgress=0;var e=this._animDuration||s;this._rafId=requestAnimationFrame(function i(s){var o=s-t._animStart;t._animProgress=c(o/e,0,1),t.render(),t._animProgress<1&&(t._rafId=requestAnimationFrame(i))})},S.prototype._bindEvents=function(){var t,e=this;this._responsive&&window.addEventListener("resize",function(){clearTimeout(t),t=setTimeout(function(){e._initSize(),e.render()},80)});this.canvas.addEventListener("mousemove",function(t){var i=e.canvas.getBoundingClientRect(),s=t.clientX-i.left,o=t.clientY-i.top;e._onHover(s,o)}),this.canvas.addEventListener("mouseleave",function(){e._hoverCat=-1,e._hoverSeries=-1,e._hideTooltip(),e.render()})},S.prototype._showTooltip=function(t,e,i,s){if(this._tooltipEnabled){s.length>0&&this._tooltipEl.style.setProperty("--mc-tt-accent",s[0].color);var o='<div class="mc-tooltip-date">'+i+"</div>";s.forEach(function(t){o+='<div class="mc-tooltip-row"><div class="mc-tooltip-dot" style="background:'+t.color+'"></div><span>'+t.name+'</span><span class="mc-tooltip-val" style="margin-left:8px;font-weight:600">'+v(t.value)+"</span></div>"}),this._tooltipEl.innerHTML=o,this._tooltipEl.classList.add("visible");var a=this._tooltipEl.offsetWidth,r=this._tooltipEl.offsetHeight,l=t+16,h=e-r/2;l+a>this.W-8&&(l=t-a-16),h=c(h,4,this.H-r-4),this._tooltipEl.style.left=l+"px",this._tooltipEl.style.top=h+"px"}},S.prototype._hideTooltip=function(){this._tooltipEl.classList.remove("visible")},S.prototype.exportPNG=function(t){var e=document.createElement("a");e.download=t||"chart.png",e.href=this.canvas.toDataURL("image/png"),e.click()},S.prototype._computeScale=function(){var t=0,e=this;"barStacked"===this.type||"column"===this.type&&this._stacked?this.categories.forEach(function(i,s){var o=0;e.series.forEach(function(t){t.visible&&s<t.data.length&&(o+=Math.max(0,t.data[s]))}),o>t&&(t=o)}):this.series.forEach(function(e){e.visible&&e.data.forEach(function(e){e>t&&(t=e)})}),this._scaleMax=_(1.1*t),this._step=p(this._scaleMax,5),this._ticks=[];for(var i=0;i<=this._scaleMax;i+=this._step)this._ticks.push(i)},S.prototype._clearAndDrawBackground=function(){var t=d(this.el);this._vars=t;var e=this.ctx;e.clearRect(0,0,this.W,this.H),e.fillStyle=t.card,e.fillRect(0,0,this.W,this.H)},S.prototype._drawStripes=function(){var t=this.ctx,e=this._padding,i=e.left,s=e.top,o=this.W-e.left-e.right,a=this.H-e.top-e.bottom;if(!(this._ticks.length<2))for(var r=0;r<this._ticks.length-1;r++)if(r%2!=0){var l=s+a-this._ticks[r]/this._scaleMax*a,h=s+a-this._ticks[r+1]/this._scaleMax*a;t.fillStyle="rgba(0,0,0,0.015)",t.fillRect(i,h,o,l-h)}},S.prototype._drawVerticalAxes=function(){this._drawStripes();var t=this.ctx,e=this._vars,i=this._padding,s=i.left,o=i.top,a=this.W-i.left-i.right,l=this.H-i.top-i.bottom;t.textAlign="right",t.textBaseline="middle",t.font="500 12px "+r;for(var h=0;h<this._ticks.length;h++){var n=this._ticks[h],d=o+l-n/this._scaleMax*l;this._gridLines&&(t.strokeStyle=this._gridColor||"rgba(226,232,240,0.6)",t.lineWidth=1,this._gridDashed?t.setLineDash([4,4]):t.setLineDash([]),t.beginPath(),t.moveTo(s,d),t.lineTo(s+a,d),t.stroke(),t.setLineDash([])),t.fillStyle=e.muted,t.fillText(v(n),s-8,d)}t.textAlign="center",t.textBaseline="top",t.fillStyle=e.text2,t.font="500 12px "+r;for(var c=a/this.categories.length,_=0;_<this.categories.length;_++){var p=s+c*_+c/2;t.fillText(this.categories[_],p,o+l+8)}},S.prototype._drawHorizontalStripes=function(){var t=this.ctx,e=this._padding,i=e.left,s=e.top,o=this.W-e.left-e.right,a=this.H-e.top-e.bottom;if(!(this._ticks.length<2))for(var r=0;r<this._ticks.length-1;r++)if(r%2!=0){var l=i+this._ticks[r]/this._scaleMax*o,h=i+this._ticks[r+1]/this._scaleMax*o;t.fillStyle="rgba(0,0,0,0.015)",t.fillRect(l,s,h-l,a)}},S.prototype._drawHorizontalAxes=function(){this._drawHorizontalStripes();var t=this.ctx,e=this._vars,i=this._padding,s=i.left,o=i.top,a=this.W-i.left-i.right,l=this.H-i.top-i.bottom;t.textAlign="center",t.textBaseline="top",t.font="500 12px "+r;for(var h=0;h<this._ticks.length;h++){var n=this._ticks[h],d=s+n/this._scaleMax*a;this._gridLines&&(t.strokeStyle=this._gridColor||"rgba(226,232,240,0.6)",t.lineWidth=1,this._gridDashed?t.setLineDash([4,4]):t.setLineDash([]),t.beginPath(),t.moveTo(d,o),t.lineTo(d,o+l),t.stroke(),t.setLineDash([])),t.fillStyle=e.muted,t.fillText(v(n),d,o+l+8)}t.textAlign="right",t.textBaseline="middle",t.fillStyle=e.text2,t.font="500 12px "+r;for(var c=l/this.categories.length,_=0;_<this.categories.length;_++){var p=o+c*_+c/2;t.fillText(this.categories[_],s-8,p)}},S.prototype._getBarFill=function(t,e,i,s,o,a){return this._gradient?function(t,e,i,s,o,a,r,l){var h;h=l?t.createLinearGradient(i,s,i,s+a):t.createLinearGradient(i,s,i+o,s);var n=m(e,.25);return h.addColorStop(0,e),h.addColorStop(1,n),h}(this.ctx,t,e,i,s,o,this._gradientOpacity,a):t},S.prototype._drawBarShadow=function(t,e,i,s,o,a,r){t.save(),t.shadowColor=r,t.shadowBlur=8,t.shadowOffsetX=0,t.shadowOffsetY=3,t.fillStyle="rgba(0,0,0,0.01)",t.beginPath(),t.roundRect(e,i,s,o,a),t.fill(),t.restore()},S.prototype._drawBarHighlight=function(t,e,i,s,o,a){t.save(),t.globalAlpha=.25,t.strokeStyle="rgba(255,255,255,0.7)",t.lineWidth=1,t.beginPath(),a?(t.moveTo(e+o,i+1),t.lineTo(e+s-o,i+1)):(t.moveTo(e+s-1,i+o),t.lineTo(e+s-1,i+h-o)),t.stroke(),t.restore()},C.prototype=Object.create(S.prototype),C.prototype.constructor=C,C.prototype.render=function(){this._computeScale(),this._clearAndDrawBackground(),this._drawVerticalAxes();var t=this.ctx,e=this._vars,i=this._animProgress,s=f(c(i,0,1));s=Math.max(0,s);var o=this._padding,a=o.left,l=o.top,h=this.W-o.left-o.right,n=this.H-o.top-o.bottom,d=this.categories.length,_=this.series.filter(function(t){return t.visible}),p=_.length||1,g=this._borderRadius;if(this._stacked){for(var u=(A=h/d)*(1-this._groupPadding),b=(A-(E=this._barWidth||Math.min(u,60)))/2,m=0;m<d;m++){for(var x=0,y=this._hoverCat===m,M=0;M<_.length;M++){var S=_[M],C=(B=m<S.data.length?Math.max(0,S.data[m]):0)/this._scaleMax*n*s,w=a+A*m+b,k=l+n-x-C,T=[0,0,0,0];M===_.length-1&&(T=[g,g,0,0]),this._drawBarShadow(t,w,k,E,C,T,S.color),t.globalAlpha=y?this._hoverOpacity:this._opacity,t.fillStyle=this._getBarFill(S.color,w,k,E,C,!0),t.beginPath(),t.roundRect(w,k,E,C,T),t.fill(),M===_.length-1&&C>4&&this._drawBarHighlight(t,w,k,E,g,!0),this._borderWidth>0&&(t.strokeStyle=this._borderColor,t.lineWidth=this._borderWidth,t.stroke()),i>=1&&this._stackLabels&&this._showValues&&C>20&&(t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textAlign="center",t.textBaseline="middle",t.fillStyle=this._valueColor||"#fff",t.fillText(v(B),w+E/2,k+C/2)),x+=C}if(i>=1&&this._showTotal&&x>0){var P=0;_.forEach(function(t){m<t.data.length&&(P+=Math.max(0,t.data[m]))}),t.globalAlpha=1,t.font="bold "+this._valueSize+"px "+r,t.textAlign="center",t.textBaseline="bottom",t.fillStyle=e.text2,t.fillText(v(P),a+A*m+b+E/2,l+n-x-4)}}t.globalAlpha=1}else{u=(A=h/d)*(1-this._groupPadding);var A,E=this._barWidth||(u-this._barGap*(p-1))/p,L=(A-((E=Math.min(E,60))*p+this._barGap*(p-1)))/2;this._hitAreas=[];for(M=0;M<_.length;M++)for(S=_[M],m=0;m<d;m++){var B,H=(B=m<S.data.length?S.data[m]:0)/this._scaleMax*n*s;w=a+A*m+L+M*(E+this._barGap),k=l+n-H,y=this._hoverCat===m;this._drawBarShadow(t,w,k,E,H,[g,g,0,0],S.color),y&&(t.save(),t.shadowColor=S.color,t.shadowBlur=12,t.fillStyle="rgba(0,0,0,0.01)",t.beginPath(),t.roundRect(w,k,E,H,[g,g,0,0]),t.fill(),t.restore()),t.globalAlpha=y?this._hoverOpacity:this._opacity,t.fillStyle=this._getBarFill(S.color,w,k,E,H,!0),t.beginPath(),t.roundRect(w,k,E,H,[g,g,0,0]),t.fill(),H>4&&this._drawBarHighlight(t,w,k,E,g,!0),this._borderWidth>0&&(t.strokeStyle=this._borderColor,t.lineWidth=this._borderWidth,t.stroke()),this._hitAreas.push({ci:m,si:M,x:w,y:k,w:E,h:H,series:S}),i>=1&&this._showValues&&(t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textAlign="center",t.textBaseline=H>20?"top":"bottom",this._valueColor?t.fillStyle=this._valueColor:t.fillStyle=H>20?"#fff":e.text2,t.fillText(v(B),w+E/2,H>20?k+4:k-4))}t.globalAlpha=1}},C.prototype._onHover=function(t,e){var i=this._hoverCat;this._hoverCat=-1;var s=this._padding,o=s.left,a=this.W-s.left-s.right,r=a/this.categories.length;if(t>=o&&t<=o+a&&e>=s.top&&e<=this.H-s.bottom&&(this._hoverCat=Math.floor((t-o)/r),this._hoverCat=c(this._hoverCat,0,this.categories.length-1)),this._hoverCat!==i){if(this._hoverCat>=0){var l=[],h=this;this.series.forEach(function(t){t.visible&&h._hoverCat<t.data.length&&l.push({name:t.name,value:t.data[h._hoverCat],color:t.color})}),this._showTooltip(t,e,this.categories[this._hoverCat],l)}else this._hideTooltip();this.render()}},w.prototype=Object.create(S.prototype),w.prototype.constructor=w,w.prototype.render=function(){this._computeScale(),this._clearAndDrawBackground(),this._drawHorizontalAxes();var t=this.ctx,e=this._vars,i=this._animProgress,s=f(c(i,0,1));s=Math.max(0,s);for(var o=this._padding,a=o.left,l=o.top,h=this.W-o.left-o.right,n=this.H-o.top-o.bottom,d=this.categories.length,_=this.series.filter(function(t){return t.visible}),p=_.length||1,g=this._borderRadius,u=n/d,b=u*(1-this._groupPadding),m=this._barWidth||(b-this._barGap*(p-1))/p,x=(u-((m=Math.min(m,40))*p+this._barGap*(p-1)))/2,y=0;y<_.length;y++)for(var M=_[y],S=0;S<d;S++){var C=S<M.data.length?M.data[S]:0,w=C/this._scaleMax*h*s,k=l+u*S+x+y*(m+this._barGap),T=a,P=this._hoverCat===S;if(this._drawBarShadow(t,T,k,w,m,[0,g,g,0],M.color),P&&(t.save(),t.shadowColor=M.color,t.shadowBlur=12,t.fillStyle="rgba(0,0,0,0.01)",t.beginPath(),t.roundRect(T,k,w,m,[0,g,g,0]),t.fill(),t.restore()),t.globalAlpha=P?this._hoverOpacity:this._opacity,t.fillStyle=this._getBarFill(M.color,T,k,w,m,!1),t.beginPath(),t.roundRect(T,k,w,m,[0,g,g,0]),t.fill(),w>4&&(t.save(),t.globalAlpha=.25,t.strokeStyle="rgba(255,255,255,0.7)",t.lineWidth=1,t.beginPath(),t.moveTo(T+w-1,k+g),t.lineTo(T+w-1,k+m-g),t.stroke(),t.restore()),this._borderWidth>0&&(t.strokeStyle=this._borderColor,t.lineWidth=this._borderWidth,t.stroke()),i>=1&&this._showValues){t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textBaseline="middle";var A=k+m/2;w>40?(t.textAlign="right",t.fillStyle=this._valueColor||"#fff",t.fillText(v(C),T+w-6,A)):(t.textAlign="left",t.fillStyle=this._valueColor||e.text2,t.fillText(v(C),T+w+6,A))}}t.globalAlpha=1},w.prototype._onHover=function(t,e){var i=this._hoverCat;this._hoverCat=-1;var s=this._padding,o=this.H-s.top-s.bottom,a=o/this.categories.length;if(e>=s.top&&e<=s.top+o&&t>=s.left&&(this._hoverCat=Math.floor((e-s.top)/a),this._hoverCat=c(this._hoverCat,0,this.categories.length-1)),this._hoverCat!==i){if(this._hoverCat>=0){var r=[],l=this;this.series.forEach(function(t){t.visible&&l._hoverCat<t.data.length&&r.push({name:t.name,value:t.data[l._hoverCat],color:t.color})}),this._showTooltip(t,e,this.categories[this._hoverCat],r)}else this._hideTooltip();this.render()}},k.prototype=Object.create(S.prototype),k.prototype.constructor=k,k.prototype.render=function(){this._computeScale(),this._clearAndDrawBackground(),this._drawHorizontalAxes();var t=this.ctx,e=this._vars,i=this._animProgress,s=f(c(i,0,1));s=Math.max(0,s);for(var o=this._padding,a=o.left,l=o.top,h=this.W-o.left-o.right,n=this.H-o.top-o.bottom,d=this.categories.length,_=this._borderRadius,p=n/d,g=p*(1-this._groupPadding),u=(p-(g=Math.min(g,40)))/2,b=this.series.filter(function(t){return t.visible}),m=0;m<d;m++){for(var x=a,y=this._hoverCat===m,M=0;M<b.length;M++){var S=b[M],C=m<S.data.length?Math.max(0,S.data[m]):0,w=C/this._scaleMax*h*s,k=l+p*m+u,T=[0,0,0,0];M===b.length-1&&(T=[0,_,_,0]),0===M&&(T[0]=0,T[3]=0),this._drawBarShadow(t,x,k,w,g,T,S.color),t.globalAlpha=y?this._hoverOpacity:this._opacity,t.fillStyle=this._getBarFill(S.color,x,k,w,g,!1),t.beginPath(),t.roundRect(x,k,w,g,T),t.fill(),this._borderWidth>0&&(t.strokeStyle=this._borderColor,t.lineWidth=this._borderWidth,t.stroke()),i>=1&&this._stackLabels&&this._showValues&&w>30&&(t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textAlign="center",t.textBaseline="middle",t.fillStyle=this._valueColor||"#fff",t.fillText(v(C),x+w/2,k+g/2)),x+=w}if(i>=1&&this._showTotal){var P=0;b.forEach(function(t){m<t.data.length&&(P+=Math.max(0,t.data[m]))}),t.globalAlpha=1,t.font="bold "+this._valueSize+"px "+r,t.textAlign="left",t.textBaseline="middle",t.fillStyle=e.text2,t.fillText(v(P),x+6,l+p*m+u+g/2)}}t.globalAlpha=1},k.prototype._onHover=w.prototype._onHover,T.prototype=Object.create(S.prototype),T.prototype.constructor=T,T.prototype.render=function(){this._computeScale(),this._clearAndDrawBackground(),this._drawVerticalAxes();var t=this.ctx,e=this._vars,i=this._animProgress,s=f(c(i,0,1));s=Math.max(0,s);for(var o=this._padding,a=o.left,l=o.top,h=this.W-o.left-o.right,n=this.H-o.top-o.bottom,d=this.categories.length,_=this.series.filter(function(t){return t.visible}),p=_.length||1,g=h/d,u=Math.min(g/(p+1),28),y=u*(p-1),M=l+n,S=x(this.opts,"dotRadius",6),C=x(this.opts,"stemWidth",2),w=x(this.opts,"stemDashed",!1),k=x(this.opts,"dotBorder",!0),T=x(this.opts,"dotBorderWidth",2),P=0;P<_.length;P++)for(var A=_[P],E=0;E<d;E++){var L=E<A.data.length?A.data[E]:0,B=a+g*E+g/2-y/2+u*P,H=M-L/this._scaleMax*n*s,W=this._hoverCat===E;t.globalAlpha=W?this._hoverOpacity:.8;var R=t.createLinearGradient(B,M,B,H),D=b(A.color);R.addColorStop(0,"rgba("+D[0]+","+D[1]+","+D[2]+",0.3)"),R.addColorStop(1,"rgba("+D[0]+","+D[1]+","+D[2]+",0.8)"),t.strokeStyle=R,t.lineWidth=C,w?t.setLineDash([4,4]):t.setLineDash([]),t.beginPath(),t.moveTo(B,M),t.lineTo(B,H),t.stroke(),t.setLineDash([]),t.save(),t.shadowColor=A.color,t.shadowBlur=6,t.shadowOffsetY=2,t.fillStyle="rgba(0,0,0,0.01)",t.beginPath(),t.arc(B,H,S,0,2*Math.PI),t.fill(),t.restore();var I=t.createRadialGradient(B-.3*S,H-.3*S,0,B,H,S);I.addColorStop(0,m(A.color,.35)),I.addColorStop(1,A.color),t.fillStyle=I,t.beginPath(),t.arc(B,H,S,0,2*Math.PI),t.fill(),k&&(t.strokeStyle=e.card,t.lineWidth=T,t.stroke()),i>=1&&this._showValues&&(t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textAlign="center",t.textBaseline="bottom",t.fillStyle=this._valueColor||e.text2,t.fillText(v(L),B,H-S-3))}t.globalAlpha=1},T.prototype._onHover=C.prototype._onHover,P.prototype=Object.create(S.prototype),P.prototype.constructor=P,P.prototype.render=function(){this._computeScale(),this._clearAndDrawBackground(),this._drawVerticalAxes();var t=this.ctx,e=this._vars,i=this._animProgress,s=f(c(i,0,1));s=Math.max(0,s);var o=this._padding,a=o.left,l=o.top,h=this.W-o.left-o.right,n=this.H-o.top-o.bottom,d=this.categories.length,_=l+n,p=h/d,g=x(this.opts,"lineWidth",2.5),u=x(this.opts,"lineTension",.3),y=x(this.opts,"lineStyle","solid"),M=x(this.opts,"showArea",!1),S=x(this.opts,"areaOpacity",.15),C=[],w=[];this.series.forEach(function(t){t.visible&&("line"===t.type?w.push(t):C.push(t))});for(var k=C.length||1,T=Math.min(p/(k+1),28),P=T*(k-1),A=x(this.opts,"dotRadius",6),E=0;E<C.length;E++)for(var L=C[E],B=0;B<d;B++){var H=(B<L.data.length?L.data[B]:0)/this._scaleMax*n*s,W=a+p*B+p/2-P/2+T*E,R=_-H,D=this._hoverCat===B;t.globalAlpha=D?this._hoverOpacity:.8;var I=t.createLinearGradient(W,_,W,R),O=b(L.color);I.addColorStop(0,"rgba("+O[0]+","+O[1]+","+O[2]+",0.3)"),I.addColorStop(1,"rgba("+O[0]+","+O[1]+","+O[2]+",0.8)"),t.strokeStyle=I,t.lineWidth=2,t.beginPath(),t.moveTo(W,_),t.lineTo(W,R),t.stroke();var G=t.createRadialGradient(W-.3*A,R-.3*A,0,W,R,A);G.addColorStop(0,m(L.color,.35)),G.addColorStop(1,L.color),t.fillStyle=G,t.beginPath(),t.arc(W,R,A,0,2*Math.PI),t.fill()}for(var z=0;z<w.length;z++){var N=w[z];t.globalAlpha=1;for(var V=[],F=0;F<d;F++){var j=F<N.data.length?N.data[F]:0,q=a+p*F+p/2,Y=_-j/this._scaleMax*n*s;V.push({x:q,y:Y})}if("dashed"===y?t.setLineDash([8,4]):"dotted"===y?t.setLineDash([2,4]):t.setLineDash([]),M&&V.length>1){var X=t.createLinearGradient(0,l,0,_),J=b(N.color);if(X.addColorStop(0,"rgba("+J[0]+","+J[1]+","+J[2]+","+1.5*S+")"),X.addColorStop(.7,"rgba("+J[0]+","+J[1]+","+J[2]+","+.3*S+")"),X.addColorStop(1,"rgba("+J[0]+","+J[1]+","+J[2]+",0)"),t.globalAlpha=1,t.fillStyle=X,t.beginPath(),t.moveTo(V[0].x,_),u>0&&V.length>2){t.lineTo(V[0].x,V[0].y);for(var U=0;U<V.length-1;U++){var K=V[U],Q=V[U+1],Z=K.x+(Q.x-K.x)*u,$=Q.x-(Q.x-K.x)*u;t.bezierCurveTo(Z,K.y,$,Q.y,Q.x,Q.y)}}else for(var tt=0;tt<V.length;tt++)t.lineTo(V[tt].x,V[tt].y);t.lineTo(V[V.length-1].x,_),t.closePath(),t.fill(),t.globalAlpha=1}if(t.save(),t.shadowColor=N.color,t.shadowBlur=6,t.shadowOffsetY=2,t.strokeStyle=N.color,t.lineWidth=g,t.lineJoin="round",t.lineCap="round",t.beginPath(),u>0&&V.length>2){t.moveTo(V[0].x,V[0].y);for(var et=0;et<V.length-1;et++){var it=V[et],st=V[et+1],ot=it.x+(st.x-it.x)*u,at=st.x-(st.x-it.x)*u;t.bezierCurveTo(ot,it.y,at,st.y,st.x,st.y)}}else for(var rt=0;rt<V.length;rt++)0===rt?t.moveTo(V[rt].x,V[rt].y):t.lineTo(V[rt].x,V[rt].y);t.stroke(),t.restore(),t.setLineDash([]);for(var lt=0;lt<V.length;lt++)t.fillStyle=N.color,t.beginPath(),t.arc(V[lt].x,V[lt].y,4,0,2*Math.PI),t.fill(),t.fillStyle=e.card,t.beginPath(),t.arc(V[lt].x,V[lt].y,2,0,2*Math.PI),t.fill()}if(i>=1&&this._hoverCat>=0&&this._showValues){var ht=this._hoverCat;t.font=this._valueSize+"px "+r,t.textAlign="center",t.textBaseline="bottom",t.fillStyle=this._valueColor||e.text2,t.globalAlpha=1,this.series.forEach(function(e){if(e.visible&&!(ht>=e.data.length)){var i=e.data[ht],s=a+p*ht+p/2,o=_-i/this._scaleMax*n;t.fillText(v(i),s,o-10)}}.bind(this))}t.globalAlpha=1},P.prototype._onHover=C.prototype._onHover,A.prototype._buildDonutDOM=function(){this._root=u("div","mc-root",this.el);var t=u("div","mc-header",this._root),e=u("div","mc-titles",t);this.opts.title&&(u("div","mc-title",e).textContent=this.opts.title);this.opts.subtitle&&(u("div","mc-subtitle",e).textContent=this.opts.subtitle);var i=u("div","mc-toolbar",t),s=this;if(this._toolbar.dark&&(this._darkBtn=u("button","",i),this._darkBtn.innerHTML=y,this._darkBtn.title="Toggle dark mode",this._darkBtn.addEventListener("click",function(){s.el.classList.toggle("mc-dark"),s._darkBtn.classList.toggle("active",s.el.classList.contains("mc-dark")),s.render()})),this._toolbar.export){var o=u("button","",i);o.innerHTML=M,o.title="Export PNG",o.addEventListener("click",function(){s.exportPNG()})}"top"!==this._legendPosition||this._legendHidden||(this._legendEl=u("div","mc-legend",this._root),this._buildDonutLegend()),this._wrap=u("div","mc-wrap",this._root),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this._wrap.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this._tooltipEl=u("div","mc-tooltip",this._wrap),this.segments.length>0&&this._tooltipEl.style.setProperty("--mc-tt-accent",this.segments[0].color),"bottom"!==this._legendPosition||this._legendHidden||(this._legendEl=u("div","mc-legend",this._root),this._buildDonutLegend()),this._legendEl||(this._legendEl=u("div","mc-legend",null),this._legendEl.style.display="none")},A.prototype._buildDonutLegend=function(){this._legendEl.innerHTML="";var t=this;this.segments.forEach(function(e,i){var s=u("div","mc-legend-item",t._legendEl);e.visible||s.classList.add("disabled"),u("div","mc-legend-swatch",s).style.background=e.color,u("span","",s).textContent=e.label,s.addEventListener("click",function(){e.visible=!e.visible,s.classList.toggle("disabled",!e.visible),t.render()})})},A.prototype._initSize=function(){var t=this._wrap.getBoundingClientRect().width,e=Math.max(this._height,380);this.W=t,this.H=e,this.canvas.width=Math.round(t*i),this.canvas.height=Math.round(e*i),this.canvas.style.height=e+"px",this.ctx.setTransform(i,0,0,i,0,0)},A.prototype._startAnimation=S.prototype._startAnimation,A.prototype._bindDonutEvents=function(){var t,e=this;this._responsive&&window.addEventListener("resize",function(){clearTimeout(t),t=setTimeout(function(){e._initSize(),e.render()},80)});this.canvas.addEventListener("mousemove",function(t){var i=e.canvas.getBoundingClientRect(),s=t.clientX-i.left,o=t.clientY-i.top;e._onDonutHover(s,o)}),this.canvas.addEventListener("mouseleave",function(){e._hoverIndex=-1,e._tooltipEl.classList.remove("visible"),e.render()}),this.canvas.addEventListener("click",function(t){var i=e.canvas.getBoundingClientRect(),s=t.clientX-i.left,o=t.clientY-i.top,a=e._hitTest(s,o);e._selectedIndex=e._selectedIndex===a?-1:a,e.render()})},A.prototype._getTotal=function(){var t=0;return this.segments.forEach(function(e){e.visible&&(t+=e.value)}),t},A.prototype._hitTest=function(t,e){var i=this.W/2,s=this.H/2,o=Math.min(i,s)-30,a=o*this._innerRadius,r=t-i,l=e-s,h=Math.sqrt(r*r+l*l);if(h<a||h>o+12)return-1;var n=Math.atan2(l,r);n<-Math.PI/2&&(n+=2*Math.PI);var d=this._getTotal();if(d<=0)return-1;for(var c=-Math.PI/2,_=0;_<this.segments.length;_++)if(this.segments[_].visible){var p=this.segments[_].value/d*Math.PI*2;if(n>=c&&n<c+p)return _;c+=p}return-1},A.prototype._onDonutHover=function(t,e){var i=this._hoverIndex;if(this._hoverIndex=this._hitTest(t,e),this._hoverIndex!==i){if(this._hoverIndex>=0&&this._tooltipEnabled){var s=this.segments[this._hoverIndex];this._tooltipEl.style.setProperty("--mc-tt-accent",s.color);var o=this._getTotal(),a=o>0?(s.value/o*100).toFixed(1):"0.0",r='<div class="mc-tooltip-date">'+s.label+'</div><div class="mc-tooltip-row"><div class="mc-tooltip-dot" style="background:'+s.color+'"></div><span>'+v(s.value)+'</span><span class="mc-tooltip-val" style="margin-left:8px;font-weight:600">'+a+"%</span></div>";this._tooltipEl.innerHTML=r,this._tooltipEl.classList.add("visible");var l=this._tooltipEl.offsetWidth,h=t+16;h+l>this.W-8&&(h=t-l-16),this._tooltipEl.style.left=h+"px",this._tooltipEl.style.top=e-20+"px"}else this._tooltipEl.classList.remove("visible");this.render()}},A.prototype.render=function(){var t=d(this.el),e=this.ctx;e.clearRect(0,0,this.W,this.H),e.fillStyle=t.card,e.fillRect(0,0,this.W,this.H);var i=g(this._animProgress),s=this._getTotal();if(!(s<=0)){for(var o=this.W/2,a=this.H/2,l=Math.min(o,a)-30,h=l*this._innerRadius,n=-Math.PI/2,c=2*Math.PI*i,_=this._padAngle,p=this._strokeWidth,f="auto"===this._strokeColor?t.card:this._strokeColor,u=0;u<this.segments.length;u++){var b=this.segments[u];if(b.visible){var x=b.value/s*Math.PI*2,y=Math.min(x-_,c-(n+Math.PI/2));if(y<=0)n+=x;else{var M=this._hoverIndex===u,S=this._selectedIndex===u,C=M||S?this._hoverScale:1,w=M||S?8:0,k=n+x/2,T=w*Math.cos(k),P=w*Math.sin(k),A=e.createLinearGradient(o+T+l*Math.cos(n),a+P+l*Math.sin(n),o+T+l*Math.cos(n+y),a+P+l*Math.sin(n+y));A.addColorStop(0,b.color),A.addColorStop(1,m(b.color,.15)),M&&(e.save(),e.shadowColor=b.color,e.shadowBlur=16,e.fillStyle="rgba(0,0,0,0.01)",e.beginPath(),e.arc(o+T,a+P,l*C,n+_/2,n+_/2+y),e.arc(o+T,a+P,h,n+_/2+y,n+_/2,!0),e.closePath(),e.fill(),e.restore()),e.fillStyle=A,e.globalAlpha=M?this._hoverOpacity:this._opacity,e.beginPath(),e.arc(o+T,a+P,l*(C>1?C:1),n+_/2,n+_/2+y),e.arc(o+T,a+P,h,n+_/2+y,n+_/2,!0),e.closePath(),e.fill(),p>0&&(e.strokeStyle=f,e.lineWidth=p,e.stroke()),n+=x}}}if(e.globalAlpha=1,this._innerRadius>0){var E=e.createRadialGradient(o,a,.8*h,o,a,h);E.addColorStop(0,"rgba(0,0,0,0)"),E.addColorStop(1,"rgba(0,0,0,0.06)"),e.fillStyle=E,e.beginPath(),e.arc(o,a,h,0,2*Math.PI),e.fill()}var L=this._centerLabel,B=this._centerSubLabel;if(null==L||null==B)if(this._selectedIndex>=0&&this.segments[this._selectedIndex].visible){var H=this.segments[this._selectedIndex];null==L&&(L=v(H.value)),null==B&&(B=H.label)}else null==L&&(L=v(s)),null==B&&(B="Total");e.textAlign="center",e.textBaseline="middle",e.fillStyle=t.text,e.font="bold 24px "+r,e.fillText(L,o,a-6),e.fillStyle=t.muted,e.font="12px "+r,e.fillText(B,o,a+16)}},A.prototype.exportPNG=S.prototype.exportPNG,E.prototype._buildGaugeDOM=function(){this._root=u("div","mc-root",this.el);var t=u("div","mc-header",this._root),e=u("div","mc-titles",t);this.opts.title&&(u("div","mc-title",e).textContent=this.opts.title);this.opts.subtitle&&(u("div","mc-subtitle",e).textContent=this.opts.subtitle);var i=u("div","mc-toolbar",t),s=this;this._toolbar.dark&&(this._darkBtn=u("button","",i),this._darkBtn.innerHTML=y,this._darkBtn.title="Toggle dark mode",this._darkBtn.addEventListener("click",function(){s.el.classList.toggle("mc-dark"),s._darkBtn.classList.toggle("active",s.el.classList.contains("mc-dark")),s.render()})),this._wrap=u("div","mc-wrap",this._root),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this._wrap.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d")},E.prototype._initSize=function(){var t=this._wrap.getBoundingClientRect().width,e=Math.min(t/2-30,180),s=e+e*this._arcWidth/2+70;s=Math.max(200,Math.min(s,320)),this.W=t,this.H=s,this.canvas.width=Math.round(t*i),this.canvas.height=Math.round(s*i),this.canvas.style.height=s+"px",this.ctx.setTransform(i,0,0,i,0,0)},E.prototype._startAnimation=S.prototype._startAnimation,E.prototype._bindGaugeEvents=function(){var t,e=this;this._responsive&&window.addEventListener("resize",function(){clearTimeout(t),t=setTimeout(function(){e._initSize(),e.render()},80)})},E.prototype.render=function(){var t=d(this.el),e=this.ctx;e.clearRect(0,0,this.W,this.H),e.fillStyle=t.card,e.fillRect(0,0,this.W,this.H);var i=g(this._animProgress),s=this.W/2,o=this.H-40,a=Math.min(s-30,o-20,180),l=a*this._arcWidth,h=this.max-this.min,n=this;this.zones.forEach(function(t){var i=c((t.from-n.min)/h,0,1),r=c((t.to-n.min)/h,0,1),d=Math.PI+i*Math.PI,_=Math.PI+r*Math.PI;e.beginPath(),e.arc(s,o,a,d,_),e.lineWidth=l,e.strokeStyle=t.color,e.globalAlpha=.25,e.stroke()}),e.globalAlpha=1;var _=c((this.value-this.min)/h,0,1)*i,p=Math.PI+_*Math.PI;if(this.zones.forEach(function(t){var i=c((t.from-n.min)/h,0,1),r=c((t.to-n.min)/h,0,1),d=Math.PI+i*Math.PI,_=Math.PI+r*Math.PI,v=Math.min(_,p);if(!(v<=d)){var g=s+a*Math.cos(d),f=o+a*Math.sin(d),u=s+a*Math.cos(v),b=o+a*Math.sin(v),x=e.createLinearGradient(g,f,u,b);x.addColorStop(0,t.color),x.addColorStop(1,m(t.color,.2)),e.beginPath(),e.arc(s,o,a,d,v),e.lineWidth=l,e.strokeStyle=x,e.lineCap="butt",e.stroke()}}),e.save(),e.globalAlpha=.08,e.beginPath(),e.arc(s,o,a+.35*l,Math.PI,2*Math.PI),e.lineWidth=1.5,e.strokeStyle="#fff",e.stroke(),e.restore(),this._showTicks){e.strokeStyle=t.muted,e.lineWidth=1;for(var f=0;f<=10;f++){var u=f/10,b=Math.PI+u*Math.PI,x=a-l/2-4,y=a-l/2-10,M=s+x*Math.cos(b),S=o+x*Math.sin(b),C=s+y*Math.cos(b),w=o+y*Math.sin(b);e.beginPath(),e.moveTo(M,S),e.lineTo(C,w),e.stroke()}}var k=a-l/2-8,T=Math.PI+_*Math.PI,P=s+k*Math.cos(T),A=o+k*Math.sin(T);e.save(),e.shadowColor="rgba(0,0,0,0.3)",e.shadowBlur=6,e.shadowOffsetY=2,e.strokeStyle=this._needleColor||t.text,e.lineWidth=this._needleWidth,e.lineCap="round",e.beginPath(),e.moveTo(s,o),e.lineTo(P,A),e.stroke(),e.restore(),e.fillStyle=this._needleColor||t.text,e.beginPath(),e.arc(s,o,6,0,2*Math.PI),e.fill(),e.fillStyle=t.card,e.beginPath(),e.arc(s,o,3,0,2*Math.PI),e.fill(),e.textAlign="center",e.textBaseline="bottom",e.fillStyle=t.text,e.font="bold 28px "+r,e.fillText(v(this.value*i),s,o-16),this._unit&&(e.font="13px "+r,e.fillStyle=t.muted,e.fillText(this._unit,s,o-0)),e.font="500 12px "+r,e.fillStyle=t.muted,e.textAlign="center",e.textBaseline="top",e.fillText(v(this.min),s-a,o+6),e.fillText(v(this.max),s+a,o+6)},E.prototype.exportPNG=S.prototype.exportPNG,L.prototype._buildHeatmapDOM=function(){this._root=u("div","mc-root",this.el);var t=u("div","mc-header",this._root),e=u("div","mc-titles",t);this.opts.title&&(u("div","mc-title",e).textContent=this.opts.title);this.opts.subtitle&&(u("div","mc-subtitle",e).textContent=this.opts.subtitle);var i=u("div","mc-toolbar",t),s=this;if(this._toolbar.dark&&(this._darkBtn=u("button","",i),this._darkBtn.innerHTML=y,this._darkBtn.title="Toggle dark mode",this._darkBtn.addEventListener("click",function(){s.el.classList.toggle("mc-dark"),s._darkBtn.classList.toggle("active",s.el.classList.contains("mc-dark")),s.render()})),this._toolbar.export){var o=u("button","",i);o.innerHTML=M,o.title="Export PNG",o.addEventListener("click",function(){s.exportPNG()})}this._wrap=u("div","mc-wrap",this._root),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this._wrap.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this._tooltipEl=u("div","mc-tooltip",this._wrap)},L.prototype._initSize=function(){var t=this._wrap.getBoundingClientRect().width,e=this._padding,s=this.yLabels.length||1,o=Math.max(this._height,e.top+e.bottom+36*s);this.W=t,this.H=o,this.canvas.width=Math.round(t*i),this.canvas.height=Math.round(o*i),this.canvas.style.height=o+"px",this.ctx.setTransform(i,0,0,i,0,0)},L.prototype._startAnimation=S.prototype._startAnimation,L.prototype._computeMinMax=function(){this._dataMin=1/0,this._dataMax=-1/0;for(var t=0;t<this.data.length;t++){var e=this.data[t][2];e<this._dataMin&&(this._dataMin=e),e>this._dataMax&&(this._dataMax=e)}this._dataMin===1/0&&(this._dataMin=0,this._dataMax=1),this._grid={};for(var i=0;i<this.data.length;i++){var s=this.data[i];this._grid[s[0]+","+s[1]]=s[2]}},L.prototype._interpolateColor=function(t){var e=this.colorRange[0],i=this.colorRange[1],s=b(e),o=b(i);return"rgb("+Math.round(s[0]+(o[0]-s[0])*t)+","+Math.round(s[1]+(o[1]-s[1])*t)+","+Math.round(s[2]+(o[2]-s[2])*t)+")"},L.prototype._bindHeatmapEvents=function(){var t,e=this;this._responsive&&window.addEventListener("resize",function(){clearTimeout(t),t=setTimeout(function(){e._initSize(),e.render()},80)});this.canvas.addEventListener("mousemove",function(t){var i=e.canvas.getBoundingClientRect(),s=t.clientX-i.left,o=t.clientY-i.top;e._onHeatmapHover(s,o)}),this.canvas.addEventListener("mouseleave",function(){e._hoverCell=null,e._tooltipEl.classList.remove("visible"),e.render()})},L.prototype._onHeatmapHover=function(t,e){var i=this._padding,s=i.left+20,o=i.top,a=this.W-s-i.right,r=this.H-i.top-i.bottom,l=a/this.xLabels.length,h=r/this.yLabels.length,n=Math.floor((t-s)/l),d=Math.floor((e-o)/h),c=this._hoverCell;if(n>=0&&n<this.xLabels.length&&d>=0&&d<this.yLabels.length){var _=n+","+d,p=this._grid[_];if(null!=p){if(this._hoverCell={xi:n,yi:d},!c||c.xi!==n||c.yi!==d){if(this._tooltipEnabled){var g='<div class="mc-tooltip-date">'+this.yLabels[d]+" / "+this.xLabels[n]+'</div><div class="mc-tooltip-row"><span style="font-weight:600">'+v(p)+"</span></div>";this._tooltipEl.innerHTML=g,this._tooltipEl.classList.add("visible");var f=this._tooltipEl.offsetWidth,u=t+16;u+f>this.W-8&&(u=t-f-16),this._tooltipEl.style.left=u+"px",this._tooltipEl.style.top=e-20+"px"}this.render()}return}}c&&(this._hoverCell=null,this._tooltipEl.classList.remove("visible"),this.render())},L.prototype.render=function(){var t=d(this.el),e=this.ctx;e.clearRect(0,0,this.W,this.H),e.fillStyle=t.card,e.fillRect(0,0,this.W,this.H);for(var i=g(this._animProgress),s=this._padding,o=s.left+20,a=s.top,l=this.W-o-s.right,h=this.H-s.top-s.bottom,n=this.xLabels.length,_=this.yLabels.length,p=l/n,f=h/_,u=this._cellGap,b=this._dataMax-this._dataMin||1,m=this._cellRadius,x=0;x<_;x++)for(var y=0;y<n;y++){var M=y+","+x,S=this._grid[M];if(null!=S){var C=c((S-this._dataMin)/b,0,1)*i,w=o+y*p+u/2,k=a+x*f+u/2,T=p-u,P=f-u,A=this._hoverCell&&this._hoverCell.xi===y&&this._hoverCell.yi===x;e.save(),e.shadowColor="rgba(0,0,0,0.08)",e.shadowBlur=2,e.shadowOffsetY=1,e.fillStyle=this._interpolateColor(C),e.globalAlpha=A?1:.9,e.beginPath(),e.roundRect(w,k,T,P,m),e.fill(),e.restore(),A&&(e.save(),e.shadowColor="rgba(255,255,255,0.8)",e.shadowBlur=8,e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),e.roundRect(w,k,T,P,m),e.stroke(),e.restore()),this._showCellValues&&i>=.8&&T>20&&P>16&&(e.globalAlpha=1,e.font=this._cellFontSize+"px "+r,e.textAlign="center",e.textBaseline="middle",e.fillStyle=C>.55?"#fff":t.text,e.fillText(v(S),w+T/2,k+P/2))}}e.globalAlpha=1,e.textAlign="center",e.textBaseline="bottom",e.font="500 12px "+r,e.fillStyle=t.text2;for(var E=0;E<n;E++)e.fillText(this.xLabels[E],o+E*p+p/2,a-6);e.textAlign="right",e.textBaseline="middle";for(var L=0;L<_;L++)e.fillText(this.yLabels[L],o-8,a+L*f+f/2)},L.prototype.exportPNG=S.prototype.exportPNG,B.prototype._buildRadarDOM=function(){this._root=u("div","mc-root",this.el);var t=u("div","mc-header",this._root),e=u("div","mc-titles",t);this.opts.title&&(u("div","mc-title",e).textContent=this.opts.title);this.opts.subtitle&&(u("div","mc-subtitle",e).textContent=this.opts.subtitle);var i=u("div","mc-toolbar",t),s=this;if(this._toolbar.dark&&(this._darkBtn=u("button","",i),this._darkBtn.innerHTML=y,this._darkBtn.title="Toggle dark mode",this._darkBtn.addEventListener("click",function(){s.el.classList.toggle("mc-dark"),s._darkBtn.classList.toggle("active",s.el.classList.contains("mc-dark")),s.render()})),this._toolbar.export){var o=u("button","",i);o.innerHTML=M,o.title="Export PNG",o.addEventListener("click",function(){s.exportPNG()})}"top"!==this._legendPosition||this._legendHidden||(this._legendEl=u("div","mc-legend",this._root),this._buildRadarLegend()),this._wrap=u("div","mc-wrap",this._root),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this._wrap.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this._tooltipEl=u("div","mc-tooltip",this._wrap),this.series.length>0&&this._tooltipEl.style.setProperty("--mc-tt-accent",this.series[0].color),"bottom"!==this._legendPosition||this._legendHidden||(this._legendEl=u("div","mc-legend",this._root),this._buildRadarLegend()),this._legendEl||(this._legendEl=u("div","mc-legend",null),this._legendEl.style.display="none")},B.prototype._buildRadarLegend=function(){this._legendEl.innerHTML="";var t=this;this.series.forEach(function(e,i){var s=u("div","mc-legend-item",t._legendEl);e.visible||s.classList.add("disabled"),u("div","mc-legend-swatch",s).style.background=e.color,u("span","",s).textContent=e.name,s.addEventListener("click",function(){e.visible=!e.visible,s.classList.toggle("disabled",!e.visible),t.render()})})},B.prototype._initSize=function(){var t=this._wrap.getBoundingClientRect().width,e=Math.max(this._height,380);this.W=t,this.H=e,this.canvas.width=Math.round(t*i),this.canvas.height=Math.round(e*i),this.canvas.style.height=e+"px",this.ctx.setTransform(i,0,0,i,0,0)},B.prototype._startAnimation=S.prototype._startAnimation,B.prototype._bindRadarEvents=function(){var t,e=this;this._responsive&&window.addEventListener("resize",function(){clearTimeout(t),t=setTimeout(function(){e._initSize(),e.render()},80)});this.canvas.addEventListener("mousemove",function(t){var i=e.canvas.getBoundingClientRect(),s=t.clientX-i.left,o=t.clientY-i.top;e._onRadarHover(s,o)}),this.canvas.addEventListener("mouseleave",function(){e._hoverAxis=-1,e._tooltipEl.classList.remove("visible"),e.render()})},B.prototype._onRadarHover=function(t,e){var i=this.W/2,s=this.H/2,o=Math.min(i,s)-60,a=this.categories.length;if(0!==a){var r=t-i,l=e-s;if(Math.sqrt(r*r+l*l)>o+30)this._hoverAxis>=0&&(this._hoverAxis=-1,this._tooltipEl.classList.remove("visible"),this.render());else{for(var h=Math.atan2(l,r),n=-Math.PI/2,d=2*Math.PI/a,_=-1,p=1/0,g=0;g<a;g++){var f=n+d*g,u=Math.abs(Math.atan2(Math.sin(h-f),Math.cos(h-f)));u<p&&(p=u,_=g)}p>d/2&&(_=-1);var b=this._hoverAxis;if(this._hoverAxis=_,this._hoverAxis!==b){if(this._hoverAxis>=0&&this._tooltipEnabled){var m=[],x=this;if(this.series.forEach(function(t){t.visible&&x._hoverAxis<t.data.length&&m.push({name:t.name,value:t.data[x._hoverAxis],color:t.color})}),m.length>0){this._tooltipEl.style.setProperty("--mc-tt-accent",m[0].color);var y='<div class="mc-tooltip-date">'+this.categories[this._hoverAxis]+"</div>";m.forEach(function(t){y+='<div class="mc-tooltip-row"><div class="mc-tooltip-dot" style="background:'+t.color+'"></div><span>'+t.name+'</span><span class="mc-tooltip-val" style="margin-left:8px;font-weight:600">'+v(t.value)+"</span></div>"}),this._tooltipEl.innerHTML=y,this._tooltipEl.classList.add("visible");var M=this._tooltipEl.offsetWidth,S=t+16;S+M>this.W-8&&(S=t-M-16);var C=e-this._tooltipEl.offsetHeight/2;C=c(C,4,this.H-this._tooltipEl.offsetHeight-4),this._tooltipEl.style.left=S+"px",this._tooltipEl.style.top=C+"px"}}else this._tooltipEl.classList.remove("visible");this.render()}}}},B.prototype.render=function(){var t=d(this.el),e=this.ctx;e.clearRect(0,0,this.W,this.H),e.fillStyle=t.card,e.fillRect(0,0,this.W,this.H);var i=this._animProgress,s=f(c(i,0,1));s=Math.max(0,s);var o=this.W/2,a=this.H/2,l=Math.min(o,a)-60,h=this.categories.length;if(0!==h){for(var n=-Math.PI/2,_=2*Math.PI/h,p=this._max,g=1;g<=this._levels;g++){var u=l/this._levels*g;if(e.strokeStyle="rgba(226,232,240,0.6)",e.lineWidth=1,e.beginPath(),"circle"===this._gridStyle)e.arc(o,a,u,0,2*Math.PI);else{for(var x=0;x<=h;x++){var y=n+_*(x%h),M=o+u*Math.cos(y),S=a+u*Math.sin(y);0===x?e.moveTo(M,S):e.lineTo(M,S)}e.closePath()}if(e.stroke(),g<this._levels||g===this._levels){var C=p/this._levels*g;e.font="10px "+r,e.fillStyle=t.muted,e.textAlign="left",e.textBaseline="bottom",e.fillText(v(C),o+4,a-u-2)}}for(x=0;x<h;x++){y=n+_*x;var w=o+l*Math.cos(y),k=a+l*Math.sin(y);e.strokeStyle="rgba(226,232,240,0.4)",e.lineWidth=1,e.beginPath(),e.moveTo(o,a),e.lineTo(w,k),e.stroke(),this._hoverAxis===x&&(e.strokeStyle="rgba(99,102,241,0.3)",e.lineWidth=2,e.beginPath(),e.moveTo(o,a),e.lineTo(w,k),e.stroke())}if(this._axisLabels){e.font="500 12px "+r,e.fillStyle=t.text2;for(x=0;x<h;x++){y=n+_*x;var T=l+18,P=o+T*Math.cos(y),A=a+T*Math.sin(y);Math.abs(Math.cos(y))<.1?e.textAlign="center":Math.cos(y)>0?e.textAlign="left":e.textAlign="right",Math.abs(Math.sin(y))<.1?e.textBaseline="middle":Math.sin(y)>0?e.textBaseline="top":e.textBaseline="bottom",this._hoverAxis===x?(e.fillStyle=t.text,e.font="600 12px "+r):(e.fillStyle=t.text2,e.font="500 12px "+r),e.fillText(this.categories[x],P,A)}}for(var E=this.series.filter(function(t){return t.visible}),L=0;L<E.length;L++){var B=E[L],H=[];for(x=0;x<h;x++){y=n+_*x;var W=(O=x<B.data.length?B.data[x]:0)/p*l*s;H.push({x:o+W*Math.cos(y),y:a+W*Math.sin(y)})}var R=b(B.color);e.globalAlpha=this._fillOpacity,e.fillStyle="rgba("+R[0]+","+R[1]+","+R[2]+","+this._fillOpacity+")",e.beginPath();for(x=0;x<=h;x++){var D=H[x%h];0===x?e.moveTo(D.x,D.y):e.lineTo(D.x,D.y)}e.closePath(),e.globalAlpha=1,e.fill(),e.save(),e.shadowColor=B.color,e.shadowBlur=4,e.strokeStyle=B.color,e.lineWidth=this._lineWidth,e.lineJoin="round",e.beginPath();for(x=0;x<=h;x++){D=H[x%h];0===x?e.moveTo(D.x,D.y):e.lineTo(D.x,D.y)}e.closePath(),e.stroke(),e.restore();for(x=0;x<h;x++){D=H[x];this._hoverAxis===x&&(e.save(),e.shadowColor=B.color,e.shadowBlur=8,e.fillStyle=B.color,e.beginPath(),e.arc(D.x,D.y,this._dotRadius+2,0,2*Math.PI),e.fill(),e.restore());var I=e.createRadialGradient(D.x-.3*this._dotRadius,D.y-.3*this._dotRadius,0,D.x,D.y,this._dotRadius);if(I.addColorStop(0,m(B.color,.3)),I.addColorStop(1,B.color),e.fillStyle=I,e.beginPath(),e.arc(D.x,D.y,this._dotRadius,0,2*Math.PI),e.fill(),e.strokeStyle=t.card,e.lineWidth=1.5,e.stroke(),this._showValues&&i>=1){var O=x<B.data.length?B.data[x]:0;e.font="10px "+r,e.fillStyle=t.text2,e.textAlign="center",e.textBaseline="bottom",e.fillText(v(O),D.x,D.y-this._dotRadius-3)}}}}},B.prototype.exportPNG=S.prototype.exportPNG,CanvasRenderingContext2D.prototype.roundRect||(CanvasRenderingContext2D.prototype.roundRect=function(t,e,i,s,o){Array.isArray(o)||(o=[o,o,o,o]);var a=o[0]||0,r=o[1]||0,l=o[2]||0,h=o[3]||0;return this.moveTo(t+a,e),this.lineTo(t+i-r,e),this.quadraticCurveTo(t+i,e,t+i,e+r),this.lineTo(t+i,e+s-l),this.quadraticCurveTo(t+i,e+s,t+i-l,e+s),this.lineTo(t+h,e+s),this.quadraticCurveTo(t,e+s,t,e+s-h),this.lineTo(t,e+a),this.quadraticCurveTo(t,e,t+a,e),this.closePath(),this}),H.prototype=Object.create(S.prototype),H.prototype.constructor=H,H.prototype._computeScale=function(){var t=0,e=0;this.series.forEach(function(i){i.visible&&i.data.forEach(function(s){null!=s&&("line"===i.type?s>e&&(e=s):s>t&&(t=s))})}),this._barScaleMax=_(1.15*t),this._barStep=p(this._barScaleMax,5),this._barTicks=[];for(var i=0;i<=this._barScaleMax;i+=this._barStep)this._barTicks.push(i);if(this._dualAxis){this._lineScaleMax=_(1.15*e),this._lineStep=p(this._lineScaleMax,5),this._lineTicks=[];for(var s=0;s<=this._lineScaleMax;s+=this._lineStep)this._lineTicks.push(s)}else{var o=Math.max(t,e);this._barScaleMax=_(1.15*o),this._barStep=p(this._barScaleMax,5),this._barTicks=[];for(var a=0;a<=this._barScaleMax;a+=this._barStep)this._barTicks.push(a);this._lineScaleMax=this._barScaleMax,this._lineTicks=this._barTicks}this._scaleMax=this._barScaleMax,this._ticks=this._barTicks},H.prototype.render=function(){this._computeScale(),this._clearAndDrawBackground();var t=this.ctx,e=this._vars,i=f(c(this._animProgress,0,1));i=Math.max(0,i);var s=this._padding,o=s.left,a=s.top,l=this._dualAxis?60:s.right,h=this.W-s.left-l,n=this.H-s.top-s.bottom,d=this.categories.length,_=h/d,p=a+n,g=this._borderRadius;if(this._barTicks.length>=2)for(var u=0;u<this._barTicks.length-1;u++)if(u%2!=0){var b=a+n-this._barTicks[u]/this._barScaleMax*n,m=a+n-this._barTicks[u+1]/this._barScaleMax*n;t.fillStyle="rgba(0,0,0,0.015)",t.fillRect(o,m,h,b-m)}t.textAlign="right",t.textBaseline="middle",t.font="500 12px "+r;for(var x=0;x<this._barTicks.length;x++){var y=this._barTicks[x],M=a+n-y/this._barScaleMax*n;this._gridLines&&(t.strokeStyle=this._gridColor||"rgba(226,232,240,0.6)",t.lineWidth=1,t.setLineDash(this._gridDashed?[4,4]:[]),t.beginPath(),t.moveTo(o,M),t.lineTo(o+h,M),t.stroke(),t.setLineDash([])),t.fillStyle=e.muted,t.fillText(v(y),o-8,M)}if(this._dualAxis){t.textAlign="left";for(var S=0;S<this._lineTicks.length;S++){var C=this._lineTicks[S],w=a+n-C/this._lineScaleMax*n;t.fillStyle=e.muted,t.fillText(v(C),o+h+8,w)}}t.textAlign="center",t.textBaseline="top",t.fillStyle=e.text2,t.font="500 12px "+r;for(var k=0;k<d;k++)t.fillText(this.categories[k],o+_*k+_/2,p+8);var T=[],P=[];this.series.forEach(function(t){t.visible&&("line"===t.type?P.push(t):T.push(t))});var A=T.length||1,E=this._barWidth||Math.min(.6*_/A,60),L=(_-(E*A+this._barGap*(A-1)))/2;this._hitAreas=[];for(var B=0;B<T.length;B++)for(var H=T[B],W=0;W<d;W++){var R=W<H.data.length?H.data[W]:null;if(null!=R){var D=R/this._barScaleMax*n*i,I=o+_*W+L+B*(E+this._barGap),O=p-D,G=this._hoverCat===W;this._drawBarShadow(t,I,O,E,D,[g,g,0,0],H.color),t.globalAlpha=G?this._hoverOpacity:this._barOpacity,t.fillStyle=this._getBarFill(H.color,I,O,E,D,!0),t.beginPath(),t.roundRect(I,O,E,D,[g,g,0,0]),t.fill(),D>4&&this._drawBarHighlight(t,I,O,E,g,!0),this._hitAreas.push({ci:W,si:B,x:I,y:O,w:E,h:D,series:H})}}t.globalAlpha=1;for(var z=this._dualAxis?this._lineScaleMax:this._barScaleMax,N=0;N<P.length;N++){for(var V=P[N],F=[],j=0;j<d;j++){var q=j<V.data.length?V.data[j]:null;null!=q&&F.push({x:o+_*j+_/2,y:p-q/z*n*i})}if(!(F.length<2)){t.save(),t.shadowColor=V.color,t.shadowBlur=8,t.shadowOffsetY=2,t.strokeStyle=V.color,t.lineWidth=this._lineWidth,t.lineJoin="round",t.lineCap="round",t.beginPath();var Y=this._lineTension;if(Y>0&&F.length>2){t.moveTo(F[0].x,F[0].y);for(var X=0;X<F.length-1;X++){var J=F[X],U=F[X+1];t.bezierCurveTo(J.x+(U.x-J.x)*Y,J.y,U.x-(U.x-J.x)*Y,U.y,U.x,U.y)}}else{t.moveTo(F[0].x,F[0].y);for(var K=1;K<F.length;K++)t.lineTo(F[K].x,F[K].y)}t.stroke(),t.restore();for(var Q=0;Q<F.length;Q++)t.fillStyle=V.color,t.beginPath(),t.arc(F[Q].x,F[Q].y,5,0,2*Math.PI),t.fill(),t.fillStyle=e.card,t.beginPath(),t.arc(F[Q].x,F[Q].y,2.5,0,2*Math.PI),t.fill()}}t.globalAlpha=1},H.prototype._onHover=C.prototype._onHover,W.prototype=Object.create(S.prototype),W.prototype.constructor=W,W.prototype._computeScale=function(){for(var t=this.series.length>0?this.series[0].data:[],e=0,i=0,s=0,o=0;o<t.length;o++)(e+=t[o])>s&&(s=e),e<i&&(i=e);var a=e;this._showTotal&&a>s&&(s=a),this._showTotal&&a<i&&(i=a);var r=Math.max(Math.abs(i),Math.abs(s));this._scaleMax=_(1.15*r),this._scaleMin=i<0?-_(1.15*Math.abs(i)):0;var l=this._scaleMax-this._scaleMin;this._step=p(l,5),this._ticks=[];for(var h=this._scaleMin;h<=this._scaleMax;h+=this._step)this._ticks.push(Math.round(100*h)/100)},W.prototype.render=function(){this._computeScale(),this._clearAndDrawBackground();var t=this.ctx,e=this._vars,i=this._animProgress,s=f(c(i,0,1));s=Math.max(0,s);for(var o=this._padding,a=o.left,l=o.top,h=this.W-o.left-o.right,n=this.H-o.top-o.bottom,d=this.series.length>0?this.series[0].data:[],_=this.categories.slice(),p=d.slice(),g=0,u=0;u<d.length;u++)g+=d[u];this._showTotal&&(_.push("Total"),p.push(g));var b=_.length,m=h/b,x=this._barWidth||Math.min(.6*m,60),y=this._scaleMax-this._scaleMin,M=this._borderRadius;function S(t){return l+n-(t-this._scaleMin)/y*n}var C=this;t.textAlign="right",t.textBaseline="middle",t.font="500 12px "+r;for(var w=0;w<this._ticks.length;w++){var k=this._ticks[w],T=S.call(C,k);this._gridLines&&(t.strokeStyle=this._gridColor||"rgba(226,232,240,0.6)",t.lineWidth=1,t.setLineDash(this._gridDashed?[4,4]:[]),t.beginPath(),t.moveTo(a,T),t.lineTo(a+h,T),t.stroke(),t.setLineDash([])),t.fillStyle=e.muted,t.fillText(v(k),a-8,T)}t.textAlign="center",t.textBaseline="top",t.fillStyle=e.text2,t.font="500 12px "+r;for(var P=0;P<b;P++)t.fillText(_[P],a+m*P+m/2,l+n+8);var A=0,E=S.call(C,0);this._hitAreas=[];for(var L=0;L<b;L++){var B,H,W,R,D=this._showTotal&&L===b-1;if(D)H=S.call(C,0),W=S.call(C,g*s),R=this._totalColor;else{var I=A;A+=B=d[L],H=S.call(C,I*s),W=S.call(C,A*s),R=B>=0?this._positiveColor:this._negativeColor}var O=a+m*L+(m-x)/2,G=Math.min(H,W),z=Math.max(H,W),N=z-G,V=this._hoverCat===L;if(this._showConnectors&&L>0&&!D&&(t.strokeStyle=e.muted,t.lineWidth=1,t.setLineDash([3,3]),t.beginPath(),t.moveTo(a+m*(L-1)+(m+x)/2,E),t.lineTo(O,E),t.stroke(),t.setLineDash([])),E=D?S.call(C,g*s):S.call(C,A*s),this._drawBarShadow(t,O,G,x,N,[M,M,M,M],R),t.globalAlpha=V?this._hoverOpacity:this._opacity,t.fillStyle=this._getBarFill(R,O,G,x,N,!0),t.beginPath(),t.roundRect(O,G,x,Math.max(N,1),[M,M,M,M]),t.fill(),N>4&&this._drawBarHighlight(t,O,G,x,M,!0),i>=1&&this._showValues){t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textAlign="center";var F=D?g:d[L];t.textBaseline=W<H?"bottom":"top",t.fillStyle=this._valueColor||e.text2;var j=W<H?G-4:z+4;t.fillText(v(F),O+x/2,j)}this._hitAreas.push({ci:L,si:0,x:O,y:G,w:x,h:N,series:this.series[0]||{}})}t.globalAlpha=1},W.prototype._onHover=function(t,e){var i=this._hoverCat;this._hoverCat=-1;var s=this._padding,o=s.left,a=this.W-s.left-s.right,r=this._showTotal?this.categories.length+1:this.categories.length,l=a/r;if(t>=o&&t<=o+a&&(this._hoverCat=Math.floor((t-o)/l),this._hoverCat>=r&&(this._hoverCat=r-1)),this._hoverCat!==i&&this.render(),this._hoverCat>=0){var h=this.series.length>0?this.series[0].data:[],n=this.categories.slice();this._showTotal&&n.push("Total");for(var d=0,c=0;c<=this._hoverCat&&c<h.length;c++)d+=h[c];var _=this._showTotal&&this._hoverCat===n.length-1,p=[{color:_?this._totalColor:h[this._hoverCat]>=0?this._positiveColor:this._negativeColor,name:_?"Total":h[this._hoverCat]>=0?"Increase":"Decrease",value:_?d:h[this._hoverCat]}];_||p.push({color:"#64748b",name:"Cumulative",value:d}),this._showTooltip(t,e,n[this._hoverCat],p)}else this._hideTooltip()},R.prototype=Object.create(S.prototype),R.prototype.constructor=R,R.prototype._computeScale=function(){var t=0;this._items.forEach(function(e){var i=e.ranges;if(i&&i.length>0){var s=i[i.length-1];s>t&&(t=s)}e.actual>t&&(t=e.actual),e.target>t&&(t=e.target)}),this._scaleMax=_(1.05*t),this._step=p(this._scaleMax,5),this._ticks=[];for(var e=0;e<=this._scaleMax;e+=this._step)this._ticks.push(e)},R.prototype.render=function(){this._computeScale(),this._clearAndDrawBackground();var t=this.ctx,e=this._vars,i=g(c(this._animProgress,0,1)),s=this._padding,o=s.left,a=s.top,l=this.W-s.left-s.right,h=this.H-s.top-s.bottom,n=this._items.length,d=h/n,_=this._rangeColors;t.textAlign="center",t.textBaseline="top",t.font="500 12px "+r;for(var p=0;p<this._ticks.length;p++){var f=this._ticks[p],u=o+f/this._scaleMax*l;this._gridLines&&(t.strokeStyle=this._gridColor||"rgba(226,232,240,0.4)",t.lineWidth=1,t.setLineDash(this._gridDashed?[4,4]:[]),t.beginPath(),t.moveTo(u,a),t.lineTo(u,a+h),t.stroke(),t.setLineDash([])),t.fillStyle=e.muted,t.fillText(v(f),u,a+h+8)}t.textAlign="right",t.textBaseline="middle",t.fillStyle=e.text2,t.font="500 12px "+r,this._hitAreas=[];for(var b=this._barHeightRatio,x=0;x<n;x++){var y=this._items[x],M=a+d*x+d/2,S=.65*d,C=d*b,w=this._hoverCat===x;t.fillStyle=e.text2,t.textAlign="right",t.textBaseline="middle",t.fillText(y.label,o-8,M);for(var k=y.ranges||[],T=k.length-1;T>=0;T--){var P=k[T]/this._scaleMax*l*i;t.fillStyle=_[T]||"#e2e8f0",t.beginPath(),t.roundRect(o,M-S/2,P,S,2),t.fill()}var A=y.actual/this._scaleMax*l*i,E=t.createLinearGradient(o,0,o+A,0);E.addColorStop(0,this._barColor),E.addColorStop(1,m(this._barColor,.3)),t.fillStyle=E,t.globalAlpha=w?1:.9,t.beginPath(),t.roundRect(o,M-C/2,A,C,2),t.fill(),t.globalAlpha=1;var L=o+y.target/this._scaleMax*l*i;t.strokeStyle=this._markerColor,t.lineWidth=2.5,t.beginPath(),t.moveTo(L,M-S/2-2),t.lineTo(L,M+S/2+2),t.stroke(),this._hitAreas.push({ci:x,si:0,x:o,y:M-S/2,w:l,h:S,series:this.series[0]||{}})}},R.prototype._onHover=function(t,e){var i=this._hoverCat;this._hoverCat=-1;var s=this._padding,o=s.top,a=this.H-s.top-s.bottom,r=this._items.length,l=a/r;if(e>=o&&e<=o+a&&(this._hoverCat=Math.floor((e-o)/l),this._hoverCat>=r&&(this._hoverCat=r-1)),this._hoverCat!==i&&this.render(),this._hoverCat>=0){var h=this._items[this._hoverCat];this._showTooltip(t,e,h.label,[{color:this._barColor,name:"Actual",value:h.actual},{color:this._markerColor,name:"Target",value:h.target}])}else this._hideTooltip()},D.prototype=Object.create(S.prototype),D.prototype.constructor=D,D.prototype.render=function(){this._clearAndDrawBackground();var t=this.ctx,e=this._vars,i=this._animProgress,s=g(c(i,0,1)),o=this._padding,a=o.left,l=o.top+10,h=this.W-o.left-o.right,n=this._barHeight,d=this._segGap,_=this._segments,p=0;_.forEach(function(t){p+=t.value});var f=l+20,u=a;this._segRects=[];for(var b=0;b<_.length;b++){var x=_[b],y=x.value/p,M=(h-d*(_.length-1))*y*s,S=u,C=[0,0,0,0];this._rounded&&(0===b&&(C=[6,0,0,6]),b===_.length-1&&(C=[0,6,6,0]),1===_.length&&(C=[6,6,6,6]));var w=t.createLinearGradient(S,f,S,f+n);w.addColorStop(0,x.color),w.addColorStop(1,m(x.color,.25));var k=this._hoverCat===b;t.globalAlpha=k?1:.88,t.fillStyle=w,t.beginPath(),t.roundRect(S,f,Math.max(M,0),n,C),t.fill(),M>4&&(t.save(),t.globalAlpha=.2,t.strokeStyle="rgba(255,255,255,0.5)",t.lineWidth=1,t.beginPath(),t.moveTo(S+(0===b?C[0]:0)+1,f+1),t.lineTo(S+M-(b===_.length-1?C[1]:0)-1,f+1),t.stroke(),t.restore()),t.globalAlpha=1;var T=(100*y).toFixed(1)+"%",P=M-8;if(P>30){t.font="bold 12px "+r,t.textAlign="center",t.textBaseline="middle",t.fillStyle="#fff";var A=x.label;t.measureText(A).width>P&&(A=A.substring(0,Math.floor(P/7))+".."),t.fillText(A,S+M/2,f+n/2-(this._showPercent?7:0)),this._showPercent&&(t.font="11px "+r,t.globalAlpha=.85,t.fillText(T,S+M/2,f+n/2+8),t.globalAlpha=1)}P<=30&&i>=1&&(t.font="10px "+r,t.textAlign="center",t.textBaseline="top",t.fillStyle=e.text2,t.save(),t.translate(S+M/2,f+n+8),t.rotate(Math.PI/6),t.fillText(x.label,0,0),t.restore()),this._showSegValues&&i>=1&&P>40&&(t.font="10px "+r,t.textAlign="center",t.textBaseline="top",t.fillStyle=e.muted,t.fillText(v(x.value),S+M/2,f+n+6)),this._segRects.push({x:S,y:f,w:M,h:n,idx:b}),u+=M+d}t.globalAlpha=1},D.prototype._onHover=function(t,e){var i=this._hoverCat;if(this._hoverCat=-1,this._segRects)for(var s=0;s<this._segRects.length;s++){var o=this._segRects[s];if(t>=o.x&&t<=o.x+o.w&&e>=o.y&&e<=o.y+o.h){this._hoverCat=s;break}}if(this._hoverCat!==i&&this.render(),this._hoverCat>=0){var a=this._segments[this._hoverCat],r=0;this._segments.forEach(function(t){r+=t.value});var l=(a.value/r*100).toFixed(1);this._showTooltip(t,e,a.label,[{color:a.color,name:"Value",value:a.value},{color:"#64748b",name:"Share",value:l+"%"}])}else this._hideTooltip()},D.prototype._computeScale=function(){this._scaleMax=1,this._ticks=[]},e.bar=function(t,e){return new w(t,e)},e.column=function(t,e){return new C(t,e)},e.barStacked=function(t,e){return new k(t,e)},e.lollipop=function(t,e){return new T(t,e)},e.combo=function(t,e){return new P(t,e)},e.donut=function(t,e){return new A(t,e)},e.gauge=function(t,e){return new E(t,e)},e.heatmap=function(t,e){return new L(t,e)},e.radar=function(t,e){return new B(t,e)},e.lineBar=function(t,e){return new H(t,e)},e.waterfall=function(t,e){return new W(t,e)},e.bullet=function(t,e){return new R(t,e)},e.timeline=function(t,e){return new D(t,e)},"object"==typeof module&&module.exports&&(module.exports=e)}("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:this);
1
+ !function(t){"use strict";var e=t.NMCharts;if(!e)throw new Error("NMCharts-Categories: NMCharts must be loaded first.");var i=window.devicePixelRatio||1,o=600,s=400,a={top:50,right:24,bottom:60,left:60},r='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',l=["#6366f1","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#14b8a6"];function n(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}function d(t){return{bg:n(t,"--mc-bg")||"#f5f7fa",card:n(t,"--mc-card")||"#fff",text:n(t,"--mc-text")||"#1e293b",text2:n(t,"--mc-text2")||"#475569",muted:n(t,"--mc-muted")||"#94a3b8",grid:n(t,"--mc-grid")||"#e2e8f0",border:n(t,"--mc-border")||"#e2e8f0",hover:n(t,"--mc-hover")||"rgba(0,0,0,.04)",ttBg:n(t,"--mc-tt-bg")||"#1e293b",ttFg:n(t,"--mc-tt-fg")||"#fff",btn:n(t,"--mc-btn")||"#6366f1",btnH:n(t,"--mc-btn-h")||"#4f46e5"}}function c(t,e,i){return Math.max(e,Math.min(i,t))}function _(t){if(t<=0)return 10;var e=Math.pow(10,Math.floor(Math.log10(t))),i=t/e;return i<=1?e:i<=2?2*e:i<=5?5*e:10*e}function p(t,e){var i=t/e,o=Math.pow(10,Math.floor(Math.log10(i))),s=i/o;return s<=1?o:s<=2?2*o:s<=5?5*o:10*o}function v(t){return Math.abs(t)>=1e6?(t/1e6).toFixed(1)+"M":Math.abs(t)>=1e3?(t/1e3).toFixed(1)+"k":t%1==0?String(t):t.toFixed(1)}function f(t){return 1-Math.pow(1-t,3)}function u(t){var e=1.70158;return 1+2.70158*Math.pow(t-1,3)+e*Math.pow(t-1,2)}function g(t,e,i){var o=document.createElement(t);return e&&(o.className=e),i&&i.appendChild(o),o}function b(t){var e=t.replace("#","");return 3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),[parseInt(e.substr(0,2),16),parseInt(e.substr(2,2),16),parseInt(e.substr(4,2),16)]}function m(t,e){var i=b(t);return"rgb("+Math.round(i[0]+(255-i[0])*e)+","+Math.round(i[1]+(255-i[1])*e)+","+Math.round(i[2]+(255-i[2])*e)+")"}function y(t,e,i){return null!=t[e]?t[e]:i}var x='<svg viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 1 1 11.21 3a7 7 0 0 0 9.79 9.79z"/></svg>',M='<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>';function w(t,e,i){if(this.type=i,this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts-Categories: container not found");this.opts=e||{},this.categories=e.categories||[];var r=this.opts;this._height=y(r,"height",s),this._opacity=y(r,"opacity",y(r,"fillOpacity",.85)),this._hoverOpacity=y(r,"hoverOpacity",1),this._borderRadius=y(r,"borderRadius",4),this._showValues=y(r,"showValues",!0),this._valueSize=y(r,"valueSize",10),this._valueColor=y(r,"valueColor",null),this._gridLines=y(r,"gridLines",!0),this._gridColor=y(r,"gridColor",null),this._gridDashed=y(r,"gridDashed",!1),this._animDuration=y(r,"animDuration",o),this._toolbar=Object.assign({dark:!0,export:!0},r.toolbar||{}),this._padding=Object.assign({},a,r.padding||{}),this._legendPosition=y(r,"legendPosition","bottom"),this._legendHidden=y(r,"legendHidden",!1),this._userColors=r.colors||null,this._gradient=y(r,"gradient",!0),this._gradientOpacity=r.gradientOpacity||[.9,.4],this._tooltipEnabled=y(r,"tooltip",!0),this._responsive=y(r,"responsive",!0),this._barWidth=y(r,"barWidth",null),this._barGap=y(r,"barGap",4),this._groupPadding=y(r,"groupPadding",.25),this._stacked=y(r,"stacked",!1),this._borderWidth=y(r,"borderWidth",0),this._borderColor=y(r,"borderColor","transparent"),this._stackLabels=y(r,"stackLabels",!0),this._showTotal=y(r,"showTotal",!1),this.series=(e.series||[]).map(function(t,e){var i=r.colors||l;return{name:t.name||"Series "+(e+1),data:t.data||[],color:t.color||i[e%i.length],type:t.type||null,visible:!0}}),this._hoverCat=-1,this._hoverSeries=-1,this._animProgress=0,this._animStart=0,this._rafId=0,this._buildDOM(),this._initSize(),this._startAnimation(),this._bindEvents()}!function(){if(!document.getElementById("mc-cat-enhanced-styles")){var t=document.createElement("style");t.id="mc-cat-enhanced-styles",t.textContent=[".mc-root { box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.03); border-radius: 12px; overflow: hidden; }",".mc-tooltip { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 10px; overflow: hidden; }",'.mc-tooltip::before { content: ""; display: block; height: 3px; background: var(--mc-tt-accent, #6366f1); }',".mc-legend-swatch { width: 10px !important; height: 10px !important; border-radius: 50% !important; transition: transform .15s ease; }",".mc-legend-item:hover .mc-legend-swatch { transform: scale(1.25); }",".mc-legend-item { transition: opacity .15s ease; }"].join("\n"),document.head.appendChild(t)}}(),w.prototype._buildDOM=function(){this._root=g("div","mc-root",this.el);var t=g("div","mc-header",this._root),e=g("div","mc-titles",t);this.opts.title&&(g("div","mc-title",e).textContent=this.opts.title);this.opts.subtitle&&(g("div","mc-subtitle",e).textContent=this.opts.subtitle);var i=g("div","mc-toolbar",t),o=this;if(this._toolbar.dark&&(this._darkBtn=g("button","",i),this._darkBtn.innerHTML=x,this._darkBtn.title="Toggle dark mode",this._darkBtn.addEventListener("click",function(){o.el.classList.toggle("mc-dark"),o._darkBtn.classList.toggle("active",o.el.classList.contains("mc-dark")),o.render()})),this._toolbar.export){var s=g("button","",i);s.innerHTML=M,s.title="Export PNG",s.addEventListener("click",function(){o.exportPNG()})}"top"!==this._legendPosition||this._legendHidden||(this._legendEl=g("div","mc-legend",this._root),this._buildLegend()),this._wrap=g("div","mc-wrap",this._root),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this._wrap.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this._tooltipEl=g("div","mc-tooltip",this._wrap),this.series.length>0&&this._tooltipEl.style.setProperty("--mc-tt-accent",this.series[0].color),"bottom"!==this._legendPosition||this._legendHidden||(this._legendEl=g("div","mc-legend",this._root),this._buildLegend()),this._legendEl||(this._legendEl=g("div","mc-legend",null),this._legendEl.style.display="none")},w.prototype._buildLegend=function(){this._legendEl.innerHTML="";var t=this;this.series.forEach(function(e,i){var o=g("div","mc-legend-item",t._legendEl);e.visible||o.classList.add("disabled"),g("div","mc-legend-swatch",o).style.background=e.color,g("span","",o).textContent=e.name,o.addEventListener("click",function(){e.visible=!e.visible,o.classList.toggle("disabled",!e.visible),t.render()})})},w.prototype._initSize=function(){var t=this._wrap.getBoundingClientRect().width,e=this._height;this.W=t,this.H=e,this.canvas.width=Math.round(t*i),this.canvas.height=Math.round(e*i),this.canvas.style.height=e+"px",this.ctx.setTransform(i,0,0,i,0,0)},w.prototype._startAnimation=function(){var t=this;this._animStart=performance.now(),this._animProgress=0;var e=this._animDuration||o;this._rafId=requestAnimationFrame(function i(o){var s=o-t._animStart;t._animProgress=c(s/e,0,1),t.render(),t._animProgress<1&&(t._rafId=requestAnimationFrame(i))})},w.prototype._bindEvents=function(){var t=this;if(this._boundListeners=[],this._responsive){var e,i=function(){clearTimeout(e),e=setTimeout(function(){t._initSize(),t.render()},80)};window.addEventListener("resize",i),this._boundListeners.push({target:window,type:"resize",fn:i})}var o=function(e){t._hoverRaf||(t._hoverRaf=requestAnimationFrame(function(){t._hoverRaf=0;var i=t.canvas.getBoundingClientRect();t._onHover(e.clientX-i.left,e.clientY-i.top)}))},s=function(){t._hoverCat=-1,t._hoverSeries=-1,t._hideTooltip(),t.render()};this.canvas.addEventListener("mousemove",o),this.canvas.addEventListener("mouseleave",s),this._boundListeners.push({target:this.canvas,type:"mousemove",fn:o}),this._boundListeners.push({target:this.canvas,type:"mouseleave",fn:s})},w.prototype.destroy=function(){this._rafId&&cancelAnimationFrame(this._rafId),this._hoverRaf&&cancelAnimationFrame(this._hoverRaf),this._boundListeners&&(this._boundListeners.forEach(function(t){t.target.removeEventListener(t.type,t.fn)}),this._boundListeners=[]),this._zoomPanListeners&&(this._zoomPanListeners.forEach(function(t){t.target.removeEventListener(t.type,t.fn)}),this._zoomPanListeners=[]),this._root&&this._root.parentNode&&this._root.parentNode.removeChild(this._root)},w.prototype._showTooltip=function(t,e,i,o){if(this._tooltipEnabled){o.length>0&&this._tooltipEl.style.setProperty("--mc-tt-accent",o[0].color);var s='<div class="mc-tooltip-date">'+i+"</div>";o.forEach(function(t){s+='<div class="mc-tooltip-row"><div class="mc-tooltip-dot" style="background:'+t.color+'"></div><span>'+t.name+'</span><span class="mc-tooltip-val" style="margin-left:8px;font-weight:600">'+v(t.value)+"</span></div>"}),this._tooltipEl.innerHTML=s,this._tooltipEl.classList.add("visible");var a=this._tooltipEl.offsetWidth,r=this._tooltipEl.offsetHeight,l=t+16,h=e-r/2;l+a>this.W-8&&(l=t-a-16),h=c(h,4,this.H-r-4),this._tooltipEl.style.left=l+"px",this._tooltipEl.style.top=h+"px"}},w.prototype._hideTooltip=function(){this._tooltipEl.classList.remove("visible")},w.prototype.exportPNG=function(t){var e=document.createElement("a");e.download=t||"chart.png",e.href=this.canvas.toDataURL("image/png"),e.click()},w.prototype.appendData=function(t,e,i){var o=(i=i||{}).maxPoints||0,s=this.series[t];return s?(s.data.push(e),o>0&&s.data.length>o&&(s.data.shift(),this.categories&&this.categories.length>o&&this.categories.shift()),i.category&&this.categories&&this.categories.push(i.category),this._animProgress=1,this.render(),this):this},w.prototype.updateData=function(t,e){var i=this;return e&&(this.categories=e),t.forEach(function(t,e){i.series[e]&&(i.series[e].data=t.data||i.series[e].data,t.color&&(i.series[e].color=t.color),t.name&&(i.series[e].name=t.name))}),this._animProgress=1,this.render(),this},w.prototype._drawAnnotations=function(){var t=this.opts.annotations;if(t&&t.length)for(var e=this.ctx,i=this._vars,o=this._padding,s=o.left,a=o.top,l=this.W-o.left-o.right,h=this.H-o.top-o.bottom,n=this.categories?this.categories.length:0,d=n>0?l/n:l,c=a+h,_=this._barScaleMax||this._scaleMax||100,p=0;p<t.length;p++){var v=t[p];if("line"===v.type){var f=c-(null!=v.value?v.value:0)/_*h;e.save(),e.strokeStyle=v.color||"#ef4444",e.lineWidth=v.lineWidth||1.5,e.setLineDash(v.dash||[6,4]),e.beginPath(),e.moveTo(s,f),e.lineTo(s+l,f),e.stroke(),e.setLineDash([]),v.label&&(e.fillStyle=v.color||"#ef4444",e.font="bold 10px "+r,e.textAlign=v.labelAlign||"right",e.textBaseline="bottom",e.fillText(v.label,s+l-4,f-4)),e.restore()}else if("band"===v.type){var u=c-(v.from||0)/_*h,g=c-(v.to||0)/_*h;e.save(),e.fillStyle=v.color||"rgba(239,68,68,0.08)",e.fillRect(s,Math.min(u,g),l,Math.abs(g-u)),v.label&&(e.fillStyle=v.labelColor||v.color||"#ef4444",e.font="bold 9px "+r,e.textAlign="right",e.textBaseline="top",e.fillText(v.label,s+l-4,Math.min(u,g)+3)),e.restore()}else if("vline"===v.type){var b="number"==typeof v.category?v.category:this.categories?this.categories.indexOf(v.category):-1;if(b<0)continue;var m=s+d*b+d/2;e.save(),e.strokeStyle=v.color||"#f59e0b",e.lineWidth=v.lineWidth||1.5,e.setLineDash(v.dash||[6,4]),e.beginPath(),e.moveTo(m,a),e.lineTo(m,c),e.stroke(),e.setLineDash([]),v.label&&(e.fillStyle=v.color||"#f59e0b",e.font="bold 10px "+r,e.textAlign="center",e.textBaseline="bottom",e.fillText(v.label,m,a-2)),e.restore()}else if("marker"===v.type){var y="number"==typeof v.category?v.category:this.categories?this.categories.indexOf(v.category):-1;if(y<0)continue;var x=s+d*y+d/2,M=c-(v.value||0)/_*h,w=v.radius||6;e.save(),e.fillStyle=v.color||"#ef4444",e.shadowColor=v.color||"#ef4444",e.shadowBlur=8,e.beginPath(),e.arc(x,M,w,0,2*Math.PI),e.fill(),e.shadowBlur=0,e.fillStyle=i.card,e.beginPath(),e.arc(x,M,.45*w,0,2*Math.PI),e.fill(),v.label&&(e.fillStyle=v.color||"#ef4444",e.font="bold 10px "+r,e.textAlign="center",e.textBaseline="bottom",e.fillText(v.label,x,M-w-4)),e.restore()}}},e.lttb=function(t,e){if(e>=t.length||e<=2)return t;for(var i=[t[0]],o=(t.length-2)/(e-2),s=0,a=0;a<e-2;a++){var r=Math.floor((a+1)*o)+1,l=Math.floor((a+2)*o)+1;l>t.length&&(l=t.length);for(var h=0,n=0,d=l-r,c=r;c<l;c++)h+="number"==typeof t[c][0]?t[c][0]:c,n+="number"==typeof t[c][1]?t[c][1]:t[c];h/=d,n/=d;var _="number"==typeof t[s][0]?t[s][0]:s,p="number"==typeof t[s][1]?t[s][1]:t[s],v=Math.floor(a*o)+1,f=Math.floor((a+1)*o)+1;f>t.length&&(f=t.length);for(var u=-1,g=v,b=v;b<f;b++){var m="number"==typeof t[b][0]?t[b][0]:b,y="number"==typeof t[b][1]?t[b][1]:t[b],x=Math.abs((_-h)*(y-p)-(_-m)*(n-p));x>u&&(u=x,g=b)}i.push(t[g]),s=g}return i.push(t[t.length-1]),i},w.prototype._enableZoomPan=function(){if(this.opts.zoomPan){var t=this;this._zoomStart=0,this._zoomEnd=this.categories?this.categories.length:0,this._allCategories=this.categories?this.categories.slice():[],this._allSeriesData=this.series.map(function(t){return t.data.slice()}),this._isDragging=!1,this._dragStartX=0,this._panStartZoom=0,this.canvas.addEventListener("wheel",function(e){e.preventDefault();var i=t._allCategories.length;if(!(i<=2)){var o=c(t._zoomEnd-t._zoomStart+2*(e.deltaY>0?1:-1),3,i),s=(t._zoomStart+t._zoomEnd)/2;t._zoomStart=Math.max(0,Math.round(s-o/2)),t._zoomEnd=Math.min(i,t._zoomStart+Math.round(o)),t._zoomStart<0&&(t._zoomStart=0),t._applyZoom()}},{passive:!1}),this.canvas.addEventListener("mousedown",function(e){e.shiftKey&&(t._isDragging=!0,t._dragStartX=e.clientX,t._panStartZoom=t._zoomStart,e.preventDefault())});var e=function(e){if(t._isDragging){var i=t._padding,o=t.W-i.left-i.right,s=t._allCategories.length,a=t._zoomEnd-t._zoomStart,r=e.clientX-t._dragStartX,l=Math.round(-r/(o/a)),h=c(t._panStartZoom+l,0,s-a);t._zoomStart=h,t._zoomEnd=h+a,t._applyZoom()}},i=function(){t._isDragging=!1};document.addEventListener("mousemove",e),document.addEventListener("mouseup",i),this._zoomPanListeners=[{target:document,type:"mousemove",fn:e},{target:document,type:"mouseup",fn:i}],this.canvas.addEventListener("dblclick",function(){t._zoomStart=0,t._zoomEnd=t._allCategories.length,t._applyZoom()})}},w.prototype._applyZoom=function(){var t=this._zoomStart,e=this._zoomEnd;this.categories=this._allCategories.slice(t,e);var i=this;this.series.forEach(function(o,s){o.data=i._allSeriesData[s].slice(t,e)}),this.render()};var S=w.prototype._bindEvents;function T(t,e){w.call(this,t,e,"column")}function k(t,e){w.call(this,t,e,"bar")}function C(t,e){w.call(this,t,e,"barStacked")}function P(t,e){w.call(this,t,e,"lollipop")}function L(t,e){w.call(this,t,e,"combo")}function E(t,e){if(this.type="donut",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts-Categories: container not found");this.opts=e||{},this._innerRadius=y(e,"innerRadius",.6),this._padAngle=y(e,"padAngle",.02),this._cornerRadius=y(e,"cornerRadius",0),this._centerLabel=y(e,"centerLabel",null),this._centerSubLabel=y(e,"centerSubLabel",null),this._hoverScale=y(e,"hoverScale",1.06),this._strokeWidth=y(e,"strokeWidth",2),this._strokeColor=y(e,"strokeColor","auto"),this._height=y(e,"height",s),this._opacity=y(e,"opacity",y(e,"fillOpacity",.88)),this._hoverOpacity=y(e,"hoverOpacity",1),this._animDuration=y(e,"animDuration",o),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._legendPosition=y(e,"legendPosition","bottom"),this._legendHidden=y(e,"legendHidden",!1),this._tooltipEnabled=y(e,"tooltip",!0),this._responsive=y(e,"responsive",!0),this._gradient=y(e,"gradient",!1),this._gradientOpacity=e.gradientOpacity||[.9,.4],this.segments=(e.segments||[]).map(function(t,i){var o=e.colors||l;return{label:t.label||"Segment "+(i+1),value:t.value||0,color:t.color||o[i%o.length],visible:!0}}),this._hoverIndex=-1,this._selectedIndex=-1,this._animProgress=0,this._animStart=0,this._rafId=0,this._buildDonutDOM(),this._initSize(),this._startAnimation(),this._bindDonutEvents()}function A(t,e){if(this.type="gauge",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts-Categories: container not found");this.opts=e||{},this.value=e.value||0,this.min=null!=e.min?e.min:0,this.max=null!=e.max?e.max:100,this.zones=e.zones||[{from:0,to:40,color:"#10b981"},{from:40,to:70,color:"#f59e0b"},{from:70,to:100,color:"#ef4444"}],this._needleColor=y(e,"needleColor",null),this._needleWidth=y(e,"needleWidth",2.5),this._arcWidth=y(e,"arcWidth",.22),this._showTicks=y(e,"showTicks",!0),this._unit=y(e,"unit",e.unit||""),this._height=y(e,"height",s),this._animDuration=y(e,"animDuration",o),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._responsive=y(e,"responsive",!0),this._animProgress=0,this._animStart=0,this._rafId=0,this._buildGaugeDOM(),this._initSize(),this._startAnimation(),this._bindGaugeEvents()}function W(t,e){if(this.type="heatmap",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts-Categories: container not found");this.opts=e||{},this.xLabels=e.xLabels||e.xCategories||[],this.yLabels=e.yLabels||e.yCategories||[],this.data=e.data||[];var i=e.colorRange;i&&i.min&&i.max?this.colorRange=[i.min,i.max]:this.colorRange=(Array.isArray(i)?i:null)||["#dbeafe","#1e40af"],this._cellRadius=y(e,"cellRadius",3),this._cellGap=y(e,"cellGap",2),this._showCellValues=y(e,"showCellValues",!0),this._cellFontSize=y(e,"cellFontSize",11),this._height=y(e,"height",s),this._animDuration=y(e,"animDuration",o),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._tooltipEnabled=y(e,"tooltip",!0),this._responsive=y(e,"responsive",!0),this._padding=Object.assign({},a,e.padding||{}),this._hoverCell=null,this._animProgress=0,this._animStart=0,this._rafId=0,this._buildHeatmapDOM(),this._initSize(),this._computeMinMax(),this._startAnimation(),this._bindHeatmapEvents()}function R(t,e){if(this.type="radar",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts-Categories: container not found");if(this.opts=e||{},this.categories=e.categories||[],this._levels=y(e,"levels",5),this._fillOpacity=y(e,"fillOpacity",.2),this._lineWidth=y(e,"lineWidth",2),this._dotRadius=y(e,"dotRadius",4),this._showValues=y(e,"showValues",!1),this._gridStyle=y(e,"gridStyle","polygon"),this._axisLabels=y(e,"axisLabels",!0),this._max=y(e,"max",null),this._height=y(e,"height",s),this._animDuration=y(e,"animDuration",o),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._legendPosition=y(e,"legendPosition","bottom"),this._legendHidden=y(e,"legendHidden",!1),this._tooltipEnabled=y(e,"tooltip",!0),this._responsive=y(e,"responsive",!0),this.series=(e.series||[]).map(function(t,i){var o=e.colors||l;return{name:t.name||"Series "+(i+1),data:t.data||[],color:t.color||o[i%o.length],visible:!0}}),null==this._max){var i=0;this.series.forEach(function(t){t.data.forEach(function(t){t>i&&(i=t)})}),this._max=_(1.1*i)}this._hoverAxis=-1,this._animProgress=0,this._animStart=0,this._rafId=0,this._buildRadarDOM(),this._initSize(),this._startAnimation(),this._bindRadarEvents()}function H(t,e){this._barWidth=y(e,"barWidth",32),this._barOpacity=y(e,"barOpacity",.7),this._lineWidth=y(e,"lineWidth",2.5),this._lineTension=y(e,"lineTension",.4),this._dualAxis=y(e,"dualAxis",!1),w.call(this,t,e,"lineBar")}function B(t,e){this._showTotal=y(e,"showTotal",!0),this._showConnectors=y(e,"showConnectors",!0),this._positiveColor=y(e,"positiveColor","#10b981"),this._negativeColor=y(e,"negativeColor","#ef4444"),this._totalColor=y(e,"totalColor","#6366f1"),w.call(this,t,e,"waterfall")}function D(t,e){this._items=e.items||[],this._rangeColors=y(e,"rangeColors",["#94a3b8","#cbd5e1","#e2e8f0"]),this._markerColor=y(e,"markerColor","#1e293b"),this._barColor=y(e,"barColor","#1e293b"),this._barHeightRatio=y(e,"barHeight",.4),e.categories=this._items.map(function(t){return t.label}),e.series=[{name:"Actual",data:this._items.map(function(t){return t.actual}),color:"#1e293b"}],w.call(this,t,e,"bullet")}function I(t,e){this._segments=e.segments||[],this._barHeight=y(e,"height",60),this._showPercent=y(e,"showPercent",!0),this._showSegValues=y(e,"showValues",!0),this._rounded=y(e,"rounded",!0),this._segGap=y(e,"gap",2),e.height=Math.max(this._barHeight+120,180),e.series=[{name:"Timeline",data:this._segments.map(function(t){return t.value}),color:"#6366f1"}],e.categories=this._segments.map(function(t){return t.label}),e.legendHidden=!0,w.call(this,t,e,"timeline")}function z(t,e){if(this.type="treemap",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts: container not found");this.opts=e||{},this._height=y(e,"height",s),this._animDuration=y(e,"animDuration",o),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._tooltipEnabled=y(e,"tooltip",!0),this._borderRadius=y(e,"cellRadius",3),this._cellGap=y(e,"cellGap",2),this._showLabels=y(e,"showLabels",!0),this._showValues=y(e,"showValues",!0),this._gradient=y(e,"gradient",!0);var i=e.colors||l;this._items=(e.items||[]).map(function(t,e){return{label:t.label||"Item "+(e+1),value:t.value||0,color:t.color||i[e%i.length],children:t.children||null}}),this.series=[],this.categories=[],this._hoverIdx=-1,this._rects=[],this._animProgress=0,this._animStart=0,this._rafId=0,this._legendHidden=!0,this._buildDOM(),this._initSize(),this._startAnimation(),this._bindEvents()}function O(t,e){if(this.type="funnel",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts: container not found");this.opts=e||{},this._height=y(e,"height",s),this._animDuration=y(e,"animDuration",o),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._tooltipEnabled=y(e,"tooltip",!0),this._neckWidth=y(e,"neckWidth",.25),this._gap=y(e,"gap",3),this._showLabels=y(e,"showLabels",!0),this._showValues=y(e,"showValues",!0),this._gradient=y(e,"gradient",!0),this._borderRadius=y(e,"borderRadius",0),this._direction=y(e,"direction","vertical");var i=e.colors||l;this._stages=(e.stages||[]).map(function(t,e){return{label:t.label||"Stage "+(e+1),value:t.value||0,color:t.color||i[e%i.length]}}),this._hoverIdx=-1,this._stageRects=[],this._animProgress=0,this._animStart=0,this._rafId=0,this.series=[],this.categories=[],this._legendHidden=!0,this._buildDOM(),this._initSize(),this._startAnimation(),this._bindEvents()}function G(t,e){if(this.type="polar",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts: container not found");this.opts=e||{},this._height=y(e,"height",s),this._animDuration=y(e,"animDuration",o),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._tooltipEnabled=y(e,"tooltip",!0),this._showLabels=y(e,"showLabels",!0),this._showValues=y(e,"showValues",!0),this._innerRadius=y(e,"innerRadius",.15),this._padAngle=y(e,"padAngle",.02),this._gradient=y(e,"gradient",!0);var i=e.colors||l;this._segments=(e.segments||[]).map(function(t,e){return{label:t.label||"Segment "+(e+1),value:t.value||0,color:t.color||i[e%i.length]}}),this._hoverIdx=-1,this._slices=[],this._animProgress=0,this._animStart=0,this._rafId=0,this.series=[],this.categories=[],this._legendHidden=!0,this._buildDOM(),this._initSize(),this._startAnimation(),this._bindEvents()}function N(t,e){if(this.type="scatter",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts: container not found");this.opts=e||{},this._height=y(e,"height",s),this._animDuration=y(e,"animDuration",o),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._tooltipEnabled=y(e,"tooltip",!0),this._showValues=y(e,"showValues",!1),this._gridLines=y(e,"gridLines",!0),this._gridDashed=y(e,"gridDashed",!0),this._bubbleMode=y(e,"bubbleMode",!1),this._minRadius=y(e,"minRadius",4),this._maxRadius=y(e,"maxRadius",30),this._xLabel=y(e,"xLabel",""),this._yLabel=y(e,"yLabel",""),this._legendHidden=y(e,"legendHidden",!1),this._legendPosition=y(e,"legendPosition","bottom"),this._gradient=y(e,"gradient",!0),this._padding=Object.assign({},{top:30,right:30,bottom:55,left:60},e.padding||{});var i=e.colors||l;this.series=(e.series||[]).map(function(t,e){return{name:t.name||"Series "+(e+1),data:t.data||[],color:t.color||i[e%i.length],visible:!0}}),this.categories=[],this._hoverPoint=null,this._animProgress=0,this._animStart=0,this._rafId=0,this._buildDOM(),this._initSize(),this._startAnimation(),this._bindEvents()}function q(t,e){if(this.type="sankey",this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts: container not found");this.opts=e||{},this._height=y(e,"height",s),this._animDuration=y(e,"animDuration",o),this._toolbar=Object.assign({dark:!0,export:!0},e.toolbar||{}),this._tooltipEnabled=y(e,"tooltip",!0),this._nodeWidth=y(e,"nodeWidth",20),this._nodePadding=y(e,"nodePadding",16),this._gradient=y(e,"gradient",!0),this._showLabels=y(e,"showLabels",!0),this._borderRadius=y(e,"borderRadius",3);var i=e.colors||l;this._nodes=(e.nodes||[]).map(function(t,e){return{name:t.name||t,color:t.color||i[e%i.length]}}),this._links=(e.links||[]).map(function(t){return{source:t.source,target:t.target,value:t.value||0}}),this._hoverLink=-1,this._linkPaths=[],this._nodeRects=[],this._animProgress=0,this._animStart=0,this._rafId=0,this.series=[],this.categories=[],this._legendHidden=!0,this._buildDOM(),this._initSize(),this._computeLayout(),this._startAnimation(),this._bindEvents()}function V(t,e){w.call(this,t,e,"boxplot"),this._boxWidth=y(e,"boxWidth",null),this._whiskerWidth=y(e,"whiskerWidth",.5),this._outlierRadius=y(e,"outlierRadius",3),this._showOutliers=y(e,"showOutliers",!0),this._boxData=e.series&&e.series[0]&&e.series[0].data||[]}function F(t,e,i){this.el="string"==typeof t?document.querySelector(t):t,this.el&&(i=i||{},this._data=e||[],this._type=i.type||"line",this._color=i.color||"#6366f1",this._fillColor=i.fillColor||null,this._width=i.width||this.el.offsetWidth||120,this._height=i.height||i.h||32,this._lineWidth=i.lineWidth||1.5,this._showLast=!1!==i.showLast,this._showMinMax=i.showMinMax||!1,this._barGap=i.barGap||1,this._borderRadius=i.borderRadius||1,this._interactive=i.interactive||!1,this._gradient=!1!==i.gradient,this._build(),this._render(),this._interactive&&this._bind())}function j(t,e){this._charts=t||[],this._opts=e||{},this._active=null,this._bind()}w.prototype._bindEvents=function(){S.call(this),this._enableZoomPan()},w.prototype._computeScale=function(){var t=0,e=this;"barStacked"===this.type||"column"===this.type&&this._stacked?this.categories.forEach(function(i,o){var s=0;e.series.forEach(function(t){t.visible&&o<t.data.length&&(s+=Math.max(0,t.data[o]))}),s>t&&(t=s)}):this.series.forEach(function(e){e.visible&&e.data.forEach(function(e){e>t&&(t=e)})}),this._scaleMax=_(1.1*t),this._step=p(this._scaleMax,5),this._ticks=[];for(var i=0;i<=this._scaleMax;i+=this._step)this._ticks.push(i)},w.prototype._clearAndDrawBackground=function(){var t=d(this.el);this._vars=t;var e=this.ctx;e.clearRect(0,0,this.W,this.H),e.fillStyle=t.card,e.fillRect(0,0,this.W,this.H)},w.prototype._drawStripes=function(){var t=this.ctx,e=this._padding,i=e.left,o=e.top,s=this.W-e.left-e.right,a=this.H-e.top-e.bottom;if(!(this._ticks.length<2))for(var r=0;r<this._ticks.length-1;r++)if(r%2!=0){var l=o+a-this._ticks[r]/this._scaleMax*a,h=o+a-this._ticks[r+1]/this._scaleMax*a;t.fillStyle="rgba(0,0,0,0.015)",t.fillRect(i,h,s,l-h)}},w.prototype._drawVerticalAxes=function(){if(this.categories&&this.categories.length){this._drawStripes();var t=this.ctx,e=this._vars,i=this._padding,o=i.left,s=i.top,a=this.W-i.left-i.right,l=this.H-i.top-i.bottom;t.textAlign="right",t.textBaseline="middle",t.font="500 12px "+r;for(var h=0;h<this._ticks.length;h++){var n=this._ticks[h],d=s+l-n/this._scaleMax*l;this._gridLines&&(t.strokeStyle=this._gridColor||"rgba(226,232,240,0.6)",t.lineWidth=1,this._gridDashed?t.setLineDash([4,4]):t.setLineDash([]),t.beginPath(),t.moveTo(o,d),t.lineTo(o+a,d),t.stroke(),t.setLineDash([])),t.fillStyle=e.muted,t.fillText(v(n),o-8,d)}t.textAlign="center",t.textBaseline="top",t.fillStyle=e.text2,t.font="500 12px "+r;for(var c=a/this.categories.length,_=0;_<this.categories.length;_++){var p=o+c*_+c/2;t.fillText(this.categories[_],p,s+l+8)}}},w.prototype._drawHorizontalStripes=function(){var t=this.ctx,e=this._padding,i=e.left,o=e.top,s=this.W-e.left-e.right,a=this.H-e.top-e.bottom;if(!(this._ticks.length<2))for(var r=0;r<this._ticks.length-1;r++)if(r%2!=0){var l=i+this._ticks[r]/this._scaleMax*s,h=i+this._ticks[r+1]/this._scaleMax*s;t.fillStyle="rgba(0,0,0,0.015)",t.fillRect(l,o,h-l,a)}},w.prototype._drawHorizontalAxes=function(){if(this.categories&&this.categories.length){this._drawHorizontalStripes();var t=this.ctx,e=this._vars,i=this._padding,o=i.left,s=i.top,a=this.W-i.left-i.right,l=this.H-i.top-i.bottom;t.textAlign="center",t.textBaseline="top",t.font="500 12px "+r;for(var h=0;h<this._ticks.length;h++){var n=this._ticks[h],d=o+n/this._scaleMax*a;this._gridLines&&(t.strokeStyle=this._gridColor||"rgba(226,232,240,0.6)",t.lineWidth=1,this._gridDashed?t.setLineDash([4,4]):t.setLineDash([]),t.beginPath(),t.moveTo(d,s),t.lineTo(d,s+l),t.stroke(),t.setLineDash([])),t.fillStyle=e.muted,t.fillText(v(n),d,s+l+8)}t.textAlign="right",t.textBaseline="middle",t.fillStyle=e.text2,t.font="500 12px "+r;for(var c=l/this.categories.length,_=0;_<this.categories.length;_++){var p=s+c*_+c/2;t.fillText(this.categories[_],o-8,p)}}},w.prototype._getBarFill=function(t,e,i,o,s,a){return this._gradient?function(t,e,i,o,s,a,r,l){var h;h=l?t.createLinearGradient(i,o,i,o+a):t.createLinearGradient(i,o,i+s,o);var n=m(e,.25);return h.addColorStop(0,e),h.addColorStop(1,n),h}(this.ctx,t,e,i,o,s,this._gradientOpacity,a):t},w.prototype._drawBarShadow=function(t,e,i,o,s,a,r){t.save(),t.shadowColor=r,t.shadowBlur=8,t.shadowOffsetX=0,t.shadowOffsetY=3,t.fillStyle="rgba(0,0,0,0.01)",t.beginPath(),t.roundRect(e,i,o,s,a),t.fill(),t.restore()},w.prototype._drawBarHighlight=function(t,e,i,o,s,a){t.save(),t.globalAlpha=.25,t.strokeStyle="rgba(255,255,255,0.7)",t.lineWidth=1,t.beginPath(),a?(t.moveTo(e+s,i+1),t.lineTo(e+o-s,i+1)):(t.moveTo(e+o-1,i+s),t.lineTo(e+o-1,i+h-s)),t.stroke(),t.restore()},T.prototype=Object.create(w.prototype),T.prototype.constructor=T,T.prototype.render=function(){if(this._computeScale(),this._clearAndDrawBackground(),this._drawVerticalAxes(),this.categories&&this.categories.length){var t=this.ctx,e=this._vars,i=this._animProgress,o=u(c(i,0,1));o=Math.max(0,o);var s=this._padding,a=s.left,l=s.top,h=this.W-s.left-s.right,n=this.H-s.top-s.bottom,d=this.categories.length,_=this.series.filter(function(t){return t.visible}),p=_.length||1,f=this._borderRadius;if(this._stacked){for(var g=(L=h/d)*(1-this._groupPadding),b=(L-(E=this._barWidth||Math.min(g,60)))/2,m=0;m<d;m++){for(var y=0,x=this._hoverCat===m,M=0;M<_.length;M++){var w=_[M],S=(W=m<w.data.length?Math.max(0,w.data[m]):0)/this._scaleMax*n*o,T=a+L*m+b,k=l+n-y-S,C=[0,0,0,0];M===_.length-1&&(C=[f,f,0,0]),this._drawBarShadow(t,T,k,E,S,C,w.color),t.globalAlpha=x?this._hoverOpacity:this._opacity,t.fillStyle=this._getBarFill(w.color,T,k,E,S,!0),t.beginPath(),t.roundRect(T,k,E,S,C),t.fill(),M===_.length-1&&S>4&&this._drawBarHighlight(t,T,k,E,f,!0),this._borderWidth>0&&(t.strokeStyle=this._borderColor,t.lineWidth=this._borderWidth,t.stroke()),i>=1&&this._stackLabels&&this._showValues&&S>20&&(t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textAlign="center",t.textBaseline="middle",t.fillStyle=this._valueColor||"#fff",t.fillText(v(W),T+E/2,k+S/2)),y+=S}if(i>=1&&this._showTotal&&y>0){var P=0;_.forEach(function(t){m<t.data.length&&(P+=Math.max(0,t.data[m]))}),t.globalAlpha=1,t.font="bold "+this._valueSize+"px "+r,t.textAlign="center",t.textBaseline="bottom",t.fillStyle=e.text2,t.fillText(v(P),a+L*m+b+E/2,l+n-y-4)}}t.globalAlpha=1}else{g=(L=h/d)*(1-this._groupPadding);var L,E=this._barWidth||(g-this._barGap*(p-1))/p,A=(L-((E=Math.min(E,60))*p+this._barGap*(p-1)))/2;this._hitAreas=[];for(M=0;M<_.length;M++)for(w=_[M],m=0;m<d;m++){var W,R=(W=m<w.data.length?w.data[m]:0)/this._scaleMax*n*o;T=a+L*m+A+M*(E+this._barGap),k=l+n-R,x=this._hoverCat===m;this._drawBarShadow(t,T,k,E,R,[f,f,0,0],w.color),x&&(t.save(),t.shadowColor=w.color,t.shadowBlur=12,t.fillStyle="rgba(0,0,0,0.01)",t.beginPath(),t.roundRect(T,k,E,R,[f,f,0,0]),t.fill(),t.restore()),t.globalAlpha=x?this._hoverOpacity:this._opacity,t.fillStyle=this._getBarFill(w.color,T,k,E,R,!0),t.beginPath(),t.roundRect(T,k,E,R,[f,f,0,0]),t.fill(),R>4&&this._drawBarHighlight(t,T,k,E,f,!0),this._borderWidth>0&&(t.strokeStyle=this._borderColor,t.lineWidth=this._borderWidth,t.stroke()),this._hitAreas.push({ci:m,si:M,x:T,y:k,w:E,h:R,series:w}),i>=1&&this._showValues&&(t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textAlign="center",t.textBaseline=R>20?"top":"bottom",this._valueColor?t.fillStyle=this._valueColor:t.fillStyle=R>20?"#fff":e.text2,t.fillText(v(W),T+E/2,R>20?k+4:k-4))}t.globalAlpha=1,this._drawAnnotations()}}},T.prototype._onHover=function(t,e){var i=this._hoverCat;this._hoverCat=-1;var o=this._padding,s=o.left,a=this.W-o.left-o.right,r=a/this.categories.length;if(t>=s&&t<=s+a&&e>=o.top&&e<=this.H-o.bottom&&(this._hoverCat=Math.floor((t-s)/r),this._hoverCat=c(this._hoverCat,0,this.categories.length-1)),this._hoverCat!==i){if(this._hoverCat>=0){var l=[],h=this;this.series.forEach(function(t){t.visible&&h._hoverCat<t.data.length&&l.push({name:t.name,value:t.data[h._hoverCat],color:t.color})}),this._showTooltip(t,e,this.categories[this._hoverCat],l)}else this._hideTooltip();this.render()}},k.prototype=Object.create(w.prototype),k.prototype.constructor=k,k.prototype.render=function(){if(this._computeScale(),this._clearAndDrawBackground(),this._drawHorizontalAxes(),this.categories&&this.categories.length){var t=this.ctx,e=this._vars,i=this._animProgress,o=u(c(i,0,1));o=Math.max(0,o);for(var s=this._padding,a=s.left,l=s.top,h=this.W-s.left-s.right,n=this.H-s.top-s.bottom,d=this.categories.length,_=this.series.filter(function(t){return t.visible}),p=_.length||1,f=this._borderRadius,g=n/d,b=g*(1-this._groupPadding),m=this._barWidth||(b-this._barGap*(p-1))/p,y=(g-((m=Math.min(m,40))*p+this._barGap*(p-1)))/2,x=0;x<_.length;x++)for(var M=_[x],w=0;w<d;w++){var S=w<M.data.length?M.data[w]:0,T=S/this._scaleMax*h*o,k=l+g*w+y+x*(m+this._barGap),C=a,P=this._hoverCat===w;if(this._drawBarShadow(t,C,k,T,m,[0,f,f,0],M.color),P&&(t.save(),t.shadowColor=M.color,t.shadowBlur=12,t.fillStyle="rgba(0,0,0,0.01)",t.beginPath(),t.roundRect(C,k,T,m,[0,f,f,0]),t.fill(),t.restore()),t.globalAlpha=P?this._hoverOpacity:this._opacity,t.fillStyle=this._getBarFill(M.color,C,k,T,m,!1),t.beginPath(),t.roundRect(C,k,T,m,[0,f,f,0]),t.fill(),T>4&&(t.save(),t.globalAlpha=.25,t.strokeStyle="rgba(255,255,255,0.7)",t.lineWidth=1,t.beginPath(),t.moveTo(C+T-1,k+f),t.lineTo(C+T-1,k+m-f),t.stroke(),t.restore()),this._borderWidth>0&&(t.strokeStyle=this._borderColor,t.lineWidth=this._borderWidth,t.stroke()),i>=1&&this._showValues){t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textBaseline="middle";var L=k+m/2;T>40?(t.textAlign="right",t.fillStyle=this._valueColor||"#fff",t.fillText(v(S),C+T-6,L)):(t.textAlign="left",t.fillStyle=this._valueColor||e.text2,t.fillText(v(S),C+T+6,L))}}t.globalAlpha=1}},k.prototype._onHover=function(t,e){var i=this._hoverCat;this._hoverCat=-1;var o=this._padding,s=this.H-o.top-o.bottom,a=s/this.categories.length;if(e>=o.top&&e<=o.top+s&&t>=o.left&&(this._hoverCat=Math.floor((e-o.top)/a),this._hoverCat=c(this._hoverCat,0,this.categories.length-1)),this._hoverCat!==i){if(this._hoverCat>=0){var r=[],l=this;this.series.forEach(function(t){t.visible&&l._hoverCat<t.data.length&&r.push({name:t.name,value:t.data[l._hoverCat],color:t.color})}),this._showTooltip(t,e,this.categories[this._hoverCat],r)}else this._hideTooltip();this.render()}},C.prototype=Object.create(w.prototype),C.prototype.constructor=C,C.prototype.render=function(){if(this._computeScale(),this._clearAndDrawBackground(),this._drawHorizontalAxes(),this.categories&&this.categories.length){var t=this.ctx,e=this._vars,i=this._animProgress,o=u(c(i,0,1));o=Math.max(0,o);for(var s=this._padding,a=s.left,l=s.top,h=this.W-s.left-s.right,n=this.H-s.top-s.bottom,d=this.categories.length,_=this._borderRadius,p=n/d,f=p*(1-this._groupPadding),g=(p-(f=Math.min(f,40)))/2,b=this.series.filter(function(t){return t.visible}),m=0;m<d;m++){for(var y=a,x=this._hoverCat===m,M=0;M<b.length;M++){var w=b[M],S=m<w.data.length?Math.max(0,w.data[m]):0,T=S/this._scaleMax*h*o,k=l+p*m+g,C=[0,0,0,0];M===b.length-1&&(C=[0,_,_,0]),0===M&&(C[0]=0,C[3]=0),this._drawBarShadow(t,y,k,T,f,C,w.color),t.globalAlpha=x?this._hoverOpacity:this._opacity,t.fillStyle=this._getBarFill(w.color,y,k,T,f,!1),t.beginPath(),t.roundRect(y,k,T,f,C),t.fill(),this._borderWidth>0&&(t.strokeStyle=this._borderColor,t.lineWidth=this._borderWidth,t.stroke()),i>=1&&this._stackLabels&&this._showValues&&T>30&&(t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textAlign="center",t.textBaseline="middle",t.fillStyle=this._valueColor||"#fff",t.fillText(v(S),y+T/2,k+f/2)),y+=T}if(i>=1&&this._showTotal){var P=0;b.forEach(function(t){m<t.data.length&&(P+=Math.max(0,t.data[m]))}),t.globalAlpha=1,t.font="bold "+this._valueSize+"px "+r,t.textAlign="left",t.textBaseline="middle",t.fillStyle=e.text2,t.fillText(v(P),y+6,l+p*m+g+f/2)}}t.globalAlpha=1}},C.prototype._onHover=k.prototype._onHover,P.prototype=Object.create(w.prototype),P.prototype.constructor=P,P.prototype.render=function(){if(this._computeScale(),this._clearAndDrawBackground(),this._drawVerticalAxes(),this.categories&&this.categories.length){var t=this.ctx,e=this._vars,i=this._animProgress,o=u(c(i,0,1));o=Math.max(0,o);for(var s=this._padding,a=s.left,l=s.top,h=this.W-s.left-s.right,n=this.H-s.top-s.bottom,d=this.categories.length,_=this.series.filter(function(t){return t.visible}),p=_.length||1,f=h/d,g=Math.min(f/(p+1),28),x=g*(p-1),M=l+n,w=y(this.opts,"dotRadius",6),S=y(this.opts,"stemWidth",2),T=y(this.opts,"stemDashed",!1),k=y(this.opts,"dotBorder",!0),C=y(this.opts,"dotBorderWidth",2),P=0;P<_.length;P++)for(var L=_[P],E=0;E<d;E++){var A=E<L.data.length?L.data[E]:0,W=a+f*E+f/2-x/2+g*P,R=M-A/this._scaleMax*n*o,H=this._hoverCat===E;t.globalAlpha=H?this._hoverOpacity:.8;var B=t.createLinearGradient(W,M,W,R),D=b(L.color);B.addColorStop(0,"rgba("+D[0]+","+D[1]+","+D[2]+",0.3)"),B.addColorStop(1,"rgba("+D[0]+","+D[1]+","+D[2]+",0.8)"),t.strokeStyle=B,t.lineWidth=S,T?t.setLineDash([4,4]):t.setLineDash([]),t.beginPath(),t.moveTo(W,M),t.lineTo(W,R),t.stroke(),t.setLineDash([]),t.save(),t.shadowColor=L.color,t.shadowBlur=6,t.shadowOffsetY=2,t.fillStyle="rgba(0,0,0,0.01)",t.beginPath(),t.arc(W,R,w,0,2*Math.PI),t.fill(),t.restore();var I=t.createRadialGradient(W-.3*w,R-.3*w,0,W,R,w);I.addColorStop(0,m(L.color,.35)),I.addColorStop(1,L.color),t.fillStyle=I,t.beginPath(),t.arc(W,R,w,0,2*Math.PI),t.fill(),k&&(t.strokeStyle=e.card,t.lineWidth=C,t.stroke()),i>=1&&this._showValues&&(t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textAlign="center",t.textBaseline="bottom",t.fillStyle=this._valueColor||e.text2,t.fillText(v(A),W,R-w-3))}t.globalAlpha=1}},P.prototype._onHover=T.prototype._onHover,L.prototype=Object.create(w.prototype),L.prototype.constructor=L,L.prototype.render=function(){if(this._computeScale(),this._clearAndDrawBackground(),this._drawVerticalAxes(),this.categories&&this.categories.length){var t=this.ctx,e=this._vars,i=this._animProgress,o=u(c(i,0,1));o=Math.max(0,o);var s=this._padding,a=s.left,l=s.top,h=this.W-s.left-s.right,n=this.H-s.top-s.bottom,d=this.categories.length,_=l+n,p=h/d,f=y(this.opts,"lineWidth",2.5),g=y(this.opts,"lineTension",.3),x=y(this.opts,"lineStyle","solid"),M=y(this.opts,"showArea",!1),w=y(this.opts,"areaOpacity",.15),S=[],T=[];this.series.forEach(function(t){t.visible&&("line"===t.type?T.push(t):S.push(t))});for(var k=S.length||1,C=Math.min(p/(k+1),28),P=C*(k-1),L=y(this.opts,"dotRadius",6),E=0;E<S.length;E++)for(var A=S[E],W=0;W<d;W++){var R=(W<A.data.length?A.data[W]:0)/this._scaleMax*n*o,H=a+p*W+p/2-P/2+C*E,B=_-R,D=this._hoverCat===W;t.globalAlpha=D?this._hoverOpacity:.8;var I=t.createLinearGradient(H,_,H,B),z=b(A.color);I.addColorStop(0,"rgba("+z[0]+","+z[1]+","+z[2]+",0.3)"),I.addColorStop(1,"rgba("+z[0]+","+z[1]+","+z[2]+",0.8)"),t.strokeStyle=I,t.lineWidth=2,t.beginPath(),t.moveTo(H,_),t.lineTo(H,B),t.stroke();var O=t.createRadialGradient(H-.3*L,B-.3*L,0,H,B,L);O.addColorStop(0,m(A.color,.35)),O.addColorStop(1,A.color),t.fillStyle=O,t.beginPath(),t.arc(H,B,L,0,2*Math.PI),t.fill()}for(var G=0;G<T.length;G++){var N=T[G];t.globalAlpha=1;for(var q=[],V=0;V<d;V++){var F=V<N.data.length?N.data[V]:0,j=a+p*V+p/2,X=_-F/this._scaleMax*n*o;q.push({x:j,y:X})}if("dashed"===x?t.setLineDash([8,4]):"dotted"===x?t.setLineDash([2,4]):t.setLineDash([]),M&&q.length>1){var Y=t.createLinearGradient(0,l,0,_),Z=b(N.color);if(Y.addColorStop(0,"rgba("+Z[0]+","+Z[1]+","+Z[2]+","+1.5*w+")"),Y.addColorStop(.7,"rgba("+Z[0]+","+Z[1]+","+Z[2]+","+.3*w+")"),Y.addColorStop(1,"rgba("+Z[0]+","+Z[1]+","+Z[2]+",0)"),t.globalAlpha=1,t.fillStyle=Y,t.beginPath(),t.moveTo(q[0].x,_),g>0&&q.length>2){t.lineTo(q[0].x,q[0].y);for(var J=0;J<q.length-1;J++){var Q=q[J],U=q[J+1],K=Q.x+(U.x-Q.x)*g,$=U.x-(U.x-Q.x)*g;t.bezierCurveTo(K,Q.y,$,U.y,U.x,U.y)}}else for(var tt=0;tt<q.length;tt++)t.lineTo(q[tt].x,q[tt].y);t.lineTo(q[q.length-1].x,_),t.closePath(),t.fill(),t.globalAlpha=1}if(t.save(),t.shadowColor=N.color,t.shadowBlur=6,t.shadowOffsetY=2,t.strokeStyle=N.color,t.lineWidth=f,t.lineJoin="round",t.lineCap="round",t.beginPath(),g>0&&q.length>2){t.moveTo(q[0].x,q[0].y);for(var et=0;et<q.length-1;et++){var it=q[et],ot=q[et+1],st=it.x+(ot.x-it.x)*g,at=ot.x-(ot.x-it.x)*g;t.bezierCurveTo(st,it.y,at,ot.y,ot.x,ot.y)}}else for(var rt=0;rt<q.length;rt++)0===rt?t.moveTo(q[rt].x,q[rt].y):t.lineTo(q[rt].x,q[rt].y);t.stroke(),t.restore(),t.setLineDash([]);for(var lt=0;lt<q.length;lt++)t.fillStyle=N.color,t.beginPath(),t.arc(q[lt].x,q[lt].y,4,0,2*Math.PI),t.fill(),t.fillStyle=e.card,t.beginPath(),t.arc(q[lt].x,q[lt].y,2,0,2*Math.PI),t.fill()}if(i>=1&&this._hoverCat>=0&&this._showValues){var ht=this._hoverCat;t.font=this._valueSize+"px "+r,t.textAlign="center",t.textBaseline="bottom",t.fillStyle=this._valueColor||e.text2,t.globalAlpha=1,this.series.forEach(function(e){if(e.visible&&!(ht>=e.data.length)){var i=e.data[ht],o=a+p*ht+p/2,s=_-i/this._scaleMax*n;t.fillText(v(i),o,s-10)}}.bind(this))}t.globalAlpha=1}},L.prototype._onHover=T.prototype._onHover,E.prototype._buildDonutDOM=function(){this._root=g("div","mc-root",this.el);var t=g("div","mc-header",this._root),e=g("div","mc-titles",t);this.opts.title&&(g("div","mc-title",e).textContent=this.opts.title);this.opts.subtitle&&(g("div","mc-subtitle",e).textContent=this.opts.subtitle);var i=g("div","mc-toolbar",t),o=this;if(this._toolbar.dark&&(this._darkBtn=g("button","",i),this._darkBtn.innerHTML=x,this._darkBtn.title="Toggle dark mode",this._darkBtn.addEventListener("click",function(){o.el.classList.toggle("mc-dark"),o._darkBtn.classList.toggle("active",o.el.classList.contains("mc-dark")),o.render()})),this._toolbar.export){var s=g("button","",i);s.innerHTML=M,s.title="Export PNG",s.addEventListener("click",function(){o.exportPNG()})}"top"!==this._legendPosition||this._legendHidden||(this._legendEl=g("div","mc-legend",this._root),this._buildDonutLegend()),this._wrap=g("div","mc-wrap",this._root),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this._wrap.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this._tooltipEl=g("div","mc-tooltip",this._wrap),this.segments.length>0&&this._tooltipEl.style.setProperty("--mc-tt-accent",this.segments[0].color),"bottom"!==this._legendPosition||this._legendHidden||(this._legendEl=g("div","mc-legend",this._root),this._buildDonutLegend()),this._legendEl||(this._legendEl=g("div","mc-legend",null),this._legendEl.style.display="none")},E.prototype._buildDonutLegend=function(){this._legendEl.innerHTML="";var t=this;this.segments.forEach(function(e,i){var o=g("div","mc-legend-item",t._legendEl);e.visible||o.classList.add("disabled"),g("div","mc-legend-swatch",o).style.background=e.color,g("span","",o).textContent=e.label,o.addEventListener("click",function(){e.visible=!e.visible,o.classList.toggle("disabled",!e.visible),t.render()})})},E.prototype._initSize=function(){var t=this._wrap.getBoundingClientRect().width,e=Math.max(this._height,380);this.W=t,this.H=e,this.canvas.width=Math.round(t*i),this.canvas.height=Math.round(e*i),this.canvas.style.height=e+"px",this.ctx.setTransform(i,0,0,i,0,0)},E.prototype._startAnimation=w.prototype._startAnimation,E.prototype._bindDonutEvents=function(){var t=this;if(this._boundListeners=this._boundListeners||[],this._responsive){var e,i=function(){clearTimeout(e),e=setTimeout(function(){t._initSize(),t.render()},80)};window.addEventListener("resize",i),this._boundListeners.push({target:window,type:"resize",fn:i})}var o=function(e){var i=t.canvas.getBoundingClientRect();t._onDonutHover(e.clientX-i.left,e.clientY-i.top)},s=function(){t._hoverIndex=-1,t._tooltipEl.classList.remove("visible"),t.render()},a=function(e){var i=t.canvas.getBoundingClientRect(),o=t._hitTest(e.clientX-i.left,e.clientY-i.top);t._selectedIndex=t._selectedIndex===o?-1:o,t.render()};this.canvas.addEventListener("mousemove",o),this.canvas.addEventListener("mouseleave",s),this.canvas.addEventListener("click",a),this._boundListeners.push({target:this.canvas,type:"mousemove",fn:o}),this._boundListeners.push({target:this.canvas,type:"mouseleave",fn:s}),this._boundListeners.push({target:this.canvas,type:"click",fn:a})},E.prototype.destroy=w.prototype.destroy,E.prototype._getTotal=function(){var t=0;return this.segments.forEach(function(e){e.visible&&(t+=e.value)}),t},E.prototype._hitTest=function(t,e){var i=this.W/2,o=this.H/2,s=Math.min(i,o)-30,a=s*this._innerRadius,r=t-i,l=e-o,h=Math.sqrt(r*r+l*l);if(h<a||h>s+12)return-1;var n=Math.atan2(l,r);n<-Math.PI/2&&(n+=2*Math.PI);var d=this._getTotal();if(d<=0)return-1;for(var c=-Math.PI/2,_=0;_<this.segments.length;_++)if(this.segments[_].visible){var p=this.segments[_].value/d*Math.PI*2;if(n>=c&&n<c+p)return _;c+=p}return-1},E.prototype._onDonutHover=function(t,e){var i=this._hoverIndex;if(this._hoverIndex=this._hitTest(t,e),this._hoverIndex!==i){if(this._hoverIndex>=0&&this._tooltipEnabled){var o=this.segments[this._hoverIndex];this._tooltipEl.style.setProperty("--mc-tt-accent",o.color);var s=this._getTotal(),a=s>0?(o.value/s*100).toFixed(1):"0.0",r='<div class="mc-tooltip-date">'+o.label+'</div><div class="mc-tooltip-row"><div class="mc-tooltip-dot" style="background:'+o.color+'"></div><span>'+v(o.value)+'</span><span class="mc-tooltip-val" style="margin-left:8px;font-weight:600">'+a+"%</span></div>";this._tooltipEl.innerHTML=r,this._tooltipEl.classList.add("visible");var l=this._tooltipEl.offsetWidth,h=t+16;h+l>this.W-8&&(h=t-l-16),this._tooltipEl.style.left=h+"px",this._tooltipEl.style.top=e-20+"px"}else this._tooltipEl.classList.remove("visible");this.render()}},E.prototype.render=function(){var t=d(this.el),e=this.ctx;e.clearRect(0,0,this.W,this.H),e.fillStyle=t.card,e.fillRect(0,0,this.W,this.H);var i=f(this._animProgress),o=this._getTotal();if(!(o<=0)){for(var s=this.W/2,a=this.H/2,l=Math.min(s,a)-30,h=l*this._innerRadius,n=-Math.PI/2,c=2*Math.PI*i,_=this._padAngle,p=this._strokeWidth,u="auto"===this._strokeColor?t.card:this._strokeColor,g=0;g<this.segments.length;g++){var b=this.segments[g];if(b.visible){var y=b.value/o*Math.PI*2,x=Math.min(y-_,c-(n+Math.PI/2));if(x<=0)n+=y;else{var M=this._hoverIndex===g,w=this._selectedIndex===g,S=M||w?this._hoverScale:1,T=M||w?8:0,k=n+y/2,C=T*Math.cos(k),P=T*Math.sin(k),L=e.createLinearGradient(s+C+l*Math.cos(n),a+P+l*Math.sin(n),s+C+l*Math.cos(n+x),a+P+l*Math.sin(n+x));L.addColorStop(0,b.color),L.addColorStop(1,m(b.color,.15)),M&&(e.save(),e.shadowColor=b.color,e.shadowBlur=16,e.fillStyle="rgba(0,0,0,0.01)",e.beginPath(),e.arc(s+C,a+P,l*S,n+_/2,n+_/2+x),e.arc(s+C,a+P,h,n+_/2+x,n+_/2,!0),e.closePath(),e.fill(),e.restore()),e.fillStyle=L,e.globalAlpha=M?this._hoverOpacity:this._opacity,e.beginPath(),e.arc(s+C,a+P,l*(S>1?S:1),n+_/2,n+_/2+x),e.arc(s+C,a+P,h,n+_/2+x,n+_/2,!0),e.closePath(),e.fill(),p>0&&(e.strokeStyle=u,e.lineWidth=p,e.stroke()),n+=y}}}if(e.globalAlpha=1,this._innerRadius>0){var E=e.createRadialGradient(s,a,.8*h,s,a,h);E.addColorStop(0,"rgba(0,0,0,0)"),E.addColorStop(1,"rgba(0,0,0,0.06)"),e.fillStyle=E,e.beginPath(),e.arc(s,a,h,0,2*Math.PI),e.fill()}var A=this._centerLabel,W=this._centerSubLabel;if(null==A||null==W)if(this._selectedIndex>=0&&this.segments[this._selectedIndex].visible){var R=this.segments[this._selectedIndex];null==A&&(A=v(R.value)),null==W&&(W=R.label)}else null==A&&(A=v(o)),null==W&&(W="Total");e.textAlign="center",e.textBaseline="middle",e.fillStyle=t.text,e.font="bold 24px "+r,e.fillText(A,s,a-6),e.fillStyle=t.muted,e.font="12px "+r,e.fillText(W,s,a+16)}},E.prototype.exportPNG=w.prototype.exportPNG,A.prototype._buildGaugeDOM=function(){this._root=g("div","mc-root",this.el);var t=g("div","mc-header",this._root),e=g("div","mc-titles",t);this.opts.title&&(g("div","mc-title",e).textContent=this.opts.title);this.opts.subtitle&&(g("div","mc-subtitle",e).textContent=this.opts.subtitle);var i=g("div","mc-toolbar",t),o=this;this._toolbar.dark&&(this._darkBtn=g("button","",i),this._darkBtn.innerHTML=x,this._darkBtn.title="Toggle dark mode",this._darkBtn.addEventListener("click",function(){o.el.classList.toggle("mc-dark"),o._darkBtn.classList.toggle("active",o.el.classList.contains("mc-dark")),o.render()})),this._wrap=g("div","mc-wrap",this._root),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this._wrap.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d")},A.prototype._initSize=function(){var t=this._wrap.getBoundingClientRect().width,e=Math.min(t/2-30,180),o=e+e*this._arcWidth/2+70;o=Math.max(200,Math.min(o,320)),this.W=t,this.H=o,this.canvas.width=Math.round(t*i),this.canvas.height=Math.round(o*i),this.canvas.style.height=o+"px",this.ctx.setTransform(i,0,0,i,0,0)},A.prototype._startAnimation=w.prototype._startAnimation,A.prototype._bindGaugeEvents=function(){var t=this;if(this._boundListeners=this._boundListeners||[],this._responsive){var e,i=function(){clearTimeout(e),e=setTimeout(function(){t._initSize(),t.render()},80)};window.addEventListener("resize",i),this._boundListeners.push({target:window,type:"resize",fn:i})}},A.prototype.destroy=w.prototype.destroy,A.prototype.render=function(){var t=d(this.el),e=this.ctx;e.clearRect(0,0,this.W,this.H),e.fillStyle=t.card,e.fillRect(0,0,this.W,this.H);var i=f(this._animProgress),o=this.W/2,s=this.H-40,a=Math.min(o-30,s-20,180),l=a*this._arcWidth,h=this.max-this.min,n=this;this.zones.forEach(function(t){var i=c((t.from-n.min)/h,0,1),r=c((t.to-n.min)/h,0,1),d=Math.PI+i*Math.PI,_=Math.PI+r*Math.PI;e.beginPath(),e.arc(o,s,a,d,_),e.lineWidth=l,e.strokeStyle=t.color,e.globalAlpha=.25,e.stroke()}),e.globalAlpha=1;var _=c((this.value-this.min)/h,0,1)*i,p=Math.PI+_*Math.PI;if(this.zones.forEach(function(t){var i=c((t.from-n.min)/h,0,1),r=c((t.to-n.min)/h,0,1),d=Math.PI+i*Math.PI,_=Math.PI+r*Math.PI,v=Math.min(_,p);if(!(v<=d)){var f=o+a*Math.cos(d),u=s+a*Math.sin(d),g=o+a*Math.cos(v),b=s+a*Math.sin(v),y=e.createLinearGradient(f,u,g,b);y.addColorStop(0,t.color),y.addColorStop(1,m(t.color,.2)),e.beginPath(),e.arc(o,s,a,d,v),e.lineWidth=l,e.strokeStyle=y,e.lineCap="butt",e.stroke()}}),e.save(),e.globalAlpha=.08,e.beginPath(),e.arc(o,s,a+.35*l,Math.PI,2*Math.PI),e.lineWidth=1.5,e.strokeStyle="#fff",e.stroke(),e.restore(),this._showTicks){e.strokeStyle=t.muted,e.lineWidth=1;for(var u=0;u<=10;u++){var g=u/10,b=Math.PI+g*Math.PI,y=a-l/2-4,x=a-l/2-10,M=o+y*Math.cos(b),w=s+y*Math.sin(b),S=o+x*Math.cos(b),T=s+x*Math.sin(b);e.beginPath(),e.moveTo(M,w),e.lineTo(S,T),e.stroke()}}var k=a-l/2-8,C=Math.PI+_*Math.PI,P=o+k*Math.cos(C),L=s+k*Math.sin(C);e.save(),e.shadowColor="rgba(0,0,0,0.3)",e.shadowBlur=6,e.shadowOffsetY=2,e.strokeStyle=this._needleColor||t.text,e.lineWidth=this._needleWidth,e.lineCap="round",e.beginPath(),e.moveTo(o,s),e.lineTo(P,L),e.stroke(),e.restore(),e.fillStyle=this._needleColor||t.text,e.beginPath(),e.arc(o,s,6,0,2*Math.PI),e.fill(),e.fillStyle=t.card,e.beginPath(),e.arc(o,s,3,0,2*Math.PI),e.fill(),e.textAlign="center",e.textBaseline="bottom",e.fillStyle=t.text,e.font="bold 28px "+r,e.fillText(v(this.value*i),o,s-16),this._unit&&(e.font="13px "+r,e.fillStyle=t.muted,e.fillText(this._unit,o,s-0)),e.font="500 12px "+r,e.fillStyle=t.muted,e.textAlign="center",e.textBaseline="top",e.fillText(v(this.min),o-a,s+6),e.fillText(v(this.max),o+a,s+6)},A.prototype.exportPNG=w.prototype.exportPNG,W.prototype._buildHeatmapDOM=function(){this._root=g("div","mc-root",this.el);var t=g("div","mc-header",this._root),e=g("div","mc-titles",t);this.opts.title&&(g("div","mc-title",e).textContent=this.opts.title);this.opts.subtitle&&(g("div","mc-subtitle",e).textContent=this.opts.subtitle);var i=g("div","mc-toolbar",t),o=this;if(this._toolbar.dark&&(this._darkBtn=g("button","",i),this._darkBtn.innerHTML=x,this._darkBtn.title="Toggle dark mode",this._darkBtn.addEventListener("click",function(){o.el.classList.toggle("mc-dark"),o._darkBtn.classList.toggle("active",o.el.classList.contains("mc-dark")),o.render()})),this._toolbar.export){var s=g("button","",i);s.innerHTML=M,s.title="Export PNG",s.addEventListener("click",function(){o.exportPNG()})}this._wrap=g("div","mc-wrap",this._root),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this._wrap.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this._tooltipEl=g("div","mc-tooltip",this._wrap)},W.prototype._initSize=function(){var t=this._wrap.getBoundingClientRect().width,e=this._padding,o=this.yLabels.length||1,s=Math.max(this._height,e.top+e.bottom+36*o);this.W=t,this.H=s,this.canvas.width=Math.round(t*i),this.canvas.height=Math.round(s*i),this.canvas.style.height=s+"px",this.ctx.setTransform(i,0,0,i,0,0)},W.prototype._startAnimation=w.prototype._startAnimation,W.prototype._computeMinMax=function(){this._dataMin=1/0,this._dataMax=-1/0;for(var t=0;t<this.data.length;t++){var e=this.data[t][2];e<this._dataMin&&(this._dataMin=e),e>this._dataMax&&(this._dataMax=e)}this._dataMin===1/0&&(this._dataMin=0,this._dataMax=1),this._grid={};for(var i=0;i<this.data.length;i++){var o=this.data[i];this._grid[o[0]+","+o[1]]=o[2]}},W.prototype._interpolateColor=function(t){var e=this.colorRange[0],i=this.colorRange[1],o=b(e),s=b(i);return"rgb("+Math.round(o[0]+(s[0]-o[0])*t)+","+Math.round(o[1]+(s[1]-o[1])*t)+","+Math.round(o[2]+(s[2]-o[2])*t)+")"},W.prototype._bindHeatmapEvents=function(){var t=this;if(this._boundListeners=this._boundListeners||[],this._responsive){var e,i=function(){clearTimeout(e),e=setTimeout(function(){t._initSize(),t.render()},80)};window.addEventListener("resize",i),this._boundListeners.push({target:window,type:"resize",fn:i})}var o=function(e){var i=t.canvas.getBoundingClientRect();t._onHeatmapHover(e.clientX-i.left,e.clientY-i.top)},s=function(){t._hoverCell=null,t._tooltipEl.classList.remove("visible"),t.render()};this.canvas.addEventListener("mousemove",o),this.canvas.addEventListener("mouseleave",s),this._boundListeners.push({target:this.canvas,type:"mousemove",fn:o}),this._boundListeners.push({target:this.canvas,type:"mouseleave",fn:s})},W.prototype.destroy=w.prototype.destroy,W.prototype._onHeatmapHover=function(t,e){var i=this._padding,o=i.left+20,s=i.top,a=this.W-o-i.right,r=this.H-i.top-i.bottom,l=a/this.xLabels.length,h=r/this.yLabels.length,n=Math.floor((t-o)/l),d=Math.floor((e-s)/h),c=this._hoverCell;if(n>=0&&n<this.xLabels.length&&d>=0&&d<this.yLabels.length){var _=n+","+d,p=this._grid[_];if(null!=p){if(this._hoverCell={xi:n,yi:d},!c||c.xi!==n||c.yi!==d){if(this._tooltipEnabled){var f='<div class="mc-tooltip-date">'+this.yLabels[d]+" / "+this.xLabels[n]+'</div><div class="mc-tooltip-row"><span style="font-weight:600">'+v(p)+"</span></div>";this._tooltipEl.innerHTML=f,this._tooltipEl.classList.add("visible");var u=this._tooltipEl.offsetWidth,g=t+16;g+u>this.W-8&&(g=t-u-16),this._tooltipEl.style.left=g+"px",this._tooltipEl.style.top=e-20+"px"}this.render()}return}}c&&(this._hoverCell=null,this._tooltipEl.classList.remove("visible"),this.render())},W.prototype.render=function(){var t=d(this.el),e=this.ctx;e.clearRect(0,0,this.W,this.H),e.fillStyle=t.card,e.fillRect(0,0,this.W,this.H);for(var i=f(this._animProgress),o=this._padding,s=o.left+20,a=o.top,l=this.W-s-o.right,h=this.H-o.top-o.bottom,n=this.xLabels.length,_=this.yLabels.length,p=l/n,u=h/_,g=this._cellGap,b=this._dataMax-this._dataMin||1,m=this._cellRadius,y=0;y<_;y++)for(var x=0;x<n;x++){var M=x+","+y,w=this._grid[M];if(null!=w){var S=c((w-this._dataMin)/b,0,1)*i,T=s+x*p+g/2,k=a+y*u+g/2,C=p-g,P=u-g,L=this._hoverCell&&this._hoverCell.xi===x&&this._hoverCell.yi===y;e.save(),e.shadowColor="rgba(0,0,0,0.08)",e.shadowBlur=2,e.shadowOffsetY=1,e.fillStyle=this._interpolateColor(S),e.globalAlpha=L?1:.9,e.beginPath(),e.roundRect(T,k,C,P,m),e.fill(),e.restore(),L&&(e.save(),e.shadowColor="rgba(255,255,255,0.8)",e.shadowBlur=8,e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),e.roundRect(T,k,C,P,m),e.stroke(),e.restore()),this._showCellValues&&i>=.8&&C>20&&P>16&&(e.globalAlpha=1,e.font=this._cellFontSize+"px "+r,e.textAlign="center",e.textBaseline="middle",e.fillStyle=S>.55?"#fff":t.text,e.fillText(v(w),T+C/2,k+P/2))}}e.globalAlpha=1,e.textAlign="center",e.textBaseline="bottom",e.font="500 12px "+r,e.fillStyle=t.text2;for(var E=0;E<n;E++)e.fillText(this.xLabels[E],s+E*p+p/2,a-6);e.textAlign="right",e.textBaseline="middle";for(var A=0;A<_;A++)e.fillText(this.yLabels[A],s-8,a+A*u+u/2)},W.prototype.exportPNG=w.prototype.exportPNG,R.prototype._buildRadarDOM=function(){this._root=g("div","mc-root",this.el);var t=g("div","mc-header",this._root),e=g("div","mc-titles",t);this.opts.title&&(g("div","mc-title",e).textContent=this.opts.title);this.opts.subtitle&&(g("div","mc-subtitle",e).textContent=this.opts.subtitle);var i=g("div","mc-toolbar",t),o=this;if(this._toolbar.dark&&(this._darkBtn=g("button","",i),this._darkBtn.innerHTML=x,this._darkBtn.title="Toggle dark mode",this._darkBtn.addEventListener("click",function(){o.el.classList.toggle("mc-dark"),o._darkBtn.classList.toggle("active",o.el.classList.contains("mc-dark")),o.render()})),this._toolbar.export){var s=g("button","",i);s.innerHTML=M,s.title="Export PNG",s.addEventListener("click",function(){o.exportPNG()})}"top"!==this._legendPosition||this._legendHidden||(this._legendEl=g("div","mc-legend",this._root),this._buildRadarLegend()),this._wrap=g("div","mc-wrap",this._root),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this._wrap.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this._tooltipEl=g("div","mc-tooltip",this._wrap),this.series.length>0&&this._tooltipEl.style.setProperty("--mc-tt-accent",this.series[0].color),"bottom"!==this._legendPosition||this._legendHidden||(this._legendEl=g("div","mc-legend",this._root),this._buildRadarLegend()),this._legendEl||(this._legendEl=g("div","mc-legend",null),this._legendEl.style.display="none")},R.prototype._buildRadarLegend=function(){this._legendEl.innerHTML="";var t=this;this.series.forEach(function(e,i){var o=g("div","mc-legend-item",t._legendEl);e.visible||o.classList.add("disabled"),g("div","mc-legend-swatch",o).style.background=e.color,g("span","",o).textContent=e.name,o.addEventListener("click",function(){e.visible=!e.visible,o.classList.toggle("disabled",!e.visible),t.render()})})},R.prototype._initSize=function(){var t=this._wrap.getBoundingClientRect().width,e=Math.max(this._height,380);this.W=t,this.H=e,this.canvas.width=Math.round(t*i),this.canvas.height=Math.round(e*i),this.canvas.style.height=e+"px",this.ctx.setTransform(i,0,0,i,0,0)},R.prototype._startAnimation=w.prototype._startAnimation,R.prototype._bindRadarEvents=function(){var t=this;if(this._boundListeners=this._boundListeners||[],this._responsive){var e,i=function(){clearTimeout(e),e=setTimeout(function(){t._initSize(),t.render()},80)};window.addEventListener("resize",i),this._boundListeners.push({target:window,type:"resize",fn:i})}var o=function(e){var i=t.canvas.getBoundingClientRect();t._onRadarHover(e.clientX-i.left,e.clientY-i.top)},s=function(){t._hoverAxis=-1,t._tooltipEl.classList.remove("visible"),t.render()};this.canvas.addEventListener("mousemove",o),this.canvas.addEventListener("mouseleave",s),this._boundListeners.push({target:this.canvas,type:"mousemove",fn:o}),this._boundListeners.push({target:this.canvas,type:"mouseleave",fn:s})},R.prototype.destroy=w.prototype.destroy,R.prototype._onRadarHover=function(t,e){var i=this.W/2,o=this.H/2,s=Math.min(i,o)-60,a=this.categories.length;if(0!==a){var r=t-i,l=e-o;if(Math.sqrt(r*r+l*l)>s+30)this._hoverAxis>=0&&(this._hoverAxis=-1,this._tooltipEl.classList.remove("visible"),this.render());else{for(var h=Math.atan2(l,r),n=-Math.PI/2,d=2*Math.PI/a,_=-1,p=1/0,f=0;f<a;f++){var u=n+d*f,g=Math.abs(Math.atan2(Math.sin(h-u),Math.cos(h-u)));g<p&&(p=g,_=f)}p>d/2&&(_=-1);var b=this._hoverAxis;if(this._hoverAxis=_,this._hoverAxis!==b){if(this._hoverAxis>=0&&this._tooltipEnabled){var m=[],y=this;if(this.series.forEach(function(t){t.visible&&y._hoverAxis<t.data.length&&m.push({name:t.name,value:t.data[y._hoverAxis],color:t.color})}),m.length>0){this._tooltipEl.style.setProperty("--mc-tt-accent",m[0].color);var x='<div class="mc-tooltip-date">'+this.categories[this._hoverAxis]+"</div>";m.forEach(function(t){x+='<div class="mc-tooltip-row"><div class="mc-tooltip-dot" style="background:'+t.color+'"></div><span>'+t.name+'</span><span class="mc-tooltip-val" style="margin-left:8px;font-weight:600">'+v(t.value)+"</span></div>"}),this._tooltipEl.innerHTML=x,this._tooltipEl.classList.add("visible");var M=this._tooltipEl.offsetWidth,w=t+16;w+M>this.W-8&&(w=t-M-16);var S=e-this._tooltipEl.offsetHeight/2;S=c(S,4,this.H-this._tooltipEl.offsetHeight-4),this._tooltipEl.style.left=w+"px",this._tooltipEl.style.top=S+"px"}}else this._tooltipEl.classList.remove("visible");this.render()}}}},R.prototype.render=function(){var t=d(this.el),e=this.ctx;e.clearRect(0,0,this.W,this.H),e.fillStyle=t.card,e.fillRect(0,0,this.W,this.H);var i=this._animProgress,o=u(c(i,0,1));o=Math.max(0,o);var s=this.W/2,a=this.H/2,l=Math.min(s,a)-60,h=this.categories.length;if(0!==h){for(var n=-Math.PI/2,_=2*Math.PI/h,p=this._max,f=1;f<=this._levels;f++){var g=l/this._levels*f;if(e.strokeStyle="rgba(226,232,240,0.6)",e.lineWidth=1,e.beginPath(),"circle"===this._gridStyle)e.arc(s,a,g,0,2*Math.PI);else{for(var y=0;y<=h;y++){var x=n+_*(y%h),M=s+g*Math.cos(x),w=a+g*Math.sin(x);0===y?e.moveTo(M,w):e.lineTo(M,w)}e.closePath()}if(e.stroke(),f<this._levels||f===this._levels){var S=p/this._levels*f;e.font="10px "+r,e.fillStyle=t.muted,e.textAlign="left",e.textBaseline="bottom",e.fillText(v(S),s+4,a-g-2)}}for(y=0;y<h;y++){x=n+_*y;var T=s+l*Math.cos(x),k=a+l*Math.sin(x);e.strokeStyle="rgba(226,232,240,0.4)",e.lineWidth=1,e.beginPath(),e.moveTo(s,a),e.lineTo(T,k),e.stroke(),this._hoverAxis===y&&(e.strokeStyle="rgba(99,102,241,0.3)",e.lineWidth=2,e.beginPath(),e.moveTo(s,a),e.lineTo(T,k),e.stroke())}if(this._axisLabels){e.font="500 12px "+r,e.fillStyle=t.text2;for(y=0;y<h;y++){x=n+_*y;var C=l+18,P=s+C*Math.cos(x),L=a+C*Math.sin(x);Math.abs(Math.cos(x))<.1?e.textAlign="center":Math.cos(x)>0?e.textAlign="left":e.textAlign="right",Math.abs(Math.sin(x))<.1?e.textBaseline="middle":Math.sin(x)>0?e.textBaseline="top":e.textBaseline="bottom",this._hoverAxis===y?(e.fillStyle=t.text,e.font="600 12px "+r):(e.fillStyle=t.text2,e.font="500 12px "+r),e.fillText(this.categories[y],P,L)}}for(var E=this.series.filter(function(t){return t.visible}),A=0;A<E.length;A++){var W=E[A],R=[];for(y=0;y<h;y++){x=n+_*y;var H=(z=y<W.data.length?W.data[y]:0)/p*l*o;R.push({x:s+H*Math.cos(x),y:a+H*Math.sin(x)})}var B=b(W.color);e.globalAlpha=this._fillOpacity,e.fillStyle="rgba("+B[0]+","+B[1]+","+B[2]+","+this._fillOpacity+")",e.beginPath();for(y=0;y<=h;y++){var D=R[y%h];0===y?e.moveTo(D.x,D.y):e.lineTo(D.x,D.y)}e.closePath(),e.globalAlpha=1,e.fill(),e.save(),e.shadowColor=W.color,e.shadowBlur=4,e.strokeStyle=W.color,e.lineWidth=this._lineWidth,e.lineJoin="round",e.beginPath();for(y=0;y<=h;y++){D=R[y%h];0===y?e.moveTo(D.x,D.y):e.lineTo(D.x,D.y)}e.closePath(),e.stroke(),e.restore();for(y=0;y<h;y++){D=R[y];this._hoverAxis===y&&(e.save(),e.shadowColor=W.color,e.shadowBlur=8,e.fillStyle=W.color,e.beginPath(),e.arc(D.x,D.y,this._dotRadius+2,0,2*Math.PI),e.fill(),e.restore());var I=e.createRadialGradient(D.x-.3*this._dotRadius,D.y-.3*this._dotRadius,0,D.x,D.y,this._dotRadius);if(I.addColorStop(0,m(W.color,.3)),I.addColorStop(1,W.color),e.fillStyle=I,e.beginPath(),e.arc(D.x,D.y,this._dotRadius,0,2*Math.PI),e.fill(),e.strokeStyle=t.card,e.lineWidth=1.5,e.stroke(),this._showValues&&i>=1){var z=y<W.data.length?W.data[y]:0;e.font="10px "+r,e.fillStyle=t.text2,e.textAlign="center",e.textBaseline="bottom",e.fillText(v(z),D.x,D.y-this._dotRadius-3)}}}}},R.prototype.exportPNG=w.prototype.exportPNG,CanvasRenderingContext2D.prototype.roundRect||(CanvasRenderingContext2D.prototype.roundRect=function(t,e,i,o,s){Array.isArray(s)||(s=[s,s,s,s]);var a=s[0]||0,r=s[1]||0,l=s[2]||0,h=s[3]||0;return this.moveTo(t+a,e),this.lineTo(t+i-r,e),this.quadraticCurveTo(t+i,e,t+i,e+r),this.lineTo(t+i,e+o-l),this.quadraticCurveTo(t+i,e+o,t+i-l,e+o),this.lineTo(t+h,e+o),this.quadraticCurveTo(t,e+o,t,e+o-h),this.lineTo(t,e+a),this.quadraticCurveTo(t,e,t+a,e),this.closePath(),this}),H.prototype=Object.create(w.prototype),H.prototype.constructor=H,H.prototype._computeScale=function(){var t=0,e=0;this.series.forEach(function(i){i.visible&&i.data.forEach(function(o){null!=o&&("line"===i.type?o>e&&(e=o):o>t&&(t=o))})}),this._barScaleMax=_(1.15*t),this._barStep=p(this._barScaleMax,5),this._barTicks=[];for(var i=0;i<=this._barScaleMax;i+=this._barStep)this._barTicks.push(i);if(this._dualAxis){this._lineScaleMax=_(1.15*e),this._lineStep=p(this._lineScaleMax,5),this._lineTicks=[];for(var o=0;o<=this._lineScaleMax;o+=this._lineStep)this._lineTicks.push(o)}else{var s=Math.max(t,e);this._barScaleMax=_(1.15*s),this._barStep=p(this._barScaleMax,5),this._barTicks=[];for(var a=0;a<=this._barScaleMax;a+=this._barStep)this._barTicks.push(a);this._lineScaleMax=this._barScaleMax,this._lineTicks=this._barTicks}this._scaleMax=this._barScaleMax,this._ticks=this._barTicks},H.prototype.render=function(){if(this._computeScale(),this._clearAndDrawBackground(),this.categories&&this.categories.length){var t=this.ctx,e=this._vars,i=u(c(this._animProgress,0,1));i=Math.max(0,i);var o=this._padding,s=o.left,a=o.top,l=this._dualAxis?60:o.right,h=this.W-o.left-l,n=this.H-o.top-o.bottom,d=this.categories.length,_=h/d,p=a+n,f=this._borderRadius;if(this._barTicks.length>=2)for(var g=0;g<this._barTicks.length-1;g++)if(g%2!=0){var b=a+n-this._barTicks[g]/this._barScaleMax*n,m=a+n-this._barTicks[g+1]/this._barScaleMax*n;t.fillStyle="rgba(0,0,0,0.015)",t.fillRect(s,m,h,b-m)}t.textAlign="right",t.textBaseline="middle",t.font="500 12px "+r;for(var y=0;y<this._barTicks.length;y++){var x=this._barTicks[y],M=a+n-x/this._barScaleMax*n;this._gridLines&&(t.strokeStyle=this._gridColor||"rgba(226,232,240,0.6)",t.lineWidth=1,t.setLineDash(this._gridDashed?[4,4]:[]),t.beginPath(),t.moveTo(s,M),t.lineTo(s+h,M),t.stroke(),t.setLineDash([])),t.fillStyle=e.muted,t.fillText(v(x),s-8,M)}if(this._dualAxis){t.textAlign="left";for(var w=0;w<this._lineTicks.length;w++){var S=this._lineTicks[w],T=a+n-S/this._lineScaleMax*n;t.fillStyle=e.muted,t.fillText(v(S),s+h+8,T)}}t.textAlign="center",t.textBaseline="top",t.fillStyle=e.text2,t.font="500 12px "+r;for(var k=0;k<d;k++)t.fillText(this.categories[k],s+_*k+_/2,p+8);var C=[],P=[];this.series.forEach(function(t){t.visible&&("line"===t.type?P.push(t):C.push(t))});var L=C.length||1,E=this._barWidth||Math.min(.6*_/L,60),A=(_-(E*L+this._barGap*(L-1)))/2;this._hitAreas=[];for(var W=0;W<C.length;W++)for(var R=C[W],H=0;H<d;H++){var B=H<R.data.length?R.data[H]:null;if(null!=B){var D=B/this._barScaleMax*n*i,I=s+_*H+A+W*(E+this._barGap),z=p-D,O=this._hoverCat===H;this._drawBarShadow(t,I,z,E,D,[f,f,0,0],R.color),t.globalAlpha=O?this._hoverOpacity:this._barOpacity,t.fillStyle=this._getBarFill(R.color,I,z,E,D,!0),t.beginPath(),t.roundRect(I,z,E,D,[f,f,0,0]),t.fill(),D>4&&this._drawBarHighlight(t,I,z,E,f,!0),this._hitAreas.push({ci:H,si:W,x:I,y:z,w:E,h:D,series:R})}}t.globalAlpha=1;for(var G=this._dualAxis?this._lineScaleMax:this._barScaleMax,N=0;N<P.length;N++){for(var q=P[N],V=[],F=0;F<d;F++){var j=F<q.data.length?q.data[F]:null;null!=j&&V.push({x:s+_*F+_/2,y:p-j/G*n*i})}if(!(V.length<2)){t.save(),t.shadowColor=q.color,t.shadowBlur=8,t.shadowOffsetY=2,t.strokeStyle=q.color,t.lineWidth=this._lineWidth,t.lineJoin="round",t.lineCap="round",t.beginPath();var X=this._lineTension;if(X>0&&V.length>2){t.moveTo(V[0].x,V[0].y);for(var Y=0;Y<V.length-1;Y++){var Z=V[Y],J=V[Y+1];t.bezierCurveTo(Z.x+(J.x-Z.x)*X,Z.y,J.x-(J.x-Z.x)*X,J.y,J.x,J.y)}}else{t.moveTo(V[0].x,V[0].y);for(var Q=1;Q<V.length;Q++)t.lineTo(V[Q].x,V[Q].y)}t.stroke(),t.restore();for(var U=0;U<V.length;U++)t.fillStyle=q.color,t.beginPath(),t.arc(V[U].x,V[U].y,5,0,2*Math.PI),t.fill(),t.fillStyle=e.card,t.beginPath(),t.arc(V[U].x,V[U].y,2.5,0,2*Math.PI),t.fill()}}t.globalAlpha=1,this._drawAnnotations()}},H.prototype._onHover=T.prototype._onHover,B.prototype=Object.create(w.prototype),B.prototype.constructor=B,B.prototype._computeScale=function(){for(var t=this.series.length>0?this.series[0].data:[],e=0,i=0,o=0,s=0;s<t.length;s++)(e+=t[s])>o&&(o=e),e<i&&(i=e);var a=e;this._showTotal&&a>o&&(o=a),this._showTotal&&a<i&&(i=a);var r=Math.max(Math.abs(i),Math.abs(o));this._scaleMax=_(1.15*r),this._scaleMin=i<0?-_(1.15*Math.abs(i)):0;var l=this._scaleMax-this._scaleMin;this._step=p(l,5),this._ticks=[];for(var h=this._scaleMin;h<=this._scaleMax;h+=this._step)this._ticks.push(Math.round(100*h)/100)},B.prototype.render=function(){this._computeScale(),this._clearAndDrawBackground();var t=this.ctx,e=this._vars,i=this._animProgress,o=u(c(i,0,1));o=Math.max(0,o);for(var s=this._padding,a=s.left,l=s.top,h=this.W-s.left-s.right,n=this.H-s.top-s.bottom,d=this.series.length>0?this.series[0].data:[],_=this.categories.slice(),p=d.slice(),f=0,g=0;g<d.length;g++)f+=d[g];this._showTotal&&(_.push("Total"),p.push(f));var b=_.length,m=h/b,y=this._barWidth||Math.min(.6*m,60),x=this._scaleMax-this._scaleMin,M=this._borderRadius;function w(t){return l+n-(t-this._scaleMin)/x*n}var S=this;t.textAlign="right",t.textBaseline="middle",t.font="500 12px "+r;for(var T=0;T<this._ticks.length;T++){var k=this._ticks[T],C=w.call(S,k);this._gridLines&&(t.strokeStyle=this._gridColor||"rgba(226,232,240,0.6)",t.lineWidth=1,t.setLineDash(this._gridDashed?[4,4]:[]),t.beginPath(),t.moveTo(a,C),t.lineTo(a+h,C),t.stroke(),t.setLineDash([])),t.fillStyle=e.muted,t.fillText(v(k),a-8,C)}t.textAlign="center",t.textBaseline="top",t.fillStyle=e.text2,t.font="500 12px "+r;for(var P=0;P<b;P++)t.fillText(_[P],a+m*P+m/2,l+n+8);var L=0,E=w.call(S,0);this._hitAreas=[];for(var A=0;A<b;A++){var W,R,H,B,D=this._showTotal&&A===b-1;if(D)R=w.call(S,0),H=w.call(S,f*o),B=this._totalColor;else{var I=L;L+=W=d[A],R=w.call(S,I*o),H=w.call(S,L*o),B=W>=0?this._positiveColor:this._negativeColor}var z=a+m*A+(m-y)/2,O=Math.min(R,H),G=Math.max(R,H),N=G-O,q=this._hoverCat===A;if(this._showConnectors&&A>0&&!D&&(t.strokeStyle=e.muted,t.lineWidth=1,t.setLineDash([3,3]),t.beginPath(),t.moveTo(a+m*(A-1)+(m+y)/2,E),t.lineTo(z,E),t.stroke(),t.setLineDash([])),E=D?w.call(S,f*o):w.call(S,L*o),this._drawBarShadow(t,z,O,y,N,[M,M,M,M],B),t.globalAlpha=q?this._hoverOpacity:this._opacity,t.fillStyle=this._getBarFill(B,z,O,y,N,!0),t.beginPath(),t.roundRect(z,O,y,Math.max(N,1),[M,M,M,M]),t.fill(),N>4&&this._drawBarHighlight(t,z,O,y,M,!0),i>=1&&this._showValues){t.globalAlpha=1,t.font=this._valueSize+"px "+r,t.textAlign="center";var V=D?f:d[A];t.textBaseline=H<R?"bottom":"top",t.fillStyle=this._valueColor||e.text2;var F=H<R?O-4:G+4;t.fillText(v(V),z+y/2,F)}this._hitAreas.push({ci:A,si:0,x:z,y:O,w:y,h:N,series:this.series[0]||{}})}t.globalAlpha=1},B.prototype._onHover=function(t,e){var i=this._hoverCat;this._hoverCat=-1;var o=this._padding,s=o.left,a=this.W-o.left-o.right,r=this._showTotal?this.categories.length+1:this.categories.length,l=a/r;if(t>=s&&t<=s+a&&(this._hoverCat=Math.floor((t-s)/l),this._hoverCat>=r&&(this._hoverCat=r-1)),this._hoverCat!==i&&this.render(),this._hoverCat>=0){var h=this.series.length>0?this.series[0].data:[],n=this.categories.slice();this._showTotal&&n.push("Total");for(var d=0,c=0;c<=this._hoverCat&&c<h.length;c++)d+=h[c];var _=this._showTotal&&this._hoverCat===n.length-1,p=[{color:_?this._totalColor:h[this._hoverCat]>=0?this._positiveColor:this._negativeColor,name:_?"Total":h[this._hoverCat]>=0?"Increase":"Decrease",value:_?d:h[this._hoverCat]}];_||p.push({color:"#64748b",name:"Cumulative",value:d}),this._showTooltip(t,e,n[this._hoverCat],p)}else this._hideTooltip()},D.prototype=Object.create(w.prototype),D.prototype.constructor=D,D.prototype._computeScale=function(){var t=0;this._items.forEach(function(e){var i=e.ranges;if(i&&i.length>0){var o=i[i.length-1];o>t&&(t=o)}e.actual>t&&(t=e.actual),e.target>t&&(t=e.target)}),this._scaleMax=_(1.05*t),this._step=p(this._scaleMax,5),this._ticks=[];for(var e=0;e<=this._scaleMax;e+=this._step)this._ticks.push(e)},D.prototype.render=function(){this._computeScale(),this._clearAndDrawBackground();var t=this.ctx,e=this._vars,i=f(c(this._animProgress,0,1)),o=this._padding,s=o.left,a=o.top,l=this.W-o.left-o.right,h=this.H-o.top-o.bottom,n=this._items.length,d=h/n,_=this._rangeColors;t.textAlign="center",t.textBaseline="top",t.font="500 12px "+r;for(var p=0;p<this._ticks.length;p++){var u=this._ticks[p],g=s+u/this._scaleMax*l;this._gridLines&&(t.strokeStyle=this._gridColor||"rgba(226,232,240,0.4)",t.lineWidth=1,t.setLineDash(this._gridDashed?[4,4]:[]),t.beginPath(),t.moveTo(g,a),t.lineTo(g,a+h),t.stroke(),t.setLineDash([])),t.fillStyle=e.muted,t.fillText(v(u),g,a+h+8)}t.textAlign="right",t.textBaseline="middle",t.fillStyle=e.text2,t.font="500 12px "+r,this._hitAreas=[];for(var b=this._barHeightRatio,y=0;y<n;y++){var x=this._items[y],M=a+d*y+d/2,w=.65*d,S=d*b,T=this._hoverCat===y;t.fillStyle=e.text2,t.textAlign="right",t.textBaseline="middle",t.fillText(x.label,s-8,M);for(var k=x.ranges||[],C=k.length-1;C>=0;C--){var P=k[C]/this._scaleMax*l*i;t.fillStyle=_[C]||"#e2e8f0",t.beginPath(),t.roundRect(s,M-w/2,P,w,2),t.fill()}var L=x.actual/this._scaleMax*l*i,E=t.createLinearGradient(s,0,s+L,0);E.addColorStop(0,this._barColor),E.addColorStop(1,m(this._barColor,.3)),t.fillStyle=E,t.globalAlpha=T?1:.9,t.beginPath(),t.roundRect(s,M-S/2,L,S,2),t.fill(),t.globalAlpha=1;var A=s+x.target/this._scaleMax*l*i;t.strokeStyle=this._markerColor,t.lineWidth=2.5,t.beginPath(),t.moveTo(A,M-w/2-2),t.lineTo(A,M+w/2+2),t.stroke(),this._hitAreas.push({ci:y,si:0,x:s,y:M-w/2,w:l,h:w,series:this.series[0]||{}})}},D.prototype._onHover=function(t,e){var i=this._hoverCat;this._hoverCat=-1;var o=this._padding,s=o.top,a=this.H-o.top-o.bottom,r=this._items.length,l=a/r;if(e>=s&&e<=s+a&&(this._hoverCat=Math.floor((e-s)/l),this._hoverCat>=r&&(this._hoverCat=r-1)),this._hoverCat!==i&&this.render(),this._hoverCat>=0){var h=this._items[this._hoverCat];this._showTooltip(t,e,h.label,[{color:this._barColor,name:"Actual",value:h.actual},{color:this._markerColor,name:"Target",value:h.target}])}else this._hideTooltip()},I.prototype=Object.create(w.prototype),I.prototype.constructor=I,I.prototype.render=function(){this._clearAndDrawBackground();var t=this.ctx,e=this._vars,i=this._animProgress,o=f(c(i,0,1)),s=this._padding,a=s.left,l=s.top+10,h=this.W-s.left-s.right,n=this._barHeight,d=this._segGap,_=this._segments,p=0;_.forEach(function(t){p+=t.value});var u=l+20,g=a;this._segRects=[];for(var b=0;b<_.length;b++){var y=_[b],x=y.value/p,M=(h-d*(_.length-1))*x*o,w=g,S=[0,0,0,0];this._rounded&&(0===b&&(S=[6,0,0,6]),b===_.length-1&&(S=[0,6,6,0]),1===_.length&&(S=[6,6,6,6]));var T=t.createLinearGradient(w,u,w,u+n);T.addColorStop(0,y.color),T.addColorStop(1,m(y.color,.25));var k=this._hoverCat===b;t.globalAlpha=k?1:.88,t.fillStyle=T,t.beginPath(),t.roundRect(w,u,Math.max(M,0),n,S),t.fill(),M>4&&(t.save(),t.globalAlpha=.2,t.strokeStyle="rgba(255,255,255,0.5)",t.lineWidth=1,t.beginPath(),t.moveTo(w+(0===b?S[0]:0)+1,u+1),t.lineTo(w+M-(b===_.length-1?S[1]:0)-1,u+1),t.stroke(),t.restore()),t.globalAlpha=1;var C=(100*x).toFixed(1)+"%",P=M-8;if(P>30){t.font="bold 12px "+r,t.textAlign="center",t.textBaseline="middle",t.fillStyle="#fff";var L=y.label;t.measureText(L).width>P&&(L=L.substring(0,Math.floor(P/7))+".."),t.fillText(L,w+M/2,u+n/2-(this._showPercent?7:0)),this._showPercent&&(t.font="11px "+r,t.globalAlpha=.85,t.fillText(C,w+M/2,u+n/2+8),t.globalAlpha=1)}P<=30&&i>=1&&(t.font="10px "+r,t.textAlign="center",t.textBaseline="top",t.fillStyle=e.text2,t.save(),t.translate(w+M/2,u+n+8),t.rotate(Math.PI/6),t.fillText(y.label,0,0),t.restore()),this._showSegValues&&i>=1&&P>40&&(t.font="10px "+r,t.textAlign="center",t.textBaseline="top",t.fillStyle=e.muted,t.fillText(v(y.value),w+M/2,u+n+6)),this._segRects.push({x:w,y:u,w:M,h:n,idx:b}),g+=M+d}t.globalAlpha=1},I.prototype._onHover=function(t,e){var i=this._hoverCat;if(this._hoverCat=-1,this._segRects)for(var o=0;o<this._segRects.length;o++){var s=this._segRects[o];if(t>=s.x&&t<=s.x+s.w&&e>=s.y&&e<=s.y+s.h){this._hoverCat=o;break}}if(this._hoverCat!==i&&this.render(),this._hoverCat>=0){var a=this._segments[this._hoverCat],r=0;this._segments.forEach(function(t){r+=t.value});var l=(a.value/r*100).toFixed(1);this._showTooltip(t,e,a.label,[{color:a.color,name:"Value",value:a.value},{color:"#64748b",name:"Share",value:l+"%"}])}else this._hideTooltip()},I.prototype._computeScale=function(){this._scaleMax=1,this._ticks=[]},z.prototype._buildDOM=w.prototype._buildDOM,z.prototype._initSize=w.prototype._initSize,z.prototype._startAnimation=w.prototype._startAnimation,z.prototype._bindEvents=function(){var t=this;this._boundListeners=[];var e=function(){t._initSize(),t.render()};window.addEventListener("resize",e),this._boundListeners.push({target:window,type:"resize",fn:e});var i=function(e){t._hoverRaf||(t._hoverRaf=requestAnimationFrame(function(){t._hoverRaf=0;var i=t.canvas.getBoundingClientRect();t._onHover(e.clientX-i.left,e.clientY-i.top)}))},o=function(){t._hoverIdx=-1,t._hideTooltip(),t.render()};this.canvas.addEventListener("mousemove",i),this.canvas.addEventListener("mouseleave",o),this._boundListeners.push({target:this.canvas,type:"mousemove",fn:i}),this._boundListeners.push({target:this.canvas,type:"mouseleave",fn:o})},z.prototype._showTooltip=w.prototype._showTooltip,z.prototype._hideTooltip=w.prototype._hideTooltip,z.prototype.exportPNG=w.prototype.exportPNG,z.prototype._layout=function(t,e,i,o,s){var a=[];if(!t.length||o<=0||s<=0)return a;var r=0;if(t.forEach(function(t){r+=t.value}),r<=0)return a;for(var l=t.slice().sort(function(t,e){return e.value-t.value}).slice(),h=e,n=i,d=o,c=s;l.length>0;){var _=d>=c,p=_?c:d,v=0;l.forEach(function(t){v+=t.value});for(var f=[l[0]],u=l[0].value,g=1/0,b=1;b<l.length;b++){var m=f.concat(l[b]),y=u+l[b].value,x=p*(y/v);x<1&&(x=1);for(var M=0,w=0;w<m.length;w++){var S=m[w].value/y,T=_?x:p*S,k=_?p*S:x;T<1&&(T=1),k<1&&(k=1);var C=Math.max(T/k,k/T);C>M&&(M=C)}if(!(M<=g))break;g=M,f=m,u=y}var P=(_?d:c)*(u/v),L=0;for(w=0;w<f.length;w++){var E,A,W,R,H=(_?c:d)*(S=f[w].value/u);_?(E=h,A=n+L,W=P,R=H):(E=h+L,A=n,W=H,R=P),a.push({x:E,y:A,w:W,h:R,item:f[w],idx:a.length}),L+=H}_?(h+=P,d-=P):(n+=P,c-=P),l=l.slice(f.length)}return a},z.prototype.render=function(){var t=this.ctx,e=d(this.el),i=f(this._animProgress),o=this._cellGap,s=10,a=10,l=10,h=10;t.clearRect(0,0,this.W,this.H),t.fillStyle=e.card,t.fillRect(0,0,this.W,this.H),this._rects=this._layout(this._items,h,s,this.W-h-a,this.H-s-l);for(var n=0;n<this._rects.length;n++){var c=this._rects[n],_=c.x+o/2,p=c.y+o/2,u=(c.w-o)*i,g=(c.h-o)*i;if(!(u<1||g<1)){var b=this._hoverIdx===n,y=b?1:.85;if(t.save(),t.globalAlpha=y,this._gradient){var x=t.createLinearGradient(_,p,_,p+g);x.addColorStop(0,c.item.color),x.addColorStop(1,m(c.item.color,.2)),t.fillStyle=x}else t.fillStyle=c.item.color;var M=Math.min(this._borderRadius,u/4,g/4);t.beginPath(),t.moveTo(_+M,p),t.lineTo(_+u-M,p),t.quadraticCurveTo(_+u,p,_+u,p+M),t.lineTo(_+u,p+g-M),t.quadraticCurveTo(_+u,p+g,_+u-M,p+g),t.lineTo(_+M,p+g),t.quadraticCurveTo(_,p+g,_,p+g-M),t.lineTo(_,p+M),t.quadraticCurveTo(_,p,_+M,p),t.closePath(),t.fill(),b&&(t.shadowColor=c.item.color,t.shadowBlur=12,t.fill(),t.shadowBlur=0),t.globalAlpha=1,this._showLabels&&u>40&&g>30&&i>=1&&(t.fillStyle="#fff",t.font="bold "+Math.min(14,Math.max(10,u/8))+"px "+r,t.textAlign="left",t.textBaseline="top",t.fillText(c.item.label,_+6,p+6,u-12),this._showValues&&g>45&&(t.font=Math.min(12,Math.max(9,u/10))+"px "+r,t.globalAlpha=.85,t.fillText(v(c.item.value),_+6,p+24,u-12),t.globalAlpha=1)),t.restore()}}},z.prototype._onHover=function(t,e){var i=this._hoverIdx;this._hoverIdx=-1;for(var o=0;o<this._rects.length;o++){var s=this._rects[o];if(t>=s.x&&t<=s.x+s.w&&e>=s.y&&e<=s.y+s.h){this._hoverIdx=o;break}}if(this._hoverIdx!==i&&this.render(),this._hoverIdx>=0){var a=this._rects[this._hoverIdx].item,r=0;this._items.forEach(function(t){r+=t.value}),this._showTooltip(t,e,a.label,[{color:a.color,name:"Value",value:a.value},{color:"#64748b",name:"Share",value:(a.value/r*100).toFixed(1)+"%"}])}else this._hideTooltip()},z.prototype._computeScale=function(){this._scaleMax=1,this._ticks=[]},z.prototype.destroy=w.prototype.destroy,O.prototype._buildDOM=w.prototype._buildDOM,O.prototype._initSize=w.prototype._initSize,O.prototype._startAnimation=w.prototype._startAnimation,O.prototype._bindEvents=z.prototype._bindEvents,O.prototype._showTooltip=w.prototype._showTooltip,O.prototype._hideTooltip=w.prototype._hideTooltip,O.prototype.exportPNG=w.prototype.exportPNG,O.prototype.render=function(){var t=this.ctx,e=d(this.el),i=f(this._animProgress),o=this._stages;if(o.length){t.clearRect(0,0,this.W,this.H),t.fillStyle=e.card,t.fillRect(0,0,this.W,this.H);var s=16,a=16,l=16,h=16,n=o[0].value||1,c=this._gap,_=this._neckWidth,p=this.W-h-a,u=(this.H-s-l-c*(o.length-1))/o.length,g=h+p/2;this._stageRects=[];for(var b=0;b<o.length;b++){var y=o[b],x=y.value/n,M=(_+(1-_)*x)*p*i,w=(_+(1-_)*(b<o.length-1?o[b+1].value/n:x*_))*p*i,S=s+b*(u+c),T=this._hoverIdx===b;if(t.save(),t.globalAlpha=T?1:.88,this._gradient){var k=t.createLinearGradient(g-M/2,S,g+M/2,S);k.addColorStop(0,m(y.color,.15)),k.addColorStop(.5,y.color),k.addColorStop(1,m(y.color,.15)),t.fillStyle=k}else t.fillStyle=y.color;if(t.beginPath(),t.moveTo(g-M/2,S),t.lineTo(g+M/2,S),t.lineTo(g+w/2,S+u),t.lineTo(g-w/2,S+u),t.closePath(),t.fill(),T&&(t.shadowColor=y.color,t.shadowBlur=14,t.fill(),t.shadowBlur=0),t.globalAlpha=1,this._showLabels&&i>=.8){t.fillStyle="#fff",t.font="bold 13px "+r,t.textAlign="center",t.textBaseline="middle";var C=S+u/2;t.fillText(y.label,g,C-(this._showValues?8:0)),this._showValues&&(t.font="11px "+r,t.globalAlpha=.85,t.fillText(v(y.value)+" ("+(100*x).toFixed(1)+"%)",g,C+10),t.globalAlpha=1)}t.restore(),this._stageRects.push({x:g-Math.max(M,w)/2,y:S,w:Math.max(M,w),h:u,idx:b})}}},O.prototype._onHover=function(t,e){var i=this._hoverIdx;this._hoverIdx=-1;for(var o=0;o<this._stageRects.length;o++){var s=this._stageRects[o];if(t>=s.x&&t<=s.x+s.w&&e>=s.y&&e<=s.y+s.h){this._hoverIdx=o;break}}if(this._hoverIdx!==i&&this.render(),this._hoverIdx>=0){var a=this._stages[this._hoverIdx],r=this._hoverIdx>0?(a.value/this._stages[0].value*100).toFixed(1)+"%":"100%";this._showTooltip(t,e,a.label,[{color:a.color,name:"Value",value:a.value},{color:"#64748b",name:"Conversion",value:r}])}else this._hideTooltip()},O.prototype._computeScale=function(){this._scaleMax=1,this._ticks=[]},O.prototype.destroy=w.prototype.destroy,G.prototype._buildDOM=w.prototype._buildDOM,G.prototype._initSize=w.prototype._initSize,G.prototype._startAnimation=w.prototype._startAnimation,G.prototype._bindEvents=z.prototype._bindEvents,G.prototype._showTooltip=w.prototype._showTooltip,G.prototype._hideTooltip=w.prototype._hideTooltip,G.prototype.exportPNG=w.prototype.exportPNG,G.prototype.render=function(){var t=this.ctx,e=d(this.el),i=u(c(this._animProgress,0,1)),o=this._segments;if(o.length){t.clearRect(0,0,this.W,this.H),t.fillStyle=e.card,t.fillRect(0,0,this.W,this.H);var s=this.W/2,a=this.H/2,l=Math.min(s,a)-40,h=l*this._innerRadius,n=0;o.forEach(function(t){t.value>n&&(n=t.value)}),n<=0&&(n=1);var _=o.length,p=2*Math.PI/_,v=this._padAngle;this._slices=[];for(var f=0;f<_;f++){var g=o[f],b=-Math.PI/2+f*p+v/2,y=b+p-v,x=h+(l-h)*(g.value/n)*i,M=this._hoverIdx===f;if(t.save(),t.globalAlpha=M?1:.85,this._gradient){var w=t.createRadialGradient(s,a,h,s,a,x);w.addColorStop(0,m(g.color,.25)),w.addColorStop(1,g.color),t.fillStyle=w}else t.fillStyle=g.color;if(t.beginPath(),t.arc(s,a,x,b,y),t.arc(s,a,h,y,b,!0),t.closePath(),t.fill(),M&&(t.shadowColor=g.color,t.shadowBlur=16,t.fill(),t.shadowBlur=0),t.strokeStyle=e.card,t.lineWidth=1.5,t.stroke(),t.globalAlpha=1,this._showLabels&&i>=.8){var S=(b+y)/2,T=l+18,k=s+T*Math.cos(S),C=a+T*Math.sin(S);t.fillStyle=e.text,t.font="11px "+r,t.textAlign=S>Math.PI/2||S<-Math.PI/2?"right":"left",t.textBaseline="middle",t.fillText(g.label,k,C)}t.restore(),this._slices.push({startA:b,endA:y,r:x,idx:f})}t.beginPath(),t.arc(s,a,h-1,0,2*Math.PI),t.fillStyle=e.card,t.fill()}},G.prototype._onHover=function(t,e){var i=this.W/2,o=this.H/2,s=t-i,a=e-o,r=Math.sqrt(s*s+a*a),l=Math.atan2(a,s);l<-Math.PI/2&&(l+=2*Math.PI);var h=this._hoverIdx;this._hoverIdx=-1;var n=Math.min(i,o)-40;if(r>=n*this._innerRadius&&r<=n+10)for(var d=0;d<this._slices.length;d++){var c=this._slices[d],_=c.startA,p=c.endA,v=l;if(v<_&&(v+=2*Math.PI),v>=_&&v<=p&&r<=c.r){this._hoverIdx=d;break}}if(this._hoverIdx!==h&&this.render(),this._hoverIdx>=0){var f=this._segments[this._hoverIdx],u=0;this._segments.forEach(function(t){u+=t.value}),this._showTooltip(t,e,f.label,[{color:f.color,name:"Value",value:f.value},{color:"#64748b",name:"Share",value:(f.value/u*100).toFixed(1)+"%"}])}else this._hideTooltip()},G.prototype._computeScale=function(){this._scaleMax=1,this._ticks=[]},G.prototype.destroy=w.prototype.destroy,N.prototype._buildDOM=w.prototype._buildDOM,N.prototype._buildLegend=w.prototype._buildLegend,N.prototype._initSize=w.prototype._initSize,N.prototype._startAnimation=w.prototype._startAnimation,N.prototype._showTooltip=w.prototype._showTooltip,N.prototype._hideTooltip=w.prototype._hideTooltip,N.prototype.exportPNG=w.prototype.exportPNG,N.prototype._bindEvents=function(){var t=this;this._boundListeners=[];var e=function(){t._initSize(),t.render()};window.addEventListener("resize",e),this._boundListeners.push({target:window,type:"resize",fn:e});var i=function(e){t._hoverRaf||(t._hoverRaf=requestAnimationFrame(function(){t._hoverRaf=0;var i=t.canvas.getBoundingClientRect();t._onHover(e.clientX-i.left,e.clientY-i.top)}))},o=function(){t._hoverPoint=null,t._hideTooltip(),t.render()};this.canvas.addEventListener("mousemove",i),this.canvas.addEventListener("mouseleave",o),this._boundListeners.push({target:this.canvas,type:"mousemove",fn:i}),this._boundListeners.push({target:this.canvas,type:"mouseleave",fn:o})},N.prototype._computeExtents=function(){var t=1/0,e=-1/0,i=1/0,o=-1/0,s=0;this.series.forEach(function(a){a.visible&&a.data.forEach(function(a){a[0]<t&&(t=a[0]),a[0]>e&&(e=a[0]),a[1]<i&&(i=a[1]),a[1]>o&&(o=a[1]),a.length>2&&a[2]>s&&(s=a[2])})}),t===1/0&&(t=0,e=100,i=0,o=100);var a=.08*(e-t)||10,r=.08*(o-i)||10;this._xMin=t-a,this._xMax=e+a,this._yMin=i-r,this._yMax=o+r,this._rMax=s||1},N.prototype.render=function(){var t=this.ctx,e=d(this.el),i=f(this._animProgress),o=this._padding;t.clearRect(0,0,this.W,this.H),t.fillStyle=e.card,t.fillRect(0,0,this.W,this.H),this._computeExtents();var s=o.left,a=o.top,l=this.W-o.left-o.right,h=this.H-o.top-o.bottom,n=this._xMax-this._xMin||1,c=this._yMax-this._yMin||1,_=this;function u(t){return s+(t-_._xMin)/n*l}function g(t){return a+h-(t-_._yMin)/c*h}if(this._gridLines){t.strokeStyle=e.grid,t.lineWidth=.5,this._gridDashed&&t.setLineDash([4,4]);var b=p(n,6),y=p(c,5);t.font="10px "+r,t.fillStyle=e.muted,t.textAlign="right",t.textBaseline="middle";for(var x=Math.ceil(this._yMin/y)*y;x<=this._yMax;x+=y){var M=g(x);t.beginPath(),t.moveTo(s,M),t.lineTo(s+l,M),t.stroke(),t.fillText(v(x),s-8,M)}t.textAlign="center",t.textBaseline="top";for(var w=Math.ceil(this._xMin/b)*b;w<=this._xMax;w+=b){var S=u(w);t.beginPath(),t.moveTo(S,a),t.lineTo(S,a+h),t.stroke(),t.fillText(v(w),S,a+h+8)}t.setLineDash([])}this._xLabel&&(t.fillStyle=e.text2,t.font="11px "+r,t.textAlign="center",t.fillText(this._xLabel,s+l/2,this.H-6)),this._yLabel&&(t.save(),t.fillStyle=e.text2,t.font="11px "+r,t.translate(12,a+h/2),t.rotate(-Math.PI/2),t.textAlign="center",t.fillText(this._yLabel,0,0),t.restore()),t.strokeStyle=e.grid,t.lineWidth=1,t.strokeRect(s,a,l,h),this._pointRects=[];for(var T=this._minRadius,k=this._maxRadius,C=0;C<this.series.length;C++){var P=this.series[C];if(P.visible)for(var L=0;L<P.data.length;L++){var E=P.data[L],A=u(E[0]),W=g(E[1]),R=this._bubbleMode&&E.length>2?T+(k-T)*(E[2]/this._rMax):T+2;R*=i;var H=this._hoverPoint&&this._hoverPoint.si===C&&this._hoverPoint.pi===L;if(t.save(),H&&(t.shadowColor=P.color,t.shadowBlur=12),this._gradient){var B=t.createRadialGradient(A-.3*R,W-.3*R,0,A,W,R);B.addColorStop(0,m(P.color,.3)),B.addColorStop(1,P.color),t.fillStyle=B}else t.fillStyle=P.color;t.globalAlpha=H?1:.75,t.beginPath(),t.arc(A,W,R,0,2*Math.PI),t.fill(),t.strokeStyle=e.card,t.lineWidth=1.5,t.globalAlpha=1,t.stroke(),t.restore(),this._pointRects.push({x:A,y:W,r:Math.max(R,6),si:C,pi:L})}}},N.prototype._onHover=function(t,e){var i=this._hoverPoint;this._hoverPoint=null;for(var o=1/0,s=0;s<this._pointRects.length;s++){var a=this._pointRects[s],r=t-a.x,l=e-a.y,h=Math.sqrt(r*r+l*l);h<=a.r+4&&h<o&&(o=h,this._hoverPoint=a)}if((!i&&this._hoverPoint||i&&!this._hoverPoint||i&&this._hoverPoint&&(i.si!==this._hoverPoint.si||i.pi!==this._hoverPoint.pi))&&this.render(),this._hoverPoint){var n=this.series[this._hoverPoint.si],d=n.data[this._hoverPoint.pi],c=[{color:n.color,name:"X",value:d[0]},{color:n.color,name:"Y",value:d[1]}];d.length>2&&c.push({color:"#64748b",name:"Size",value:d[2]}),this._showTooltip(t,e,n.name,c)}else this._hideTooltip()},N.prototype._computeScale=function(){this._scaleMax=1,this._ticks=[]},N.prototype.destroy=w.prototype.destroy,q.prototype._buildDOM=w.prototype._buildDOM,q.prototype._initSize=w.prototype._initSize,q.prototype._startAnimation=w.prototype._startAnimation,q.prototype._bindEvents=z.prototype._bindEvents,q.prototype._showTooltip=w.prototype._showTooltip,q.prototype._hideTooltip=w.prototype._hideTooltip,q.prototype.exportPNG=w.prototype.exportPNG,q.prototype._computeLayout=function(){var t=this._nodes,e=this._links,i=20,o=20,s=20,a=20,r=this.W-a-o,l=this.H-i-s,h=this._nodeWidth,n=this._nodePadding,d={};t.forEach(function(t,e){d[e]={idx:e,node:t,layer:-1,value:0,sourceLinks:[],targetLinks:[]}}),e.forEach(function(t){d[t.source].sourceLinks.push(t),d[t.target].targetLinks.push(t)});var c={};function _(t,e){c[t]&&d[t].layer>=e||(c[t]=!0,d[t].layer=Math.max(d[t].layer,e),d[t].sourceLinks.forEach(function(t){_(t.target,e+1)}))}var p={};e.forEach(function(t){p[t.target]=!0}),t.forEach(function(t,e){p[e]||_(e,0)}),t.forEach(function(t,e){-1===d[e].layer&&(d[e].layer=0)}),t.forEach(function(t,e){var i=0,o=0;d[e].targetLinks.forEach(function(t){i+=t.value}),d[e].sourceLinks.forEach(function(t){o+=t.value}),d[e].value=Math.max(i,o)});var v=[],f=0;Object.keys(d).forEach(function(t){d[t].layer>f&&(f=d[t].layer)});for(var u=0;u<=f;u++){var g=[];Object.keys(d).forEach(function(t){d[t].layer===u&&g.push(d[t])}),v.push(g)}var b=f>0?(r-h)/f:0,m=0;v.forEach(function(t){var e=0;t.forEach(function(t){e+=t.value}),e>m&&(m=e)});var y=m>0?(l-n*(Math.max.apply(null,v.map(function(t){return t.length}))-1))/m:1;y<=0&&(y=1),v.forEach(function(t,e){var o=a+e*b,s=0;t.forEach(function(t){s+=t.value*y}),s+=(t.length-1)*n;var r=i+(l-s)/2;t.forEach(function(t){var e=Math.max(t.value*y,4);t.x=o,t.y=r,t.w=h,t.h=e,t.sy=0,t.ty=0,r+=e+n})}),this._layoutNodes=d,this._layoutLayers=v,this._nodeScale=y},q.prototype.render=function(){var t=this.ctx,e=d(this.el),i=f(this._animProgress),o=this._layoutNodes,s=this._links;t.clearRect(0,0,this.W,this.H),t.fillStyle=e.card,t.fillRect(0,0,this.W,this.H),Object.keys(o).forEach(function(t){o[t].sy=0,o[t].ty=0}),this._linkPaths=[];for(var a=0;a<s.length;a++){var l=s[a],h=o[l.source],n=o[l.target],c=Math.max(l.value*this._nodeScale,2)*i,_=h.x+h.w,p=h.y+h.sy+c/2,u=n.x,g=n.y+n.ty+c/2,b=this._hoverLink===a;if(t.save(),t.globalAlpha=b?.55:.25,this._gradient){var y=t.createLinearGradient(_,0,u,0);y.addColorStop(0,h.node.color),y.addColorStop(1,n.node.color),t.strokeStyle=y}else t.strokeStyle=h.node.color;t.lineWidth=c,t.lineCap="butt",t.beginPath();var x=(_+u)/2;t.moveTo(_,p),t.bezierCurveTo(x,p,x,g,u,g),t.stroke(),t.restore(),this._linkPaths.push({x0:_,y0:p-c/2,x1:u,y1:g-c/2,h:c,idx:a,src:h,tgt:n}),h.sy+=c,n.ty+=c}this._nodeRects=[];var M=this;Object.keys(o).forEach(function(s){var a=o[s],l=a.h*i;if(t.save(),M._gradient){var h=t.createLinearGradient(a.x,a.y,a.x+a.w,a.y);h.addColorStop(0,a.node.color),h.addColorStop(1,m(a.node.color,.2)),t.fillStyle=h}else t.fillStyle=a.node.color;t.shadowColor=a.node.color,t.shadowBlur=6;var n=Math.min(M._borderRadius,a.w/4,l/4);if(t.beginPath(),t.moveTo(a.x+n,a.y),t.lineTo(a.x+a.w-n,a.y),t.quadraticCurveTo(a.x+a.w,a.y,a.x+a.w,a.y+n),t.lineTo(a.x+a.w,a.y+l-n),t.quadraticCurveTo(a.x+a.w,a.y+l,a.x+a.w-n,a.y+l),t.lineTo(a.x+n,a.y+l),t.quadraticCurveTo(a.x,a.y+l,a.x,a.y+l-n),t.lineTo(a.x,a.y+n),t.quadraticCurveTo(a.x,a.y,a.x+n,a.y),t.closePath(),t.fill(),t.restore(),M._showLabels&&i>=.8){t.fillStyle=e.text,t.font="11px "+r;var d=0===a.layer;d?(t.textAlign="left",t.textBaseline="middle",t.fillText(a.node.name,a.x+a.w+6,a.y+l/2)):(t.textAlign="right",t.textBaseline="middle",t.fillText(a.node.name,a.x-6,a.y+l/2)),t.fillStyle=e.muted,t.font="10px "+r,t.fillText(v(a.value),d?a.x+a.w+6:a.x-6,a.y+l/2+14)}M._nodeRects.push({x:a.x,y:a.y,w:a.w,h:l,idx:parseInt(s)})})},q.prototype._onHover=function(t,e){var i=this._hoverLink;this._hoverLink=-1;for(var o=0;o<this._linkPaths.length;o++){var s=this._linkPaths[o];s.x0,s.x1;if(t>=s.x0&&t<=s.x1){var a=(t-s.x0)/(s.x1-s.x0),r=a*a*(3-2*a),l=s.y0+s.h/2+r*(s.y1+s.h/2-(s.y0+s.h/2));if(Math.abs(e-l)<s.h/2+4){this._hoverLink=o;break}}}if(this._hoverLink!==i&&this.render(),this._hoverLink>=0){var h=this._links[this._hoverLink],n=this._layoutNodes[h.source],d=this._layoutNodes[h.target];this._showTooltip(t,e,n.node.name+" → "+d.node.name,[{color:n.node.color,name:"Flow",value:h.value}])}else this._hideTooltip()},q.prototype._computeScale=function(){this._scaleMax=1,this._ticks=[]},q.prototype.destroy=w.prototype.destroy,V.prototype=Object.create(w.prototype),V.prototype.constructor=V,V.prototype.render=function(){this._clearAndDrawBackground(),this._computeScale(),this._drawGrid(),this._drawBoxes()},V.prototype._computeScale=function(){var t=-1/0,e=1/0;this._boxData.forEach(function(i){i.max>t&&(t=i.max),i.min<e&&(e=i.min),i.outliers&&i.outliers.forEach(function(i){i>t&&(t=i),i<e&&(e=i)})}),e===1/0&&(e=0,t=100);var i=t-e||10;this._scaleMin=e-.05*i,this._scaleMax=_(1.05*t),this._step=p(this._scaleMax-this._scaleMin,5),this._ticks=[];for(var o=Math.max(0,Math.floor(this._scaleMin/this._step)*this._step);o<=this._scaleMax;o+=this._step)this._ticks.push(o);this._scaleMin||(this._scaleMin=0)},V.prototype._drawGrid=function(){var t=this.ctx,e=this._vars,i=this._padding,o=i.top,s=this.H-i.top-i.bottom;t.font="10px "+r,t.fillStyle=e.muted,t.strokeStyle=e.grid,t.lineWidth=.5,this._gridDashed&&t.setLineDash([4,4]);for(var a=0;a<this._ticks.length;a++){var l=this._ticks[a],h=o+s-(l-this._scaleMin)/(this._scaleMax-this._scaleMin)*s;t.beginPath(),t.moveTo(i.left,h),t.lineTo(this.W-i.right,h),t.stroke(),t.textAlign="right",t.textBaseline="middle",t.fillText(v(l),i.left-8,h)}t.setLineDash([]);var n=this.categories.length,d=this.W-i.left-i.right,c=n>0?d/n:d;t.textAlign="center",t.textBaseline="top",t.fillStyle=e.text2,t.font="11px "+r;for(a=0;a<n;a++){var _=i.left+c*a+c/2;t.fillText(this.categories[a],_,this.H-i.bottom+10)}},V.prototype._drawBoxes=function(){var t=this.ctx,e=this._vars,i=this._padding,o=f(this._animProgress),s=this._animProgress,a=i.top,h=this.H-i.top-i.bottom,n=this.W-i.left-i.right,d=this._boxData.length;if(0!==d){var c=n/d,_=this._boxWidth||Math.min(.5*c,50),p=_*this._whiskerWidth,u=this._scaleMin,g=this._scaleMax-u||1,b=this._userColors||l;this._boxRects=[];for(var y=0;y<d;y++){var x=this._boxData[y],M=i.left+c*y+c/2,w=b[y%b.length],S=this._hoverCat===y,T=V(x.min),k=V(x.q1),C=V(x.median),P=V(x.q3),L=V(x.max),E=C+(T-C)*o,A=C+(k-C)*o,W=C+(P-C)*o,R=C+(L-C)*o;t.save(),t.strokeStyle=S?w:e.text2,t.lineWidth=1.5,t.beginPath(),t.moveTo(M,R),t.lineTo(M,E),t.stroke(),t.beginPath(),t.moveTo(M-p/2,R),t.lineTo(M+p/2,R),t.moveTo(M-p/2,E),t.lineTo(M+p/2,E),t.stroke();var H=M-_/2,B=W,D=A-W;if(this._gradient){var I=t.createLinearGradient(H,B,H,B+D);I.addColorStop(0,w),I.addColorStop(1,m(w,.25)),t.fillStyle=I}else t.fillStyle=w;t.globalAlpha=S?.95:.8;var z=Math.min(this._borderRadius,_/4);if(t.beginPath(),t.moveTo(H+z,B),t.lineTo(H+_-z,B),t.quadraticCurveTo(H+_,B,H+_,B+z),t.lineTo(H+_,B+D-z),t.quadraticCurveTo(H+_,B+D,H+_-z,B+D),t.lineTo(H+z,B+D),t.quadraticCurveTo(H,B+D,H,B+D-z),t.lineTo(H,B+z),t.quadraticCurveTo(H,B,H+z,B),t.closePath(),t.fill(),t.globalAlpha=1,S&&(t.shadowColor=w,t.shadowBlur=10,t.fill(),t.shadowBlur=0),t.strokeStyle=w,t.lineWidth=1.5,t.stroke(),t.strokeStyle="#fff",t.lineWidth=2.5,t.beginPath(),t.moveTo(H+2,C),t.lineTo(H+_-2,C),t.stroke(),this._showOutliers&&x.outliers&&s>=.8){var O=this._outlierRadius;t.fillStyle=w,t.globalAlpha=.6;for(var G=0;G<x.outliers.length;G++){var N=V(x.outliers[G]);t.beginPath(),t.arc(M,N,O,0,2*Math.PI),t.fill()}t.globalAlpha=1}if(S&&s>=1){t.fillStyle=e.text,t.font="10px "+r,t.textAlign="left",t.textBaseline="middle";var q=M+_/2+6;t.fillText("max: "+v(x.max),q,L),t.fillText("Q3: "+v(x.q3),q,P),t.fillText("med: "+v(x.median),q,C),t.fillText("Q1: "+v(x.q1),q,k),t.fillText("min: "+v(x.min),q,T)}t.restore(),this._boxRects.push({x:H,y:B,w:_,h:D,cx:M,idx:y})}}function V(t){return a+h-(t-u)/g*h}},V.prototype._onHover=function(t,e){var i=this._hoverCat;if(this._hoverCat=-1,this._boxRects)for(var o=0;o<this._boxRects.length;o++){this._boxRects[o];var s=this._padding,a=(this.W-s.left-s.right)/this._boxData.length,r=s.left+a*o;if(t>=r&&t<=r+a&&e>=s.top&&e<=this.H-s.bottom){this._hoverCat=o;break}}if(this._hoverCat!==i&&this.render(),this._hoverCat>=0){var h=this._boxData[this._hoverCat],n=(this._userColors||l)[this._hoverCat%(this._userColors||l).length];this._showTooltip(t,e,this.categories[this._hoverCat]||"Box "+(this._hoverCat+1),[{color:n,name:"Max",value:h.max},{color:n,name:"Q3",value:h.q3},{color:n,name:"Median",value:h.median},{color:n,name:"Q1",value:h.q1},{color:n,name:"Min",value:h.min}])}else this._hideTooltip()},F.prototype._build=function(){this.canvas=document.createElement("canvas"),this.canvas.style.display="inline-block",this.canvas.style.verticalAlign="middle",this.canvas.style.width=this._width+"px",this.canvas.style.height=this._height+"px",this.canvas.width=Math.round(this._width*i),this.canvas.height=Math.round(this._height*i),this.el.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this.ctx.setTransform(i,0,0,i,0,0),this._interactive&&(this._tipEl=document.createElement("div"),this._tipEl.style.cssText="position:absolute;display:none;padding:3px 7px;border-radius:4px;font-size:10px;font-weight:600;pointer-events:none;white-space:nowrap;z-index:99;background:#1e293b;color:#fff;box-shadow:0 2px 6px rgba(0,0,0,.15);",this.el.style.position=this.el.style.position||"relative",this.el.appendChild(this._tipEl))},F.prototype._render=function(t){var e=this.ctx,i=this._data,o=this._width,s=this._height,a=i.length;if(0!==a){e.clearRect(0,0,o,s);for(var r=1/0,l=-1/0,h=0,n=0,d=0;d<a;d++)i[d]<r&&(r=i[d],h=d),i[d]>l&&(l=i[d],n=d);var c=l-r||1;if("bar"===this._type){var _=(o-(a-1)*this._barGap)/a,p=Math.min(this._borderRadius,_/3);for(d=0;d<a;d++){var v=(i[d]-r)/c*(s-4);v<1&&(v=1);var f=d*(_+this._barGap),u=s-2-v,g=t===d,y=d===a-1;e.fillStyle=g||y&&this._showLast?this._color:m(this._color,.3),e.globalAlpha=g?1:.7,e.beginPath(),e.moveTo(f+p,u),e.lineTo(f+_-p,u),e.quadraticCurveTo(f+_,u,f+_,u+p),e.lineTo(f+_,u+v),e.lineTo(f,u+v),e.lineTo(f,u+p),e.quadraticCurveTo(f,u,f+p,u),e.closePath(),e.fill()}e.globalAlpha=1}else{var x=[];for(d=0;d<a;d++)x.push({x:2+d/(a-1)*(o-4),y:2+(1-(i[d]-r)/c)*(s-4)});if("area"===this._type||this._gradient){var M=e.createLinearGradient(0,0,0,s),w=b(this._fillColor||this._color);M.addColorStop(0,"rgba("+w[0]+","+w[1]+","+w[2]+",0.25)"),M.addColorStop(1,"rgba("+w[0]+","+w[1]+","+w[2]+",0.02)"),e.fillStyle=M,e.beginPath(),e.moveTo(x[0].x,s);for(d=0;d<x.length;d++)e.lineTo(x[d].x,x[d].y);e.lineTo(x[x.length-1].x,s),e.closePath(),e.fill()}e.strokeStyle=this._color,e.lineWidth=this._lineWidth,e.lineJoin="round",e.lineCap="round",e.beginPath();for(d=0;d<x.length;d++)0===d?e.moveTo(x[d].x,x[d].y):e.lineTo(x[d].x,x[d].y);if(e.stroke(),this._showLast){var S=x[x.length-1];e.fillStyle=this._color,e.beginPath(),e.arc(S.x,S.y,2.5,0,2*Math.PI),e.fill()}if(this._showMinMax&&(e.fillStyle="#ef4444",e.beginPath(),e.arc(x[h].x,x[h].y,2,0,2*Math.PI),e.fill(),e.fillStyle="#10b981",e.beginPath(),e.arc(x[n].x,x[n].y,2,0,2*Math.PI),e.fill()),null!=t&&t>=0&&t<x.length){var T=x[t];e.strokeStyle="rgba(99,102,241,0.3)",e.lineWidth=1,e.setLineDash([2,2]),e.beginPath(),e.moveTo(T.x,0),e.lineTo(T.x,s),e.stroke(),e.setLineDash([]),e.fillStyle=this._color,e.beginPath(),e.arc(T.x,T.y,3,0,2*Math.PI),e.fill(),e.fillStyle="#fff",e.beginPath(),e.arc(T.x,T.y,1.5,0,2*Math.PI),e.fill()}}}},F.prototype._bind=function(){var t=this;this.canvas.addEventListener("mousemove",function(e){var i=t.canvas.getBoundingClientRect(),o=e.clientX-i.left,s=t._data.length,a=Math.round(o/t._width*(s-1));if(a=c(a,0,s-1),t._render(a),t._tipEl){t._tipEl.style.display="block",t._tipEl.textContent=v(t._data[a]);var r=o-t._tipEl.offsetWidth/2;t._tipEl.style.left=c(r,0,t._width-t._tipEl.offsetWidth)+"px",t._tipEl.style.top="-20px"}}),this.canvas.addEventListener("mouseleave",function(){t._render(),t._tipEl&&(t._tipEl.style.display="none")}),this.canvas.style.cursor="crosshair"},F.prototype.update=function(t){this._data=t,this._render()},F.prototype.destroy=function(){this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this._tipEl&&this._tipEl.parentNode&&this._tipEl.parentNode.removeChild(this._tipEl)},j.prototype._bind=function(){var t=this;this._charts.forEach(function(e,i){if(e&&e.canvas){e._onHover&&e._onHover.bind(e);e.canvas.addEventListener("click",function(o){var s=e.canvas.getBoundingClientRect(),a=o.clientX-s.left;if(e.categories&&e.categories.length){var r=e._padding||{left:60,right:24},l=(e.W-r.left-(r.right||24))/e.categories.length,h=Math.floor((a-r.left)/l);h=c(h,0,e.categories.length-1);var n=e.categories[h];t._active&&t._active.category===n?(t._active=null,t._clearHighlights()):(t._active={chartIdx:i,categoryIdx:h,category:n},t._applyHighlights(n))}})}})},j.prototype._applyHighlights=function(t){this._charts.forEach(function(e){if(e&&e.categories){var i=e.categories.indexOf(t);e._linkedHighlight=i,e.render()}})},j.prototype._clearHighlights=function(){this._charts.forEach(function(t){t&&(t._linkedHighlight=-1,t.render())})},j.prototype.destroy=function(){this._clearHighlights(),this._charts=[]};var X=w.prototype._clearAndDrawBackground;w.prototype._clearAndDrawBackground=function(){if(X.call(this),null!=this._linkedHighlight&&this._linkedHighlight>=0&&this.categories){var t=this.ctx,e=this._padding,i=this.W-e.left-e.right,o=this.H-e.top-e.bottom,s=i/this.categories.length,a=e.left+s*this._linkedHighlight;t.fillStyle="rgba(99,102,241,0.08)",t.fillRect(a,e.top,s,o),t.fillStyle="#6366f1",t.fillRect(a,e.top,s,3)}},e.bar=function(t,e){return new k(t,e)},e.column=function(t,e){return new T(t,e)},e.barStacked=function(t,e){return new C(t,e)},e.lollipop=function(t,e){return new P(t,e)},e.combo=function(t,e){return new L(t,e)},e.donut=function(t,e){return new E(t,e)},e.gauge=function(t,e){return new A(t,e)},e.heatmap=function(t,e){return new W(t,e)},e.radar=function(t,e){return new R(t,e)},e.lineBar=function(t,e){return new H(t,e)},e.waterfall=function(t,e){return new B(t,e)},e.bullet=function(t,e){return new D(t,e)},e.timeline=function(t,e){return new I(t,e)},e.treemap=function(t,e){return new z(t,e)},e.funnel=function(t,e){return new O(t,e)},e.polar=function(t,e){return new G(t,e)},e.scatter=function(t,e){return new N(t,e)},e.sankey=function(t,e){return new q(t,e)},e.boxplot=function(t,e){return new V(t,e)},e.sparkline=function(t,e,i){return new F(t,e,i)},e.link=function(t,e){return new j(t,e)},"object"==typeof module&&module.exports&&(module.exports=e)}("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:this);
@@ -1 +1 @@
1
- !function(e){"use strict";var t=e.NMCharts;if(!t)throw new Error("NMCharts-Extras: NMCharts must be loaded first.");function n(e){var t=this.canvas;if(t){var n,r=t.width/(window.devicePixelRatio||1),a=t.height/(window.devicePixelRatio||1),o=t.toDataURL("image/png"),i=['<?xml version="1.0" encoding="UTF-8"?>','<svg xmlns="http://www.w3.org/2000/svg"',' xmlns:xlink="http://www.w3.org/1999/xlink"',' width="'+r+'" height="'+a+'"',' viewBox="0 0 '+r+" "+a+'">'," <title>"+(this.opts&&this.opts.title?(n=this.opts.title,String(n).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")):"Chart")+"</title>",' <image x="0" y="0" width="'+r+'" height="'+a+'"',' xlink:href="'+o+'"',' href="'+o+'"/>',"</svg>"].join("\n"),c=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(c),d=document.createElement("a");d.download=e||"chart.svg",d.href=l,d.click(),setTimeout(function(){URL.revokeObjectURL(l)},1e3)}else console.warn("NMCharts exportSVG: no canvas found on instance")}t.themes={corporate:["#1e3a5f","#2d6a9f","#4a90d9","#7cb5ec","#a8d1f0","#2f4858","#547a96","#8fb3c9"],pastel:["#a8d8ea","#aa96da","#fcbad3","#ffffd2","#b5ead7","#c7ceea","#ffdac1","#e2f0cb"],vibrant:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd","#01a3a4","#f368e0"],monochrome:["#1a1a2e","#3d3d5c","#5f5f8a","#8282b8","#a5a5d0","#c8c8e6","#e0e0f0","#f0f0f8"],colorblind:["#0072B2","#E69F00","#009E73","#D55E00","#CC79A7","#56B4E9","#F0E442","#999999"]},t.prototype.exportSVG=n;["create","bar","column","barStacked","lollipop","combo","donut","gauge","heatmap","radar","lineBar","waterfall","bullet","timeline"].forEach(function(e){var r=t[e];"function"==typeof r&&(t[e]=function(a,o){var i,c,l,d=function(e){if(!e||!e.theme)return e;var n=t.themes[e.theme];if(!n)return e;var r=Object.assign({},e);return r.colors||(r.colors=n),r.series&&(r.series=r.series.map(function(e,t){return e.color?e:Object.assign({},e,{color:n[t%n.length]})})),r}(o),s=r.call(t,a,d);if(!s)return s;if("function"!=typeof s.exportSVG&&(s.exportSVG=n.bind(s)),function(e,t){var n=e._root;if(n){var r=(e.opts||{}).title||"",a=r?r+" — "+t+" chart":t+" chart";n.setAttribute("role","img"),n.setAttribute("aria-label",a),n.setAttribute("tabindex","0");var o=e.series,i=e.categories;if(o&&o.length){var c=document.createElement("table");c.style.cssText=["position:absolute","width:1px","height:1px","padding:0","margin:-1px","overflow:hidden","clip:rect(0,0,0,0)","white-space:nowrap","border:0"].join(";");var l=document.createElement("caption");if(l.textContent=a,c.appendChild(l),i&&i.length){var d=document.createElement("thead"),s=document.createElement("tr"),f=document.createElement("th");f.textContent="Series",s.appendChild(f),i.forEach(function(e){var t=document.createElement("th");t.setAttribute("scope","col"),t.textContent=String(e),s.appendChild(t)}),d.appendChild(s),c.appendChild(d);var p=document.createElement("tbody");o.forEach(function(e){var t=document.createElement("tr"),n=document.createElement("th");n.setAttribute("scope","row"),n.textContent=e.name||"",t.appendChild(n),(e.data||[]).forEach(function(e){var n=document.createElement("td");n.textContent=null!=e?String(e):"",t.appendChild(n)}),p.appendChild(t)}),c.appendChild(p)}else{var u=document.createElement("tbody");o.forEach(function(e){var t=document.createElement("tr"),n=document.createElement("td");n.textContent=e.name||"";var r=document.createElement("td");r.textContent=null!=e.value?String(e.value):Array.isArray(e.data)?e.data.join(", "):"",t.appendChild(n),t.appendChild(r),u.appendChild(t)}),c.appendChild(u)}n.style.position=n.style.position||"relative",n.appendChild(c)}}}(s,"create"===e?"line":e),"undefined"!=typeof ResizeObserver&&s._root){var f=(i=function(){"function"==typeof s._initSize&&s._initSize(),"function"==typeof s.render&&s.render(),"function"==typeof s._renderNav&&s._renderNav()},c=150,function(){var e=this,t=arguments;clearTimeout(l),l=setTimeout(function(){i.apply(e,t)},c)}),p=new ResizeObserver(function(e){e&&e.length&&f()});p.observe(s._root),s._resizeObserver=p;var u=s.destroy;s.destroy=function(){s._resizeObserver&&(s._resizeObserver.disconnect(),s._resizeObserver=null),"function"==typeof u&&u.call(s)}}return s})}),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:this);
1
+ !function(e){"use strict";var t=e.NMCharts;if(!t)throw new Error("NMCharts-Extras: NMCharts must be loaded first.");function n(e){var t=this.canvas;if(t){var n,r=t.width/(window.devicePixelRatio||1),a=t.height/(window.devicePixelRatio||1),o=t.toDataURL("image/png"),i=['<?xml version="1.0" encoding="UTF-8"?>','<svg xmlns="http://www.w3.org/2000/svg"',' xmlns:xlink="http://www.w3.org/1999/xlink"',' width="'+r+'" height="'+a+'"',' viewBox="0 0 '+r+" "+a+'">'," <title>"+(this.opts&&this.opts.title?(n=this.opts.title,String(n).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")):"Chart")+"</title>",' <image x="0" y="0" width="'+r+'" height="'+a+'"',' xlink:href="'+o+'"',' href="'+o+'"/>',"</svg>"].join("\n"),c=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(c),d=document.createElement("a");d.download=e||"chart.svg",d.href=l,d.click(),setTimeout(function(){URL.revokeObjectURL(l)},1e3)}else console.warn("NMCharts exportSVG: no canvas found on instance")}t.themes={corporate:["#1e3a5f","#2d6a9f","#4a90d9","#7cb5ec","#a8d1f0","#2f4858","#547a96","#8fb3c9"],pastel:["#a8d8ea","#aa96da","#fcbad3","#ffffd2","#b5ead7","#c7ceea","#ffdac1","#e2f0cb"],vibrant:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd","#01a3a4","#f368e0"],monochrome:["#1a1a2e","#3d3d5c","#5f5f8a","#8282b8","#a5a5d0","#c8c8e6","#e0e0f0","#f0f0f8"],colorblind:["#0072B2","#E69F00","#009E73","#D55E00","#CC79A7","#56B4E9","#F0E442","#999999"]},t.prototype.exportSVG=n;["create","bar","column","barStacked","lollipop","combo","donut","gauge","heatmap","radar","lineBar","waterfall","bullet","timeline","treemap","funnel","polar","scatter","sankey","boxplot","sparkline"].forEach(function(e){var r=t[e];"function"==typeof r&&(t[e]=function(a,o){var i,c,l,d=function(e){if(!e||!e.theme)return e;var n=t.themes[e.theme];if(!n)return e;var r=Object.assign({},e);return r.colors||(r.colors=n),r.series&&(r.series=r.series.map(function(e,t){return e.color?e:Object.assign({},e,{color:n[t%n.length]})})),r}(o),s=r.call(t,a,d);if(!s)return s;if("function"!=typeof s.exportSVG&&(s.exportSVG=n.bind(s)),function(e,t){var n=e._root;if(n){var r=(e.opts||{}).title||"",a=r?r+" — "+t+" chart":t+" chart";n.setAttribute("role","img"),n.setAttribute("aria-label",a),n.setAttribute("tabindex","0");var o=e.series,i=e.categories;if(o&&o.length){var c=document.createElement("table");c.style.cssText=["position:absolute","width:1px","height:1px","padding:0","margin:-1px","overflow:hidden","clip:rect(0,0,0,0)","white-space:nowrap","border:0"].join(";");var l=document.createElement("caption");if(l.textContent=a,c.appendChild(l),i&&i.length){var d=document.createElement("thead"),s=document.createElement("tr"),f=document.createElement("th");f.textContent="Series",s.appendChild(f),i.forEach(function(e){var t=document.createElement("th");t.setAttribute("scope","col"),t.textContent=String(e),s.appendChild(t)}),d.appendChild(s),c.appendChild(d);var p=document.createElement("tbody");o.forEach(function(e){var t=document.createElement("tr"),n=document.createElement("th");n.setAttribute("scope","row"),n.textContent=e.name||"",t.appendChild(n),(e.data||[]).forEach(function(e){var n=document.createElement("td");n.textContent=null!=e?String(e):"",t.appendChild(n)}),p.appendChild(t)}),c.appendChild(p)}else{var u=document.createElement("tbody");o.forEach(function(e){var t=document.createElement("tr"),n=document.createElement("td");n.textContent=e.name||"";var r=document.createElement("td");r.textContent=null!=e.value?String(e.value):Array.isArray(e.data)?e.data.join(", "):"",t.appendChild(n),t.appendChild(r),u.appendChild(t)}),c.appendChild(u)}n.style.position=n.style.position||"relative",n.appendChild(c)}}}(s,"create"===e?"line":e),"undefined"!=typeof ResizeObserver&&s._root){var f=(i=function(){"function"==typeof s._initSize&&s._initSize(),"function"==typeof s.render&&s.render(),"function"==typeof s._renderNav&&s._renderNav()},c=150,function(){var e=this,t=arguments;clearTimeout(l),l=setTimeout(function(){i.apply(e,t)},c)}),p=new ResizeObserver(function(e){e&&e.length&&f()});p.observe(s._root),s._resizeObserver=p;var u=s.destroy;s.destroy=function(){s._resizeObserver&&(s._resizeObserver.disconnect(),s._resizeObserver=null),"function"==typeof u&&u.call(s)}}return s})}),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:this);
package/nmcharts.d.ts CHANGED
@@ -39,8 +39,8 @@ interface NMChartsOptions {
39
39
  interface NMChartsInstance {
40
40
  render(): void;
41
41
  exportPNG(filename?: string): void;
42
- /** Export chart as SVG file (raster image embedded in SVG wrapper) */
43
- exportSVG(filename?: string): void;
42
+ /** Export chart as SVG file (requires nmcharts-extras.js) */
43
+ exportSVG?(filename?: string): void;
44
44
  setDarkMode(enabled: boolean): void;
45
45
  updateSeries(series: NMChartsSeries[]): void;
46
46
  destroy(): void;
@@ -79,6 +79,8 @@ interface NMCategoryOptions {
79
79
  gridColor?: string;
80
80
  gridDashed?: boolean;
81
81
  colors?: string[];
82
+ zoomPan?: boolean;
83
+ annotations?: NMAnnotation[];
82
84
  barWidth?: number;
83
85
  barGap?: number;
84
86
  groupPadding?: number;
@@ -314,6 +316,69 @@ interface NMLinkInstance {
314
316
  destroy(): void;
315
317
  }
316
318
 
319
+ interface NMBookingTimelineOptions {
320
+ title?: string;
321
+ month?: number;
322
+ year?: number;
323
+ properties?: Array<{
324
+ name: string;
325
+ location?: string;
326
+ rating?: number;
327
+ avatar?: string;
328
+ color?: string;
329
+ }>;
330
+ bookings?: Array<{
331
+ property: number;
332
+ guest?: string;
333
+ checkIn: string;
334
+ checkOut: string;
335
+ status?: 'confirmed' | 'pending' | 'checked-in' | 'checked-out' | 'cancelled' | 'blocked';
336
+ price?: string;
337
+ platform?: 'airbnb' | 'booking' | 'direct' | string;
338
+ color?: string;
339
+ guestAvatar?: string;
340
+ nights?: number;
341
+ }>;
342
+ cellWidth?: number;
343
+ rowHeight?: number;
344
+ avatarSize?: number;
345
+ statusColors?: Record<string, string>;
346
+ onBookingClick?: (booking: any) => void;
347
+ }
348
+
349
+ interface NMBookingTimelineInstance {
350
+ destroy(): void;
351
+ }
352
+
353
+ interface NMAnnotation {
354
+ type: 'line' | 'band' | 'vline' | 'marker';
355
+ value?: number;
356
+ from?: number;
357
+ to?: number;
358
+ category?: string | number;
359
+ color?: string;
360
+ label?: string;
361
+ labelColor?: string;
362
+ labelAlign?: string;
363
+ lineWidth?: number;
364
+ dash?: number[];
365
+ radius?: number;
366
+ }
367
+
368
+ interface NMDiagnosticResult {
369
+ nmchartsLoaded: boolean;
370
+ version: string;
371
+ debug: boolean;
372
+ cspFallback: boolean;
373
+ stylesInjected: boolean;
374
+ nmchartsStyleTag: boolean;
375
+ dpr: number;
376
+ roundRectNative: boolean;
377
+ container: any;
378
+ cssVars?: any;
379
+ chartMethods: string[];
380
+ }
381
+
317
382
  // --- Theme definitions ---
318
383
 
319
384
  interface NMChartsThemes {
@@ -348,7 +413,11 @@ interface NMChartsStatic {
348
413
  boxplot(selector: string | HTMLElement, options: NMBoxplotOptions): NMCategoryInstance;
349
414
  sparkline(selector: string | HTMLElement, data: number[], options?: NMSparklineOptions): NMSparklineInstance;
350
415
  link(charts: NMCategoryInstance[], options?: NMLinkOptions): NMLinkInstance;
416
+ bookingTimeline(selector: string | HTMLElement, options: NMBookingTimelineOptions): NMBookingTimelineInstance;
351
417
  lttb(data: any[], threshold: number): any[];
418
+ diagnose(selector?: string | HTMLElement): NMDiagnosticResult;
419
+ debug: boolean;
420
+ _cspNonce: string;
352
421
  themes: NMChartsThemes;
353
422
  }
354
423
 
@@ -364,6 +433,10 @@ export {
364
433
  NMBulletOptions, NMTimelineOptions, NMWaterfallOptions,
365
434
  NMTreemapOptions, NMFunnelOptions, NMPolarOptions,
366
435
  NMScatterOptions, NMSankeyOptions, NMBoxplotOptions,
436
+ NMSparklineOptions, NMSparklineInstance,
437
+ NMLinkOptions, NMLinkInstance,
438
+ NMBookingTimelineOptions, NMBookingTimelineInstance,
439
+ NMAnnotation, NMDiagnosticResult,
367
440
  NMChartsThemes
368
441
  };
369
442
  export default NMCharts;