@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.
- package/nmcharts-categories.min.js +1 -1
- package/nmcharts-extras.min.js +1 -1
- package/nmcharts.d.ts +75 -2
- package/nmcharts.esm.js +1152 -2
- package/nmcharts.js +1170 -1
- package/package.json +17 -7
- package/nmcharts-categories.js +0 -5597
- package/nmcharts-extras.js +0 -320
package/nmcharts.esm.js
CHANGED
|
@@ -7,8 +7,1158 @@
|
|
|
7
7
|
* const chart = NMCharts.create('#container', { ... });
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var NMCharts;!function(){"use strict";var e=!1,i=[":root{","--mc-bg:#f5f7fa;--mc-card:#fff;--mc-text:#1e293b;--mc-text2:#475569;--mc-muted:#94a3b8;","--mc-grid:#e2e8f0;--mc-border:#e2e8f0;--mc-hover:rgba(0,0,0,.04);","--mc-tt-bg:#1e293b;--mc-tt-fg:#fff;","--mc-sel:rgba(79,70,229,.1);--mc-sel-b:rgba(79,70,229,.3);","--mc-btn:#4f46e5;--mc-btn-h:#4338ca;--mc-mask:rgba(148,163,184,.18);","}",".mc-dark{","--mc-bg:#0f172a;--mc-card:#1e293b;--mc-text:#f1f5f9;--mc-text2:#cbd5e1;--mc-muted:#64748b;","--mc-grid:#334155;--mc-border:#334155;--mc-hover:rgba(255,255,255,.05);","--mc-tt-bg:#0f172a;--mc-tt-fg:#f1f5f9;","--mc-sel:rgba(129,120,255,.15);--mc-sel-b:rgba(129,120,255,.35);","--mc-btn:#6366f1;--mc-btn-h:#818cf8;--mc-mask:rgba(100,116,139,.3);","}",'.mc-root{position:relative;background:var(--mc-card);border-radius:12px;box-shadow:0 2px 16px rgba(0,0,0,.08);padding:20px 20px 14px;user-select:none;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;color:var(--mc-text);transition:background .3s,box-shadow .3s}',".mc-dark .mc-root{box-shadow:0 2px 24px rgba(0,0,0,.3)}",".mc-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}",".mc-titles{text-align:center;flex:1}",".mc-title{font-size:18px;font-weight:600}",".mc-subtitle{font-size:12px;color:var(--mc-muted);margin-top:2px}",".mc-toolbar{display:flex;gap:4px;flex-shrink:0}",".mc-toolbar button{width:32px;height:32px;border:1px solid var(--mc-border);border-radius:6px;background:transparent;color:var(--mc-text2);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s,border-color .15s}",".mc-toolbar button:hover{background:var(--mc-hover)}",".mc-toolbar button.active{background:var(--mc-btn);color:#fff;border-color:var(--mc-btn)}",".mc-toolbar button svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}",".mc-wrap{position:relative;width:100%}",".mc-wrap canvas{display:block;width:100%}",".mc-legend{display:flex;justify-content:center;gap:20px;margin-top:8px;flex-wrap:wrap}",".mc-legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--mc-text2);cursor:pointer;padding:2px 6px;border-radius:4px;transition:background .15s}",".mc-legend-item:hover{background:var(--mc-hover)}",".mc-legend-swatch{width:14px;height:3px;border-radius:2px}",".mc-legend-item.disabled .mc-legend-swatch{opacity:.25}",".mc-legend-item.disabled span:last-child{text-decoration:line-through;opacity:.4}",".mc-tooltip{position:absolute;pointer-events:none;opacity:0;background:var(--mc-tt-bg);color:var(--mc-tt-fg);border-radius:8px;padding:10px 14px;font-size:12px;line-height:1.6;white-space:nowrap;box-shadow:0 4px 12px rgba(0,0,0,.2);transition:opacity .1s;z-index:10}",".mc-tooltip.visible{opacity:1}",".mc-tooltip-date{font-weight:600;margin-bottom:2px}",".mc-tooltip-row{display:flex;align-items:center;gap:6px}",".mc-tooltip-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}",".mc-tooltip-val{margin-left:auto;padding-left:12px;font-weight:600}",".mc-selection{position:absolute;top:0;height:100%;background:var(--mc-sel);border-left:1px solid var(--mc-sel-b);border-right:1px solid var(--mc-sel-b);pointer-events:none;display:none}",".mc-reset{position:absolute;top:8px;right:8px;background:var(--mc-btn);color:#fff;border:none;border-radius:6px;padding:4px 10px;font-size:11px;font-weight:500;cursor:pointer;opacity:0;pointer-events:none;transition:opacity .2s}",".mc-reset.visible{opacity:1;pointer-events:auto}",".mc-reset:hover{background:var(--mc-btn-h)}",".mc-nav{position:relative;width:100%;height:48px;margin-top:6px;border-top:1px solid var(--mc-border)}",".mc-nav canvas{display:block;width:100%;height:48px}",".mc-nav-mask{position:absolute;top:0;height:100%;background:var(--mc-mask);pointer-events:none}",".mc-nav-mask.left{left:0}",".mc-nav-mask.right{right:0}",".mc-nav-win{position:absolute;top:0;height:100%;border-left:2px solid var(--mc-btn);border-right:2px solid var(--mc-btn);cursor:grab;z-index:2}",".mc-nav-h{position:absolute;top:50%;transform:translateY(-50%);width:6px;height:20px;background:var(--mc-btn);border-radius:3px;cursor:ew-resize;z-index:3}",".mc-nav-h.l{left:-4px}",".mc-nav-h.r{right:-4px}",".mc-root:fullscreen,.mc-root:-webkit-full-screen{display:flex;flex-direction:column;justify-content:center;max-width:100%;width:100%;border-radius:0}"].join("\n"),n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function o(t,e,i){return t+(e-t)*i}function r(t,e,i){return Math.max(e,Math.min(i,t))}function s(t,e){var i=Math.floor(Math.log10(t)),n=t/Math.pow(10,i);return(e?n<1.5?1:n<3?2:n<7?5:10:n<=1?1:n<=2?2:n<=5?5:10)*Math.pow(10,i)}function l(t){return Math.abs(t)>=1e3?t.toLocaleString("en-US",{maximumFractionDigits:1}):t===Math.floor(t)?t.toString():t.toFixed(1)}function c(t,e,i,_t){var T=typeof _t==="number"?_t:1;var n=e.length;if(!(n<2))if(i||t.moveTo(e[0][0],e[0][1]),2!==n){if(T<=0){for(var j=1;j<n;j++)t.lineTo(e[j][0],e[j][1]);return}for(var a=[],o=[],r=[],s=0;s<n-1;s++)a[s]=e[s+1][0]-e[s][0],o[s]=e[s+1][1]-e[s][1],r[s]=0===a[s]?0:o[s]/a[s];var l=[r[0]];for(s=1;s<n-1;s++)l[s]=r[s-1]*r[s]<=0?0:(r[s-1]+r[s])/2;for(l[n-1]=r[n-2],s=0;s<n-1;s++)if(Math.abs(r[s])<1e-10)l[s]=0,l[s+1]=0;else{var c=l[s]/r[s],d=l[s+1]/r[s],h=c*c+d*d;if(h>9){var p=3/Math.sqrt(h);l[s]=p*c*r[s],l[s+1]=p*d*r[s]}}for(s=0;s<n-1;s++){var v=a[s]*T/3;t.bezierCurveTo(e[s][0]+v,e[s][1]+l[s]*v,e[s+1][0]-v,e[s+1][1]-l[s+1]*v,e[s+1][0],e[s+1][1])}}else t.lineTo(e[1][0],e[1][1])}function d(t,e){return"rgba("+parseInt(t.slice(1,3),16)+","+parseInt(t.slice(3,5),16)+","+parseInt(t.slice(5,7),16)+","+e+")"}function h(t){return getComputedStyle(document.documentElement).getPropertyValue("--mc-"+t).trim()}function p(t,e,i){var n=document.createElement(t);return e&&(n.className=e),i&&i.appendChild(n),n}function v(t,n){if(function(){if(!e){e=!0;var t=document.createElement("style");t.textContent=i,document.head.appendChild(t)}}(),n=n||{},this.el="string"==typeof t?document.querySelector(t):t,!this.el)throw new Error("NMCharts: container not found");this.opts=n,this.bands=n.bands||[],this.forecastFrom=n.forecastFrom||null;var a=n.toolbar||{};this.series=(n.series||[]).map(function(t){return{name:t.name,data:t.data.slice().sort(function(t,e){return t[0]-e[0]}),color:t.color,type:t.type||"area",dashStyle:t.dashStyle||null,lineWidth:t.lineWidth||2.5,tension:typeof t.tension==="number"?t.tension:1,visible:!0}}),this._buildDOM(n,a),this._computeFullBounds(),this.viewXMin=this.fullXMin,this.viewXMax=this.fullXMax,this._dragStart=null,this._dragging=!1,this._panning=!1,this._panAnchorX=0,this._panViewStart=0,this._panViewEnd=0,this._hoverIdx=-1,this._zoomed=!1,this._entryProgress=0,this._entryStart=performance.now(),this._initSize(),this._buildLegend(),this._bindEvents(),this._bindNavigator(),this._startEntryAnim()}v.prototype._buildDOM=function(t,e){var i=p("div","mc-root",this.el);this._root=i;var n=p("div","mc-header",i);p("div","",n).style.width="120px";var a=p("div","mc-titles",n);p("div","mc-title",a).textContent=t.title||"",p("div","mc-subtitle",a).innerHTML=t.subtitle||"Drag to zoom · Shift+drag to pan · Scroll to zoom · Double-click to reset";var o=p("div","mc-toolbar",n),r=this;if(!1!==e.dark){var s=p("button","",o);s.title="Dark mode",s.innerHTML='<svg viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 0 1 11.21 3a7 7 0 1 0 9.79 9.79z"/></svg>',s.addEventListener("click",function(){r.el.classList.toggle("mc-dark"),s.classList.toggle("active"),r.render(),r._renderNav()})}if(!1!==e.export){var l=p("button","",o);l.title="Export PNG",l.innerHTML='<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>',l.addEventListener("click",function(){r.exportPNG()})}if(!1!==e.fullscreen){var c=p("button","",o);c.title="Fullscreen",c.innerHTML='<svg viewBox="0 0 24 24"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>',c.addEventListener("click",function(){document.fullscreenElement?(document.exitFullscreen||document.webkitExitFullscreen).call(document):(i.requestFullscreen||i.webkitRequestFullscreen).call(i)}),["fullscreenchange","webkitfullscreenchange"].forEach(function(t){document.addEventListener(t,function(){setTimeout(function(){r._initSize(),r.render(),r._renderNav()},100)})})}var d=p("div","mc-wrap",i);this._wrap=d,this.canvas=p("canvas","",d),this.ctx=this.canvas.getContext("2d"),this._tooltipEl=p("div","mc-tooltip",d),this._selEl=p("div","mc-selection",d),this._resetBtn=p("button","mc-reset",d),this._resetBtn.textContent="Reset zoom";var h=p("div","mc-nav",i);this._navWrap=h,this._navCanvas=p("canvas","",h),this._navCtx=this._navCanvas.getContext("2d"),this._navMaskL=p("div","mc-nav-mask left",h),this._navMaskR=p("div","mc-nav-mask right",h);var v=p("div","mc-nav-win",h);this._navWin=v,this._navHL=p("div","mc-nav-h l",v),this._navHR=p("div","mc-nav-h r",v),this._legendEl=p("div","mc-legend",i)},v.prototype._computeFullBounds=function(){for(var t=1/0,e=-1/0,i=0;i<this.series.length;i++){var n=this.series[i].data;n.length&&(t=Math.min(t,n[0][0]),e=Math.max(e,n[n.length-1][0]))}this.fullXMin=t,this.fullXMax=e},v.prototype._initSize=function(){var t=window.devicePixelRatio||1,e=this._wrap.getBoundingClientRect().width,i=Math.round(.42*e);this.canvas.width=e*t,this.canvas.height=i*t,this.canvas.style.height=i+"px",this.ctx.setTransform(t,0,0,t,0,0),this.W=e,this.H=i,this.pX=58,this.pY=24,this.pW=e-58-24,this.pH=i-24-44;var n=this._navWrap.getBoundingClientRect().width;this._navCanvas.width=n*t,this._navCanvas.height=48*t,this._navCtx.setTransform(t,0,0,t,0,0),this._nW=n,this._nH=48},v.prototype._buildLegend=function(){var t=this;this._legendEl.innerHTML="",this.series.forEach(function(e){var i=p("div","mc-legend-item"+(e.visible?"":" disabled"),t._legendEl),n="line"===e.type?"background:transparent;border-top:2.5px "+("dashed"===e.dashStyle?"dashed":"dotted"===e.dashStyle?"dotted":"solid")+" "+e.color+";height:0;margin-top:1px":"background:"+e.color;i.innerHTML='<div class="mc-legend-swatch" style="'+n+'"></div><span>'+e.name+"</span>",i.addEventListener("click",function(){e.visible=!e.visible,i.classList.toggle("disabled",!e.visible),t.render(),t._renderNav()})})},v.prototype._x2px=function(t){return this.pX+(t-this.viewXMin)/(this.viewXMax-this.viewXMin)*this.pW},v.prototype._y2px=function(t,e){return this.pY+this.pH-(t-e.min)/(e.max-e.min)*this.pH},v.prototype._px2x=function(t){return this.viewXMin+(t-this.pX)/this.pW*(this.viewXMax-this.viewXMin)},v.prototype._yScale=function(){for(var t=1/0,e=-1/0,i=0;i<this.series.length;i++)if(this.series[i].visible)for(var n=this.series[i].data,a=0;a<n.length;a++)n[a][0]>=this.viewXMin&&n[a][0]<=this.viewXMax&&(t=Math.min(t,n[a][1]),e=Math.max(e,n[a][1]));return t===1/0&&(t=0,e=100),function(t,e){t===e&&(t-=1,e+=1);for(var i=s(e-t,!1),n=s(i/5,!0),a=Math.floor(t/n)*n,o=Math.ceil(e/n)*n,r=[],l=a;l<=o+.5*n;l+=n)r.push(Math.round(1e10*l)/1e10);return{min:a,max:o,step:n,ticks:r}}(t=Math.min(0,t),e)},v.prototype._startEntryAnim=function(){var t=this,e=performance.now();!function i(n){var a=r((n-e)/800,0,1);t._entryProgress=1-Math.pow(1-a,3),t.render(),t._renderNav(),a<1&&requestAnimationFrame(i)}(e)},v.prototype.render=function(){var t=this.ctx,e=this._yScale(),i=this,a=h("grid"),o=h("muted"),s='11px -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif';t.clearRect(0,0,this.W,this.H),this.bands.forEach(function(n){var a=i._y2px(Math.min(n.to,e.max),e),o=i._y2px(Math.max(n.from,e.min),e);o<=i.pY||a>=i.pY+i.pH||(a=r(a,i.pY,i.pY+i.pH),o=r(o,i.pY,i.pY+i.pH),t.fillStyle=n.color,t.fillRect(i.pX,a,i.pW,o-a),n.label&&(t.save(),t.font="9px "+s,t.fillStyle=n.labelColor||n.color,t.textAlign="right",t.textBaseline="top",t.globalAlpha=.7,t.fillText(n.label,i.pX+i.pW-4,a+2),t.restore()))}),t.save(),t.font=s,t.textAlign="right",t.textBaseline="middle",e.ticks.forEach(function(n){var r=i._y2px(n,e);t.strokeStyle=a,t.lineWidth=1,t.beginPath(),t.moveTo(i.pX,Math.round(r)+.5),t.lineTo(i.pX+i.pW,Math.round(r)+.5),t.stroke(),t.fillStyle=o,t.fillText(l(n),i.pX-8,r)}),t.restore();var p=function(t,e,i){for(var n=e-t,a=864e5,o=[a,2*a,5*a,7*a,14*a,30*a,60*a,90*a,180*a,365*a],r=a,s=0;s<o.length;s++)if(n/o[s]<=i){r=o[s];break}for(var l=[],c=Math.ceil(t/r)*r;c<=e;c+=r)l.push(c);return l}(this.viewXMin,this.viewXMax,Math.floor(this.pW/80));t.save(),t.font=s,t.textAlign="center",t.textBaseline="top",t.fillStyle=o,p.forEach(function(e){var o=i._x2px(e);o>=i.pX&&o<=i.pX+i.pW&&(t.strokeStyle=a,t.beginPath(),t.moveTo(Math.round(o)+.5,i.pY+i.pH),t.lineTo(Math.round(o)+.5,i.pY+i.pH+5),t.stroke(),t.fillText(function(t){var e=new Date(t);return e.getUTCDate()+" "+n[e.getUTCMonth()]}(e),o,i.pY+i.pH+8))}),t.restore(),t.strokeStyle=a,t.lineWidth=1,t.beginPath(),t.moveTo(this.pX,this.pY),t.lineTo(this.pX,this.pY+this.pH),t.lineTo(this.pX+this.pW,this.pY+this.pH),t.stroke(),t.save(),t.beginPath(),t.rect(this.pX,this.pY,this.pW,this.pH),t.clip();var v=this.pW*this._entryProgress;if(this.series.forEach(function(n){if(n.visible){for(var a=[],o=.05*(i.viewXMax-i.viewXMin),r=0;r<n.data.length;r++){var s=n.data[r][0],l=n.data[r][1];s<i.viewXMin-o||s>i.viewXMax+o||a.push([i._x2px(s),i._y2px(l,e),s])}if(!(a.length<2)){var h=i._y2px(e.min,e);t.save(),t.beginPath(),t.rect(i.pX,i.pY,v,i.pH),t.clip();var p=a,u=null;if(i.forecastFrom){p=[],u=[];for(var f=0;f<a.length;f++)a[f][2]<i.forecastFrom?p.push(a[f]):u.push(a[f]);p.length&&u.length&&u.unshift(p[p.length-1])}var m="line"===n.type,g="dashed"===n.dashStyle?[6,4]:"dotted"===n.dashStyle?[2,3]:null;x(p,!1),u&&u.length>=2&&x(u,!0),t.restore()}}function x(e,a){if(!(e.length<2)){if(!m){var o=t.createLinearGradient(0,i.pY,0,h);o.addColorStop(0,d(n.color,.22)),o.addColorStop(1,d(n.color,.02)),t.beginPath(),t.moveTo(e[0][0],h),t.lineTo(e[0][0],e[0][1]),c(t,e,!0,n.tension),t.lineTo(e[e.length-1][0],h),t.closePath(),t.fillStyle=o,t.fill()}var r=a?[6,4]:g;r&&t.setLineDash(r),t.beginPath(),c(t,e,!1,n.tension),t.strokeStyle=n.color,t.lineWidth=n.lineWidth,t.lineJoin="round",t.lineCap="round",t.stroke(),r&&t.setLineDash([])}}}),this._hoverIdx>=0&&this._entryProgress>=1){var u=null;this.series.forEach(function(n){if(n.visible&&!(i._hoverIdx>=n.data.length)){var a=n.data[i._hoverIdx],o=i._x2px(a[0]),r=i._y2px(a[1],e);u=o,t.beginPath(),t.arc(o,r,5,0,2*Math.PI),t.fillStyle=h("card"),t.fill(),t.strokeStyle=n.color,t.lineWidth=2.5,t.stroke()}}),null!==u&&(t.strokeStyle=d(o,.4),t.lineWidth=1,t.setLineDash([4,3]),t.beginPath(),t.moveTo(Math.round(u)+.5,i.pY),t.lineTo(Math.round(u)+.5,i.pY+i.pH),t.stroke(),t.setLineDash([]))}t.restore()},v.prototype._renderNav=function(){var t=this._navCtx,e=this._nW,i=this._nH,n=this,a=e-2-2,o=i-4-4;t.clearRect(0,0,e,i);var r=1/0,s=-1/0;this.series.forEach(function(t){t.visible&&t.data.forEach(function(t){r=Math.min(r,t[1]),s=Math.max(s,t[1])})}),r===1/0&&(r=0,s=100),r=Math.min(0,r);var l=4+o;this.series.forEach(function(e){if(e.visible){var i=e.data.map(function(t){return[2+(t[0]-n.fullXMin)/(n.fullXMax-n.fullXMin)*a,4+o-(t[1]-r)/(s-r)*o]});if(!(i.length<2)){if("line"!==e.type){var h=t.createLinearGradient(0,4,0,l);h.addColorStop(0,d(e.color,.18)),h.addColorStop(1,d(e.color,.02)),t.beginPath(),t.moveTo(i[0][0],l),t.lineTo(i[0][0],i[0][1]),c(t,i,!0,e.tension),t.lineTo(i[i.length-1][0],l),t.closePath(),t.fillStyle=h,t.fill()}var p="dashed"===e.dashStyle?[4,3]:"dotted"===e.dashStyle?[2,2]:null;p&&t.setLineDash(p),t.beginPath(),c(t,i,!1,e.tension),t.strokeStyle=d(e.color,.6),t.lineWidth=1.2,t.stroke(),p&&t.setLineDash([])}}});var h=(this.viewXMin-this.fullXMin)/(this.fullXMax-this.fullXMin)*100,p=(this.fullXMax-this.viewXMax)/(this.fullXMax-this.fullXMin)*100;this._navWin.style.left=h+"%",this._navWin.style.right=p+"%",this._navMaskL.style.width=h+"%",this._navMaskR.style.width=p+"%"},v.prototype._bindNavigator=function(){var t,e,i,n=this,a=null;function o(o,r){o.preventDefault(),o.stopPropagation(),a=r,t=o.clientX,e=n.viewXMin,i=n.viewXMax,document.addEventListener("mousemove",s),document.addEventListener("mouseup",l)}function s(o){var s=n._navWrap.getBoundingClientRect(),l=(o.clientX-t)/s.width*(n.fullXMax-n.fullXMin),c=1728e5;if("move"===a){var d=e+l,h=i+l;d<n.fullXMin&&(h+=n.fullXMin-d,d=n.fullXMin),h>n.fullXMax&&(d-=h-n.fullXMax,h=n.fullXMax),n.viewXMin=d,n.viewXMax=h}else"left"===a?n.viewXMin=r(e+l,n.fullXMin,n.viewXMax-c):n.viewXMax=r(i+l,n.viewXMin+c,n.fullXMax);n._zoomed=n.viewXMin>n.fullXMin||n.viewXMax<n.fullXMax,n._resetBtn.classList.toggle("visible",n._zoomed),n.render(),n._renderNav()}function l(){a=null,document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",l)}this._navWin.addEventListener("mousedown",function(t){o(t,"move")}),this._navHL.addEventListener("mousedown",function(t){o(t,"left")}),this._navHR.addEventListener("mousedown",function(t){o(t,"right")}),this._navWrap.addEventListener("mousedown",function(t){if(t.target===n._navCanvas){var e=n._navWrap.getBoundingClientRect(),i=n.fullXMin+(t.clientX-e.left)/e.width*(n.fullXMax-n.fullXMin),a=n.viewXMax-n.viewXMin,o=i-a/2,r=i+a/2;o<n.fullXMin&&(r+=n.fullXMin-o,o=n.fullXMin),r>n.fullXMax&&(o-=r-n.fullXMax,r=n.fullXMax),n._zoomed=!0,n._resetBtn.classList.add("visible"),n._animateTo(o,r)}})},v.prototype._animateTo=function(t,e){var i={a:this.viewXMin,b:this.viewXMax},n=this,a=performance.now();!function s(l){var c=r((l-a)/400,0,1),d=1-Math.pow(1-c,3);n.viewXMin=o(i.a,t,d),n.viewXMax=o(i.b,e,d),n.render(),n._renderNav(),c<1&&requestAnimationFrame(s)}(a)},v.prototype._bindEvents=function(){var t,e=this,i=this.canvas;function n(t){var e=i.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}function a(t){return t.x>=e.pX&&t.x<=e.pX+e.pW&&t.y>=e.pY&&t.y<=e.pY+e.pH}window.addEventListener("resize",function(){clearTimeout(t),t=setTimeout(function(){e._initSize(),e.render(),e._renderNav()},80)}),i.addEventListener("mousedown",function(t){var o=n(t);a(o)&&(t.shiftKey&&e._zoomed?(e._panning=!0,e._panAnchorX=o.x,e._panViewStart=e.viewXMin,e._panViewEnd=e.viewXMax,i.style.cursor="grabbing"):(e._dragStart=o.x,e._dragging=!0,e._selEl.style.display="block",e._selEl.style.left=o.x+"px",e._selEl.style.width="0px"))}),i.addEventListener("mousemove",function(t){var o=n(t);if(e._panning){var s=o.x-e._panAnchorX,l=e._panViewEnd-e._panViewStart,c=-s/e.pW*l,d=e._panViewStart+c,h=e._panViewEnd+c;return d<e.fullXMin&&(h+=e.fullXMin-d,d=e.fullXMin),h>e.fullXMax&&(d-=h-e.fullXMax,h=e.fullXMax),e.viewXMin=d,e.viewXMax=h,e.render(),void e._renderNav()}if(e._dragging){var p=Math.min(e._dragStart,o.x),v=Math.abs(o.x-e._dragStart);p=r(p,e.pX,e.pX+e.pW);var u=r(p+v,e.pX,e.pX+e.pW);return e._selEl.style.left=p+"px",void(e._selEl.style.width=u-p+"px")}if(a(o)){i.style.cursor=t.shiftKey&&e._zoomed?"grab":"crosshair";var f=function(t){for(var i=e._px2x(t),n=null,a=0;a<e.series.length;a++)if(e.series[a].visible){n=e.series[a].data;break}if(!n||!n.length)return-1;for(var o=0,r=1/0,s=0;s<n.length;s++){var l=Math.abs(n[s][0]-i);l<r&&(r=l,o=s)}return o}(o.x);f!==e._hoverIdx&&(e._hoverIdx=f,e.render()),e._showTooltip(o,f)}else e._hideTooltip()}),window.addEventListener("mouseup",function(){if(e._panning)return e._panning=!1,void(i.style.cursor="crosshair");if(e._dragging){e._dragging=!1,e._selEl.style.display="none";var t=parseFloat(e._selEl.style.width);if(t<10)e._dragStart=null;else{var n=parseFloat(e._selEl.style.left);e._zoomed=!0,e._resetBtn.classList.add("visible"),e._animateTo(e._px2x(n),e._px2x(n+t)),e._dragStart=null}}}),i.addEventListener("mouseleave",function(){e._hideTooltip()}),i.addEventListener("dblclick",function(t){t.preventDefault(),e._zoomed&&(e._zoomed=!1,e._resetBtn.classList.remove("visible"),e._animateTo(e.fullXMin,e.fullXMax))}),i.addEventListener("wheel",function(t){var i=n(t);if(a(i)){t.preventDefault();var o=t.deltaY>0?1.15:1/1.15,r=e._px2x(i.x),s=e.viewXMax-e.viewXMin,l=s*o;if(!(l<1728e5)){var c=(r-e.viewXMin)/s,d=Math.max(r-c*l,e.fullXMin),h=Math.min(r+(1-c)*l,e.fullXMax);e.viewXMin=d,e.viewXMax=h,e._zoomed=d>e.fullXMin||h<e.fullXMax,e._resetBtn.classList.toggle("visible",e._zoomed),e.render(),e._renderNav()}}},{passive:!1}),this._resetBtn.addEventListener("click",function(){e._zoomed=!1,e._resetBtn.classList.remove("visible"),e._animateTo(e.fullXMin,e.fullXMax)}),document.addEventListener("keydown",function(t){if("INPUT"!==t.target.tagName&&"TEXTAREA"!==t.target.tagName){var i=e.viewXMax-e.viewXMin,n=.15*i;if("ArrowLeft"===t.key){var a=Math.max(e.viewXMin-n,e.fullXMin);e._animateTo(a,a+i)}else if("ArrowRight"===t.key){var o=Math.min(e.viewXMax+n,e.fullXMax);e._animateTo(o-i,o)}else if("+"===t.key||"="===t.key){var r=.7*i,s=(e.viewXMin+e.viewXMax)/2;e._zoomed=!0,e._resetBtn.classList.add("visible"),e._animateTo(s-r/2,s+r/2)}else if("-"===t.key){var l=Math.min(1.4*i,e.fullXMax-e.fullXMin),c=(e.viewXMin+e.viewXMax)/2,d=Math.max(c-l/2,e.fullXMin),h=Math.min(c+l/2,e.fullXMax);e._zoomed=d>e.fullXMin||h<e.fullXMax,e._resetBtn.classList.toggle("visible",e._zoomed),e._animateTo(d,h)}else"Escape"===t.key&&e._zoomed&&(e._zoomed=!1,e._resetBtn.classList.remove("visible"),e._animateTo(e.fullXMin,e.fullXMax))}});var o=null;i.addEventListener("touchstart",function(t){1===t.touches.length?(e._panning=!0,e._panAnchorX=t.touches[0].clientX-i.getBoundingClientRect().left,e._panViewStart=e.viewXMin,e._panViewEnd=e.viewXMax):2===t.touches.length&&(e._panning=!1,o=Math.abs(t.touches[1].clientX-t.touches[0].clientX)),t.preventDefault()},{passive:!1}),i.addEventListener("touchmove",function(t){if(1===t.touches.length&&e._panning){var n=t.touches[0].clientX-i.getBoundingClientRect().left-e._panAnchorX,a=e._panViewEnd-e._panViewStart,r=-n/e.pW*a,s=e._panViewStart+r,l=e._panViewEnd+r;s<e.fullXMin&&(l+=e.fullXMin-s,s=e.fullXMin),l>e.fullXMax&&(s-=l-e.fullXMax,l=e.fullXMax),e.viewXMin=s,e.viewXMax=l,e.render(),e._renderNav()}else if(2===t.touches.length&&o){var c=Math.abs(t.touches[1].clientX-t.touches[0].clientX),d=o/c,h=(t.touches[0].clientX+t.touches[1].clientX)/2-i.getBoundingClientRect().left,p=e._px2x(h),v=e.viewXMax-e.viewXMin,u=v*d;if(u<1728e5)return void t.preventDefault();var f=(p-e.viewXMin)/v;e.viewXMin=Math.max(p-f*u,e.fullXMin),e.viewXMax=Math.min(p+(1-f)*u,e.fullXMax),e._zoomed=!0,e._resetBtn.classList.add("visible"),o=c,e.render(),e._renderNav()}t.preventDefault()},{passive:!1}),i.addEventListener("touchend",function(){e._panning=!1,o=null})},v.prototype._showTooltip=function(t,e){if(e<0)this._hideTooltip();else{var i="",o=null;if(this.series.forEach(function(t){!t.visible||e>=t.data.length||(o||(o=t.data[e][0]),i+='<div class="mc-tooltip-row"><div class="mc-tooltip-dot" style="background:'+t.color+'"></div><span>'+t.name+'</span><span class="mc-tooltip-val">'+l(t.data[e][1])+"</span></div>")}),o){i='<div class="mc-tooltip-date">'+function(t){var e=new Date(t);return a[e.getUTCDay()]+", "+n[e.getUTCMonth()]+" "+e.getUTCDate()+", "+e.getUTCFullYear()}(o)+"</div>"+i,this._tooltipEl.innerHTML=i,this._tooltipEl.classList.add("visible");var s=this._tooltipEl.offsetWidth,c=this._tooltipEl.offsetHeight,d=t.x+16,h=t.y-c/2;d+s>this.W-8&&(d=t.x-s-16),h=r(h,4,this.H-c-4),this._tooltipEl.style.left=d+"px",this._tooltipEl.style.top=h+"px"}else this._hideTooltip()}},v.prototype._hideTooltip=function(){this._tooltipEl.classList.remove("visible"),this._hoverIdx>=0&&(this._hoverIdx=-1,this.render())},v.prototype.exportPNG=function(t){var e=document.createElement("a");e.download=t||"chart.png",e.href=this.canvas.toDataURL("image/png"),e.click()},v.prototype.setDarkMode=function(t){this.el.classList.toggle("mc-dark",t),this.render(),this._renderNav()},v.prototype.updateSeries=function(t){this.series=t.map(function(t){return{name:t.name,data:t.data.slice().sort(function(t,e){return t[0]-e[0]}),color:t.color,type:t.type||"area",dashStyle:t.dashStyle||null,lineWidth:t.lineWidth||2.5,tension:typeof t.tension==="number"?t.tension:1,visible:!0}}),this._computeFullBounds(),this.viewXMin=this.fullXMin,this.viewXMax=this.fullXMax,this._zoomed=!1,this._resetBtn.classList.remove("visible"),this._buildLegend(),this.render(),this._renderNav()},v.prototype.destroy=function(){this._root.remove()},v.create=function(t,e){return new v(t,e)}
|
|
11
|
-
|
|
10
|
+
var NMCharts;
|
|
11
|
+
!(function () {
|
|
12
|
+
"use strict";
|
|
13
|
+
var e = !1,
|
|
14
|
+
_styleEl = null,
|
|
15
|
+
_instanceCount = 0,
|
|
16
|
+
i = [
|
|
17
|
+
":root{",
|
|
18
|
+
"--mc-bg:#f5f7fa;--mc-card:#fff;--mc-text:#1e293b;--mc-text2:#475569;--mc-muted:#94a3b8;",
|
|
19
|
+
"--mc-grid:#e2e8f0;--mc-border:#e2e8f0;--mc-hover:rgba(0,0,0,.04);",
|
|
20
|
+
"--mc-tt-bg:#1e293b;--mc-tt-fg:#fff;",
|
|
21
|
+
"--mc-sel:rgba(79,70,229,.1);--mc-sel-b:rgba(79,70,229,.3);",
|
|
22
|
+
"--mc-btn:#4f46e5;--mc-btn-h:#4338ca;--mc-mask:rgba(148,163,184,.18);",
|
|
23
|
+
"}",
|
|
24
|
+
".mc-dark{",
|
|
25
|
+
"--mc-bg:#0f172a;--mc-card:#1e293b;--mc-text:#f1f5f9;--mc-text2:#cbd5e1;--mc-muted:#64748b;",
|
|
26
|
+
"--mc-grid:#334155;--mc-border:#334155;--mc-hover:rgba(255,255,255,.05);",
|
|
27
|
+
"--mc-tt-bg:#0f172a;--mc-tt-fg:#f1f5f9;",
|
|
28
|
+
"--mc-sel:rgba(129,120,255,.15);--mc-sel-b:rgba(129,120,255,.35);",
|
|
29
|
+
"--mc-btn:#6366f1;--mc-btn-h:#818cf8;--mc-mask:rgba(100,116,139,.3);",
|
|
30
|
+
"}",
|
|
31
|
+
'.mc-root{position:relative;background:var(--mc-card);border-radius:12px;box-shadow:0 2px 16px rgba(0,0,0,.08);padding:20px 20px 14px;user-select:none;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;color:var(--mc-text);transition:background .3s,box-shadow .3s}',
|
|
32
|
+
".mc-dark .mc-root{box-shadow:0 2px 24px rgba(0,0,0,.3)}",
|
|
33
|
+
".mc-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}",
|
|
34
|
+
".mc-titles{text-align:center;flex:1}",
|
|
35
|
+
".mc-title{font-size:18px;font-weight:600}",
|
|
36
|
+
".mc-subtitle{font-size:12px;color:var(--mc-muted);margin-top:2px}",
|
|
37
|
+
".mc-toolbar{display:flex;gap:4px;flex-shrink:0}",
|
|
38
|
+
".mc-toolbar button{width:32px;height:32px;border:1px solid var(--mc-border);border-radius:6px;background:transparent;color:var(--mc-text2);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s,border-color .15s}",
|
|
39
|
+
".mc-toolbar button:hover{background:var(--mc-hover)}",
|
|
40
|
+
".mc-toolbar button.active{background:var(--mc-btn);color:#fff;border-color:var(--mc-btn)}",
|
|
41
|
+
".mc-toolbar button svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}",
|
|
42
|
+
".mc-wrap{position:relative;width:100%}",
|
|
43
|
+
".mc-wrap canvas{display:block;width:100%}",
|
|
44
|
+
".mc-legend{display:flex;justify-content:center;gap:20px;margin-top:8px;flex-wrap:wrap}",
|
|
45
|
+
".mc-legend-item{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--mc-text2);cursor:pointer;padding:2px 6px;border-radius:4px;transition:background .15s}",
|
|
46
|
+
".mc-legend-item:hover{background:var(--mc-hover)}",
|
|
47
|
+
".mc-legend-swatch{width:14px;height:3px;border-radius:2px}",
|
|
48
|
+
".mc-legend-item.disabled .mc-legend-swatch{opacity:.25}",
|
|
49
|
+
".mc-legend-item.disabled span:last-child{text-decoration:line-through;opacity:.4}",
|
|
50
|
+
".mc-tooltip{position:absolute;pointer-events:none;opacity:0;background:var(--mc-tt-bg);color:var(--mc-tt-fg);border-radius:8px;padding:10px 14px;font-size:12px;line-height:1.6;white-space:nowrap;box-shadow:0 4px 12px rgba(0,0,0,.2);transition:opacity .1s;z-index:10}",
|
|
51
|
+
".mc-tooltip.visible{opacity:1}",
|
|
52
|
+
".mc-tooltip-date{font-weight:600;margin-bottom:2px}",
|
|
53
|
+
".mc-tooltip-row{display:flex;align-items:center;gap:6px}",
|
|
54
|
+
".mc-tooltip-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}",
|
|
55
|
+
".mc-tooltip-val{margin-left:auto;padding-left:12px;font-weight:600}",
|
|
56
|
+
".mc-selection{position:absolute;top:0;height:100%;background:var(--mc-sel);border-left:1px solid var(--mc-sel-b);border-right:1px solid var(--mc-sel-b);pointer-events:none;display:none}",
|
|
57
|
+
".mc-reset{position:absolute;top:8px;right:8px;background:var(--mc-btn);color:#fff;border:none;border-radius:6px;padding:4px 10px;font-size:11px;font-weight:500;cursor:pointer;opacity:0;pointer-events:none;transition:opacity .2s}",
|
|
58
|
+
".mc-reset.visible{opacity:1;pointer-events:auto}",
|
|
59
|
+
".mc-reset:hover{background:var(--mc-btn-h)}",
|
|
60
|
+
".mc-nav{position:relative;width:100%;height:48px;margin-top:6px;border-top:1px solid var(--mc-border)}",
|
|
61
|
+
".mc-nav canvas{display:block;width:100%;height:48px}",
|
|
62
|
+
".mc-nav-mask{position:absolute;top:0;height:100%;background:var(--mc-mask);pointer-events:none}",
|
|
63
|
+
".mc-nav-mask.left{left:0}",
|
|
64
|
+
".mc-nav-mask.right{right:0}",
|
|
65
|
+
".mc-nav-win{position:absolute;top:0;height:100%;border-left:2px solid var(--mc-btn);border-right:2px solid var(--mc-btn);cursor:grab;z-index:2}",
|
|
66
|
+
".mc-nav-h{position:absolute;top:50%;transform:translateY(-50%);width:6px;height:20px;background:var(--mc-btn);border-radius:3px;cursor:ew-resize;z-index:3}",
|
|
67
|
+
".mc-nav-h.l{left:-4px}",
|
|
68
|
+
".mc-nav-h.r{right:-4px}",
|
|
69
|
+
".mc-root:fullscreen,.mc-root:-webkit-full-screen{display:flex;flex-direction:column;justify-content:center;max-width:100%;width:100%;border-radius:0}",
|
|
70
|
+
].join("\n"),
|
|
71
|
+
n = [
|
|
72
|
+
"Jan",
|
|
73
|
+
"Feb",
|
|
74
|
+
"Mar",
|
|
75
|
+
"Apr",
|
|
76
|
+
"May",
|
|
77
|
+
"Jun",
|
|
78
|
+
"Jul",
|
|
79
|
+
"Aug",
|
|
80
|
+
"Sep",
|
|
81
|
+
"Oct",
|
|
82
|
+
"Nov",
|
|
83
|
+
"Dec",
|
|
84
|
+
],
|
|
85
|
+
a = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
86
|
+
function o(t, e, i) {
|
|
87
|
+
return t + (e - t) * i;
|
|
88
|
+
}
|
|
89
|
+
function r(t, e, i) {
|
|
90
|
+
return Math.max(e, Math.min(i, t));
|
|
91
|
+
}
|
|
92
|
+
function s(t, e) {
|
|
93
|
+
var i = Math.floor(Math.log10(t)),
|
|
94
|
+
n = t / Math.pow(10, i);
|
|
95
|
+
return (
|
|
96
|
+
(e
|
|
97
|
+
? n < 1.5
|
|
98
|
+
? 1
|
|
99
|
+
: n < 3
|
|
100
|
+
? 2
|
|
101
|
+
: n < 7
|
|
102
|
+
? 5
|
|
103
|
+
: 10
|
|
104
|
+
: n <= 1
|
|
105
|
+
? 1
|
|
106
|
+
: n <= 2
|
|
107
|
+
? 2
|
|
108
|
+
: n <= 5
|
|
109
|
+
? 5
|
|
110
|
+
: 10) * Math.pow(10, i)
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
function l(t) {
|
|
114
|
+
return Math.abs(t) >= 1e3
|
|
115
|
+
? t.toLocaleString("en-US", { maximumFractionDigits: 1 })
|
|
116
|
+
: t === Math.floor(t)
|
|
117
|
+
? t.toString()
|
|
118
|
+
: t.toFixed(1);
|
|
119
|
+
}
|
|
120
|
+
function c(t, e, i, _t) {
|
|
121
|
+
var T = typeof _t === "number" ? _t : 1;
|
|
122
|
+
var n = e.length;
|
|
123
|
+
if (!(n < 2))
|
|
124
|
+
if ((i || t.moveTo(e[0][0], e[0][1]), 2 !== n)) {
|
|
125
|
+
if (T <= 0) {
|
|
126
|
+
for (var j = 1; j < n; j++) t.lineTo(e[j][0], e[j][1]);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
for (var a = [], o = [], r = [], s = 0; s < n - 1; s++)
|
|
130
|
+
((a[s] = e[s + 1][0] - e[s][0]),
|
|
131
|
+
(o[s] = e[s + 1][1] - e[s][1]),
|
|
132
|
+
(r[s] = 0 === a[s] ? 0 : o[s] / a[s]));
|
|
133
|
+
var l = [r[0]];
|
|
134
|
+
for (s = 1; s < n - 1; s++)
|
|
135
|
+
l[s] = r[s - 1] * r[s] <= 0 ? 0 : (r[s - 1] + r[s]) / 2;
|
|
136
|
+
for (l[n - 1] = r[n - 2], s = 0; s < n - 1; s++)
|
|
137
|
+
if (Math.abs(r[s]) < 1e-10) ((l[s] = 0), (l[s + 1] = 0));
|
|
138
|
+
else {
|
|
139
|
+
var c = l[s] / r[s],
|
|
140
|
+
d = l[s + 1] / r[s],
|
|
141
|
+
h = c * c + d * d;
|
|
142
|
+
if (h > 9) {
|
|
143
|
+
var p = 3 / Math.sqrt(h);
|
|
144
|
+
((l[s] = p * c * r[s]), (l[s + 1] = p * d * r[s]));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
for (s = 0; s < n - 1; s++) {
|
|
148
|
+
var v = (a[s] * T) / 3;
|
|
149
|
+
t.bezierCurveTo(
|
|
150
|
+
e[s][0] + v,
|
|
151
|
+
e[s][1] + l[s] * v,
|
|
152
|
+
e[s + 1][0] - v,
|
|
153
|
+
e[s + 1][1] - l[s + 1] * v,
|
|
154
|
+
e[s + 1][0],
|
|
155
|
+
e[s + 1][1],
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
} else t.lineTo(e[1][0], e[1][1]);
|
|
159
|
+
}
|
|
160
|
+
function d(t, e) {
|
|
161
|
+
return (
|
|
162
|
+
"rgba(" +
|
|
163
|
+
parseInt(t.slice(1, 3), 16) +
|
|
164
|
+
"," +
|
|
165
|
+
parseInt(t.slice(3, 5), 16) +
|
|
166
|
+
"," +
|
|
167
|
+
parseInt(t.slice(5, 7), 16) +
|
|
168
|
+
"," +
|
|
169
|
+
e +
|
|
170
|
+
")"
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
function h(t, root) {
|
|
174
|
+
var el = root || document.documentElement;
|
|
175
|
+
return getComputedStyle(el)
|
|
176
|
+
.getPropertyValue("--mc-" + t)
|
|
177
|
+
.trim();
|
|
178
|
+
}
|
|
179
|
+
function p(t, e, i) {
|
|
180
|
+
var n = document.createElement(t);
|
|
181
|
+
return (e && (n.className = e), i && i.appendChild(n), n);
|
|
182
|
+
}
|
|
183
|
+
function v(t, n) {
|
|
184
|
+
if (
|
|
185
|
+
((function () {
|
|
186
|
+
if (!e) {
|
|
187
|
+
e = !0;
|
|
188
|
+
_styleEl = document.createElement("style");
|
|
189
|
+
_styleEl.setAttribute("data-nmcharts", "");
|
|
190
|
+
((_styleEl.textContent = i), document.head.appendChild(_styleEl));
|
|
191
|
+
}
|
|
192
|
+
_instanceCount++;
|
|
193
|
+
})(),
|
|
194
|
+
(n = n || {}),
|
|
195
|
+
(this.el = "string" == typeof t ? document.querySelector(t) : t),
|
|
196
|
+
!this.el)
|
|
197
|
+
)
|
|
198
|
+
throw new Error("NMCharts: container not found");
|
|
199
|
+
((this.opts = n),
|
|
200
|
+
(this.bands = n.bands || []),
|
|
201
|
+
(this.forecastFrom = n.forecastFrom || null));
|
|
202
|
+
var a = n.toolbar || {};
|
|
203
|
+
((this.series = (n.series || []).map(function (t) {
|
|
204
|
+
return {
|
|
205
|
+
name: t.name,
|
|
206
|
+
data: t.data.slice().sort(function (t, e) {
|
|
207
|
+
return t[0] - e[0];
|
|
208
|
+
}),
|
|
209
|
+
color: t.color,
|
|
210
|
+
type: t.type || "area",
|
|
211
|
+
dashStyle: t.dashStyle || null,
|
|
212
|
+
lineWidth: t.lineWidth || 2.5,
|
|
213
|
+
tension: typeof t.tension === "number" ? t.tension : 1,
|
|
214
|
+
visible: !0,
|
|
215
|
+
};
|
|
216
|
+
})),
|
|
217
|
+
this._buildDOM(n, a),
|
|
218
|
+
this._computeFullBounds(),
|
|
219
|
+
(this.viewXMin = this.fullXMin),
|
|
220
|
+
(this.viewXMax = this.fullXMax),
|
|
221
|
+
(this._dragStart = null),
|
|
222
|
+
(this._dragging = !1),
|
|
223
|
+
(this._panning = !1),
|
|
224
|
+
(this._panAnchorX = 0),
|
|
225
|
+
(this._panViewStart = 0),
|
|
226
|
+
(this._panViewEnd = 0),
|
|
227
|
+
(this._hoverIdx = -1),
|
|
228
|
+
(this._zoomed = !1),
|
|
229
|
+
(this._entryProgress = 0),
|
|
230
|
+
(this._entryStart = performance.now()),
|
|
231
|
+
(this._rafId = null),
|
|
232
|
+
(this._resizeTimer = null),
|
|
233
|
+
(this._externalListeners = []),
|
|
234
|
+
(this._destroyed = !1),
|
|
235
|
+
this._initSize(),
|
|
236
|
+
this._buildLegend(),
|
|
237
|
+
this._bindEvents(),
|
|
238
|
+
this._bindNavigator(),
|
|
239
|
+
this._startEntryAnim());
|
|
240
|
+
}
|
|
241
|
+
((v.prototype._buildDOM = function (t, e) {
|
|
242
|
+
var i = p("div", "mc-root", this.el);
|
|
243
|
+
this._root = i;
|
|
244
|
+
var n = p("div", "mc-header", i);
|
|
245
|
+
p("div", "", n).style.width = "120px";
|
|
246
|
+
var a = p("div", "mc-titles", n);
|
|
247
|
+
((p("div", "mc-title", a).textContent = t.title || ""),
|
|
248
|
+
(p("div", "mc-subtitle", a).innerHTML =
|
|
249
|
+
t.subtitle ||
|
|
250
|
+
"Drag to zoom · Shift+drag to pan · Scroll to zoom · Double-click to reset"));
|
|
251
|
+
var o = p("div", "mc-toolbar", n),
|
|
252
|
+
r = this;
|
|
253
|
+
if (!1 !== e.dark) {
|
|
254
|
+
var s = p("button", "", o);
|
|
255
|
+
((s.title = "Dark mode"),
|
|
256
|
+
(s.innerHTML =
|
|
257
|
+
'<svg viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 0 1 11.21 3a7 7 0 1 0 9.79 9.79z"/></svg>'),
|
|
258
|
+
s.addEventListener("click", function () {
|
|
259
|
+
(r.el.classList.toggle("mc-dark"),
|
|
260
|
+
s.classList.toggle("active"),
|
|
261
|
+
r.render(),
|
|
262
|
+
r._renderNav());
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
if (!1 !== e.export) {
|
|
266
|
+
var l = p("button", "", o);
|
|
267
|
+
((l.title = "Export PNG"),
|
|
268
|
+
(l.innerHTML =
|
|
269
|
+
'<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>'),
|
|
270
|
+
l.addEventListener("click", function () {
|
|
271
|
+
r.exportPNG();
|
|
272
|
+
}));
|
|
273
|
+
}
|
|
274
|
+
if (!1 !== e.fullscreen) {
|
|
275
|
+
var c = p("button", "", o);
|
|
276
|
+
((c.title = "Fullscreen"),
|
|
277
|
+
(c.innerHTML =
|
|
278
|
+
'<svg viewBox="0 0 24 24"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>'),
|
|
279
|
+
c.addEventListener("click", function () {
|
|
280
|
+
document.fullscreenElement
|
|
281
|
+
? (document.exitFullscreen || document.webkitExitFullscreen).call(
|
|
282
|
+
document,
|
|
283
|
+
)
|
|
284
|
+
: (i.requestFullscreen || i.webkitRequestFullscreen).call(i);
|
|
285
|
+
}),
|
|
286
|
+
["fullscreenchange", "webkitfullscreenchange"].forEach(function (t) {
|
|
287
|
+
var fn = function () {
|
|
288
|
+
if (r._destroyed) return;
|
|
289
|
+
setTimeout(function () {
|
|
290
|
+
if (r._destroyed) return;
|
|
291
|
+
(r._initSize(), r.render(), r._renderNav());
|
|
292
|
+
}, 100);
|
|
293
|
+
};
|
|
294
|
+
document.addEventListener(t, fn);
|
|
295
|
+
r._externalListeners.push({ target: document, type: t, fn: fn });
|
|
296
|
+
}));
|
|
297
|
+
}
|
|
298
|
+
var d = p("div", "mc-wrap", i);
|
|
299
|
+
((this._wrap = d),
|
|
300
|
+
(this.canvas = p("canvas", "", d)),
|
|
301
|
+
(this.ctx = this.canvas.getContext("2d")),
|
|
302
|
+
(this._tooltipEl = p("div", "mc-tooltip", d)),
|
|
303
|
+
(this._selEl = p("div", "mc-selection", d)),
|
|
304
|
+
(this._resetBtn = p("button", "mc-reset", d)),
|
|
305
|
+
(this._resetBtn.textContent = "Reset zoom"));
|
|
306
|
+
var h = p("div", "mc-nav", i);
|
|
307
|
+
((this._navWrap = h),
|
|
308
|
+
(this._navCanvas = p("canvas", "", h)),
|
|
309
|
+
(this._navCtx = this._navCanvas.getContext("2d")),
|
|
310
|
+
(this._navMaskL = p("div", "mc-nav-mask left", h)),
|
|
311
|
+
(this._navMaskR = p("div", "mc-nav-mask right", h)));
|
|
312
|
+
var v = p("div", "mc-nav-win", h);
|
|
313
|
+
((this._navWin = v),
|
|
314
|
+
(this._navHL = p("div", "mc-nav-h l", v)),
|
|
315
|
+
(this._navHR = p("div", "mc-nav-h r", v)),
|
|
316
|
+
(this._legendEl = p("div", "mc-legend", i)));
|
|
317
|
+
}),
|
|
318
|
+
(v.prototype._computeFullBounds = function () {
|
|
319
|
+
for (var t = 1 / 0, e = -1 / 0, i = 0; i < this.series.length; i++) {
|
|
320
|
+
var n = this.series[i].data;
|
|
321
|
+
n.length &&
|
|
322
|
+
((t = Math.min(t, n[0][0])), (e = Math.max(e, n[n.length - 1][0])));
|
|
323
|
+
}
|
|
324
|
+
((this.fullXMin = t), (this.fullXMax = e));
|
|
325
|
+
}),
|
|
326
|
+
(v.prototype._initSize = function () {
|
|
327
|
+
var t = window.devicePixelRatio || 1,
|
|
328
|
+
e = this._wrap.getBoundingClientRect().width,
|
|
329
|
+
i = Math.round(0.42 * e);
|
|
330
|
+
((this.canvas.width = e * t),
|
|
331
|
+
(this.canvas.height = i * t),
|
|
332
|
+
(this.canvas.style.height = i + "px"),
|
|
333
|
+
this.ctx.setTransform(t, 0, 0, t, 0, 0),
|
|
334
|
+
(this.W = e),
|
|
335
|
+
(this.H = i),
|
|
336
|
+
(this.pX = 58),
|
|
337
|
+
(this.pY = 24),
|
|
338
|
+
(this.pW = e - 58 - 24),
|
|
339
|
+
(this.pH = i - 24 - 44));
|
|
340
|
+
var n = this._navWrap.getBoundingClientRect().width;
|
|
341
|
+
((this._navCanvas.width = n * t),
|
|
342
|
+
(this._navCanvas.height = 48 * t),
|
|
343
|
+
this._navCtx.setTransform(t, 0, 0, t, 0, 0),
|
|
344
|
+
(this._nW = n),
|
|
345
|
+
(this._nH = 48));
|
|
346
|
+
}),
|
|
347
|
+
(v.prototype._buildLegend = function () {
|
|
348
|
+
var t = this;
|
|
349
|
+
((this._legendEl.innerHTML = ""),
|
|
350
|
+
this.series.forEach(function (e) {
|
|
351
|
+
var i = p(
|
|
352
|
+
"div",
|
|
353
|
+
"mc-legend-item" + (e.visible ? "" : " disabled"),
|
|
354
|
+
t._legendEl,
|
|
355
|
+
),
|
|
356
|
+
n =
|
|
357
|
+
"line" === e.type
|
|
358
|
+
? "background:transparent;border-top:2.5px " +
|
|
359
|
+
("dashed" === e.dashStyle
|
|
360
|
+
? "dashed"
|
|
361
|
+
: "dotted" === e.dashStyle
|
|
362
|
+
? "dotted"
|
|
363
|
+
: "solid") +
|
|
364
|
+
" " +
|
|
365
|
+
e.color +
|
|
366
|
+
";height:0;margin-top:1px"
|
|
367
|
+
: "background:" + e.color;
|
|
368
|
+
((i.innerHTML =
|
|
369
|
+
'<div class="mc-legend-swatch" style="' +
|
|
370
|
+
n +
|
|
371
|
+
'"></div><span>' +
|
|
372
|
+
e.name +
|
|
373
|
+
"</span>"),
|
|
374
|
+
i.addEventListener("click", function () {
|
|
375
|
+
((e.visible = !e.visible),
|
|
376
|
+
i.classList.toggle("disabled", !e.visible),
|
|
377
|
+
t.render(),
|
|
378
|
+
t._renderNav());
|
|
379
|
+
}));
|
|
380
|
+
}));
|
|
381
|
+
}),
|
|
382
|
+
(v.prototype._x2px = function (t) {
|
|
383
|
+
return (
|
|
384
|
+
this.pX +
|
|
385
|
+
((t - this.viewXMin) / (this.viewXMax - this.viewXMin)) * this.pW
|
|
386
|
+
);
|
|
387
|
+
}),
|
|
388
|
+
(v.prototype._y2px = function (t, e) {
|
|
389
|
+
return this.pY + this.pH - ((t - e.min) / (e.max - e.min)) * this.pH;
|
|
390
|
+
}),
|
|
391
|
+
(v.prototype._px2x = function (t) {
|
|
392
|
+
return (
|
|
393
|
+
this.viewXMin +
|
|
394
|
+
((t - this.pX) / this.pW) * (this.viewXMax - this.viewXMin)
|
|
395
|
+
);
|
|
396
|
+
}),
|
|
397
|
+
(v.prototype._yScale = function () {
|
|
398
|
+
for (var t = 1 / 0, e = -1 / 0, i = 0; i < this.series.length; i++)
|
|
399
|
+
if (this.series[i].visible)
|
|
400
|
+
for (var n = this.series[i].data, a = 0; a < n.length; a++)
|
|
401
|
+
n[a][0] >= this.viewXMin &&
|
|
402
|
+
n[a][0] <= this.viewXMax &&
|
|
403
|
+
((t = Math.min(t, n[a][1])), (e = Math.max(e, n[a][1])));
|
|
404
|
+
return (
|
|
405
|
+
t === 1 / 0 && ((t = 0), (e = 100)),
|
|
406
|
+
(function (t, e) {
|
|
407
|
+
t === e && ((t -= 1), (e += 1));
|
|
408
|
+
for (
|
|
409
|
+
var i = s(e - t, !1),
|
|
410
|
+
n = s(i / 5, !0),
|
|
411
|
+
a = Math.floor(t / n) * n,
|
|
412
|
+
o = Math.ceil(e / n) * n,
|
|
413
|
+
r = [],
|
|
414
|
+
l = a;
|
|
415
|
+
l <= o + 0.5 * n;
|
|
416
|
+
l += n
|
|
417
|
+
)
|
|
418
|
+
r.push(Math.round(1e10 * l) / 1e10);
|
|
419
|
+
return { min: a, max: o, step: n, ticks: r };
|
|
420
|
+
})((t = Math.min(0, t)), e)
|
|
421
|
+
);
|
|
422
|
+
}),
|
|
423
|
+
(v.prototype._startEntryAnim = function () {
|
|
424
|
+
var t = this,
|
|
425
|
+
e = performance.now();
|
|
426
|
+
!(function i(n) {
|
|
427
|
+
if (t._destroyed) return;
|
|
428
|
+
var a = r((n - e) / 800, 0, 1);
|
|
429
|
+
((t._entryProgress = 1 - Math.pow(1 - a, 3)),
|
|
430
|
+
t.render(),
|
|
431
|
+
t._renderNav(),
|
|
432
|
+
a < 1 && (t._rafId = requestAnimationFrame(i)));
|
|
433
|
+
})(e);
|
|
434
|
+
}),
|
|
435
|
+
(v.prototype.render = function () {
|
|
436
|
+
var t = this.ctx,
|
|
437
|
+
e = this._yScale(),
|
|
438
|
+
i = this,
|
|
439
|
+
a = h("grid", i._root),
|
|
440
|
+
o = h("muted", i._root),
|
|
441
|
+
s =
|
|
442
|
+
'11px -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif';
|
|
443
|
+
(t.clearRect(0, 0, this.W, this.H),
|
|
444
|
+
this.bands.forEach(function (n) {
|
|
445
|
+
var a = i._y2px(Math.min(n.to, e.max), e),
|
|
446
|
+
o = i._y2px(Math.max(n.from, e.min), e);
|
|
447
|
+
o <= i.pY ||
|
|
448
|
+
a >= i.pY + i.pH ||
|
|
449
|
+
((a = r(a, i.pY, i.pY + i.pH)),
|
|
450
|
+
(o = r(o, i.pY, i.pY + i.pH)),
|
|
451
|
+
(t.fillStyle = n.color),
|
|
452
|
+
t.fillRect(i.pX, a, i.pW, o - a),
|
|
453
|
+
n.label &&
|
|
454
|
+
(t.save(),
|
|
455
|
+
(t.font = "9px " + s),
|
|
456
|
+
(t.fillStyle = n.labelColor || n.color),
|
|
457
|
+
(t.textAlign = "right"),
|
|
458
|
+
(t.textBaseline = "top"),
|
|
459
|
+
(t.globalAlpha = 0.7),
|
|
460
|
+
t.fillText(n.label, i.pX + i.pW - 4, a + 2),
|
|
461
|
+
t.restore()));
|
|
462
|
+
}),
|
|
463
|
+
t.save(),
|
|
464
|
+
(t.font = s),
|
|
465
|
+
(t.textAlign = "right"),
|
|
466
|
+
(t.textBaseline = "middle"),
|
|
467
|
+
e.ticks.forEach(function (n) {
|
|
468
|
+
var r = i._y2px(n, e);
|
|
469
|
+
((t.strokeStyle = a),
|
|
470
|
+
(t.lineWidth = 1),
|
|
471
|
+
t.beginPath(),
|
|
472
|
+
t.moveTo(i.pX, Math.round(r) + 0.5),
|
|
473
|
+
t.lineTo(i.pX + i.pW, Math.round(r) + 0.5),
|
|
474
|
+
t.stroke(),
|
|
475
|
+
(t.fillStyle = o),
|
|
476
|
+
t.fillText(l(n), i.pX - 8, r));
|
|
477
|
+
}),
|
|
478
|
+
t.restore());
|
|
479
|
+
var p = (function (t, e, i) {
|
|
480
|
+
for (
|
|
481
|
+
var n = e - t,
|
|
482
|
+
a = 864e5,
|
|
483
|
+
o = [
|
|
484
|
+
a,
|
|
485
|
+
2 * a,
|
|
486
|
+
5 * a,
|
|
487
|
+
7 * a,
|
|
488
|
+
14 * a,
|
|
489
|
+
30 * a,
|
|
490
|
+
60 * a,
|
|
491
|
+
90 * a,
|
|
492
|
+
180 * a,
|
|
493
|
+
365 * a,
|
|
494
|
+
],
|
|
495
|
+
r = a,
|
|
496
|
+
s = 0;
|
|
497
|
+
s < o.length;
|
|
498
|
+
s++
|
|
499
|
+
)
|
|
500
|
+
if (n / o[s] <= i) {
|
|
501
|
+
r = o[s];
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
for (var l = [], c = Math.ceil(t / r) * r; c <= e; c += r) l.push(c);
|
|
505
|
+
return l;
|
|
506
|
+
})(this.viewXMin, this.viewXMax, Math.floor(this.pW / 80));
|
|
507
|
+
(t.save(),
|
|
508
|
+
(t.font = s),
|
|
509
|
+
(t.textAlign = "center"),
|
|
510
|
+
(t.textBaseline = "top"),
|
|
511
|
+
(t.fillStyle = o),
|
|
512
|
+
p.forEach(function (e) {
|
|
513
|
+
var o = i._x2px(e);
|
|
514
|
+
o >= i.pX &&
|
|
515
|
+
o <= i.pX + i.pW &&
|
|
516
|
+
((t.strokeStyle = a),
|
|
517
|
+
t.beginPath(),
|
|
518
|
+
t.moveTo(Math.round(o) + 0.5, i.pY + i.pH),
|
|
519
|
+
t.lineTo(Math.round(o) + 0.5, i.pY + i.pH + 5),
|
|
520
|
+
t.stroke(),
|
|
521
|
+
t.fillText(
|
|
522
|
+
(function (t) {
|
|
523
|
+
var e = new Date(t);
|
|
524
|
+
return e.getUTCDate() + " " + n[e.getUTCMonth()];
|
|
525
|
+
})(e),
|
|
526
|
+
o,
|
|
527
|
+
i.pY + i.pH + 8,
|
|
528
|
+
));
|
|
529
|
+
}),
|
|
530
|
+
t.restore(),
|
|
531
|
+
(t.strokeStyle = a),
|
|
532
|
+
(t.lineWidth = 1),
|
|
533
|
+
t.beginPath(),
|
|
534
|
+
t.moveTo(this.pX, this.pY),
|
|
535
|
+
t.lineTo(this.pX, this.pY + this.pH),
|
|
536
|
+
t.lineTo(this.pX + this.pW, this.pY + this.pH),
|
|
537
|
+
t.stroke(),
|
|
538
|
+
t.save(),
|
|
539
|
+
t.beginPath(),
|
|
540
|
+
t.rect(this.pX, this.pY, this.pW, this.pH),
|
|
541
|
+
t.clip());
|
|
542
|
+
var v = this.pW * this._entryProgress;
|
|
543
|
+
if (
|
|
544
|
+
(this.series.forEach(function (n) {
|
|
545
|
+
if (n.visible) {
|
|
546
|
+
for (
|
|
547
|
+
var a = [], o = 0.05 * (i.viewXMax - i.viewXMin), r = 0;
|
|
548
|
+
r < n.data.length;
|
|
549
|
+
r++
|
|
550
|
+
) {
|
|
551
|
+
var s = n.data[r][0],
|
|
552
|
+
l = n.data[r][1];
|
|
553
|
+
s < i.viewXMin - o ||
|
|
554
|
+
s > i.viewXMax + o ||
|
|
555
|
+
a.push([i._x2px(s), i._y2px(l, e), s]);
|
|
556
|
+
}
|
|
557
|
+
if (!(a.length < 2)) {
|
|
558
|
+
var h = i._y2px(e.min, e);
|
|
559
|
+
(t.save(), t.beginPath(), t.rect(i.pX, i.pY, v, i.pH), t.clip());
|
|
560
|
+
var p = a,
|
|
561
|
+
u = null;
|
|
562
|
+
if (i.forecastFrom) {
|
|
563
|
+
((p = []), (u = []));
|
|
564
|
+
for (var f = 0; f < a.length; f++)
|
|
565
|
+
a[f][2] < i.forecastFrom ? p.push(a[f]) : u.push(a[f]);
|
|
566
|
+
p.length && u.length && u.unshift(p[p.length - 1]);
|
|
567
|
+
}
|
|
568
|
+
var m = "line" === n.type,
|
|
569
|
+
g =
|
|
570
|
+
"dashed" === n.dashStyle
|
|
571
|
+
? [6, 4]
|
|
572
|
+
: "dotted" === n.dashStyle
|
|
573
|
+
? [2, 3]
|
|
574
|
+
: null;
|
|
575
|
+
(x(p, !1), u && u.length >= 2 && x(u, !0), t.restore());
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
function x(e, a) {
|
|
579
|
+
if (!(e.length < 2)) {
|
|
580
|
+
if (!m) {
|
|
581
|
+
var o = t.createLinearGradient(0, i.pY, 0, h);
|
|
582
|
+
(o.addColorStop(0, d(n.color, 0.22)),
|
|
583
|
+
o.addColorStop(1, d(n.color, 0.02)),
|
|
584
|
+
t.beginPath(),
|
|
585
|
+
t.moveTo(e[0][0], h),
|
|
586
|
+
t.lineTo(e[0][0], e[0][1]),
|
|
587
|
+
c(t, e, !0, n.tension),
|
|
588
|
+
t.lineTo(e[e.length - 1][0], h),
|
|
589
|
+
t.closePath(),
|
|
590
|
+
(t.fillStyle = o),
|
|
591
|
+
t.fill());
|
|
592
|
+
}
|
|
593
|
+
var r = a ? [6, 4] : g;
|
|
594
|
+
(r && t.setLineDash(r),
|
|
595
|
+
t.beginPath(),
|
|
596
|
+
c(t, e, !1, n.tension),
|
|
597
|
+
(t.strokeStyle = n.color),
|
|
598
|
+
(t.lineWidth = n.lineWidth),
|
|
599
|
+
(t.lineJoin = "round"),
|
|
600
|
+
(t.lineCap = "round"),
|
|
601
|
+
t.stroke(),
|
|
602
|
+
r && t.setLineDash([]));
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}),
|
|
606
|
+
this._hoverIdx >= 0 && this._entryProgress >= 1)
|
|
607
|
+
) {
|
|
608
|
+
var u = null;
|
|
609
|
+
(this.series.forEach(function (n) {
|
|
610
|
+
if (n.visible && !(i._hoverIdx >= n.data.length)) {
|
|
611
|
+
var a = n.data[i._hoverIdx],
|
|
612
|
+
o = i._x2px(a[0]),
|
|
613
|
+
r = i._y2px(a[1], e);
|
|
614
|
+
((u = o),
|
|
615
|
+
t.beginPath(),
|
|
616
|
+
t.arc(o, r, 5, 0, 2 * Math.PI),
|
|
617
|
+
(t.fillStyle = h("card", i._root)),
|
|
618
|
+
t.fill(),
|
|
619
|
+
(t.strokeStyle = n.color),
|
|
620
|
+
(t.lineWidth = 2.5),
|
|
621
|
+
t.stroke());
|
|
622
|
+
}
|
|
623
|
+
}),
|
|
624
|
+
null !== u &&
|
|
625
|
+
((t.strokeStyle = d(o, 0.4)),
|
|
626
|
+
(t.lineWidth = 1),
|
|
627
|
+
t.setLineDash([4, 3]),
|
|
628
|
+
t.beginPath(),
|
|
629
|
+
t.moveTo(Math.round(u) + 0.5, i.pY),
|
|
630
|
+
t.lineTo(Math.round(u) + 0.5, i.pY + i.pH),
|
|
631
|
+
t.stroke(),
|
|
632
|
+
t.setLineDash([])));
|
|
633
|
+
}
|
|
634
|
+
t.restore();
|
|
635
|
+
}),
|
|
636
|
+
(v.prototype._renderNav = function () {
|
|
637
|
+
var t = this._navCtx,
|
|
638
|
+
e = this._nW,
|
|
639
|
+
i = this._nH,
|
|
640
|
+
n = this,
|
|
641
|
+
a = e - 2 - 2,
|
|
642
|
+
o = i - 4 - 4;
|
|
643
|
+
t.clearRect(0, 0, e, i);
|
|
644
|
+
var r = 1 / 0,
|
|
645
|
+
s = -1 / 0;
|
|
646
|
+
(this.series.forEach(function (t) {
|
|
647
|
+
t.visible &&
|
|
648
|
+
t.data.forEach(function (t) {
|
|
649
|
+
((r = Math.min(r, t[1])), (s = Math.max(s, t[1])));
|
|
650
|
+
});
|
|
651
|
+
}),
|
|
652
|
+
r === 1 / 0 && ((r = 0), (s = 100)),
|
|
653
|
+
(r = Math.min(0, r)));
|
|
654
|
+
var l = 4 + o;
|
|
655
|
+
this.series.forEach(function (e) {
|
|
656
|
+
if (e.visible) {
|
|
657
|
+
var i = e.data.map(function (t) {
|
|
658
|
+
return [
|
|
659
|
+
2 + ((t[0] - n.fullXMin) / (n.fullXMax - n.fullXMin)) * a,
|
|
660
|
+
4 + o - ((t[1] - r) / (s - r)) * o,
|
|
661
|
+
];
|
|
662
|
+
});
|
|
663
|
+
if (!(i.length < 2)) {
|
|
664
|
+
if ("line" !== e.type) {
|
|
665
|
+
var h = t.createLinearGradient(0, 4, 0, l);
|
|
666
|
+
(h.addColorStop(0, d(e.color, 0.18)),
|
|
667
|
+
h.addColorStop(1, d(e.color, 0.02)),
|
|
668
|
+
t.beginPath(),
|
|
669
|
+
t.moveTo(i[0][0], l),
|
|
670
|
+
t.lineTo(i[0][0], i[0][1]),
|
|
671
|
+
c(t, i, !0, e.tension),
|
|
672
|
+
t.lineTo(i[i.length - 1][0], l),
|
|
673
|
+
t.closePath(),
|
|
674
|
+
(t.fillStyle = h),
|
|
675
|
+
t.fill());
|
|
676
|
+
}
|
|
677
|
+
var p =
|
|
678
|
+
"dashed" === e.dashStyle
|
|
679
|
+
? [4, 3]
|
|
680
|
+
: "dotted" === e.dashStyle
|
|
681
|
+
? [2, 2]
|
|
682
|
+
: null;
|
|
683
|
+
(p && t.setLineDash(p),
|
|
684
|
+
t.beginPath(),
|
|
685
|
+
c(t, i, !1, e.tension),
|
|
686
|
+
(t.strokeStyle = d(e.color, 0.6)),
|
|
687
|
+
(t.lineWidth = 1.2),
|
|
688
|
+
t.stroke(),
|
|
689
|
+
p && t.setLineDash([]));
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
var h =
|
|
694
|
+
((this.viewXMin - this.fullXMin) / (this.fullXMax - this.fullXMin)) *
|
|
695
|
+
100,
|
|
696
|
+
p =
|
|
697
|
+
((this.fullXMax - this.viewXMax) / (this.fullXMax - this.fullXMin)) *
|
|
698
|
+
100;
|
|
699
|
+
((this._navWin.style.left = h + "%"),
|
|
700
|
+
(this._navWin.style.right = p + "%"),
|
|
701
|
+
(this._navMaskL.style.width = h + "%"),
|
|
702
|
+
(this._navMaskR.style.width = p + "%"));
|
|
703
|
+
}),
|
|
704
|
+
(v.prototype._bindNavigator = function () {
|
|
705
|
+
var t,
|
|
706
|
+
e,
|
|
707
|
+
i,
|
|
708
|
+
n = this,
|
|
709
|
+
a = null;
|
|
710
|
+
function o(o, r) {
|
|
711
|
+
(o.preventDefault(),
|
|
712
|
+
o.stopPropagation(),
|
|
713
|
+
(a = r),
|
|
714
|
+
(t = o.clientX),
|
|
715
|
+
(e = n.viewXMin),
|
|
716
|
+
(i = n.viewXMax),
|
|
717
|
+
document.addEventListener("mousemove", s),
|
|
718
|
+
document.addEventListener("mouseup", l));
|
|
719
|
+
}
|
|
720
|
+
function s(o) {
|
|
721
|
+
var s = n._navWrap.getBoundingClientRect(),
|
|
722
|
+
l = ((o.clientX - t) / s.width) * (n.fullXMax - n.fullXMin),
|
|
723
|
+
c = 1728e5;
|
|
724
|
+
if ("move" === a) {
|
|
725
|
+
var d = e + l,
|
|
726
|
+
h = i + l;
|
|
727
|
+
(d < n.fullXMin && ((h += n.fullXMin - d), (d = n.fullXMin)),
|
|
728
|
+
h > n.fullXMax && ((d -= h - n.fullXMax), (h = n.fullXMax)),
|
|
729
|
+
(n.viewXMin = d),
|
|
730
|
+
(n.viewXMax = h));
|
|
731
|
+
} else
|
|
732
|
+
"left" === a
|
|
733
|
+
? (n.viewXMin = r(e + l, n.fullXMin, n.viewXMax - c))
|
|
734
|
+
: (n.viewXMax = r(i + l, n.viewXMin + c, n.fullXMax));
|
|
735
|
+
((n._zoomed = n.viewXMin > n.fullXMin || n.viewXMax < n.fullXMax),
|
|
736
|
+
n._resetBtn.classList.toggle("visible", n._zoomed),
|
|
737
|
+
n.render(),
|
|
738
|
+
n._renderNav());
|
|
739
|
+
}
|
|
740
|
+
function l() {
|
|
741
|
+
((a = null),
|
|
742
|
+
document.removeEventListener("mousemove", s),
|
|
743
|
+
document.removeEventListener("mouseup", l));
|
|
744
|
+
}
|
|
745
|
+
(this._navWin.addEventListener("mousedown", function (t) {
|
|
746
|
+
o(t, "move");
|
|
747
|
+
}),
|
|
748
|
+
this._navHL.addEventListener("mousedown", function (t) {
|
|
749
|
+
o(t, "left");
|
|
750
|
+
}),
|
|
751
|
+
this._navHR.addEventListener("mousedown", function (t) {
|
|
752
|
+
o(t, "right");
|
|
753
|
+
}),
|
|
754
|
+
this._navWrap.addEventListener("mousedown", function (t) {
|
|
755
|
+
if (t.target === n._navCanvas) {
|
|
756
|
+
var e = n._navWrap.getBoundingClientRect(),
|
|
757
|
+
i =
|
|
758
|
+
n.fullXMin +
|
|
759
|
+
((t.clientX - e.left) / e.width) * (n.fullXMax - n.fullXMin),
|
|
760
|
+
a = n.viewXMax - n.viewXMin,
|
|
761
|
+
o = i - a / 2,
|
|
762
|
+
r = i + a / 2;
|
|
763
|
+
(o < n.fullXMin && ((r += n.fullXMin - o), (o = n.fullXMin)),
|
|
764
|
+
r > n.fullXMax && ((o -= r - n.fullXMax), (r = n.fullXMax)),
|
|
765
|
+
(n._zoomed = !0),
|
|
766
|
+
n._resetBtn.classList.add("visible"),
|
|
767
|
+
n._animateTo(o, r));
|
|
768
|
+
}
|
|
769
|
+
}));
|
|
770
|
+
}),
|
|
771
|
+
(v.prototype._animateTo = function (t, e) {
|
|
772
|
+
var i = { a: this.viewXMin, b: this.viewXMax },
|
|
773
|
+
n = this,
|
|
774
|
+
a = performance.now();
|
|
775
|
+
!(function s(l) {
|
|
776
|
+
if (n._destroyed) return;
|
|
777
|
+
var c = r((l - a) / 400, 0, 1),
|
|
778
|
+
d = 1 - Math.pow(1 - c, 3);
|
|
779
|
+
((n.viewXMin = o(i.a, t, d)),
|
|
780
|
+
(n.viewXMax = o(i.b, e, d)),
|
|
781
|
+
n.render(),
|
|
782
|
+
n._renderNav(),
|
|
783
|
+
c < 1 && (n._rafId = requestAnimationFrame(s)));
|
|
784
|
+
})(a);
|
|
785
|
+
}),
|
|
786
|
+
(v.prototype._bindEvents = function () {
|
|
787
|
+
var t,
|
|
788
|
+
e = this,
|
|
789
|
+
i = this.canvas;
|
|
790
|
+
function n(t) {
|
|
791
|
+
var e = i.getBoundingClientRect();
|
|
792
|
+
return { x: t.clientX - e.left, y: t.clientY - e.top };
|
|
793
|
+
}
|
|
794
|
+
function a(t) {
|
|
795
|
+
return (
|
|
796
|
+
t.x >= e.pX && t.x <= e.pX + e.pW && t.y >= e.pY && t.y <= e.pY + e.pH
|
|
797
|
+
);
|
|
798
|
+
}
|
|
799
|
+
(function () {
|
|
800
|
+
var resizeFn = function () {
|
|
801
|
+
(clearTimeout(e._resizeTimer),
|
|
802
|
+
(e._resizeTimer = setTimeout(function () {
|
|
803
|
+
if (e._destroyed) return;
|
|
804
|
+
(e._initSize(), e.render(), e._renderNav());
|
|
805
|
+
}, 80)));
|
|
806
|
+
};
|
|
807
|
+
window.addEventListener("resize", resizeFn);
|
|
808
|
+
e._externalListeners.push({ target: window, type: "resize", fn: resizeFn });
|
|
809
|
+
})(),
|
|
810
|
+
i.addEventListener("mousedown", function (t) {
|
|
811
|
+
var o = n(t);
|
|
812
|
+
a(o) &&
|
|
813
|
+
(t.shiftKey && e._zoomed
|
|
814
|
+
? ((e._panning = !0),
|
|
815
|
+
(e._panAnchorX = o.x),
|
|
816
|
+
(e._panViewStart = e.viewXMin),
|
|
817
|
+
(e._panViewEnd = e.viewXMax),
|
|
818
|
+
(i.style.cursor = "grabbing"))
|
|
819
|
+
: ((e._dragStart = o.x),
|
|
820
|
+
(e._dragging = !0),
|
|
821
|
+
(e._selEl.style.display = "block"),
|
|
822
|
+
(e._selEl.style.left = o.x + "px"),
|
|
823
|
+
(e._selEl.style.width = "0px")));
|
|
824
|
+
}),
|
|
825
|
+
i.addEventListener("mousemove", function (t) {
|
|
826
|
+
var o = n(t);
|
|
827
|
+
if (e._panning) {
|
|
828
|
+
var s = o.x - e._panAnchorX,
|
|
829
|
+
l = e._panViewEnd - e._panViewStart,
|
|
830
|
+
c = (-s / e.pW) * l,
|
|
831
|
+
d = e._panViewStart + c,
|
|
832
|
+
h = e._panViewEnd + c;
|
|
833
|
+
return (
|
|
834
|
+
d < e.fullXMin && ((h += e.fullXMin - d), (d = e.fullXMin)),
|
|
835
|
+
h > e.fullXMax && ((d -= h - e.fullXMax), (h = e.fullXMax)),
|
|
836
|
+
(e.viewXMin = d),
|
|
837
|
+
(e.viewXMax = h),
|
|
838
|
+
e.render(),
|
|
839
|
+
void e._renderNav()
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
if (e._dragging) {
|
|
843
|
+
var p = Math.min(e._dragStart, o.x),
|
|
844
|
+
v = Math.abs(o.x - e._dragStart);
|
|
845
|
+
p = r(p, e.pX, e.pX + e.pW);
|
|
846
|
+
var u = r(p + v, e.pX, e.pX + e.pW);
|
|
847
|
+
return (
|
|
848
|
+
(e._selEl.style.left = p + "px"),
|
|
849
|
+
void (e._selEl.style.width = u - p + "px")
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
if (a(o)) {
|
|
853
|
+
i.style.cursor = t.shiftKey && e._zoomed ? "grab" : "crosshair";
|
|
854
|
+
var f = (function (t) {
|
|
855
|
+
for (
|
|
856
|
+
var i = e._px2x(t), n = null, a = 0;
|
|
857
|
+
a < e.series.length;
|
|
858
|
+
a++
|
|
859
|
+
)
|
|
860
|
+
if (e.series[a].visible) {
|
|
861
|
+
n = e.series[a].data;
|
|
862
|
+
break;
|
|
863
|
+
}
|
|
864
|
+
if (!n || !n.length) return -1;
|
|
865
|
+
for (var o = 0, r = 1 / 0, s = 0; s < n.length; s++) {
|
|
866
|
+
var l = Math.abs(n[s][0] - i);
|
|
867
|
+
l < r && ((r = l), (o = s));
|
|
868
|
+
}
|
|
869
|
+
return o;
|
|
870
|
+
})(o.x);
|
|
871
|
+
(f !== e._hoverIdx && ((e._hoverIdx = f), e.render()),
|
|
872
|
+
e._showTooltip(o, f));
|
|
873
|
+
} else e._hideTooltip();
|
|
874
|
+
}),
|
|
875
|
+
(function () {
|
|
876
|
+
var mouseupFn = function () {
|
|
877
|
+
if (e._panning)
|
|
878
|
+
return ((e._panning = !1), void (i.style.cursor = "crosshair"));
|
|
879
|
+
if (e._dragging) {
|
|
880
|
+
((e._dragging = !1), (e._selEl.style.display = "none"));
|
|
881
|
+
var t = parseFloat(e._selEl.style.width);
|
|
882
|
+
if (t < 10) e._dragStart = null;
|
|
883
|
+
else {
|
|
884
|
+
var n = parseFloat(e._selEl.style.left);
|
|
885
|
+
((e._zoomed = !0),
|
|
886
|
+
e._resetBtn.classList.add("visible"),
|
|
887
|
+
e._animateTo(e._px2x(n), e._px2x(n + t)),
|
|
888
|
+
(e._dragStart = null));
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
window.addEventListener("mouseup", mouseupFn);
|
|
893
|
+
e._externalListeners.push({ target: window, type: "mouseup", fn: mouseupFn });
|
|
894
|
+
})(),
|
|
895
|
+
i.addEventListener("mouseleave", function () {
|
|
896
|
+
e._hideTooltip();
|
|
897
|
+
}),
|
|
898
|
+
i.addEventListener("dblclick", function (t) {
|
|
899
|
+
(t.preventDefault(),
|
|
900
|
+
e._zoomed &&
|
|
901
|
+
((e._zoomed = !1),
|
|
902
|
+
e._resetBtn.classList.remove("visible"),
|
|
903
|
+
e._animateTo(e.fullXMin, e.fullXMax)));
|
|
904
|
+
}),
|
|
905
|
+
i.addEventListener(
|
|
906
|
+
"wheel",
|
|
907
|
+
function (t) {
|
|
908
|
+
var i = n(t);
|
|
909
|
+
if (a(i)) {
|
|
910
|
+
t.preventDefault();
|
|
911
|
+
var o = t.deltaY > 0 ? 1.15 : 1 / 1.15,
|
|
912
|
+
r = e._px2x(i.x),
|
|
913
|
+
s = e.viewXMax - e.viewXMin,
|
|
914
|
+
l = s * o;
|
|
915
|
+
if (!(l < 1728e5)) {
|
|
916
|
+
var c = (r - e.viewXMin) / s,
|
|
917
|
+
d = Math.max(r - c * l, e.fullXMin),
|
|
918
|
+
h = Math.min(r + (1 - c) * l, e.fullXMax);
|
|
919
|
+
((e.viewXMin = d),
|
|
920
|
+
(e.viewXMax = h),
|
|
921
|
+
(e._zoomed = d > e.fullXMin || h < e.fullXMax),
|
|
922
|
+
e._resetBtn.classList.toggle("visible", e._zoomed),
|
|
923
|
+
e.render(),
|
|
924
|
+
e._renderNav());
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
},
|
|
928
|
+
{ passive: !1 },
|
|
929
|
+
),
|
|
930
|
+
this._resetBtn.addEventListener("click", function () {
|
|
931
|
+
((e._zoomed = !1),
|
|
932
|
+
e._resetBtn.classList.remove("visible"),
|
|
933
|
+
e._animateTo(e.fullXMin, e.fullXMax));
|
|
934
|
+
}),
|
|
935
|
+
(function () {
|
|
936
|
+
var keydownFn = function (t) {
|
|
937
|
+
if (e._destroyed) return;
|
|
938
|
+
if ("INPUT" !== t.target.tagName && "TEXTAREA" !== t.target.tagName) {
|
|
939
|
+
var i = e.viewXMax - e.viewXMin,
|
|
940
|
+
n = 0.15 * i;
|
|
941
|
+
if ("ArrowLeft" === t.key) {
|
|
942
|
+
var a = Math.max(e.viewXMin - n, e.fullXMin);
|
|
943
|
+
e._animateTo(a, a + i);
|
|
944
|
+
} else if ("ArrowRight" === t.key) {
|
|
945
|
+
var o = Math.min(e.viewXMax + n, e.fullXMax);
|
|
946
|
+
e._animateTo(o - i, o);
|
|
947
|
+
} else if ("+" === t.key || "=" === t.key) {
|
|
948
|
+
var r = 0.7 * i,
|
|
949
|
+
s = (e.viewXMin + e.viewXMax) / 2;
|
|
950
|
+
((e._zoomed = !0),
|
|
951
|
+
e._resetBtn.classList.add("visible"),
|
|
952
|
+
e._animateTo(s - r / 2, s + r / 2));
|
|
953
|
+
} else if ("-" === t.key) {
|
|
954
|
+
var l = Math.min(1.4 * i, e.fullXMax - e.fullXMin),
|
|
955
|
+
c = (e.viewXMin + e.viewXMax) / 2,
|
|
956
|
+
d = Math.max(c - l / 2, e.fullXMin),
|
|
957
|
+
h = Math.min(c + l / 2, e.fullXMax);
|
|
958
|
+
((e._zoomed = d > e.fullXMin || h < e.fullXMax),
|
|
959
|
+
e._resetBtn.classList.toggle("visible", e._zoomed),
|
|
960
|
+
e._animateTo(d, h));
|
|
961
|
+
} else
|
|
962
|
+
"Escape" === t.key &&
|
|
963
|
+
e._zoomed &&
|
|
964
|
+
((e._zoomed = !1),
|
|
965
|
+
e._resetBtn.classList.remove("visible"),
|
|
966
|
+
e._animateTo(e.fullXMin, e.fullXMax));
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
document.addEventListener("keydown", keydownFn);
|
|
970
|
+
e._externalListeners.push({ target: document, type: "keydown", fn: keydownFn });
|
|
971
|
+
})();
|
|
972
|
+
var o = null;
|
|
973
|
+
(i.addEventListener(
|
|
974
|
+
"touchstart",
|
|
975
|
+
function (t) {
|
|
976
|
+
(1 === t.touches.length
|
|
977
|
+
? ((e._panning = !0),
|
|
978
|
+
(e._panAnchorX =
|
|
979
|
+
t.touches[0].clientX - i.getBoundingClientRect().left),
|
|
980
|
+
(e._panViewStart = e.viewXMin),
|
|
981
|
+
(e._panViewEnd = e.viewXMax))
|
|
982
|
+
: 2 === t.touches.length &&
|
|
983
|
+
((e._panning = !1),
|
|
984
|
+
(o = Math.abs(t.touches[1].clientX - t.touches[0].clientX))),
|
|
985
|
+
t.preventDefault());
|
|
986
|
+
},
|
|
987
|
+
{ passive: !1 },
|
|
988
|
+
),
|
|
989
|
+
i.addEventListener(
|
|
990
|
+
"touchmove",
|
|
991
|
+
function (t) {
|
|
992
|
+
if (1 === t.touches.length && e._panning) {
|
|
993
|
+
var n =
|
|
994
|
+
t.touches[0].clientX -
|
|
995
|
+
i.getBoundingClientRect().left -
|
|
996
|
+
e._panAnchorX,
|
|
997
|
+
a = e._panViewEnd - e._panViewStart,
|
|
998
|
+
r = (-n / e.pW) * a,
|
|
999
|
+
s = e._panViewStart + r,
|
|
1000
|
+
l = e._panViewEnd + r;
|
|
1001
|
+
(s < e.fullXMin && ((l += e.fullXMin - s), (s = e.fullXMin)),
|
|
1002
|
+
l > e.fullXMax && ((s -= l - e.fullXMax), (l = e.fullXMax)),
|
|
1003
|
+
(e.viewXMin = s),
|
|
1004
|
+
(e.viewXMax = l),
|
|
1005
|
+
e.render(),
|
|
1006
|
+
e._renderNav());
|
|
1007
|
+
} else if (2 === t.touches.length && o) {
|
|
1008
|
+
var c = Math.abs(t.touches[1].clientX - t.touches[0].clientX),
|
|
1009
|
+
d = o / c,
|
|
1010
|
+
h =
|
|
1011
|
+
(t.touches[0].clientX + t.touches[1].clientX) / 2 -
|
|
1012
|
+
i.getBoundingClientRect().left,
|
|
1013
|
+
p = e._px2x(h),
|
|
1014
|
+
v = e.viewXMax - e.viewXMin,
|
|
1015
|
+
u = v * d;
|
|
1016
|
+
if (u < 1728e5) return void t.preventDefault();
|
|
1017
|
+
var f = (p - e.viewXMin) / v;
|
|
1018
|
+
((e.viewXMin = Math.max(p - f * u, e.fullXMin)),
|
|
1019
|
+
(e.viewXMax = Math.min(p + (1 - f) * u, e.fullXMax)),
|
|
1020
|
+
(e._zoomed = !0),
|
|
1021
|
+
e._resetBtn.classList.add("visible"),
|
|
1022
|
+
(o = c),
|
|
1023
|
+
e.render(),
|
|
1024
|
+
e._renderNav());
|
|
1025
|
+
}
|
|
1026
|
+
t.preventDefault();
|
|
1027
|
+
},
|
|
1028
|
+
{ passive: !1 },
|
|
1029
|
+
),
|
|
1030
|
+
i.addEventListener("touchend", function () {
|
|
1031
|
+
((e._panning = !1), (o = null));
|
|
1032
|
+
}));
|
|
1033
|
+
}),
|
|
1034
|
+
(v.prototype._showTooltip = function (t, e) {
|
|
1035
|
+
if (e < 0) this._hideTooltip();
|
|
1036
|
+
else {
|
|
1037
|
+
var i = "",
|
|
1038
|
+
o = null;
|
|
1039
|
+
if (
|
|
1040
|
+
(this.series.forEach(function (t) {
|
|
1041
|
+
!t.visible ||
|
|
1042
|
+
e >= t.data.length ||
|
|
1043
|
+
(o || (o = t.data[e][0]),
|
|
1044
|
+
(i +=
|
|
1045
|
+
'<div class="mc-tooltip-row"><div class="mc-tooltip-dot" style="background:' +
|
|
1046
|
+
t.color +
|
|
1047
|
+
'"></div><span>' +
|
|
1048
|
+
t.name +
|
|
1049
|
+
'</span><span class="mc-tooltip-val">' +
|
|
1050
|
+
l(t.data[e][1]) +
|
|
1051
|
+
"</span></div>"));
|
|
1052
|
+
}),
|
|
1053
|
+
o)
|
|
1054
|
+
) {
|
|
1055
|
+
((i =
|
|
1056
|
+
'<div class="mc-tooltip-date">' +
|
|
1057
|
+
(function (t) {
|
|
1058
|
+
var e = new Date(t);
|
|
1059
|
+
return (
|
|
1060
|
+
a[e.getUTCDay()] +
|
|
1061
|
+
", " +
|
|
1062
|
+
n[e.getUTCMonth()] +
|
|
1063
|
+
" " +
|
|
1064
|
+
e.getUTCDate() +
|
|
1065
|
+
", " +
|
|
1066
|
+
e.getUTCFullYear()
|
|
1067
|
+
);
|
|
1068
|
+
})(o) +
|
|
1069
|
+
"</div>" +
|
|
1070
|
+
i),
|
|
1071
|
+
(this._tooltipEl.innerHTML = i),
|
|
1072
|
+
this._tooltipEl.classList.add("visible"));
|
|
1073
|
+
var s = this._tooltipEl.offsetWidth,
|
|
1074
|
+
c = this._tooltipEl.offsetHeight,
|
|
1075
|
+
d = t.x + 16,
|
|
1076
|
+
h = t.y - c / 2;
|
|
1077
|
+
(d + s > this.W - 8 && (d = t.x - s - 16),
|
|
1078
|
+
(h = r(h, 4, this.H - c - 4)),
|
|
1079
|
+
(this._tooltipEl.style.left = d + "px"),
|
|
1080
|
+
(this._tooltipEl.style.top = h + "px"));
|
|
1081
|
+
} else this._hideTooltip();
|
|
1082
|
+
}
|
|
1083
|
+
}),
|
|
1084
|
+
(v.prototype._hideTooltip = function () {
|
|
1085
|
+
(this._tooltipEl.classList.remove("visible"),
|
|
1086
|
+
this._hoverIdx >= 0 && ((this._hoverIdx = -1), this.render()));
|
|
1087
|
+
}),
|
|
1088
|
+
(v.prototype.exportPNG = function (t) {
|
|
1089
|
+
var e = document.createElement("a");
|
|
1090
|
+
((e.download = t || "chart.png"),
|
|
1091
|
+
(e.href = this.canvas.toDataURL("image/png")),
|
|
1092
|
+
e.click());
|
|
1093
|
+
}),
|
|
1094
|
+
(v.prototype.setDarkMode = function (t) {
|
|
1095
|
+
(this.el.classList.toggle("mc-dark", t),
|
|
1096
|
+
this.render(),
|
|
1097
|
+
this._renderNav());
|
|
1098
|
+
}),
|
|
1099
|
+
(v.prototype.updateSeries = function (t) {
|
|
1100
|
+
((this.series = t.map(function (t) {
|
|
1101
|
+
return {
|
|
1102
|
+
name: t.name,
|
|
1103
|
+
data: t.data.slice().sort(function (t, e) {
|
|
1104
|
+
return t[0] - e[0];
|
|
1105
|
+
}),
|
|
1106
|
+
color: t.color,
|
|
1107
|
+
type: t.type || "area",
|
|
1108
|
+
dashStyle: t.dashStyle || null,
|
|
1109
|
+
lineWidth: t.lineWidth || 2.5,
|
|
1110
|
+
tension: typeof t.tension === "number" ? t.tension : 1,
|
|
1111
|
+
visible: !0,
|
|
1112
|
+
};
|
|
1113
|
+
})),
|
|
1114
|
+
this._computeFullBounds(),
|
|
1115
|
+
(this.viewXMin = this.fullXMin),
|
|
1116
|
+
(this.viewXMax = this.fullXMax),
|
|
1117
|
+
(this._zoomed = !1),
|
|
1118
|
+
this._resetBtn.classList.remove("visible"),
|
|
1119
|
+
this._buildLegend(),
|
|
1120
|
+
this.render(),
|
|
1121
|
+
this._renderNav());
|
|
1122
|
+
}),
|
|
1123
|
+
(v.prototype.destroy = function () {
|
|
1124
|
+
this._destroyed = !0;
|
|
1125
|
+
// Cancel pending animations
|
|
1126
|
+
if (this._rafId) { cancelAnimationFrame(this._rafId); this._rafId = null; }
|
|
1127
|
+
// Clear resize debounce timer
|
|
1128
|
+
if (this._resizeTimer) { clearTimeout(this._resizeTimer); this._resizeTimer = null; }
|
|
1129
|
+
// Remove all external listeners (window/document)
|
|
1130
|
+
if (this._externalListeners) {
|
|
1131
|
+
for (var i = 0; i < this._externalListeners.length; i++) {
|
|
1132
|
+
var l = this._externalListeners[i];
|
|
1133
|
+
l.target.removeEventListener(l.type, l.fn);
|
|
1134
|
+
}
|
|
1135
|
+
this._externalListeners = [];
|
|
1136
|
+
}
|
|
1137
|
+
// Remove DOM
|
|
1138
|
+
if (this._root && this._root.parentNode) {
|
|
1139
|
+
this._root.parentNode.removeChild(this._root);
|
|
1140
|
+
}
|
|
1141
|
+
// Decrement instance count; remove global CSS when last instance is destroyed
|
|
1142
|
+
_instanceCount--;
|
|
1143
|
+
if (_instanceCount <= 0 && _styleEl && _styleEl.parentNode) {
|
|
1144
|
+
_styleEl.parentNode.removeChild(_styleEl);
|
|
1145
|
+
_styleEl = null;
|
|
1146
|
+
e = !1;
|
|
1147
|
+
_instanceCount = 0;
|
|
1148
|
+
}
|
|
1149
|
+
// Null out references to aid GC
|
|
1150
|
+
this.canvas = null;
|
|
1151
|
+
this.ctx = null;
|
|
1152
|
+
this._navCanvas = null;
|
|
1153
|
+
this._navCtx = null;
|
|
1154
|
+
this._tooltipEl = null;
|
|
1155
|
+
this.el = null;
|
|
1156
|
+
}),
|
|
1157
|
+
(v.create = function (t, e) {
|
|
1158
|
+
return new v(t, e);
|
|
1159
|
+
}));
|
|
1160
|
+
NMCharts = v;
|
|
1161
|
+
})();
|
|
12
1162
|
|
|
13
1163
|
export { NMCharts };
|
|
14
1164
|
export default NMCharts;
|