@syhr/dga-charts 1.0.0 → 1.0.2
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/dist/index.cjs +31 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1189 -1120
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +31 -23
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
"use strict";var Pt=Object.defineProperty;var Wt=(S,t,e)=>t in S?Pt(S,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):S[t]=e;var K=(S,t,e)=>Wt(S,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class zt{constructor(){this._h=Object.create(null)}on(t,e){return(this._h[t]||(this._h[t]=[])).push(e),this}off(t,e){return e?(this._h[t]&&(this._h[t]=this._h[t].filter(o=>o!==e)),this):(delete this._h[t],this)}emit(t,e){return(this._h[t]||[]).slice().forEach(o=>o(e)),this}dispose(){this._h=Object.create(null)}}class yt{constructor(t={}){this.zoom=1,this.panX=0,this.panY=0,this._min=t.min??.3,this._max=t.max??6,this._step=t.step??.12,this._dragging=!1,this._dragStart=null,this._panStart=null}onWheel(t,e,o){const s=t<0?1:-1,i=Math.min(this._max,Math.max(this._min,this.zoom*(1+s*this._step))),n=i/this.zoom;return this.panX=e-n*(e-this.panX),this.panY=o-n*(o-this.panY),this.zoom=i,this}startDrag(t,e){this._dragging=!0,this._dragStart={x:t,y:e},this._panStart={x:this.panX,y:this.panY}}moveDrag(t,e,o){return this._dragging?(this.panX=this._panStart.x+(t-this._dragStart.x)*o,this.panY=this._panStart.y+(e-this._dragStart.y)*o,!0):!1}endDrag(){const t=this._dragging;return this._dragging=!1,t}reset(){return this.zoom=1,this.panX=0,this.panY=0,this}get isDragging(){return this._dragging}get state(){return{zoom:this.zoom,panX:this.panX,panY:this.panY}}applyTransform(t){t.translate(this.panX,this.panY),t.scale(this.zoom,this.zoom)}}function kt(S,t){const e=S.replace("#",""),o=parseInt(e.slice(0,2),16),s=parseInt(e.slice(2,4),16),i=parseInt(e.slice(4,6),16);return`rgba(${o},${s},${i},${t})`}function E(S,t){for(const e of Object.keys(t)){const o=t[e];o!==null&&typeof o=="object"&&!Array.isArray(o)?(S[e]=S[e]&&typeof S[e]=="object"?S[e]:{},E(S[e],o)):S[e]=o}return S}function mt(S,t,e){let o=!1;for(let s=0,i=e.length-1;s<e.length;i=s++){const[n,l]=e[s],[h,a]=e[i];l>t!=a>t&&S<(h-n)*(t-l)/(a-l)+n&&(o=!o)}return o}class bt{constructor(t,e){this.container=t,this.el=document.createElement("div"),this.el.style.position="absolute",this.el.style.pointerEvents="none",this.el.style.display="none",this.el.style.zIndex="9999",this.el.style.transition="left 0.1s, top 0.1s",window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t.appendChild(this.el),this.updateTheme(e)}updateTheme(t){if(!t)return;const e=t.tooltip||{},o=e.textStyle||{};this.el.style.backgroundColor=e.backgroundColor||t.tooltipBg||"rgba(6,13,31,0.93)",this.el.style.color=o.color||t.tooltipTextColor||"#c8ddf0";let s=e.padding!==void 0?e.padding:t.tooltipPadding||10;typeof s=="number"?this.el.style.padding=`${s}px`:Array.isArray(s)?this.el.style.padding=s.map(i=>`${i}px`).join(" "):this.el.style.padding=s+"px",this.el.style.borderRadius="5px",this.el.style.border=`1px solid ${t.zoneBorderColor||"rgba(255,255,255,0.25)"}`,this.el.style.boxShadow="0 0 10px rgba(0,0,0,0.45)",this.el.style.fontFamily=t.fontFamily||"Rajdhani, sans-serif",this.el.style.fontSize=o.fontSize!==void 0?typeof o.fontSize=="number"?`${o.fontSize}px`:o.fontSize:"12px"}show(t,e,o,s={},i={},n=null){this.el.innerHTML=t,this.el.style.display="block",this.el.style.backgroundColor=s.backgroundColor||i.tooltipBg||"rgba(6,13,31,0.93)";const l=s.borderWidth!==void 0?typeof s.borderWidth=="number"?`${s.borderWidth}px`:s.borderWidth:"1px",h=s.borderColor||(n?n.borderColor||i.zoneBorderColor||n.color:"rgba(255,255,255,0.25)");this.el.style.border=`${l} solid ${h}`,s.padding!==void 0?typeof s.padding=="number"?this.el.style.padding=`${s.padding}px`:Array.isArray(s.padding)?this.el.style.padding=s.padding.map(p=>`${p}px`).join(" "):this.el.style.padding=s.padding:this.el.style.padding=(i.tooltipPadding||10)+"px";const a=s.textStyle||{};this.el.style.color=a.color||i.tooltipTextColor||"#c8ddf0",this.el.style.fontStyle=a.fontStyle||"",this.el.style.fontWeight=a.fontWeight||a.fontStyle||"",this.el.style.fontSize=a.fontSize!==void 0?typeof a.fontSize=="number"?`${a.fontSize}px`:a.fontSize:"12px",this.el.style.fontFamily=i.fontFamily||"Rajdhani, sans-serif";const r=this.container.getBoundingClientRect(),c=this.el.offsetWidth,d=this.el.offsetHeight;let f=e+15,g=o-d/2;f+c>r.width&&(f=e-c-15),g<0&&(g=0),g+d>r.height&&(g=r.height-d),this.el.style.left=f+"px",this.el.style.top=g+"px"}hide(){this.el.style.display="none"}dispose(){this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el)}}function dt(S,t,e={},o=45){const s=(f,g,p)=>f==null?p:typeof f=="string"&&f.endsWith("%")?parseFloat(f)/100*g:parseFloat(f)||0,i=s(e.left,S,o),n=s(e.right,S,o),l=s(e.top,t,o),h=s(e.bottom,t,o),a=Math.max(0,S-i-n),r=Math.max(0,t-l-h),c=i+a/2,d=l+r/2;return{left:i,right:n,top:l,bottom:h,availW:a,availH:r,cx:c,cy:d}}function lt(S,t,e,o,s,i=1,n=0){const l=(s+n)*i;if(o==="circle"||o==="ring")S.arc(t,e,l,0,Math.PI*2);else if(o==="star"){const h=l*.42;for(let a=0;a<10;a++){const r=a*Math.PI/5-Math.PI/2,c=a%2===0?l:h;a===0?S.moveTo(t+c*Math.cos(r),e+c*Math.sin(r)):S.lineTo(t+c*Math.cos(r),e+c*Math.sin(r))}S.closePath()}else if(o==="triangle"){for(let h=0;h<3;h++){const a=-Math.PI/2+h*2*Math.PI/3,r=t+l*Math.cos(a),c=e+l*Math.sin(a);h===0?S.moveTo(r,c):S.lineTo(r,c)}S.closePath()}else if(o==="diamond")S.moveTo(t,e-l),S.lineTo(t+l,e),S.lineTo(t,e+l),S.lineTo(t-l,e),S.closePath();else if(o==="square"||o==="rect"){const h=(s+n)*2*i,a=t-h/2,r=e-h/2;S.rect(a,r,h,h)}else S.arc(t,e,l,0,Math.PI*2)}const Mt=[{id:"PD",name:"PD",desc:"局部放电",color:"#A0DC99",labelColor:"#1a4a1a",points:[[1,0,0],[.95,.05,0],[.95,0,.05]]},{id:"D1",name:"D1",desc:"低能放电",color:"#77A3FC",labelColor:"#ffffff",points:[[.85,.15,0],[0,1,0],[0,.75,.25],[.6,.15,.25]]},{id:"D2",name:"D2",desc:"高能放电",color:"#E3F2FF",labelColor:"#1a3a6c",points:[[0,.75,.25],[0,.28,.72],[.32,.28,.4],[.45,.15,.4],[.6,.15,.25]]},{id:"T1",name:"T1",desc:"热故障 < 300°C",color:"#CBE4FD",labelColor:"#1a2a6c",points:[[.95,.05,0],[.85,.05,.1],[.9,0,.1],[.95,0,.05]]},{id:"T2",name:"T2",desc:"热故障 300 ~ 700°C",color:"#56AD4A",labelColor:"#e8ffe0",points:[[.85,.05,.1],[.45,.05,.5],[.5,0,.5],[.9,0,.1]]},{id:"T3",name:"T3",desc:"热故障 > 700°C",color:"#5490FF",labelColor:"#e0eeff",points:[[.5,0,.5],[.35,.15,.5],[0,.15,.85],[0,0,1]]},{id:"DT",name:"DT",desc:"混合故障(放电+热)",color:"#313CFF",labelColor:"#c8d8ff",points:[[.95,.05,0],[.85,.15,0],[.45,.15,.4],[.32,.28,.4],[0,.28,.72],[0,.15,.85],[.35,.15,.5],[.45,.05,.5]]}],Xt=[{id:"PD",name:"PD",desc:"电晕型局部放电",color:"#A0DC99",labelColor:"#1a4a1a",points:[[.975,0,.025],[.955,.02,.025],[.83,.02,.15],[.85,0,.15]]},{id:"S",name:"S",desc:"温度<200℃时的杂散气体",color:"#313CFF",labelColor:"#c8d8ff",points:[[1,0,0],[.45,.55,0],[.08,.52,.4],[.08,.3,.62],[.15,.3,.55],[.15,.25,.6],[.4,.25,.35],[.65,0,.35],[.85,0,.15],[.83,.02,.15],[.955,.02,.025],[.975,0,.025]]},{id:"C",name:"C",desc:"绝缘纸可能碳化",color:"#3587FF",labelColor:"#ffffff",points:[[.65,0,.35],[.4,.25,.35],[.15,.25,.6],[.15,.3,.55],[0,.3,.7],[0,0,1]]},{id:"O",name:"O",desc:"过热温度<250℃,绝缘纸不碳化",color:"#6AA4FF",labelColor:"#c8d8ff",points:[[.08,.92,0],[0,1,0],[0,.3,.7],[.08,.3,.62]]},{id:"ND",name:"ND",desc:"未确定",color:"#BEE1FD",labelColor:"#1a2a6c",points:[[.45,.55,0],[.08,.92,0],[.08,.52,.4]]}],Ft=[{id:"PD",name:"PD",desc:"电晕型局部放电",color:"#A0DC99",labelColor:"#1a4a1a",points:[[.85,.15,0],[.83,.15,.02],[.96,.02,.02],[.98,.02,0]]},{id:"T2",name:"T2",desc:"中温过热 (300~700℃)",color:"#56AD4A",labelColor:"#1a4a1a",points:[[.9,0,.1],[.65,0,.35],[.525,.125,.35],[.775,.125,.1]]},{id:"S",name:"S",desc:"温度<200℃时的杂散气体",color:"#313CFF",labelColor:"#c8d8ff",points:[[.85,.15,0],[.35,.65,0],[.25,.65,.1],[.75,.15,.1]]},{id:"C",name:"C",desc:"绝缘纸可能碳化",color:"#3587FF",labelColor:"#ffffff",points:[[.6,.3,.1],[0,.3,.7],[.15,.15,.7],[.35,.15,.5],[.375,.125,.5],[.775,.125,.1]]},{id:"O",name:"O",desc:"过热",color:"#6AA4FF",labelColor:"#1a3a6c",points:[[1,0,0],[.98,.02,0],[.96,.02,.02],[.83,.15,.02],[.85,.15,0],[0,1,0],[0,.9,.1],[.35,.55,.1],[.45,.55,0],[.85,.15,0],[.75,.15,.1],[.9,0,.1]]},{id:"T3-H",name:"T3-H",desc:"仅矿物油过热",color:"#77A3FC",labelColor:"#ffffff",points:[[.35,.3,.35],[0,.65,.35],[0,0,1],[.65,0,.35],[.525,.125,.35],[.375,.125,.5],[.35,.15,.5],[.15,.15,.7],[0,.3,.7]],labelAt:[.1,.42,.48]},{id:"ND",name:"ND",desc:"未确定",color:"#E3F2FF",labelColor:"#1a3a6c",points:[[.6,.3,.1],[0,.9,.1],[0,.65,.35],[.35,.3,.35]]}],ot=[{name:"PD",title:"电晕型局部放电",color:"#A0DC99",desc:"电晕型局部放电",poly:[[0,33],[-1,33],[-1,24.5],[0,24.5]]},{name:"D1",title:"低能量放电或火花型局部放电",color:"#81ADFF",desc:"低能量放电或火花型局部放电",poly:[[0,40],[38,12],[32,-6.1],[4,16],[0,1.5]]},{name:"D2",title:"高能量放电",color:"#E3F2FF",desc:"高能量放电",poly:[[4,16],[32,-6.1],[24.3,-30],[0,-3],[0,1.5]]},{name:"T3",title:"过热故障,t>700℃",color:"#5490FF",desc:"过热故障,t>700℃",poly:[[0,-3],[24.3,-30],[23.5,-32.4],[1,-32.4],[-6,-4]]},{name:"T2",title:"过热故障,300℃<t<700℃",color:"#56AD4A",desc:"中温热故障,铁心或铜导体局部过热,C₂H₄+CH₄ 均较高",poly:[[-6,-4],[1,-32.4],[-22.5,-32.4]]},{name:"T1",title:"过热故障,t<300℃",color:"#CBE4FD",desc:"低温热故障(<300°C),CH₄+C₂H₆ 为主要特征气体",poly:[[-6,-4],[-22.5,-32.4],[-23.5,-32.4],[-35,3],[0,1.5],[0,-3]]},{name:"S",title:"温度<200℃时的杂散气体",color:"#2735FF",desc:"温度<200℃时的杂散气体",poly:[[0,1.5],[-35,3.1],[-38,12.4],[0,40],[0,33],[-1,33],[-1,24.5],[0,24.5]]}],nt=[{name:"PD",title:"电晕型局部放电",color:"#A0DC99",desc:"内部局部放电,H₂ 占比 >93%",poly:[[0,33],[-1,33],[-1,24.5],[0,24.5]]},{name:"D1",title:"低能量放电或火花型局部放电",color:"#81ADFF",desc:"低能量火花放电,绕组匝间短路早期,H₂+C₂H₂ 较高",poly:[[0,40],[38,12],[32,-6.1],[4,16],[0,1.5]]},{name:"D2",title:"高能量放电",color:"#E3F2FF",desc:"高能量电弧放电,严重绝缘故障,C₂H₂ 占比高",poly:[[4,16],[32,-6.1],[24.3,-30],[0,-3],[0,1.5]]},{name:"S",title:"温度<200℃时的杂散气体",color:"#2735FF",desc:"温度<200℃时的杂散气体",poly:[[0,1.5],[-35,3.1],[-38,12.4],[0,40],[0,33],[-1,33],[-1,24.5],[0,24.5]]},{name:"T3-H",title:"——仅矿物油过热",color:"#25A53D",desc:"700℃以上高温过热,C₂H₄ 占比高,总烃快速增长",poly:[[0,-3],[24.3,-30],[23.5,-32.4],[2.5,-32.4],[-3.5,-3]]},{name:"C",title:"绝缘纸可能碳化",color:"#3587FF",desc:"绝缘纸可能碳化",poly:[[-3.5,-3],[2.5,-32.4],[-21.5,-32.4],[-11,-8]]},{name:"O",title:"过热温度<250℃,绝缘纸不碳化",color:"#6AA4FF",desc:"过热温度<250℃,绝缘纸不碳化",poly:[[-3.5,-3],[-11,-8],[-21.5,-32.4],[-23.5,-32.4],[-35,3.1],[0,1.5],[0,-3]]}],Dt=[{name:"D1/PD",title:"局部放电",color:"rgba(56,139,253,0.22)",labelColor:"rgba(56,139,253,0.9)",poly:[[-2,3],[3,3],[3,0],[-2,0]]},{name:"T3/DT",title:"高温热故障/放电+热",color:"rgba(63,185,80,0.18)",labelColor:"rgba(63,185,80,0.9)",poly:[[-2,0],[3,0],[3,-2],[-2,-2]]},{name:"T1",title:"过热故障,t<300℃",color:"rgba(250,199,75,0.22)",labelColor:"rgba(250,199,75,0.9)",poly:[[-2,-2],[0,-2],[0,-3],[-2,-3]]},{name:"T2",title:"过热故障,300℃<t<700℃",color:"rgba(240,120,60,0.25)",labelColor:"rgba(240,120,60,0.9)",poly:[[0,-2],[.4,-2],[.4,-3],[0,-3]]},{name:"T3",title:"过热故障,t>700℃",color:"rgba(46,160,67,0.22)",labelColor:"rgba(46,160,67,0.9)",poly:[[.4,-2],[3,-2],[3,-3],[.4,-3]]}],Yt=[{name:"D2",title:"高能放电",color:"rgba(56,139,253,0.28)",labelColor:"rgba(100,180,255,0.95)",poly:[[-2,3],[3,3],[3,0],[1,0],[1,1],[-2,1]]},{name:"D1",title:"低能放电",color:"rgba(56,139,253,0.15)",labelColor:"rgba(130,190,255,0.85)",poly:[[-2,1],[1,1],[1,0],[-2,0]]},{name:"PD",title:"局部放电",color:"rgba(63,185,80,0.18)",labelColor:"rgba(63,185,80,0.9)",poly:[[-2,0],[0,0],[0,-2],[-2,-2]]},{name:"T3/DT",title:"高温热/放电+热",color:"rgba(250,199,75,0.18)",labelColor:"rgba(250,199,75,0.9)",poly:[[0,0],[3,0],[3,-2],[0,-2]]},{name:"T1",title:"过热故障,t<300℃",color:"rgba(250,199,75,0.22)",labelColor:"rgba(250,199,75,0.9)",poly:[[-2,-2],[0,-2],[0,-3],[-2,-3]]},{name:"T2",title:"过热故障,300℃<t<700℃",color:"rgba(240,120,60,0.25)",labelColor:"rgba(240,120,60,0.9)",poly:[[0,-2],[.4,-2],[.4,-3],[0,-3]]},{name:"T3",title:"过热故障,t>700℃",color:"rgba(46,160,67,0.22)",labelColor:"rgba(46,160,67,0.9)",poly:[[.4,-2],[3,-2],[3,-3],[.4,-3]]}],Et=[{name:"PD",title:"电晕型局部放电",fill:"#09FAFF",edgeColor:"#09FAFF",p1:[0,0,0],p2:[.2,.1,.01]},{name:"T1",title:"过热故障,t<300℃",fill:"#EC9B9A",edgeColor:"#EC9B9A",p1:[0,1,0],p2:[1,10,.01]},{name:"T2",title:"过热故障,300℃<t<700℃",fill:"#A0C9F5",edgeColor:"#A0C9F5",p1:[1,1,0],p2:[4,10,.1]},{name:"T3",title:"过热故障,t>700℃",fill:"#CA677B",edgeColor:"#CA677B",p1:[4,1,0],p2:[10,10,.2]},{name:"D1",title:"低能量放电火花型局部放电",fill:"#FF7B16",edgeColor:"#FF7B16",p1:[1,.1,1],p2:[10,.5,10]},{name:"D2",title:"高能量放电",fill:"#48FF16",edgeColor:"#48FF16",p1:[2,.1,.6],p2:[10,1,2.5]}];function rt(S){if(!Array.isArray(S))return[];const t=S.map(o=>Math.max(Number(o)||0,0)),e=t.reduce((o,s)=>o+s,0);return e===0?t.map(()=>0):t.map(o=>{const s=o/e*100;return Math.round(s*100)/100})}function St(S,t,e,o,s){const i=[S,t,e,o,s].map(d=>Math.max(0,Number(d)||0)),n=i.reduce((d,f)=>d+f,0);if(n<=0)return null;const l=i.map(d=>d/n),h=40,a=[90,18,-54,-126,162];let r=0,c=0;for(let d=0;d<5;d++){const f=a[d]*Math.PI/180;r+=l[d]*h*Math.cos(f),c+=l[d]*h*Math.sin(f)}return{x:r,y:c,ratio:l}}function vt(S,t,e){let o=!1;for(let s=0,i=e.length-1;s<e.length;i=s++){const[n,l]=e[s],[h,a]=e[i];l>t!=a>t&&S<(h-n)*(t-l)/(a-l)+n&&(o=!o)}return o}const Rt={duvalTriangle1:(S,t,e)=>{if(S+t+e<=0)return{code:"INVALID",label:"无效输入"};const[s,i,n]=rt([S,t,e]);return s>=98?{code:"PD",label:"局部放电"}:i>=23&&n<=13?{code:"D1",label:"低能放电"}:i>=23&&i<=40&&n>=13&&n<=29?{code:"D2",label:"高能放电"}:n<=4&&i<=20?{code:"T1",label:"热故障(t < 300℃)"}:n<=4&&i>20&&i<=50?{code:"T2",label:"热故障(300℃ < t < 700℃)"}:n<=15&&i>=50?{code:"T3",label:"热故障(t > 700℃)"}:{code:"ND",label:"区域未定义"}},duvalTriangle4:(S,t,e)=>{if(S+t+e<=0)return{code:"INVALID",label:"无效输入"};const[s,i,n]=rt([S,t,e]);return i>=1&&n>=2&&n<=15?{code:"PD",label:"电晕型局部放电"}:s<=9&&i>=24&&i<=46&&n<=36?{code:"S",label:"温度<200℃时的杂散气体"}:s<=9&&i<=30?{code:"O",label:"过热温度<250℃,绝缘纸不碳化"}:i>=24&&i<=30&&n>=36?{code:"C",label:"绝缘纸可能碳化"}:{code:"ND",label:"区域未定义"}},duvalTriangle5:(S,t,e)=>{if(S+t+e<=0)return{code:"INVALID",label:"无效输入"};const[s,i,n]=rt([S,t,e]);return s>=85&&s<=100&&n>=0&&n<=15?{code:"PD",label:"电晕型局部放电"}:i>=35&&i<=100&&n>=0&&n<=14||i>=35&&i<=70&&n>=30&&n<=75?{code:"T3",label:"高温过热故障(t > 700℃)"}:i>=10&&i<=35&&n>=0&&n<=12?{code:"T2",label:"中温过热故障(t > 300℃)"}:i>=10&&i<=70&&n>=12&&n<=30?{code:"C",label:"绝缘纸碳化故障"}:i<=10&&n>=15&&n<=54?{code:"S",label:"矿物油杂散气体(低温过热 90℃~200℃)"}:i<=10&&(n<=15||n>=54)?{code:"O",label:"过热故障"}:{code:"ND",label:"区域未定义"}},duvalPentagon1:(S,t,e,o,s)=>{const i=St(S,e,o,t,s);if(!i)return{code:"INVALID",label:"无效输入",desc:"",color:""};const{x:n,y:l}=i;for(let a=0;a<ot.length-1;a++){const r=ot[a];if(vt(n,l,r.poly))return{code:r.name,label:r.title,desc:r.desc,color:r.color}}const h=ot[ot.length-1];return{code:h.name,label:h.title,desc:h.desc,color:h.color}},duvalPentagon2:(S,t,e,o,s)=>{const i=St(S,e,o,t,s);if(!i)return{code:"INVALID",label:"无效输入",desc:"",color:""};const{x:n,y:l}=i;for(let a=0;a<nt.length-1;a++){const r=nt[a];if(vt(n,l,r.poly))return{code:r.name,label:r.title,desc:r.desc,color:r.color}}const h=nt[nt.length-1];return{code:h.name,label:h.title,desc:h.desc,color:h.color}}},$=class ${static docToRatio(t,e){const o=$.DOC_R,i=$.DOC_ANGLES.map(n=>{const l=n*Math.PI/180;return[o*Math.cos(l),o*Math.sin(l)]});for(let n=0;n<5;n++)if(Math.hypot(t-i[n][0],e-i[n][1])<.5){const l=[0,0,0,0,0];return l[n]=1,l}for(let n=0;n<5;n++){const l=(n+1)%5,[h,a]=i[n],[r,c]=i[l],d=r-h,f=c-a,g=d*d+f*f;if(g<1e-10)continue;const p=((t-h)*d+(e-a)*f)/g;if(p>=-1e-6&&p<=1+1e-6&&Math.abs((e-a)*d-(t-h)*f)/Math.sqrt(g)<.15){const y=Math.max(0,Math.min(1,p)),u=[0,0,0,0,0];return u[n]=1-y,u[l]=y,u}}for(let n=0;n<5;n++){const l=[0,0],h=i[n],a=i[(n+1)%5],r=(h[1]-a[1])*(l[0]-a[0])+(a[0]-h[0])*(l[1]-a[1]);if(Math.abs(r)<1e-10)continue;const c=((h[1]-a[1])*(t-a[0])+(a[0]-h[0])*(e-a[1]))/r,d=((a[1]-l[1])*(t-a[0])+(l[0]-a[0])*(e-a[1]))/r,f=1-c-d;if(c>=-.01&&d>=-.01&&f>=-.01){const g=new Array(5).fill(c/5);g[n]+=d,g[(n+1)%5]+=f;const p=g.reduce((m,y)=>m+Math.max(0,y),0);return g.map(m=>Math.max(0,m)/p)}}return null}static ratioToDoc(t){const e=$.DOC_R,o=$.DOC_ANGLES;let s=0,i=0;for(let n=0;n<5;n++){const l=o[n]*Math.PI/180;s+=t[n]*e*Math.cos(l),i+=t[n]*e*Math.sin(l)}return[s,i]}static canvasToRatio(t,e,o,s,i){const n=Array.from({length:5},(l,h)=>$.canvasVertex(h,o,s,i));if(!mt(t,e,n))return null;for(let l=0;l<5;l++){const h=[o,s],a=n[l],r=n[(l+1)%5],c=(a[1]-r[1])*(h[0]-r[0])+(r[0]-a[0])*(h[1]-r[1]);if(Math.abs(c)<1e-10)continue;const d=((a[1]-r[1])*(t-r[0])+(r[0]-a[0])*(e-r[1]))/c,f=((r[1]-h[1])*(t-r[0])+(h[0]-r[0])*(e-r[1]))/c,g=1-d-f;if(d>=-1e-9&&f>=-1e-9&&g>=-1e-9){const p=new Array(5).fill(d/5);p[l]+=f,p[(l+1)%5]+=g;const m=p.reduce((y,u)=>y+Math.max(0,u),0);return p.map(y=>Math.max(0,y)/m)}}return null}static canvasVertex(t,e,o,s){const i=-Math.PI/2+t*2*Math.PI/5;return[e+s*Math.cos(i),o+s*Math.sin(i)]}static docToCanvas(t,e,o,s,i){return[o+t/$.DOC_R*i,s-e/$.DOC_R*i]}static polyToCanvas(t,e,o,s){if(t.length===2)return $.docToCanvas(t[0],t[1],e,o,s);let i=0,n=0;for(let l=0;l<5;l++){const[h,a]=$.canvasVertex(l,e,o,s);i+=t[l]*h,n+=t[l]*a}return[i,n]}static resolveData(t,e){if(!t)return null;if(Array.isArray(t)){const o=t.length>0&&t[0]&&typeof t[0]=="object";let s;o&&e?s=e.map(n=>{const l=t.find(h=>h.name===n);return Math.max(0,(l?l.value:0)||0)}):s=t.map(n=>Math.max(0,n||0));const i=s.reduce((n,l)=>n+l,0);return i<=1e-9?null:s.map(n=>n/i)}return"x"in t&&"y"in t?$.docToRatio(t.x,t.y):null}static ratioToDocStr(t,e=1){const[o,s]=$.ratioToDoc(t);return`(${o.toFixed(e)}, ${s.toFixed(e)})`}};K($,"DOC_R",40),K($,"DOC_ANGLES",[90,18,-54,-126,162]);let W=$;const J=class J{static resolve(t){return!t||t==="dark"?{...J.DARK}:t==="light"?{...J.LIGHT}:E({...J.DARK},t)}};K(J,"DARK",{backgroundColor:"transparent",pointStyle:{itemStyle:{shape:"circle",radius:3,color:"#00e5ff",borderColor:"#ffffff",borderWidth:.5},textStyle:{show:!1,fontSize:11,color:"#00e5ff",position:"top"}},vertex:{show:!0,labelStyle:{color:"#01FFE1",fontStyle:"normal",fontWeight:"bold",fontSize:14}},grid:{show:!1,lineStyle:{lineType:"solid",lineWidth:1,lineColor:"rgba(0, 229, 255, 0.15)"}},zone:{labelStyle:{show:!0,color:"#ffffff",fontStyle:"bold",fontSize:12,letterSpacing:0,textShadow:"rgba(0,0,0,0.85)",padding:[4,8],borderRadius:4,backgroundColor:"transparent"},borderStyle:{show:!0,stroke:1,type:"solid",color:"rgba(255, 255, 255, 0.25)"}},tooltip:{show:!0,showDiagnostic:!1,showPoint:!0,backgroundColor:"rgba(6, 13, 31, 0.93)",textStyle:{color:"#c8ddf0",fontStyle:"",fontWeight:"",fontSize:12},padding:10},fontFamily:"Rajdhani, sans-serif"}),K(J,"LIGHT",{backgroundColor:"transparent",pointStyle:{itemStyle:{shape:"circle",radius:3,color:"#1d4ed8",borderColor:"#ffffff",borderWidth:.5},textStyle:{show:!1,fontSize:11,color:"#1d4ed8",position:"top"}},vertex:{show:!0,labelStyle:{color:"#1d4ed8",fontStyle:"normal",fontWeight:"bold",fontSize:14}},grid:{show:!1,lineStyle:{lineType:"solid",lineWidth:1,lineColor:"rgba(29, 78, 216, 0.15)"}},zone:{labelStyle:{show:!0,color:"#1e293b",fontStyle:"bold",fontSize:11,letterSpacing:0,textShadow:"rgba(255,255,255,0.8)",padding:[4,8],borderRadius:4,backgroundColor:"transparent"},borderStyle:{show:!0,stroke:1,type:"solid",color:"rgba(0, 0, 0, 0.25)"}},tooltip:{show:!0,showDiagnostic:!1,showPoint:!0,backgroundColor:"rgba(240, 244, 248, 0.96)",textStyle:{color:"#334155",fontStyle:"",fontWeight:"",fontSize:12},padding:10},fontFamily:"Rajdhani, sans-serif"});let at=J;class pt{static diagnose(t,e,o,s,i){const n=e&&Array.isArray(e.data)?e.data:Array.isArray(e)?e:[];if(!n.length)return null;const[l,h]=W.polyToCanvas(t,o,s,i);for(let a=0;a<n.length-1;a++){const r=n[a].poly.map(c=>W.polyToCanvas(c,o,s,i));if(mt(l,h,r))return n[a]}return n[n.length-1]}static draw(t,e,o,s,i,n,l){const h=e&&Array.isArray(e.data)?e.data:Array.isArray(e)?e:[],a=e.labelStyle||{},r=e.borderStyle||{};for(const d of h){if(!d.poly||!d.poly.length)continue;const f=d.poly.map(g=>W.polyToCanvas(g,s,i,n));t.beginPath(),f.forEach(([g,p],m)=>m===0?t.moveTo(g,p):t.lineTo(g,p)),t.closePath(),t.fillStyle=d.color||"transparent",t.fill()}for(const d of h){const f={...r,...d.borderStyle||{}};if(f.show===!1||!d.poly||!d.poly.length)continue;const g=d.poly.map(p=>W.polyToCanvas(p,s,i,n));t.beginPath(),g.forEach(([p,m],y)=>y===0?t.moveTo(p,m):t.lineTo(p,m)),t.closePath(),t.strokeStyle=f.color||d.borderColor||o.zoneBorderColor||"rgba(255,255,255,0.5)",t.lineWidth=(f.stroke??d.borderWidth??o.zoneBorderWidth??1)*1,f.type==="dashed"?t.setLineDash([4,4]):f.type==="dotted"?t.setLineDash([2,4]):t.setLineDash([]),t.stroke()}t.setLineDash([]);const c=o.fontFamily||"Rajdhani, sans-serif";for(const d of h){const f={...a,...d.labelStyle||{}};if(f.show===!1||!d.name)continue;const g=d.poly?d.poly.map(x=>W.polyToCanvas(x,s,i,n)):[];let p,m;if(d.labelAt&&Array.isArray(d.labelAt))[p,m]=W.polyToCanvas(d.labelAt,s,i,n);else if(g.length>0)p=g.reduce((x,C)=>x+C[0],0)/g.length,m=g.reduce((x,C)=>x+C[1],0)/g.length;else continue;const y=Math.round((f.fontSize||o.zoneLabelSize||12)*1),u=f.fontStyle||"bold";t.font=`${u} ${y}px ${c}`,f.letterSpacing!==void 0&&"letterSpacing"in t&&(t.letterSpacing=`${f.letterSpacing}px`),t.textAlign="center",t.textBaseline="middle";const b=d.name,w=t.measureText(b).width,v=y;if(f.backgroundColor&&f.backgroundColor!=="transparent"){let x=4,C=4;Array.isArray(f.padding)?(C=f.padding[0],x=f.padding[1]!==void 0?f.padding[1]:C):typeof lstyle.padding=="number"&&(x=C=lstyle.padding),x*=1,C*=1;const z=(f.borderRadius||0)*1,_=w+x*2,A=v+C*2,Y=p-_/2,P=m-A/2;t.fillStyle=f.backgroundColor,t.beginPath(),t.roundRect?t.roundRect(Y,P,_,A,z):t.rect(Y,P,_,A),t.fill()}f.textShadow&&f.textShadow!=="none"?(t.shadowColor=f.textShadow,t.shadowBlur=4):(t.shadowColor="transparent",t.shadowBlur=0),t.fillStyle=f.color||o.zoneLabelColor||"#fff",t.fillText(b,p,m),t.shadowBlur=0,t.shadowColor="transparent","letterSpacing"in t&&(t.letterSpacing="0px")}}}class $t{static draw(t,e,o,s,i,n,l,h){var d;const r=o.fontFamily||"Rajdhani, sans-serif";if(h&&h.show!==!1){const f=h.lineStyle||{},g=(f.lineWidth??1)*1,p=f.lineColor||"#e5e7eb",m=f.lineType||"solid";t.strokeStyle=p,t.lineWidth=g,m==="dashed"?t.setLineDash([4,4]):m==="dotted"?t.setLineDash([2,4]):t.setLineDash([]);for(const y of[.2,.4,.6,.8,1]){t.beginPath();for(let u=0;u<5;u++){const[b,w]=W.canvasVertex(u,s,i,n*y);u===0?t.moveTo(b,w):t.lineTo(b,w)}t.closePath(),t.stroke()}for(let y=0;y<5;y++){const[u,b]=W.canvasVertex(y,s,i,n);t.beginPath(),t.moveTo(s,i),t.lineTo(u,b),t.stroke()}t.setLineDash([])}if(!e||e.show===!1)return;const c=((d=e.labelStyle)==null?void 0:d.distance)!==void 0?e.labelStyle.distance:27.2;e.data.forEach((f,g)=>{const p=f.labelStyle||{},m=p.distance!==void 0?p.distance:c,y=typeof m=="string"&&m.endsWith("%")?parseFloat(m)/100*n:parseFloat(m)*1,[u,b]=W.canvasVertex(g,s,i,n+y),w=p.fontStyle||"normal",v=p.fontWeight||"bold",x=Math.round((p.fontSize||o.gasLabelSize||14)*1);t.font=`${w} ${v} ${x}px ${r}`,t.fillStyle=p.color||o.gasLabelColor||"#fff",t.textAlign="center",t.textBaseline="middle",t.shadowColor=o.gasLabelShadow,t.shadowBlur=7,t.fillText(f.name,u,b),t.shadowBlur=0})}}function xt(S){const t=S.trim().toLowerCase();if(t.startsWith("#")){let o=t.slice(1);o.length===3&&(o=o[0]+o[0]+o[1]+o[1]+o[2]+o[2]);const s=parseInt(o.substring(0,2),16),i=parseInt(o.substring(2,4),16),n=parseInt(o.substring(4,6),16),l=o.length===8?parseInt(o.substring(6,8),16)/255:1;return[s,i,n,l]}const e=t.match(/rgba?\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\)/);return e?[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),e[4]!==void 0?parseFloat(e[4]):1]:t==="transparent"?[0,0,0,0]:[255,255,255,1]}function It(S,t,e){const[o,s,i,n]=xt(S),[l,h,a,r]=xt(t),c=Math.round(o+(l-o)*e),d=Math.round(s+(h-s)*e),f=Math.round(i+(a-i)*e),g=n+(r-n)*e;return`rgba(${c},${d},${f},${g})`}class Ht{static draw(t,e,o,s,i,n,l,h,a,r){if(!e||!e.data||!Array.isArray(e.data))return[];const c=1,d=o.fontFamily||"Rajdhani, sans-serif",f=[],g=e.data;if(!g||g.length===0)return[];const p=W.resolveData(g,h);if(!p)return[];const m=e.name,y=e.shape||"circle",u=e.color||"#409eff";let b=e.size!==void 0?e.size:5;const[w,v]=W.polyToCanvas(p,s,i,n),x=pt.diagnose(p,a,s,i,n),[C,z]=W.ratioToDoc(p);r&&r.series===e&&(b*=1.5);const A=e.itemStyle||{},Y=A.borderColor||"#fff",P=A.borderWidth!==void 0?A.borderWidth:1,k=A.opacity!==void 0?A.opacity:1,M=e.textStyle||{},L=M.show!==void 0?M.show:!0,Q=M.color||u,B=M.fontSize!==void 0?M.fontSize:12,it=M.fontWeight||"normal",Z=M.position||"top",tt=M.offset||[0,0],H=e.glowStyle||{},ft=H.show!==void 0?H.show:!1,X=H.colors,I=H.blur!==void 0?H.blur:15,R=H.startColor||u,G=H.endColor||"transparent",V=H.count!==void 0?H.count:3,Lt=H.glowDistance!==void 0?H.glowDistance:2;if(t.save(),t.globalAlpha=k,ft){t.shadowColor=X?X[0]:R,t.shadowBlur=I;let j=[],O=V;if(Array.isArray(X)&&X.length>0)j=X,O=j.length;else for(let N=0;N<O;N++){const q=O>1?N/(O-1):0;j.push(It(R,G,q))}for(let N=O-1;N>=0;N--){const q=j[N];t.save(),t.fillStyle=q,t.beginPath(),lt(t,w,v,y,b,c,(N+1)*Lt),t.fill(),t.restore()}}if(t.beginPath(),lt(t,w,v,y,b,c,0),y==="ring"?(t.strokeStyle=u,t.lineWidth=P*c,t.stroke()):(t.fillStyle=u,t.fill(),P>0&&(t.strokeStyle=Y,t.lineWidth=P*c,t.stroke())),t.restore(),L&&m){t.save(),t.globalAlpha=k,t.font=`${it} ${Math.round(B*c)}px ${d}`,t.fillStyle=Q;let j="center",O="middle",N=w+tt[0]*c,q=v+tt[1]*c,et=6*c;y==="circle"||y==="ring"||y==="star"||y==="triangle"?et+=b*c:y==="square"&&(et+=b*c/2),Z==="top"?(j="center",O="bottom",q-=et):Z==="bottom"?(j="center",O="top",q+=et):Z==="left"?(j="right",O="middle",N-=et):Z==="right"?(j="left",O="middle",N+=et):Z==="center"&&(j="center",O="middle"),t.textAlign=j,t.textBaseline=O,t.fillText(m,N,q),t.restore()}return f.push({ratio:p,zone:x,docX:C,docY:z,rawData:g,name:m,series:e}),f}}const U=class U{constructor(t,e={}){if(this._el=typeof t=="string"?document.getElementById(t):t,!this._el)throw new Error(`DuvalPentagon: container not found — "${t}"`);this._theme=at.resolve(e.theme||U.DEFAULTS.theme),this._opt=E(E(E({},U.DEFAULTS),this._theme),e),this._normalizeOptions(),this._bus=new zt,this._zoom=new yt(this._opt.zoom),this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),Object.assign(this._canvas.style,{display:"block",width:"100%",height:"100%"}),this._el.appendChild(this._canvas),this._tooltipRenderer=new bt(this._el,this._theme),this._hoverRatio=null,this._hoverZone=null,this._hoverPoint=null,this._bindEvents(),this._observeResize(),this._syncCanvas(),this._renderFull()}_normalizeOptions(){if(this._opt.showTooltip!==void 0&&(this._opt.tooltip||(this._opt.tooltip={}),this._opt.tooltip.show=this._opt.showTooltip),this._opt.tooltipTrigger!==void 0&&(this._opt.tooltip||(this._opt.tooltip={}),this._opt.tooltipTrigger==="point"?(this._opt.tooltip.showDiagnostic=!1,this._opt.tooltip.showPoint=!0):this._opt.tooltipTrigger==="zone"&&(this._opt.tooltip.showDiagnostic=!0,this._opt.tooltip.showPoint=!0)),this._opt.vertex.data||(this._opt.vertex.data=["H2","C2H2","C2H4","CH4","C2H6"]),!Array.isArray(this._opt.vertex.data)||this._opt.vertex.data.length!==5)throw new Error("DuvalPentagon: vertex.data must be an array of exactly 5 elements.");const t=this._opt.vertex.labelStyle||{};this._opt.vertex.data=this._opt.vertex.data.map(e=>{if(typeof e=="string")return{name:e,labelStyle:{...t}};if(e&&typeof e=="object"){if(!e.name)throw new Error("DuvalPentagon: each vertex object in vertex.data must have a 'name' property.");return{name:e.name,labelStyle:E({...t},e.labelStyle||{})}}else throw new Error("DuvalPentagon: vertex.data elements must be either strings or objects with a 'name' property.")}),this._opt.gasOrder=this._opt.vertex.data.map(e=>e.name),this._opt.zone?Array.isArray(this._opt.zone)?this._opt.zone={data:this._opt.zone}:typeof this._opt.zone=="object"&&!this._opt.zone.data&&(this._opt.zone.data=U.DEFAULT_ZONES):this._opt.zone={data:U.DEFAULT_ZONES}}setOption(t){return t.theme!==void 0&&(this._theme=at.resolve(t.theme),this._tooltipRenderer.updateTheme(this._theme),this._opt=E(E(E({},U.DEFAULTS),this._theme),this._opt)),E(this._opt,t),this._normalizeOptions(),this._syncCanvas(),this._render(),this}setSeries(t){return this._opt.series=Array.isArray(t)?t:[t],this._renderFull(),this}zoomReset(){return this._zoom.reset(),this._renderFull(),this}on(t,e){return this._bus.on(t,e),this}off(t,e){return this._bus.off(t,e),this}dispose(){var e,o;(e=this._ro)==null||e.disconnect(),this._tooltipRenderer.dispose();const t=this._canvas;t&&(t.removeEventListener("wheel",this._onWheel),t.removeEventListener("mousedown",this._onDown),t.removeEventListener("mousemove",this._onMove),t.removeEventListener("mouseleave",this._onLeave),t.removeEventListener("dblclick",this._onDbl),(o=t.parentNode)==null||o.removeChild(t)),window.removeEventListener("mouseup",this._onUp),this._bus.dispose()}_bindEvents(){const t=this._canvas;this._onWheel=e=>{e.preventDefault();const o=t.getBoundingClientRect(),s=(e.clientX-o.left)*(this._cssW/o.width),i=(e.clientY-o.top)*(this._cssH/o.height);this._zoom.onWheel(e.deltaY,s,i),this._bus.emit("zoom",this._zoom.state),this._renderFull()},this._onDown=e=>{e.button===0&&(this._zoom.startDrag(e.clientX,e.clientY),t.style.cursor="grabbing")},this._onMove=e=>{const o=t.getBoundingClientRect(),s=this._cssW/o.width;if(this._zoom.moveDrag(e.clientX,e.clientY,s)){this._renderFull();return}const i=((e.clientX-o.left)*s-this._zoom.panX)/this._zoom.zoom,n=((e.clientY-o.top)*s-this._zoom.panY)/this._zoom.zoom,{cx:l,cy:h,R:a,S:r}=this._dims();let c=null,d=1/0;if(this._drawnResults)for(const p of this._drawnResults){const[m,y]=W.polyToCanvas(p.ratio,l,h,a),u=p.series.size||Math.max(5,r*.013),b=Math.hypot(m-i,y-n);b<Math.max(u*1.5,12)&&b<d&&(d=b,c=p)}const f=this._opt.tooltip||{},g=f.show!==!1;if(c&&g&&f.showPoint!==!1)t.style.cursor="pointer",this._hoverPoint=c,this._hoverRatio=c.ratio,this._hoverZone=c.zone,this._bus.emit("hover",{ratio:c.ratio,zone:c.zone,docX:c.docX,docY:c.docY,point:c.series});else{t.style.cursor="default",this._hoverPoint=null;const p=W.canvasToRatio(i,n,l,h,a);if(p&&g&&f.showDiagnostic!==!1){this._hoverRatio=p,this._hoverZone=pt.diagnose(p,this._opt.zone,l,h,a);const[m,y]=W.ratioToDoc(p);this._bus.emit("hover",{ratio:p,zone:this._hoverZone,docX:m,docY:y})}else this._hoverRatio=null,this._hoverZone=null,this._bus.emit("hover",null)}this._renderFull()},this._onUp=()=>{this._zoom.endDrag()&&(t.style.cursor=this._hoverPoint?"pointer":"default",this._bus.emit("zoom",this._zoom.state))},this._onLeave=()=>{this._hoverRatio=null,this._hoverZone=null,this._hoverPoint=null,this._bus.emit("hover",null),this._renderFull()},this._onDbl=()=>{this.zoomReset(),this._bus.emit("zoom",this._zoom.state)},t.addEventListener("wheel",this._onWheel,{passive:!1}),t.addEventListener("mousedown",this._onDown),t.addEventListener("mousemove",this._onMove),t.addEventListener("mouseleave",this._onLeave),t.addEventListener("dblclick",this._onDbl),window.addEventListener("mouseup",this._onUp),t.style.cursor="default"}_observeResize(){typeof ResizeObserver>"u"||(this._ro=new ResizeObserver(()=>{this._syncCanvas(),this._renderFull()}),this._ro.observe(this._el))}_syncCanvas(){const t=window.devicePixelRatio||1,e=this._el.clientWidth||300,o=this._el.clientHeight||300;this._cssW=e,this._cssH=o,this._canvas.width=Math.round(e*t),this._canvas.height=Math.round(o*t)}_dims(){var a;const t=this._cssW,e=this._cssH,o=((a=this._opt)==null?void 0:a.grid)||{};if(!(o.left!==void 0||o.right!==void 0||o.top!==void 0||o.bottom!==void 0)){const r=Math.min(t,e);return{W:t,H:e,S:r,cx:t/2,cy:e/2,R:r*.385}}const i=dt(t,e,o,0),l=Math.min(i.availW,i.availH)/2,h=l/.385;return{W:t,H:e,S:h,cx:i.cx,cy:i.cy,R:l}}_render(){this._hoverRatio=null,this._hoverZone=null,this._hoverPoint=null,this._renderFull()}_renderFull(){var y;const t=this._ctx;if(!t)return;const e=window.devicePixelRatio||1,{W:o,H:s,S:i,cx:n,cy:l,R:h}=this._dims(),a=this._theme,r=this._opt.gasOrder,c=this._opt.zone,d=this._opt.vertex;t.setTransform(e,0,0,e,0,0),t.clearRect(0,0,o,s);const f=this._opt.backgroundColor||a.backgroundColor||"transparent";f!=="transparent"&&(t.fillStyle=f,t.fillRect(0,0,o,s)),t.save(),this._zoom.applyTransform(t),pt.draw(t,c,a,n,l,h,i),$t.draw(t,d,a,n,l,h,i,this._opt.grid);const g=[];for(const u of this._opt.series||[]){const b=Ht.draw(t,u,a,n,l,h,i,r,c,this._hoverPoint);Array.isArray(b)&&b.forEach(w=>{g.push({series:u,...w})})}this._drawnResults=g;const p=this._opt.tooltip||{};if(p.show!==!1&&this._hoverRatio){let u=0,b=0;(this._hoverPoint||p.showDiagnostic!==!1)&&([u,b]=W.polyToCanvas(this._hoverRatio,n,l,h));const w=u*this._zoom.zoom+this._zoom.panX,v=b*this._zoom.zoom+this._zoom.panY;let x="";typeof p.formatter=="function"?x=p.formatter({ratio:this._hoverRatio,zone:this._hoverZone,point:(y=this._hoverPoint)==null?void 0:y.series,gasOrder:r}):x=this._defaultTooltipHTML(this._hoverRatio,this._hoverZone,a,r,this._hoverPoint),this._tooltipRenderer.show(x,w,v,p,a,this._hoverZone)}else this._tooltipRenderer.hide();t.restore(),g.length>0&&this._bus.emit("diagnose",g)}_defaultTooltipHTML(t,e,o,s,i){var d;const n=((d=this._opt.vertex)==null?void 0:d.data)||[],l=i==null?void 0:i.rawData;let h="";i&&i.name&&(h=`<div style="font-size:14px; font-weight:bold; margin-bottom:4px; color:#fff;">${i.name}</div>`);const a=e?`${e.name} ${e.title}`:"Outside",r=e?e.color:"#fff";let c=`
|
|
2
|
-
${
|
|
3
|
-
<div style="color:${
|
|
4
|
-
${
|
|
1
|
+
"use strict";var Yt=Object.defineProperty;var Ft=(w,t,e)=>t in w?Yt(w,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[t]=e;var J=(w,t,e)=>Ft(w,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"];class gt{constructor(){this._h=Object.create(null)}on(t,e){return(this._h[t]||(this._h[t]=[])).push(e),this}off(t,e){return e?(this._h[t]&&(this._h[t]=this._h[t].filter(o=>o!==e)),this):(delete this._h[t],this)}emit(t,e){return(this._h[t]||[]).slice().forEach(o=>o(e)),this}dispose(){this._h=Object.create(null)}}class vt{constructor(t={}){this.zoom=1,this.panX=0,this.panY=0,this._min=t.min??.3,this._max=t.max??6,this._step=t.step??.12,this._dragging=!1,this._dragStart=null,this._panStart=null}onWheel(t,e,o){const i=t<0?1:-1,s=Math.min(this._max,Math.max(this._min,this.zoom*(1+i*this._step))),n=s/this.zoom;return this.panX=e-n*(e-this.panX),this.panY=o-n*(o-this.panY),this.zoom=s,this}startDrag(t,e){this._dragging=!0,this._dragStart={x:t,y:e},this._panStart={x:this.panX,y:this.panY}}moveDrag(t,e,o){return this._dragging?(this.panX=this._panStart.x+(t-this._dragStart.x)*o,this.panY=this._panStart.y+(e-this._dragStart.y)*o,!0):!1}endDrag(){const t=this._dragging;return this._dragging=!1,t}reset(){return this.zoom=1,this.panX=0,this.panY=0,this}get isDragging(){return this._dragging}get state(){return{zoom:this.zoom,panX:this.panX,panY:this.panY}}applyTransform(t){t.translate(this.panX,this.panY),t.scale(this.zoom,this.zoom)}}function xt(w,t){const e=w.replace("#",""),o=parseInt(e.slice(0,2),16),i=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16);return`rgba(${o},${i},${s},${t})`}function X(w,t){for(const e of Object.keys(t)){const o=t[e];o!==null&&typeof o=="object"&&!Array.isArray(o)?(w[e]=w[e]&&typeof w[e]=="object"?w[e]:{},X(w[e],o)):w[e]=o}return w}function dt(w,t,e){let o=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){const[n,r]=e[i],[h,a]=e[s];r>t!=a>t&&w<(h-n)*(t-r)/(a-r)+n&&(o=!o)}return o}class _t{constructor(t,e){this.container=t,this.el=document.createElement("div"),this.el.style.position="absolute",this.el.style.pointerEvents="none",this.el.style.display="none",this.el.style.zIndex="9999",this.el.style.transition="left 0.1s, top 0.1s",window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t.appendChild(this.el),this.updateTheme(e)}updateTheme(t){if(!t)return;const e=t.tooltip||{},o=e.textStyle||{};this.el.style.backgroundColor=e.backgroundColor||t.tooltipBg||"rgba(6,13,31,0.93)",this.el.style.color=o.color||t.tooltipTextColor||"#c8ddf0";let i=e.padding!==void 0?e.padding:t.tooltipPadding||10;typeof i=="number"?this.el.style.padding=`${i}px`:Array.isArray(i)?this.el.style.padding=i.map(s=>`${s}px`).join(" "):this.el.style.padding=i+"px",this.el.style.borderRadius="5px",this.el.style.border=`1px solid ${t.zoneBorderColor||"rgba(255,255,255,0.25)"}`,this.el.style.boxShadow="0 0 10px rgba(0,0,0,0.45)",this.el.style.fontFamily=t.fontFamily||"Rajdhani, sans-serif",this.el.style.fontSize=o.fontSize!==void 0?typeof o.fontSize=="number"?`${o.fontSize}px`:o.fontSize:"12px"}show(t,e,o,i={},s={},n=null){this.el.innerHTML=t,this.el.style.display="block",this.el.style.backgroundColor=i.backgroundColor||s.tooltipBg||"rgba(6,13,31,0.93)";const r=i.borderWidth!==void 0?typeof i.borderWidth=="number"?`${i.borderWidth}px`:i.borderWidth:"1px",h=i.borderColor||(n?n.borderColor||s.zoneBorderColor||n.color:"rgba(255,255,255,0.25)");this.el.style.border=`${r} solid ${h}`,i.padding!==void 0?typeof i.padding=="number"?this.el.style.padding=`${i.padding}px`:Array.isArray(i.padding)?this.el.style.padding=i.padding.map(u=>`${u}px`).join(" "):this.el.style.padding=i.padding:this.el.style.padding=(s.tooltipPadding||10)+"px";const a=i.textStyle||{};this.el.style.color=a.color||s.tooltipTextColor||"#c8ddf0",this.el.style.fontStyle=a.fontStyle||"",this.el.style.fontWeight=a.fontWeight||a.fontStyle||"",this.el.style.fontSize=a.fontSize!==void 0?typeof a.fontSize=="number"?`${a.fontSize}px`:a.fontSize:"12px",this.el.style.fontFamily=s.fontFamily||"Rajdhani, sans-serif";const l=this.container.getBoundingClientRect(),c=this.el.offsetWidth,d=this.el.offsetHeight;let p=e+15,b=o-d/2;p+c>l.width&&(p=e-c-15),b<0&&(b=0),b+d>l.height&&(b=l.height-d),this.el.style.left=p+"px",this.el.style.top=b+"px"}hide(){this.el.style.display="none"}dispose(){this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el)}}function yt(w,t,e={},o=45){const i=(p,b,u)=>p==null?u:typeof p=="string"&&p.endsWith("%")?parseFloat(p)/100*b:parseFloat(p)||0,s=i(e.left,w,o),n=i(e.right,w,o),r=i(e.top,t,o),h=i(e.bottom,t,o),a=Math.max(0,w-s-n),l=Math.max(0,t-r-h),c=s+a/2,d=r+l/2;return{left:s,right:n,top:r,bottom:h,availW:a,availH:l,cx:c,cy:d}}function at(w,t,e,o,i,s=1,n=0){const r=(i+n)*s;if(o==="circle"||o==="ring")w.arc(t,e,r,0,Math.PI*2);else if(o==="star"){const h=r*.42;for(let a=0;a<10;a++){const l=a*Math.PI/5-Math.PI/2,c=a%2===0?r:h;a===0?w.moveTo(t+c*Math.cos(l),e+c*Math.sin(l)):w.lineTo(t+c*Math.cos(l),e+c*Math.sin(l))}w.closePath()}else if(o==="triangle"){for(let h=0;h<3;h++){const a=-Math.PI/2+h*2*Math.PI/3,l=t+r*Math.cos(a),c=e+r*Math.sin(a);h===0?w.moveTo(l,c):w.lineTo(l,c)}w.closePath()}else if(o==="diamond")w.moveTo(t,e-r),w.lineTo(t+r,e),w.lineTo(t,e+r),w.lineTo(t-r,e),w.closePath();else if(o==="square"||o==="rect"){const h=(i+n)*2*s,a=t-h/2,l=e-h/2;w.rect(a,l,h,h)}else w.arc(t,e,r,0,Math.PI*2)}const Wt=[{name:"PD",color:"#A0DC99",coordinates:[[1,0,0],[.95,.05,0],[.95,0,.05]]},{name:"D1",color:"#77A3FC",coordinates:[[.85,.15,0],[0,1,0],[0,.75,.25],[.6,.15,.25]]},{name:"D2",color:"#E3F2FF",coordinates:[[0,.75,.25],[0,.28,.72],[.32,.28,.4],[.45,.15,.4],[.6,.15,.25]]},{name:"T1",color:"#CBE4FD",coordinates:[[.95,.05,0],[.85,.05,.1],[.9,0,.1],[.95,0,.05]]},{name:"T2",color:"#56AD4A",coordinates:[[.85,.05,.1],[.45,.05,.5],[.5,0,.5],[.9,0,.1]]},{name:"T3",color:"#5490FF",coordinates:[[.5,0,.5],[.35,.15,.5],[0,.15,.85],[0,0,1]]},{name:"DT",color:"#313CFF",coordinates:[[.95,.05,0],[.85,.15,0],[.45,.15,.4],[.32,.28,.4],[0,.28,.72],[0,.15,.85],[.35,.15,.5],[.45,.05,.5]]}],$t=[{name:"PD",color:"#A0DC99",coordinates:[[.975,0,.025],[.955,.02,.025],[.83,.02,.15],[.85,0,.15]]},{name:"S",color:"#313CFF",coordinates:[[1,0,0],[.45,.55,0],[.08,.52,.4],[.08,.3,.62],[.15,.3,.55],[.15,.25,.6],[.4,.25,.35],[.65,0,.35],[.85,0,.15],[.83,.02,.15],[.955,.02,.025],[.975,0,.025]]},{name:"C",color:"#3587FF",coordinates:[[.65,0,.35],[.4,.25,.35],[.15,.25,.6],[.15,.3,.55],[0,.3,.7],[0,0,1]]},{name:"O",color:"#6AA4FF",coordinates:[[.08,.92,0],[0,1,0],[0,.3,.7],[.08,.3,.62]]},{name:"ND",color:"#BEE1FD",coordinates:[[.45,.55,0],[.08,.92,0],[.08,.52,.4]]}],It=[{name:"PD",color:"#A0DC99",coordinates:[[.85,.15,0],[.83,.15,.02],[.96,.02,.02],[.98,.02,0]]},{name:"T2",color:"#56AD4A",coordinates:[[.9,0,.1],[.65,0,.35],[.525,.125,.35],[.775,.125,.1]]},{name:"S",color:"#313CFF",coordinates:[[.85,.15,0],[.35,.65,0],[.25,.65,.1],[.75,.15,.1]]},{name:"C",color:"#3587FF",coordinates:[[.6,.3,.1],[0,.3,.7],[.15,.15,.7],[.35,.15,.5],[.375,.125,.5],[.775,.125,.1]]},{name:"O",color:"#6AA4FF",coordinates:[[1,0,0],[.98,.02,0],[.96,.02,.02],[.83,.15,.02],[.85,.15,0],[0,1,0],[0,.9,.1],[.35,.55,.1],[.45,.55,0],[.85,.15,0],[.75,.15,.1],[.9,0,.1]]},{name:"T3-H",color:"#77A3FC",coordinates:[[.35,.3,.35],[0,.65,.35],[0,0,1],[.65,0,.35],[.525,.125,.35],[.375,.125,.5],[.35,.15,.5],[.15,.15,.7],[0,.3,.7]],labelAt:[.1,.42,.48]},{name:"ND",color:"#E3F2FF",coordinates:[[.6,.3,.1],[0,.9,.1],[0,.65,.35],[.35,.3,.35]]}],it=[{name:"PD",title:"电晕型局部放电",color:"#A0DC99",coordinates:[[0,33],[-1,33],[-1,24.5],[0,24.5]]},{name:"D1",title:"低能量放电或火花型局部放电",color:"#81ADFF",coordinates:[[0,40],[38,12],[32,-6.1],[4,16],[0,1.5]]},{name:"D2",title:"高能量放电",color:"#E3F2FF",coordinates:[[4,16],[32,-6.1],[24.3,-30],[0,-3],[0,1.5]]},{name:"T3",title:"过热故障,t>700℃",color:"#5490FF",coordinates:[[0,-3],[24.3,-30],[23.5,-32.4],[1,-32.4],[-6,-4]]},{name:"T2",title:"过热故障,300℃<t<700℃",color:"#56AD4A",coordinates:[[-6,-4],[1,-32.4],[-22.5,-32.4]]},{name:"T1",title:"过热故障,t<300℃",color:"#CBE4FD",coordinates:[[-6,-4],[-22.5,-32.4],[-23.5,-32.4],[-35,3],[0,1.5],[0,-3]]},{name:"S",title:"温度<200℃时的杂散气体",color:"#2735FF",coordinates:[[0,1.5],[-35,3.1],[-38,12.4],[0,40],[0,33],[-1,33],[-1,24.5],[0,24.5]]}],rt=[{name:"PD",title:"电晕型局部放电",color:"#A0DC99",coordinates:[[0,33],[-1,33],[-1,24.5],[0,24.5]]},{name:"D1",title:"低能量放电或火花型局部放电",color:"#81ADFF",coordinates:[[0,40],[38,12],[32,-6.1],[4,16],[0,1.5]]},{name:"D2",title:"高能量放电",color:"#E3F2FF",coordinates:[[4,16],[32,-6.1],[24.3,-30],[0,-3],[0,1.5]]},{name:"S",title:"温度<200℃时的杂散气体",color:"#2735FF",coordinates:[[0,1.5],[-35,3.1],[-38,12.4],[0,40],[0,33],[-1,33],[-1,24.5],[0,24.5]]},{name:"T3-H",title:"——仅矿物油过热",color:"#25A53D",coordinates:[[0,-3],[24.3,-30],[23.5,-32.4],[2.5,-32.4],[-3.5,-3]]},{name:"C",title:"绝缘纸可能碳化",color:"#3587FF",coordinates:[[-3.5,-3],[2.5,-32.4],[-21.5,-32.4],[-11,-8]]},{name:"O",title:"过热温度<250℃,绝缘纸不碳化",color:"#6AA4FF",coordinates:[[-3.5,-3],[-11,-8],[-21.5,-32.4],[-23.5,-32.4],[-35,3.1],[0,1.5],[0,-3]]}],Xt=[{name:"D1/PD",title:"局部放电",color:"#51b4c8",coordinates:[[-2,3],[3,3],[3,0],[-2,0]]},{name:"T3/DT",title:"高温热故障/放电+热",color:"#fe9d37",coordinates:[[-2,0],[3,0],[3,-2],[-2,-2]]},{name:"T1",title:"过热故障,t<300℃",color:"#df4d41",coordinates:[[-2,-2],[0,-2],[0,-3],[-2,-3]]},{name:"T2",title:"过热故障,300℃<t<700℃",color:"#458be6",coordinates:[[0,-2],[.4,-2],[.4,-3],[0,-3]]},{name:"T3",title:"过热故障,t>700℃",color:"#8c2fae",coordinates:[[.4,-2],[3,-2],[3,-3],[.4,-3]]}],Nt=[{name:"D2",title:"高能放电",color:"#63a856",coordinates:[[-2,3],[3,3],[3,0],[1,0],[1,1],[-2,1]]},{name:"D1",title:"低能放电",color:"#f16335",coordinates:[[-2,1],[1,1],[1,0],[-2,0]]},{name:"PD",title:"局部放电",color:"#53b7cc",coordinates:[[-2,0],[0,0],[0,-2],[-2,-2]]},{name:"T3/DT",title:"高温热/放电+热",color:"#fe9d37",coordinates:[[0,0],[3,0],[3,-2],[0,-2]]},{name:"T1",title:"过热故障,t<300℃",color:"#df4d41",coordinates:[[-2,-2],[0,-2],[0,-3],[-2,-3]]},{name:"T2",title:"过热故障,300℃<t<700℃",color:"#458be6",coordinates:[[0,-2],[.4,-2],[.4,-3],[0,-3]]},{name:"T3",title:"过热故障,t>700℃",color:"#8c2fae",coordinates:[[.4,-2],[3,-2],[3,-3],[.4,-3]]}],kt=[{name:"PD",title:"电晕型局部放电",color:"#09FAFF",coordinates:[[0,0,0],[.2,.1,.01]]},{name:"T1",title:"过热故障,t<300℃",color:"#EC9B9A",coordinates:[[0,1,0],[1,10,.01]]},{name:"T2",title:"过热故障,300℃<t<700℃",color:"#A0C9F5",coordinates:[[1,1,0],[4,10,.1]]},{name:"T3",title:"过热故障,t>700℃",color:"#CA677B",coordinates:[[4,1,0],[10,10,.2]]},{name:"D1",title:"低能量放电火花型局部放电",color:"#FF7B16",coordinates:[[1,.1,1],[10,.5,10]]},{name:"D2",title:"高能量放电",color:"#48FF16",coordinates:[[2,.1,.6],[10,1,2.5]]}];function ht(w){if(!Array.isArray(w))return[];const t=w.map(o=>Math.max(Number(o)||0,0)),e=t.reduce((o,i)=>o+i,0);return e===0?t.map(()=>0):t.map(o=>{const i=o/e*100;return Math.round(i*100)/100})}function At(w,t,e,o,i){const s=[w,t,e,o,i].map(d=>Math.max(0,Number(d)||0)),n=s.reduce((d,p)=>d+p,0);if(n<=0)return null;const r=s.map(d=>d/n),h=40,a=[90,18,-54,-126,162];let l=0,c=0;for(let d=0;d<5;d++){const p=a[d]*Math.PI/180;l+=r[d]*h*Math.cos(p),c+=r[d]*h*Math.sin(p)}return{x:l,y:c,ratio:r}}function Ct(w,t,e){let o=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){const[n,r]=e[i],[h,a]=e[s];r>t!=a>t&&w<(h-n)*(t-r)/(a-r)+n&&(o=!o)}return o}const Ot={duvalTriangle1:(w,t,e)=>{if(w+t+e<=0)return{code:"INVALID",label:"无效输入"};const[i,s,n]=ht([w,t,e]);return i>=98?{code:"PD",label:"局部放电"}:s>=23&&n<=13?{code:"D1",label:"低能放电"}:s>=23&&s<=40&&n>=13&&n<=29?{code:"D2",label:"高能放电"}:n<=4&&s<=20?{code:"T1",label:"热故障(t < 300℃)"}:n<=4&&s>20&&s<=50?{code:"T2",label:"热故障(300℃ < t < 700℃)"}:n<=15&&s>=50?{code:"T3",label:"热故障(t > 700℃)"}:{code:"ND",label:"区域未定义"}},duvalTriangle4:(w,t,e)=>{if(w+t+e<=0)return{code:"INVALID",label:"无效输入"};const[i,s,n]=ht([w,t,e]);return s>=1&&n>=2&&n<=15?{code:"PD",label:"电晕型局部放电"}:i<=9&&s>=24&&s<=46&&n<=36?{code:"S",label:"温度<200℃时的杂散气体"}:i<=9&&s<=30?{code:"O",label:"过热温度<250℃,绝缘纸不碳化"}:s>=24&&s<=30&&n>=36?{code:"C",label:"绝缘纸可能碳化"}:{code:"ND",label:"区域未定义"}},duvalTriangle5:(w,t,e)=>{if(w+t+e<=0)return{code:"INVALID",label:"无效输入"};const[i,s,n]=ht([w,t,e]);return i>=85&&i<=100&&n>=0&&n<=15?{code:"PD",label:"电晕型局部放电"}:s>=35&&s<=100&&n>=0&&n<=14||s>=35&&s<=70&&n>=30&&n<=75?{code:"T3",label:"高温过热故障(t > 700℃)"}:s>=10&&s<=35&&n>=0&&n<=12?{code:"T2",label:"中温过热故障(t > 300℃)"}:s>=10&&s<=70&&n>=12&&n<=30?{code:"C",label:"绝缘纸碳化故障"}:s<=10&&n>=15&&n<=54?{code:"S",label:"矿物油杂散气体(低温过热 90℃~200℃)"}:s<=10&&(n<=15||n>=54)?{code:"O",label:"过热故障"}:{code:"ND",label:"区域未定义"}},duvalPentagon1:(w,t,e,o,i)=>{const s=At(w,e,o,t,i);if(!s)return{code:"INVALID",label:"无效输入",desc:"",color:""};const{x:n,y:r}=s;for(let a=0;a<it.length-1;a++){const l=it[a];if(Ct(n,r,l.poly))return{code:l.name,label:l.title,desc:l.desc,color:l.color}}const h=it[it.length-1];return{code:h.name,label:h.title,desc:h.desc,color:h.color}},duvalPentagon2:(w,t,e,o,i)=>{const s=At(w,e,o,t,i);if(!s)return{code:"INVALID",label:"无效输入",desc:"",color:""};const{x:n,y:r}=s;for(let a=0;a<rt.length-1;a++){const l=rt[a];if(Ct(n,r,l.poly))return{code:l.name,label:l.title,desc:l.desc,color:l.color}}const h=rt[rt.length-1];return{code:h.name,label:h.title,desc:h.desc,color:h.color}}};function zt(w,t){return w?w.startsWith("#")?xt(w,t):w.startsWith("rgb")?w.replace(/rgb(a)?\(([^)]+)\)/,(e,o,i)=>{const s=i.split(","),n=s[0].trim(),r=s[1].trim(),h=s[2].trim();return`rgba(${n},${r},${h},${t})`}):w:`rgba(0,0,0,${t})`}const I=class I{static docToRatio(t,e){const o=I.DOC_R,s=I.DOC_ANGLES.map(n=>{const r=n*Math.PI/180;return[o*Math.cos(r),o*Math.sin(r)]});for(let n=0;n<5;n++)if(Math.hypot(t-s[n][0],e-s[n][1])<.5){const r=[0,0,0,0,0];return r[n]=1,r}for(let n=0;n<5;n++){const r=(n+1)%5,[h,a]=s[n],[l,c]=s[r],d=l-h,p=c-a,b=d*d+p*p;if(b<1e-10)continue;const u=((t-h)*d+(e-a)*p)/b;if(u>=-1e-6&&u<=1+1e-6&&Math.abs((e-a)*d-(t-h)*p)/Math.sqrt(b)<.15){const g=Math.max(0,Math.min(1,u)),f=[0,0,0,0,0];return f[n]=1-g,f[r]=g,f}}for(let n=0;n<5;n++){const r=[0,0],h=s[n],a=s[(n+1)%5],l=(h[1]-a[1])*(r[0]-a[0])+(a[0]-h[0])*(r[1]-a[1]);if(Math.abs(l)<1e-10)continue;const c=((h[1]-a[1])*(t-a[0])+(a[0]-h[0])*(e-a[1]))/l,d=((a[1]-r[1])*(t-a[0])+(r[0]-a[0])*(e-a[1]))/l,p=1-c-d;if(c>=-.01&&d>=-.01&&p>=-.01){const b=new Array(5).fill(c/5);b[n]+=d,b[(n+1)%5]+=p;const u=b.reduce((S,g)=>S+Math.max(0,g),0);return b.map(S=>Math.max(0,S)/u)}}return null}static ratioToDoc(t){const e=I.DOC_R,o=I.DOC_ANGLES;let i=0,s=0;for(let n=0;n<5;n++){const r=o[n]*Math.PI/180;i+=t[n]*e*Math.cos(r),s+=t[n]*e*Math.sin(r)}return[i,s]}static canvasToRatio(t,e,o,i,s){const n=Array.from({length:5},(r,h)=>I.canvasVertex(h,o,i,s));if(!dt(t,e,n))return null;for(let r=0;r<5;r++){const h=[o,i],a=n[r],l=n[(r+1)%5],c=(a[1]-l[1])*(h[0]-l[0])+(l[0]-a[0])*(h[1]-l[1]);if(Math.abs(c)<1e-10)continue;const d=((a[1]-l[1])*(t-l[0])+(l[0]-a[0])*(e-l[1]))/c,p=((l[1]-h[1])*(t-l[0])+(h[0]-l[0])*(e-l[1]))/c,b=1-d-p;if(d>=-1e-9&&p>=-1e-9&&b>=-1e-9){const u=new Array(5).fill(d/5);u[r]+=p,u[(r+1)%5]+=b;const S=u.reduce((g,f)=>g+Math.max(0,f),0);return u.map(g=>Math.max(0,g)/S)}}return null}static canvasVertex(t,e,o,i){const s=-Math.PI/2+t*2*Math.PI/5;return[e+i*Math.cos(s),o+i*Math.sin(s)]}static docToCanvas(t,e,o,i,s){return[o+t/I.DOC_R*s,i-e/I.DOC_R*s]}static polyToCanvas(t,e,o,i){if(t.length===2)return I.docToCanvas(t[0],t[1],e,o,i);let s=0,n=0;for(let r=0;r<5;r++){const[h,a]=I.canvasVertex(r,e,o,i);s+=t[r]*h,n+=t[r]*a}return[s,n]}static resolveData(t,e){if(!t)return null;if(Array.isArray(t)){const o=t.length>0&&t[0]&&typeof t[0]=="object";let i;o&&e?i=e.map(n=>{const r=t.find(h=>h.name===n);return Math.max(0,(r?r.value:0)||0)}):i=t.map(n=>Math.max(0,n||0));const s=i.reduce((n,r)=>n+r,0);return s<=1e-9?null:i.map(n=>n/s)}return"x"in t&&"y"in t?I.docToRatio(t.x,t.y):null}static ratioToDocStr(t,e=1){const[o,i]=I.ratioToDoc(t);return`(${o.toFixed(e)}, ${i.toFixed(e)})`}};J(I,"DOC_R",40),J(I,"DOC_ANGLES",[90,18,-54,-126,162]);let R=I;const et=class et{static resolve(t){return!t||t==="dark"?{...et.DARK}:t==="light"?{...et.LIGHT}:X({...et.DARK},t)}};J(et,"DARK",{backgroundColor:"transparent",pointStyle:{itemStyle:{shape:"circle",radius:3,color:"#00e5ff",borderColor:"#ffffff",borderWidth:.5},textStyle:{show:!1,fontSize:11,color:"#00e5ff",position:"top"}},vertex:{show:!0,labelStyle:{color:"#01FFE1",fontStyle:"normal",fontWeight:"bold",fontSize:14}},grid:{show:!1,lineStyle:{lineType:"solid",lineWidth:1,lineColor:"rgba(0, 229, 255, 0.15)"}},zone:{alpha:.75,labelStyle:{show:!0,color:"#ffffff",fontStyle:"bold",fontSize:12,letterSpacing:0,textShadow:"rgba(0,0,0,0.85)",padding:[4,8],borderRadius:4,backgroundColor:"transparent"},borderStyle:{show:!0,width:1,type:"solid",color:"rgba(255, 255, 255, 0.25)"}},tooltip:{show:!0,backgroundColor:"rgba(6, 13, 31, 0.93)",textStyle:{color:"#c8ddf0",fontStyle:"",fontWeight:"",fontSize:12},padding:10},fontFamily:"Rajdhani, sans-serif"}),J(et,"LIGHT",{backgroundColor:"transparent",pointStyle:{itemStyle:{shape:"circle",radius:3,color:"#1d4ed8",borderColor:"#ffffff",borderWidth:.5},textStyle:{show:!1,fontSize:11,color:"#1d4ed8",position:"top"}},vertex:{show:!0,labelStyle:{color:"#1d4ed8",fontStyle:"normal",fontWeight:"bold",fontSize:14}},grid:{show:!1,lineStyle:{lineType:"solid",lineWidth:1,lineColor:"rgba(29, 78, 216, 0.15)"}},zone:{labelStyle:{show:!0,color:"#1e293b",fontStyle:"bold",fontSize:11,letterSpacing:0,textShadow:"rgba(255,255,255,0.8)",padding:[4,8],borderRadius:4,backgroundColor:"transparent"},borderStyle:{show:!0,width:1,type:"solid",color:"rgba(0, 0, 0, 0.25)"}},tooltip:{show:!0,backgroundColor:"rgba(240, 244, 248, 0.96)",textStyle:{color:"#334155",fontStyle:"",fontWeight:"",fontSize:12},padding:10},fontFamily:"Rajdhani, sans-serif"});let ft=et;class ct{static diagnose(t,e,o,i,s){const n=e&&Array.isArray(e.data)?e.data:[];if(!n.length)return null;const[r,h]=R.polyToCanvas(t,o,i,s);for(let a=0;a<n.length-1;a++){if(!n[a].coordinates||!n[a].coordinates.length)continue;const l=n[a].coordinates.map(c=>R.polyToCanvas(c,o,i,s));if(dt(r,h,l))return n[a]}return n[n.length-1]}static draw(t,e,o,i,s,n,r){const h=e&&Array.isArray(e.data)?e.data:[],a=e.labelStyle||{},l=e.borderStyle||{},c=e.alpha,d=e.colors||o.colors||Q;h.forEach((b,u)=>{if(!b.coordinates||!b.coordinates.length)return;const S=b.coordinates.map(f=>R.polyToCanvas(f,i,s,n));t.beginPath(),S.forEach(([f,y],m)=>m===0?t.moveTo(f,y):t.lineTo(f,y)),t.closePath();let g=b.color||d[u%d.length];c!==void 0&&g!=="transparent"&&(g=zt(g,c)),t.fillStyle=g,t.fill()}),h.forEach((b,u)=>{const S=l;if(S.show===!1||!b.coordinates||!b.coordinates.length)return;const g=b.coordinates.map(y=>R.polyToCanvas(y,i,s,n));t.beginPath(),g.forEach(([y,m],v)=>v===0?t.moveTo(y,m):t.lineTo(y,m)),t.closePath();let f=S.color||b.color||d[u%d.length];S.alpha!==void 0&&f!=="transparent"&&(f=zt(f,S.alpha)),t.strokeStyle=f,t.lineWidth=S.width??1,S.type==="dashed"?t.setLineDash([4,4]):S.type==="dotted"?t.setLineDash([2,4]):t.setLineDash([]),t.stroke()}),t.setLineDash([]);const p=o.fontFamily||"Rajdhani, sans-serif";for(const b of h){const u=a;if(u.show===!1||!b.name)continue;const S=b.coordinates?b.coordinates.map(T=>R.polyToCanvas(T,i,s,n)):[];let g,f;if(b.labelAt&&Array.isArray(b.labelAt))[g,f]=R.polyToCanvas(b.labelAt,i,s,n);else if(S.length>0)g=S.reduce((T,_)=>T+_[0],0)/S.length,f=S.reduce((T,_)=>T+_[1],0)/S.length;else continue;const y=Math.round((u.fontSize||o.zoneLabelSize||12)*1),m=u.fontStyle||"bold";t.font=`${m} ${y}px ${p}`,u.letterSpacing!==void 0&&"letterSpacing"in t&&(t.letterSpacing=`${u.letterSpacing}px`),t.textAlign="center",t.textBaseline="middle";const v=typeof u.formatter=="function"?u.formatter(b):b.name,x=t.measureText(v).width,A=y;if(u.backgroundColor&&u.backgroundColor!=="transparent"){let T=4,_=4;Array.isArray(u.padding)?(_=u.padding[0],T=u.padding[1]!==void 0?u.padding[1]:_):typeof lstyle.padding=="number"&&(T=_=lstyle.padding),T*=1,_*=1;const M=(u.borderRadius||0)*1,k=x+T*2,P=A+_*2,E=g-k/2,z=f-P/2;t.fillStyle=u.backgroundColor,t.beginPath(),t.roundRect?t.roundRect(E,z,k,P,M):t.rect(E,z,k,P),t.fill()}u.textShadow&&u.textShadow!=="none"?(t.shadowColor=u.textShadow,t.shadowBlur=4):(t.shadowColor="transparent",t.shadowBlur=0),t.fillStyle=u.color||o.zoneLabelColor||"#fff",t.fillText(v,g,f),t.shadowBlur=0,t.shadowColor="transparent","letterSpacing"in t&&(t.letterSpacing="0px")}}}class Ht{static draw(t,e,o,i,s,n,r,h){var d;const l=o.fontFamily||"Rajdhani, sans-serif";if(h&&h.show!==!1){const p=h.lineStyle||{},b=(p.lineWidth??1)*1,u=p.lineColor||"#e5e7eb",S=p.lineType||"solid";t.strokeStyle=u,t.lineWidth=b,S==="dashed"?t.setLineDash([4,4]):S==="dotted"?t.setLineDash([2,4]):t.setLineDash([]);for(const g of[.2,.4,.6,.8,1]){t.beginPath();for(let f=0;f<5;f++){const[y,m]=R.canvasVertex(f,i,s,n*g);f===0?t.moveTo(y,m):t.lineTo(y,m)}t.closePath(),t.stroke()}for(let g=0;g<5;g++){const[f,y]=R.canvasVertex(g,i,s,n);t.beginPath(),t.moveTo(i,s),t.lineTo(f,y),t.stroke()}t.setLineDash([])}if(!e||e.show===!1)return;const c=((d=e.labelStyle)==null?void 0:d.distance)!==void 0?e.labelStyle.distance:27.2;e.data.forEach((p,b)=>{const u=p.labelStyle||{},S=u.distance!==void 0?u.distance:c,g=typeof S=="string"&&S.endsWith("%")?parseFloat(S)/100*n:parseFloat(S)*1,[f,y]=R.canvasVertex(b,i,s,n+g),m=u.fontStyle||"normal",v=u.fontWeight||"bold",x=Math.round((u.fontSize||o.gasLabelSize||14)*1);t.font=`${m} ${v} ${x}px ${l}`,t.fillStyle=u.color||o.gasLabelColor||"#fff",t.textAlign="center",t.textBaseline="middle",t.shadowColor=o.gasLabelShadow,t.shadowBlur=7,t.fillText(p.name,f,y),t.shadowBlur=0})}}function Mt(w){const t=w.trim().toLowerCase();if(t.startsWith("#")){let o=t.slice(1);o.length===3&&(o=o[0]+o[0]+o[1]+o[1]+o[2]+o[2]);const i=parseInt(o.substring(0,2),16),s=parseInt(o.substring(2,4),16),n=parseInt(o.substring(4,6),16),r=o.length===8?parseInt(o.substring(6,8),16)/255:1;return[i,s,n,r]}const e=t.match(/rgba?\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\)/);return e?[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),e[4]!==void 0?parseFloat(e[4]):1]:t==="transparent"?[0,0,0,0]:[255,255,255,1]}function jt(w,t,e){const[o,i,s,n]=Mt(w),[r,h,a,l]=Mt(t),c=Math.round(o+(r-o)*e),d=Math.round(i+(h-i)*e),p=Math.round(s+(a-s)*e),b=n+(l-n)*e;return`rgba(${c},${d},${p},${b})`}class Bt{static draw(t,e,o,i,s,n,r,h,a,l){if(!e||!e.data||!Array.isArray(e.data))return[];const c=1,d=o.fontFamily||"Rajdhani, sans-serif",p=[],b=e.data;if(!b||b.length===0)return[];const u=R.resolveData(b,h);if(!u)return[];const S=e.name,g=e.shape||"circle",f=e.color||"#409eff";let y=e.size!==void 0?e.size:5;const[m,v]=R.polyToCanvas(u,i,s,n),x=ct.diagnose(u,a,i,s,n),[A,T]=R.ratioToDoc(u);l&&l.series===e&&(y*=1.5);const M=e.itemStyle||{},k=M.borderColor||"#fff",P=M.borderWidth!==void 0?M.borderWidth:1,E=M.opacity!==void 0?M.opacity:1,z=e.textStyle||{},D=z.show!==void 0?z.show:!0,j=z.color||f,N=z.fontSize!==void 0?z.fontSize:12,K=z.fontWeight||"normal",H=z.position||"top",ot=z.offset||[0,0],F=e.glowStyle||{},nt=F.show!==void 0?F.show:!1,W=F.colors,O=F.blur!==void 0?F.blur:15,$=F.startColor||f,U=F.endColor||"transparent",q=F.count!==void 0?F.count:3,Rt=F.glowDistance!==void 0?F.glowDistance:2;if(t.save(),t.globalAlpha=E,nt){t.shadowColor=W?W[0]:$,t.shadowBlur=O;let G=[],B=q;if(Array.isArray(W)&&W.length>0)G=W,B=G.length;else for(let Z=0;Z<B;Z++){const tt=B>1?Z/(B-1):0;G.push(jt($,U,tt))}for(let Z=B-1;Z>=0;Z--){const tt=G[Z];t.save(),t.fillStyle=tt,t.beginPath(),at(t,m,v,g,y,c,(Z+1)*Rt),t.fill(),t.restore()}}if(t.beginPath(),at(t,m,v,g,y,c,0),g==="ring"?(t.strokeStyle=f,t.lineWidth=P*c,t.stroke()):(t.fillStyle=f,t.fill(),P>0&&(t.strokeStyle=k,t.lineWidth=P*c,t.stroke())),t.restore(),D&&S){t.save(),t.globalAlpha=E,t.font=`${K} ${Math.round(N*c)}px ${d}`,t.fillStyle=j;let G="center",B="middle",Z=m+ot[0]*c,tt=v+ot[1]*c,st=6*c;g==="circle"||g==="ring"||g==="star"||g==="triangle"?st+=y*c:g==="square"&&(st+=y*c/2),H==="top"?(G="center",B="bottom",tt-=st):H==="bottom"?(G="center",B="top",tt+=st):H==="left"?(G="right",B="middle",Z-=st):H==="right"?(G="left",B="middle",Z+=st):H==="center"&&(G="center",B="middle"),t.textAlign=G,t.textBaseline=B,t.fillText(S,Z,tt),t.restore()}return p.push({ratio:u,zone:x,docX:A,docY:T,rawData:b,name:S,series:e}),p}}const V=class V{constructor(t,e={}){if(this._el=typeof t=="string"?document.getElementById(t):t,!this._el)throw new Error(`DuvalPentagon: container not found — "${t}"`);this._theme=ft.resolve(e.theme||V.DEFAULTS.theme),this._opt=X(X(X({},V.DEFAULTS),this._theme),e),this._normalizeOptions(),this._bus=new gt,this._zoom=new vt(this._opt.zoom),this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),Object.assign(this._canvas.style,{display:"block",width:"100%",height:"100%"}),this._el.appendChild(this._canvas),this._tooltipRenderer=new _t(this._el,this._theme),this._hoverRatio=null,this._hoverZone=null,this._hoverPoint=null,this._bindEvents(),this._observeResize(),this._syncCanvas(),this._renderFull()}_normalizeOptions(){if(this._opt.vertex.data||(this._opt.vertex.data=["H2","C2H2","C2H4","CH4","C2H6"]),!Array.isArray(this._opt.vertex.data)||this._opt.vertex.data.length!==5)throw new Error("DuvalPentagon: vertex.data must be an array of exactly 5 elements.");const t=this._opt.vertex.labelStyle||{};this._opt.vertex.data=this._opt.vertex.data.map(e=>{if(typeof e=="string")return{name:e,labelStyle:{...t}};if(e&&typeof e=="object"){if(!e.name)throw new Error("DuvalPentagon: each vertex object in vertex.data must have a 'name' property.");return{name:e.name,labelStyle:X({...t},e.labelStyle||{})}}else throw new Error("DuvalPentagon: vertex.data elements must be either strings or objects with a 'name' property.")}),this._opt.gasOrder=this._opt.vertex.data.map(e=>e.name),this._opt.zone?typeof this._opt.zone=="object"&&!this._opt.zone.data&&(this._opt.zone.data=V.DEFAULT_ZONES):this._opt.zone={data:V.DEFAULT_ZONES}}setOption(t){return t.theme!==void 0&&(this._theme=ft.resolve(t.theme),this._tooltipRenderer.updateTheme(this._theme),this._opt=X(X(X({},V.DEFAULTS),this._theme),this._opt)),X(this._opt,t),this._normalizeOptions(),this._syncCanvas(),this._render(),this}setSeries(t){return this._opt.series=Array.isArray(t)?t:[t],this._renderFull(),this}diagnose(t){const{cx:e,cy:o,R:i}=this._dims();return ct.diagnose(t,this._opt.zone,e,o,i)}zoomReset(){return this._zoom.reset(),this._renderFull(),this}on(t,e){return this._bus.on(t,e),this}off(t,e){return this._bus.off(t,e),this}dispose(){var e,o;(e=this._ro)==null||e.disconnect(),this._tooltipRenderer.dispose();const t=this._canvas;t&&(t.removeEventListener("wheel",this._onWheel),t.removeEventListener("mousedown",this._onDown),t.removeEventListener("mousemove",this._onMove),t.removeEventListener("mouseleave",this._onLeave),t.removeEventListener("dblclick",this._onDbl),(o=t.parentNode)==null||o.removeChild(t)),window.removeEventListener("mouseup",this._onUp),this._bus.dispose()}_bindEvents(){const t=this._canvas;this._onWheel=e=>{e.preventDefault();const o=t.getBoundingClientRect(),i=(e.clientX-o.left)*(this._cssW/o.width),s=(e.clientY-o.top)*(this._cssH/o.height);this._zoom.onWheel(e.deltaY,i,s),this._bus.emit("zoom",this._zoom.state),this._renderFull()},this._onDown=e=>{e.button===0&&(this._zoom.startDrag(e.clientX,e.clientY),t.style.cursor="grabbing")},this._onMove=e=>{const o=t.getBoundingClientRect(),i=this._cssW/o.width;if(this._zoom.moveDrag(e.clientX,e.clientY,i)){this._renderFull();return}const s=((e.clientX-o.left)*i-this._zoom.panX)/this._zoom.zoom,n=((e.clientY-o.top)*i-this._zoom.panY)/this._zoom.zoom,{cx:r,cy:h,R:a,S:l}=this._dims();let c=null,d=1/0;if(this._drawnResults)for(const u of this._drawnResults){const[S,g]=R.polyToCanvas(u.ratio,r,h,a),f=u.series.size||Math.max(5,l*.013),y=Math.hypot(S-s,g-n);y<Math.max(f*1.5,12)&&y<d&&(d=y,c=u)}const b=(this._opt.tooltip||{}).show!==!1;if(c&&b)t.style.cursor="pointer",this._hoverPoint=c,this._hoverRatio=c.ratio,this._hoverZone=c.zone,this._bus.emit("hover",{ratio:c.ratio,zone:c.zone,docX:c.docX,docY:c.docY,point:c.series});else{t.style.cursor="default",this._hoverPoint=null;const u=R.canvasToRatio(s,n,r,h,a);if(u&&b){this._hoverRatio=u,this._hoverZone=ct.diagnose(u,this._opt.zone,r,h,a);const[S,g]=R.ratioToDoc(u);this._bus.emit("hover",{ratio:u,zone:this._hoverZone,docX:S,docY:g})}else this._hoverRatio=null,this._hoverZone=null,this._bus.emit("hover",null)}this._renderFull()},this._onUp=()=>{this._zoom.endDrag()&&(t.style.cursor=this._hoverPoint?"pointer":"default",this._bus.emit("zoom",this._zoom.state))},this._onLeave=()=>{this._hoverRatio=null,this._hoverZone=null,this._hoverPoint=null,this._bus.emit("hover",null),this._renderFull()},this._onDbl=()=>{this.zoomReset(),this._bus.emit("zoom",this._zoom.state)},t.addEventListener("wheel",this._onWheel,{passive:!1}),t.addEventListener("mousedown",this._onDown),t.addEventListener("mousemove",this._onMove),t.addEventListener("mouseleave",this._onLeave),t.addEventListener("dblclick",this._onDbl),window.addEventListener("mouseup",this._onUp),t.style.cursor="default"}_observeResize(){typeof ResizeObserver>"u"||(this._ro=new ResizeObserver(()=>{this._syncCanvas(),this._renderFull()}),this._ro.observe(this._el))}_syncCanvas(){const t=window.devicePixelRatio||1,e=this._el.clientWidth||300,o=this._el.clientHeight||300;this._cssW=e,this._cssH=o,this._canvas.width=Math.round(e*t),this._canvas.height=Math.round(o*t)}_dims(){var a;const t=this._cssW,e=this._cssH,o=((a=this._opt)==null?void 0:a.grid)||{};if(!(o.left!==void 0||o.right!==void 0||o.top!==void 0||o.bottom!==void 0)){const l=Math.min(t,e);return{W:t,H:e,S:l,cx:t/2,cy:e/2,R:l*.385}}const s=yt(t,e,o,0),r=Math.min(s.availW,s.availH)/2,h=r/.385;return{W:t,H:e,S:h,cx:s.cx,cy:s.cy,R:r}}_render(){this._hoverRatio=null,this._hoverZone=null,this._hoverPoint=null,this._renderFull()}_renderFull(){var g;const t=this._ctx;if(!t)return;const e=window.devicePixelRatio||1,{W:o,H:i,S:s,cx:n,cy:r,R:h}=this._dims(),a=this._theme,l=this._opt.gasOrder,c=this._opt.zone,d=this._opt.vertex;t.setTransform(e,0,0,e,0,0),t.clearRect(0,0,o,i);const p=this._opt.backgroundColor||a.backgroundColor||"transparent";p!=="transparent"&&(t.fillStyle=p,t.fillRect(0,0,o,i)),t.save(),this._zoom.applyTransform(t),ct.draw(t,c,a,n,r,h,s),Ht.draw(t,d,a,n,r,h,s,this._opt.grid);const b=[];for(const f of this._opt.series||[]){const y=Bt.draw(t,f,a,n,r,h,s,l,c,this._hoverPoint);Array.isArray(y)&&y.forEach(m=>{b.push({series:f,...m})})}this._drawnResults=b;const u=this._opt.tooltip||{};if(u.show!==!1&&this._hoverPoint){let f=0,y=0;[f,y]=R.polyToCanvas(this._hoverRatio,n,r,h);const m=f*this._zoom.zoom+this._zoom.panX,v=y*this._zoom.zoom+this._zoom.panY;let x="";typeof u.formatter=="function"?x=u.formatter({ratio:this._hoverRatio,zone:this._hoverZone,point:(g=this._hoverPoint)==null?void 0:g.series,gasOrder:l}):x=this._defaultTooltipHTML(this._hoverRatio,this._hoverZone,a,l,this._hoverPoint),this._tooltipRenderer.show(x,m,v,u,a,this._hoverZone)}else this._tooltipRenderer.hide();t.restore(),b.length>0&&this._bus.emit("diagnose",b)}_defaultTooltipHTML(t,e,o,i,s){var p;const n=((p=this._opt.vertex)==null?void 0:p.data)||[],r=s==null?void 0:s.rawData,a=`<div style="font-size:14px; font-weight:bold; margin-bottom:4px; color:#fff;">${(s==null?void 0:s.name)||"Data Point"}</div>`,l=e?`${e.name||""} ${e.title||""}`.trim():"Outside",c=e?e.color:"#fff";let d=`
|
|
2
|
+
${a}
|
|
3
|
+
<div style="color:${c}; font-size:13px; font-weight:bold; padding-bottom:8px; margin-bottom:8px; border-bottom:1px solid rgba(255,255,255,0.07);">
|
|
4
|
+
${l}
|
|
5
5
|
</div>
|
|
6
|
-
`;return
|
|
6
|
+
`;return i.forEach((b,u)=>{var f,y,m,v;const S=((y=(f=n[u])==null?void 0:f.labelStyle)==null?void 0:y.color)||((v=(m=o.vertex)==null?void 0:m.labelStyle)==null?void 0:v.color)||"#fff";let g="-";if(r)if(Array.isArray(r)){const x=r[u];if(x&&typeof x=="object"){const A=r.find(T=>T.name===b);g=A&&A.value!==void 0?A.value:"-"}else g=r[u]!==void 0?r[u]:"-"}else typeof r=="object"&&(g=r[b]!==void 0?r[b]:"-");d+=`
|
|
7
7
|
<div style="display:flex; align-items:center; margin-bottom:6px; font-size:13px;">
|
|
8
|
-
<span style="display:inline-block; width:8px; height:8px; border-radius:50%; background-color:${
|
|
9
|
-
<span style="color:#cbd5e1; flex-grow:1;">${
|
|
10
|
-
<span style="color:#fff; font-weight:bold; margin-left:20px;">${
|
|
8
|
+
<span style="display:inline-block; width:8px; height:8px; border-radius:50%; background-color:${S}; margin-right:8px;"></span>
|
|
9
|
+
<span style="color:#cbd5e1; flex-grow:1;">${b}</span>
|
|
10
|
+
<span style="color:#fff; font-weight:bold; margin-left:20px;">${g}</span>
|
|
11
11
|
</div>
|
|
12
|
-
`}),c}};K(U,"DEFAULT_ZONES",ot),K(U,"DEFAULTS",{theme:"dark",vertex:{show:!0,data:["H2","C2H2","C2H4","CH4","C2H6"]},zone:null,series:[],grid:{show:!1},zoom:{min:.3,max:6,step:.12},tooltip:{show:!0,showDiagnostic:!1,showPoint:!0}});let ut=U;const ht=Object.freeze({zone:{data:Mt},backgroundColor:"#050d1a",triFill:"rgba(8,20,50,0)",grid:{show:!0,steps:10,majorEvery:2,lineStyle:{color:"rgba(255,255,255,0)",width:1,type:"solid"},majorLineStyle:{color:"rgba(255,255,255,0)",width:1,type:"solid"},labelStyle:{color:"rgba(200,220,255,0.8)",fontSize:12,fontWeight:"normal"}},side:{show:!0,data:["CH4","C2H2","C2H4"],labelStyle:{color:"#00e5ff",fontSize:14,fontWeight:"bold",offset:40},tickStyle:{show:!0,color:"rgba(200,220,255)",fontSize:14,offset:15,length:6,lineColor:"rgba(0,0,0,0.2)"},lineStyle:{color:"rgba(180,210,255,0.1)",width:1.5,type:"solid"}},tooltip:{show:!0,backgroundColor:"rgba(5,13,26,0.95)",borderColor:"#00e5ff",padding:10,textStyle:{color:"#c8d8e8",fontSize:12}},pointStyle:{itemStyle:{shape:"circle",radius:6,color:"#ff4081",borderWidth:1.5,borderColor:"rgba(255,255,255,0.7)"},textStyle:{show:!0,fontSize:12,color:"#00e5ff",position:"top"}}});class D{static computeTri(t){const{availW:e,availH:o,cx:s,cy:i}=t,n=Math.max(0,Math.min(e,o/Math.sin(Math.PI/3))),l=n*Math.sin(Math.PI/3),h=s-n/2,a=i-l/2;return{top:{x:s,y:a},left:{x:h,y:a+l},right:{x:h+n,y:a+l}}}static t2c(t,e,o,s){const{top:i,left:n,right:l}=s;return{x:t*i.x+e*n.x+o*l.x,y:t*i.y+e*n.y+o*l.y}}static c2t(t,e,o){const{top:s,left:i,right:n}=o,l=(i.y-n.y)*(s.x-n.x)+(n.x-i.x)*(s.y-n.y),h=((i.y-n.y)*(t-n.x)+(n.x-i.x)*(e-n.y))/l,a=((n.y-s.y)*(t-n.x)+(s.x-n.x)*(e-n.y))/l;return{a:h,b:a,c:1-h-a}}static polyArea(t){let e=0;for(let o=0,s=t.length;o<s;o++){const i=(o+1)%s;e+=t[o].x*t[i].y-t[i].x*t[o].y}return Math.abs(e)/2}static polyCentroid(t){const e=t.length;let o=0,s=0,i=0;for(let n=0;n<e;n++){const l=(n+1)%e,h=t[n].x*t[l].y-t[l].x*t[n].y;o+=h,s+=(t[n].x+t[l].x)*h,i+=(t[n].y+t[l].y)*h}return o/=2,{x:s/(6*o),y:i/(6*o)}}static resolveData(t,e){let o=null;if(Array.isArray(t)?t.length>=3&&(typeof t[0]=="object"&&t[0]!==null?e?o=e.map(h=>{const a=t.find(r=>r&&r.name===h);return a?a.value:0}):o=[t[0].value,t[1].value,t[2].value]:o=[t[0],t[1],t[2]]):t&&t.value&&Array.isArray(t.value)&&t.value.length>=3&&(o=[t.value[0],t.value[1],t.value[2]]),!o||o.some(h=>typeof h!="number"||isNaN(h)))return null;const[s,i,n]=o.map(h=>Math.max(0,h||0)),l=s+i+n;return l<=1e-9?[.3333,.3333,.3333]:[s/l,i/l,n/l]}}class Ot{constructor(t){this.ctx=t}render(t){const e=this.ctx,{W:o,H:s,dpr:i,scale:n,tx:l,ty:h,option:a,tri:r,zones:c,hoveredPoint:d}=t;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,o*i,s*i),e.fillStyle=a.backgroundColor,e.fillRect(0,0,o*i,s*i),e.setTransform(n*i,0,0,n*i,l*i,h*i),this.drawTriFill(r),this.drawZones(c,r,a),this.drawGrid(a,r),this.drawBorder(a,r),this.drawSideLabels(a,r),this.drawSeries(a,r,d),e.setTransform(1,0,0,1,0,0)}drawTriFill(t){const e=this.ctx,{top:o,left:s,right:i}=t;e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.lineTo(i.x,i.y),e.closePath(),e.fillStyle=ht.triFill,e.fill()}drawZones(t,e,o){var r,c,d,f;const s=this.ctx,i=this.ctx.getTransform().a/(window.devicePixelRatio||1);t.forEach(g=>{!g.points||!g.points.length||(s.beginPath(),g.points.forEach(([p,m,y],u)=>{const b=D.t2c(p,m,y,e);u===0?s.moveTo(b.x,b.y):s.lineTo(b.x,b.y)}),s.closePath(),s.fillStyle=g.color||"transparent",s.fill())});const n=((r=o.zone)==null?void 0:r.borderStyle)||{};if(t.forEach(g=>{const p=E(E({},n),g.borderStyle||{});p.show===!1||!g.points||!g.points.length||(s.beginPath(),g.points.forEach(([m,y,u],b)=>{const w=D.t2c(m,y,u,e);b===0?s.moveTo(w.x,w.y):s.lineTo(w.x,w.y)}),s.closePath(),s.strokeStyle=p.color||g.borderColor||"rgba(255,255,255,0.2)",s.lineWidth=(p.width??p.stroke??g.borderWidth??1)*i,p.type==="dashed"?s.setLineDash([4,4]):p.type==="dotted"?s.setLineDash([2,4]):s.setLineDash([]),s.stroke())}),s.setLineDash([]),!(o.showZoneLabel!==!1))return;const h=((d=(c=o.grid)==null?void 0:c.labelStyle)==null?void 0:d.fontFamily)||"Microsoft YaHei UI, monospace",a=((f=o.zone)==null?void 0:f.labelStyle)||{};t.forEach(g=>{const p=E(E({},a),g.labelStyle||{});if(p.show===!1||!g.id)return;const m=g.labelPos;if(!m)return;const y=D.t2c(m.a,m.b,m.c,e),u=Math.round((p.fontSize||11)*i),b=p.fontStyle||"bold";s.font=`${b} ${u}px ${h}`,s.textAlign="center",s.textBaseline="middle";const w=g.id,v=s.measureText(w).width,x=u;let C=y.x,z=y.y;if(p.backgroundColor&&p.backgroundColor!=="transparent"){let _=4,A=4;Array.isArray(p.padding)?(A=p.padding[0],_=p.padding[1]!==void 0?p.padding[1]:A):typeof p.padding=="number"&&(_=A=p.padding),_*=i,A*=i;const Y=(p.borderRadius||3)*i,P=v+_*2,k=x+A*2,M=C-P/2,L=z-k/2;s.fillStyle=p.backgroundColor,s.beginPath(),s.roundRect?s.roundRect(M,L,P,k,Y):s.rect(M,L,P,k),s.fill()}p.textShadow&&p.textShadow!=="none"?(s.shadowColor=p.textShadow,s.shadowBlur=4):(s.shadowColor="transparent",s.shadowBlur=0),s.fillStyle=p.color||g.labelColor||"#fff",s.fillText(w,C,z),s.shadowBlur=0,s.shadowColor="transparent"}),s.textBaseline="alphabetic"}drawBadge(t,e,o,s,i){const n=this.ctx,{badgePadding:l,badgeHeight:h,badgeRadius:a}=ht.ZONE_VIS,r=o+l*2,c=t-r/2,d=e-h/2;n.beginPath(),n.roundRect?n.roundRect(c,d,r,h,a):n.rect(c,d,r,h),n.fillStyle=i,n.fill()}drawArrow(t,e,o,s,i){const n=this.ctx,l=o-t,h=s-e,a=Math.hypot(l,h);if(a<1)return;const r=l/a,c=h/a,d=7;n.beginPath(),n.moveTo(o,s),n.lineTo(o-r*d+c*d*.5,s-c*d-r*d*.5),n.lineTo(o-r*d-c*d*.5,s-c*d+r*d*.5),n.closePath(),n.fillStyle=i,n.fill()}drawGrid(t,e){if(!t.grid||!t.grid.show)return;const o=this.ctx,s=t.grid,i=s.steps||10,n=s.majorEvery||2,l=s.lineStyle||{color:"rgba(255,255,255,0.1)",width:1,type:"solid"},h=s.majorLineStyle||{color:"rgba(255,255,255,0.2)",width:1,type:"solid"},a=this.ctx.getTransform().a/(window.devicePixelRatio||1),r=(p,m,y)=>{let u=m.x-p.x,b=m.y-p.y;const w=Math.hypot(u,b);u/=w,b/=w;const v={x:-b,y:u},x={x:b,y:-u};return(y.x-p.x)*v.x+(y.y-p.y)*v.y>0?v:x},{top:c,left:d,right:f}=e,g={bottom:r(d,f,c),left:r(d,c,f),right:r(f,c,d)};for(let p=1;p<i;p++){const m=p/i,y=p%n===0,u=y?h:l;o.strokeStyle=u.color||"transparent",o.lineWidth=(u.width??1)*a,u.type==="dashed"?o.setLineDash([4,4]):u.type==="dotted"?o.setLineDash([2,4]):o.setLineDash([]);const b=(w,v)=>{o.beginPath(),o.moveTo(w.x,w.y),o.lineTo(v.x,v.y),o.stroke()};b(D.t2c(m,1-m,0,e),D.t2c(m,0,1-m,e)),b(D.t2c(1-m,m,0,e),D.t2c(0,m,1-m,e)),b(D.t2c(1-m,0,m,e),D.t2c(0,1-m,m,e)),this.drawSideTick(p,i,m,t,e,y,g)}}drawSideTick(t,e,o,s,i,n,l){const a=(s.side||{}).tickStyle||{};if(a.show===!1)return;const r=this.ctx,c=Math.round(t*100/e);r.textAlign="center",r.textBaseline="middle";const d=a.length||6,f=a.lineColor||"rgba(0,0,0,0.2)",g=a.color||"rgba(200,220,255)",p=a.offset!==void 0?a.offset:15,m=a.fontFamily||"Microsoft YaHei UI, sans-serif",y=a.fontSize||14,b=`${a.fontWeight||"normal"} ${y}px ${m}`,w=(z,_,A)=>{r.beginPath(),r.moveTo(z.x,z.y),r.lineTo(z.x+_*d,z.y+A*d),r.strokeStyle=f,r.lineWidth=1.5,r.stroke()},v=D.t2c(o,1-o,0,i);w(v,l.left.x,l.left.y),n&&(r.fillStyle=g,r.font=b,r.save(),r.translate(v.x-p,v.y-8),r.rotate(-Math.PI/3),r.fillText(c+"",0,0),r.restore());const x=D.t2c(1-o,0,o,i);w(x,l.right.x,l.right.y),n&&(r.fillStyle=g,r.font=b,r.save(),r.translate(x.x+p,x.y-8),r.rotate(Math.PI/3),r.fillText(c+"",0,0),r.restore());const C=D.t2c(0,o,1-o,i);w(C,l.bottom.x,l.bottom.y),n&&(r.fillStyle=g,r.font=b,r.fillText(c+"",C.x,C.y+p))}drawBorder(t,e){const o=this.ctx,{top:s,left:i,right:n}=e,h=(t.side||{}).lineStyle||{color:"rgba(180,210,255,0.1)",width:1.5,type:"solid"};[{f:s,t:i},{f:s,t:n},{f:i,t:n}].forEach(({f:r,t:c})=>{o.beginPath(),o.moveTo(r.x,r.y),o.lineTo(c.x,c.y),o.strokeStyle=h.color||"transparent",o.lineWidth=h.width||1,h.type==="dashed"?o.setLineDash([4,4]):h.type==="dotted"?o.setLineDash([2,4]):o.setLineDash([]),o.stroke()}),o.setLineDash([])}drawSideLabels(t,e){var C;if(((C=t.side)==null?void 0:C.show)===!1)return;const o=this.ctx,{top:s,left:i,right:n}=e,l=t.side||{},h=l.data||["A","B","C"],a=l.labelStyle||{},r=a.fontFamily||"Microsoft YaHei UI, sans-serif",c=a.fontSize||14,d=a.fontWeight||"bold",f=a.color||"#00e5ff",g=a.offset!==void 0?a.offset:40;o.textBaseline="middle",o.textAlign="center",o.fillStyle=f,o.font=`${d} ${c}px ${r}`;const p={x:(s.x+i.x)/2,y:(s.y+i.y)/2},m=i.x-s.x,y=i.y-s.y,u=Math.hypot(m,y);o.save(),o.translate(p.x+-y/u*g,p.y+m/u*g),o.rotate(Math.atan2(y,m)+Math.PI),o.fillText((h[1]||"B")+" (%)",0,0),o.restore();const b={x:(s.x+n.x)/2,y:(s.y+n.y)/2},w=n.x-s.x,v=n.y-s.y,x=Math.hypot(w,v);o.save(),o.translate(b.x+v/x*g,b.y+-w/x*g),o.rotate(Math.atan2(v,w)),o.fillText((h[2]||"C")+" (%)",0,0),o.restore(),o.save(),o.translate((i.x+n.x)/2,(i.y+n.y)/2+g),o.fillText((h[0]||"A")+" (%)",0,0),o.restore()}drawSeries(t,e,o){var h;const s=this.ctx,i=this.ctx.getTransform().a/(window.devicePixelRatio||1),n="Microsoft YaHei UI, sans-serif",l=(h=t.side)==null?void 0:h.data;(t.series||[]).forEach(a=>{const r=a.data;if(!r||r.length===0)return;const c=a.name,d=D.resolveData(r,l);if(!d)return;const f=D.t2c(d[0],d[1],d[2],e),g=f.x,p=f.y,m=o&&o.series===a,y=a.shape||"circle",u=a.color||"#409eff";let b=a.size!==void 0?a.size:5;m&&(b*=1.5);const w=a.itemStyle||{},v=w.borderColor||"#fff",x=w.borderWidth!==void 0?w.borderWidth:1,C=w.opacity!==void 0?w.opacity:1,z=a.textStyle||{},_=z.show!==void 0?z.show:!0,A=z.color||u,Y=z.fontSize!==void 0?z.fontSize:12,P=z.fontWeight||"normal",k=z.position||"top",M=z.offset||[0,0],L=a.glowStyle||{},Q=L.show!==void 0?L.show:!1,B=L.colors,it=L.blur!==void 0?L.blur:15,Z=L.startColor||u,tt=L.endColor||"transparent",H=L.count!==void 0?L.count:3,ft=L.glowDistance!==void 0?L.glowDistance:2;if(s.save(),s.globalAlpha=C,Q){s.shadowColor=B?B[0]:Z,s.shadowBlur=it;let X=[],I=H;if(Array.isArray(B)&&B.length>0)X=B,I=X.length;else for(let R=0;R<I;R++){const G=I>1?R/(I-1):0;X.push(jt(Z,tt,G))}for(let R=I-1;R>=0;R--){const G=X[R];s.save(),s.fillStyle=G,s.beginPath(),lt(s,g,p,y,b,i,(R+1)*ft),s.fill(),s.restore()}}if(s.beginPath(),lt(s,g,p,y,b,i,0),y==="ring"?(s.strokeStyle=u,s.lineWidth=x*i,s.stroke()):(s.fillStyle=u,s.fill(),x>0&&(s.strokeStyle=v,s.lineWidth=x*i,s.stroke())),s.restore(),_&&c){s.save(),s.globalAlpha=C,s.font=`${P} ${Math.round(Y*i)}px ${n}`,s.fillStyle=A;let X="center",I="middle",R=g+M[0]*i,G=p+M[1]*i,V=6*i;y==="circle"||y==="ring"||y==="star"||y==="triangle"?V+=b*i:y==="square"&&(V+=b*i/2),k==="top"?(X="center",I="bottom",G-=V):k==="bottom"?(X="center",I="top",G+=V):k==="left"?(X="right",I="middle",R-=V):k==="right"?(X="left",I="middle",R+=V):k==="center"&&(X="center",I="middle"),s.textAlign=X,s.textBaseline=I,s.fillText(c,R,G),s.restore()}})}}class Nt{constructor(t,e={}){this.initDOM(t),this.renderer=new Ot(this.ctx),this.state={W:0,H:0,dpr:1,scale:1,tx:0,ty:0,option:{},tri:{},zones:[],hoveredPoint:null},this._zoom=new yt(e.zoom),this.events={click:null,viewChange:null,hover:null},this._initTooltip(),this.bindEvents(),this.ro=new ResizeObserver(()=>this.fitCanvas()),this.ro.observe(this.container),this.fitCanvas(),Object.keys(e).length&&this.setOption(e)}initDOM(t){let e=typeof t=="string"?document.getElementById(t):t;if(!e)throw new Error("DuvalTriangle: container not found");this.container=e.tagName.toLowerCase()==="canvas"&&e.parentElement||e,this.canvas=e.tagName.toLowerCase()==="canvas"?e:document.createElement("canvas"),e.tagName.toLowerCase()!=="canvas"&&(this.container.style.position=this.container.style.position||"relative",this.canvas.style.cssText="display:block;width:100%;height:100%;cursor:default;",this.container.appendChild(this.canvas)),this.ctx=this.canvas.getContext("2d")}_initTooltip(){var e;const t=this.state.option.tooltip||ht.tooltip;this._tooltip=new bt(this.container,{tooltipBg:t.backgroundColor||"rgba(5,13,26,0.95)",tooltipTextColor:((e=t.textStyle)==null?void 0:e.color)||"#c8d8e8",tooltipPadding:t.padding||10,zoneBorderColor:t.borderColor||"#00e5ff",fontFamily:"monospace"}),this._tooltip.el.style.whiteSpace="nowrap",this._tooltip.el.style.lineHeight="1.6"}setOption(t){!this.state.option||!Object.keys(this.state.option).length?this.state.option=E(E({},ht),t):E(this.state.option,t),this._normalizeOptions(),this.computeGeometry(),this.buildZonePaths(),this.render()}_normalizeOptions(){const t=this.state.option;t.vertex&&!t.side&&(t.side=t.vertex,delete t.vertex),t.axes&&Array.isArray(t.axes)&&(t.side||(t.side={}),t.side.data=t.axes.map(e=>typeof e=="object"?e.name:e),delete t.axes),t.axisStyle&&(t.side||(t.side={}),E(t.side,t.axisStyle),delete t.axisStyle),t.side||(t.side={}),(!t.side.data||t.side.data.length<3)&&(t.side.data=["A","B","C"]),t.zones&&Array.isArray(t.zones)&&(t.zone||(t.zone={}),t.zone.data=t.zones,delete t.zones),t.showTooltip!==void 0&&(t.tooltip||(t.tooltip={}),t.tooltip.show=t.showTooltip)}computeGeometry(){const t=window.devicePixelRatio||1;this.state.W=this.canvas.width/t,this.state.H=this.canvas.height/t,this.state.dpr=t;const e=this.state.option.padding??45,o=this.state.option.grid||{},s=dt(this.state.W,this.state.H,o,e);this.state.tri=D.computeTri(s)}buildZonePaths(){var s;const{option:t,tri:e}=this.state,o=((s=t.zone)==null?void 0:s.data)||[];this.state.zones=o.map(i=>{const n={...i},l=new Path2D;if(i.points.forEach(([h,a,r],c)=>{const d=D.t2c(h,a,r,e);c===0?l.moveTo(d.x,d.y):l.lineTo(d.x,d.y)}),l.closePath(),n.path=l,i.labelAt)n.labelPos={a:i.labelAt[0],b:i.labelAt[1],c:i.labelAt[2]};else{const h=i.points.map(c=>D.t2c(c[0],c[1],c[2],e)),a=D.polyCentroid(h),r=D.c2t(a.x,a.y,e);n.labelPos={a:r.a,b:r.b,c:r.c}}return n})}fitCanvas(){const t=window.devicePixelRatio||1,e=this.container.clientWidth||400,o=this.container.clientHeight||400;this.canvas.width=Math.round(e*t),this.canvas.height=Math.round(o*t),this.canvas.style.width=e+"px",this.canvas.style.height=o+"px",this.state.scale=1,this.state.tx=0,this.state.ty=0,this._zoom&&this._zoom.reset(),Object.keys(this.state.option).length&&(this.computeGeometry(),this.buildZonePaths(),this.render())}render(){this.state.scale=this._zoom.zoom,this.state.tx=this._zoom.panX,this.state.ty=this._zoom.panY,this.renderer.render(this.state)}bindEvents(){const t=this.canvas;this._onWheel=e=>{e.preventDefault();const o=t.getBoundingClientRect(),s=(e.clientX-o.left)*(this.state.W/o.width),i=(e.clientY-o.top)*(this.state.H/o.height);this._zoom.onWheel(e.deltaY,s,i),typeof this.events.viewChange=="function"&&this.events.viewChange(this._zoom.state),this.render()},this._onDown=e=>{if(e.button!==0)return;const o=t.getBoundingClientRect(),s=this.state.W/o.width,i=this.state.H/o.height;this._zoom.startDrag(e.clientX*s,e.clientY*i),t.style.cursor="grabbing"},this._onMove=e=>{const o=t.getBoundingClientRect(),s=this.state.W/o.width,i=this.state.H/o.height;if(this._zoom.moveDrag(e.clientX*s,e.clientY*i,1)){this.render();return}this.handleMouseMove(e)},this._onUp=()=>{this._zoom.endDrag()&&(t.style.cursor=this.state.hoveredPoint?"pointer":"default",typeof this.events.viewChange=="function"&&this.events.viewChange(this._zoom.state))},this._onLeave=()=>{this.hideTooltip(),this.state.hoveredPoint=null,typeof this.events.hover=="function"&&this.events.hover(null),this.render()},this._onDbl=()=>{this._zoom.reset(),typeof this.events.viewChange=="function"&&this.events.viewChange(this._zoom.state),this.render()},t.addEventListener("wheel",this._onWheel,{passive:!1}),t.addEventListener("mousedown",this._onDown),t.addEventListener("mousemove",this._onMove),t.addEventListener("mouseleave",this._onLeave),t.addEventListener("dblclick",this._onDbl),t.addEventListener("click",this.handleClick.bind(this)),window.addEventListener("mouseup",this._onUp)}handleMouseMove(t){var p;const e=this.canvas.getBoundingClientRect(),o=this.state.W/e.width,s=this.state.H/e.height,i=(t.clientX-e.left)*o,n=(t.clientY-e.top)*s,l=(i-this._zoom.panX)/this._zoom.zoom,h=(n-this._zoom.panY)/this._zoom.zoom,{a,b:r,c}=D.c2t(l,h,this.state.tri);if(a<-1e-7||r<-1e-7||c<-1e-7){this.hideTooltip(),this.state.hoveredPoint!==null&&(this.state.hoveredPoint=null,this.canvas.style.cursor="default",this.render());return}let d=null,f=14;const g=(p=this.state.option.side)==null?void 0:p.data;(this.state.option.series||[]).forEach(m=>{const y=m.data;if(!y)return;const u=D.resolveData(y,g);if(!u)return;const b=D.t2c(...u,this.state.tri),w=Math.hypot(b.x-l,b.y-h);w<f&&(f=w,d={series:m,raw:u})}),d!==this.state.hoveredPoint&&(this.state.hoveredPoint=d,this.canvas.style.cursor=d?"pointer":"default",this.render()),this.showTooltip(l,h,a,r,c)}handleClick(t){if(this._zoom.isDragging)return;const e=this.canvas.getBoundingClientRect(),o=this.state.W/e.width,s=this.state.H/e.height,i=(t.clientX-e.left)*o,n=(t.clientY-e.top)*s,l=(i-this._zoom.panX)/this._zoom.zoom,h=(n-this._zoom.panY)/this._zoom.zoom,{a,b:r,c}=D.c2t(l,h,this.state.tri);if(a<-1e-7||r<-1e-7||c<-1e-7)return;const d=this.getZoneAt(a,r,c);typeof this.events.click=="function"&&this.events.click({a,b:r,c,zone:d}),this.canvas.dispatchEvent(new CustomEvent("triangle:click",{detail:{a,b:r,c,zone:d},bubbles:!0}))}showTooltip(t,e,o,s,i){var y,u;const n=this.state.option.tooltip||{};if(n.show===!1||!this.state.hoveredPoint&&n.showDiagnostic===!1){this.hideTooltip();return}const l=this.getZoneAt(o,s,i),a=(this.state.option.side||{}).data||["A","B","C"];if(typeof this.events.hover=="function"&&this.events.hover({ratio:[o,s,i],zone:l,point:((y=this.state.hoveredPoint)==null?void 0:y.series)||null}),n.formatter){const b=n.formatter({a:o,b:s,c:i,sNames:a,zone:l,point:(u=this.state.hoveredPoint)==null?void 0:u.series}),w=t*this._zoom.zoom+this._zoom.panX,v=e*this._zoom.zoom+this._zoom.panY;this._tooltip.show(b,w,v,n,{},l);return}const r=this._defaultTooltipHTML(o,s,i,a,l),c=t*this._zoom.zoom+this._zoom.panX,d=e*this._zoom.zoom+this._zoom.panY,f=this.canvas.getBoundingClientRect(),g=this.container.getBoundingClientRect(),p=f.left-g.left,m=f.top-g.top;this._tooltip.show(r,c+p,d+m,n,{},l)}hideTooltip(){this._tooltip&&this._tooltip.hide()}getZoneAt(t,e,o){const s=D.t2c(t,e,o,this.state.tri),i=this.ctx;i.save(),i.setTransform(1,0,0,1,0,0);const n=(this.state.zones||[]).find(l=>l.path&&i.isPointInPath(l.path,s.x,s.y));return i.restore(),n}resetZoom(){this.state.scale=1,this.state.tx=0,this.state.ty=0,this.render(),typeof this.events.viewChange=="function"&&this.events.viewChange({scale:this.state.scale,tx:this.state.tx,ty:this.state.ty})}dispose(){var t,e,o;(t=this.ro)==null||t.disconnect(),(e=this._tooltip)==null||e.dispose(),(o=this.canvas)==null||o.remove()}_defaultTooltipHTML(t,e,o,s,i){var m,y;const n=this.state.hoveredPoint,l=this.state.option.tooltip||{},h=l.showPoint!==!1,a=l.showDiagnostic!==!1;let r="";if(n&&h){let u=((m=n.series)==null?void 0:m.name)||"";u&&(r=`<div style="font-size:14px; font-weight:bold; margin-bottom:4px; color:#fff;">${u}</div>`)}const c=i?`${i.name||i.id} ${i.desc||i.title||""}`:"Outside",d=i&&((y=i.color)==null?void 0:y.replace(/[\d.]+\)$/,"1)"))||"#fff";let f=`
|
|
13
|
-
${
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
`}),d}};J(V,"DEFAULT_ZONES",it),J(V,"DEFAULTS",{theme:"dark",colors:Q,vertex:{show:!0,data:["H2","C2H2","C2H4","CH4","C2H6"]},zone:null,series:[],grid:{show:!1},zoom:{min:.3,max:6,step:.12},tooltip:{show:!0}});let bt=V;const ut=Object.freeze({colors:Q,zone:{data:Wt,alpha:.75},backgroundColor:"#050d1a",triFill:"rgba(8,20,50,0)",grid:{show:!0,steps:10,majorEvery:2,lineStyle:{color:"rgba(255,255,255,0)",width:1,type:"solid"},majorLineStyle:{color:"rgba(255,255,255,0)",width:1,type:"solid"},labelStyle:{color:"rgba(200,220,255,0.8)",fontSize:12,fontWeight:"normal"}},side:{show:!0,data:["CH4","C2H2","C2H4"],labelStyle:{color:"#00e5ff",fontSize:14,fontWeight:"bold",offset:40},tickStyle:{show:!0,color:"rgba(200,220,255)",fontSize:14,offset:15,length:6,lineColor:"rgba(0,0,0,0.2)"},lineStyle:{color:"rgba(180,210,255,0.1)",width:1.5,type:"solid"}},tooltip:{show:!0,backgroundColor:"rgba(5,13,26,0.95)",borderColor:"#00e5ff",padding:10,textStyle:{color:"#c8d8e8",fontSize:12}},pointStyle:{itemStyle:{shape:"circle",radius:6,color:"#ff4081",borderWidth:1.5,borderColor:"rgba(255,255,255,0.7)"},textStyle:{show:!0,fontSize:12,color:"#00e5ff",position:"top"}}});class L{static computeTri(t){const{availW:e,availH:o,cx:i,cy:s}=t,n=Math.max(0,Math.min(e,o/Math.sin(Math.PI/3))),r=n*Math.sin(Math.PI/3),h=i-n/2,a=s-r/2;return{top:{x:i,y:a},left:{x:h,y:a+r},right:{x:h+n,y:a+r}}}static t2c(t,e,o,i){const{top:s,left:n,right:r}=i;return{x:t*s.x+e*n.x+o*r.x,y:t*s.y+e*n.y+o*r.y}}static c2t(t,e,o){const{top:i,left:s,right:n}=o,r=(s.y-n.y)*(i.x-n.x)+(n.x-s.x)*(i.y-n.y),h=((s.y-n.y)*(t-n.x)+(n.x-s.x)*(e-n.y))/r,a=((n.y-i.y)*(t-n.x)+(i.x-n.x)*(e-n.y))/r;return{a:h,b:a,c:1-h-a}}static polyArea(t){let e=0;for(let o=0,i=t.length;o<i;o++){const s=(o+1)%i;e+=t[o].x*t[s].y-t[s].x*t[o].y}return Math.abs(e)/2}static polyCentroid(t){const e=t.length;let o=0,i=0,s=0;for(let n=0;n<e;n++){const r=(n+1)%e,h=t[n].x*t[r].y-t[r].x*t[n].y;o+=h,i+=(t[n].x+t[r].x)*h,s+=(t[n].y+t[r].y)*h}return o/=2,{x:i/(6*o),y:s/(6*o)}}static resolveData(t,e){let o=null;if(Array.isArray(t)?t.length>=3&&(typeof t[0]=="object"&&t[0]!==null?e?o=e.map(h=>{const a=t.find(l=>l&&l.name===h);return a?a.value:0}):o=[t[0].value,t[1].value,t[2].value]:o=[t[0],t[1],t[2]]):t&&t.value&&Array.isArray(t.value)&&t.value.length>=3&&(o=[t.value[0],t.value[1],t.value[2]]),!o||o.some(h=>typeof h!="number"||isNaN(h)))return null;const[i,s,n]=o.map(h=>Math.max(0,h||0)),r=i+s+n;return r<=1e-9?[.3333,.3333,.3333]:[i/r,s/r,n/r]}}class Zt{constructor(t){this.ctx=t}render(t){const e=this.ctx,{W:o,H:i,dpr:s,scale:n,tx:r,ty:h,option:a,tri:l,zones:c,hoveredPoint:d}=t;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,o*s,i*s),e.fillStyle=a.backgroundColor,e.fillRect(0,0,o*s,i*s),e.setTransform(n*s,0,0,n*s,r*s,h*s),this.drawTriFill(l),this.drawZones(c,l,a),this.drawGrid(a,l),this.drawBorder(a,l),this.drawSideLabels(a,l),this.drawSeries(a,l,d),e.setTransform(1,0,0,1,0,0)}drawTriFill(t){const e=this.ctx,{top:o,left:i,right:s}=t;e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(i.x,i.y),e.lineTo(s.x,s.y),e.closePath(),e.fillStyle=ut.triFill,e.fill()}drawZones(t,e,o){var d,p,b,u,S,g;const i=this.ctx,s=this.ctx.getTransform().a/(window.devicePixelRatio||1),n=(d=o.zone)==null?void 0:d.alpha,r=((p=o.zone)==null?void 0:p.colors)||o.colors||Q;t.forEach((f,y)=>{if(!f.coordinates||!f.coordinates.length)return;i.beginPath(),f.coordinates.forEach(([v,x,A],T)=>{const _=L.t2c(v,x,A,e);T===0?i.moveTo(_.x,_.y):i.lineTo(_.x,_.y)}),i.closePath();let m=f.color||r[y%r.length];n!==void 0&&m!=="transparent"&&(m=Dt(m,n)),i.fillStyle=m,i.fill()});const h=((b=o.zone)==null?void 0:b.borderStyle)||{};if(t.forEach((f,y)=>{const m=h;if(m.show===!1||!f.coordinates||!f.coordinates.length)return;i.beginPath(),f.coordinates.forEach(([x,A,T],_)=>{const M=L.t2c(x,A,T,e);_===0?i.moveTo(M.x,M.y):i.lineTo(M.x,M.y)}),i.closePath();let v=m.color||f.color||r[y%r.length];m.alpha!==void 0&&v!=="transparent"&&(v=Dt(v,m.alpha)),i.strokeStyle=v,i.lineWidth=(m.width??1)*s,m.type==="dashed"?i.setLineDash([4,4]):m.type==="dotted"?i.setLineDash([2,4]):i.setLineDash([]),i.stroke()}),i.setLineDash([]),!(o.showZoneLabel!==!1))return;const l=((S=(u=o.grid)==null?void 0:u.labelStyle)==null?void 0:S.fontFamily)||"Microsoft YaHei UI, monospace",c=((g=o.zone)==null?void 0:g.labelStyle)||{};t.forEach(f=>{const y=c;if(y.show===!1||!f.name)return;let m;const v=f.labelAt;if(v&&Array.isArray(v)&&v.length>=3)m=L.t2c(v[0],v[1],v[2],e);else if(f.coordinates&&f.coordinates.length>0){const E=f.coordinates.map(([z,D,j])=>L.t2c(z,D,j,e));m={x:E.reduce((z,D)=>z+D.x,0)/E.length,y:E.reduce((z,D)=>z+D.y,0)/E.length}}else return;const x=Math.round((y.fontSize||11)*s),A=y.fontStyle||"bold";i.font=`${A} ${x}px ${l}`,i.textAlign="center",i.textBaseline="middle";const T=typeof y.formatter=="function"?y.formatter(f):f.name,_=i.measureText(T).width,M=x;let k=m.x,P=m.y;if(y.backgroundColor&&y.backgroundColor!=="transparent"){let E=4,z=4;Array.isArray(y.padding)?(z=y.padding[0],E=y.padding[1]!==void 0?y.padding[1]:z):typeof y.padding=="number"&&(E=z=y.padding),E*=s,z*=s;const D=(y.borderRadius||3)*s,j=_+E*2,N=M+z*2,K=k-j/2,H=P-N/2;i.fillStyle=y.backgroundColor,i.beginPath(),i.roundRect?i.roundRect(K,H,j,N,D):i.rect(K,H,j,N),i.fill()}y.textShadow&&y.textShadow!=="none"?(i.shadowColor=y.textShadow,i.shadowBlur=4):(i.shadowColor="transparent",i.shadowBlur=0),i.fillStyle=y.color||"#fff",i.fillText(T,k,P),i.shadowBlur=0,i.shadowColor="transparent"}),i.textBaseline="alphabetic"}drawBadge(t,e,o,i,s){const n=this.ctx,{badgePadding:r,badgeHeight:h,badgeRadius:a}=ut.ZONE_VIS,l=o+r*2,c=t-l/2,d=e-h/2;n.beginPath(),n.roundRect?n.roundRect(c,d,l,h,a):n.rect(c,d,l,h),n.fillStyle=s,n.fill()}drawArrow(t,e,o,i,s){const n=this.ctx,r=o-t,h=i-e,a=Math.hypot(r,h);if(a<1)return;const l=r/a,c=h/a,d=7;n.beginPath(),n.moveTo(o,i),n.lineTo(o-l*d+c*d*.5,i-c*d-l*d*.5),n.lineTo(o-l*d-c*d*.5,i-c*d+l*d*.5),n.closePath(),n.fillStyle=s,n.fill()}drawGrid(t,e){if(!t.grid||!t.grid.show)return;const o=this.ctx,i=t.grid,s=i.steps||10,n=i.majorEvery||2,r=i.lineStyle||{color:"rgba(255,255,255,0.1)",width:1,type:"solid"},h=i.majorLineStyle||{color:"rgba(255,255,255,0.2)",width:1,type:"solid"},a=this.ctx.getTransform().a/(window.devicePixelRatio||1),l=(u,S,g)=>{let f=S.x-u.x,y=S.y-u.y;const m=Math.hypot(f,y);f/=m,y/=m;const v={x:-y,y:f},x={x:y,y:-f};return(g.x-u.x)*v.x+(g.y-u.y)*v.y>0?v:x},{top:c,left:d,right:p}=e,b={bottom:l(d,p,c),left:l(d,c,p),right:l(p,c,d)};for(let u=1;u<s;u++){const S=u/s,g=u%n===0,f=g?h:r;o.strokeStyle=f.color||"transparent",o.lineWidth=(f.width??1)*a,f.type==="dashed"?o.setLineDash([4,4]):f.type==="dotted"?o.setLineDash([2,4]):o.setLineDash([]);const y=(m,v)=>{o.beginPath(),o.moveTo(m.x,m.y),o.lineTo(v.x,v.y),o.stroke()};y(L.t2c(S,1-S,0,e),L.t2c(S,0,1-S,e)),y(L.t2c(1-S,S,0,e),L.t2c(0,S,1-S,e)),y(L.t2c(1-S,0,S,e),L.t2c(0,1-S,S,e)),this.drawSideTick(u,s,S,t,e,g,b)}}drawSideTick(t,e,o,i,s,n,r){const a=(i.side||{}).tickStyle||{};if(a.show===!1)return;const l=this.ctx,c=Math.round(t*100/e);l.textAlign="center",l.textBaseline="middle";const d=a.length||6,p=a.lineColor||"rgba(0,0,0,0.2)",b=a.color||"rgba(200,220,255)",u=a.offset!==void 0?a.offset:15,S=a.fontFamily||"Microsoft YaHei UI, sans-serif",g=a.fontSize||14,y=`${a.fontWeight||"normal"} ${g}px ${S}`,m=(T,_,M)=>{l.beginPath(),l.moveTo(T.x,T.y),l.lineTo(T.x+_*d,T.y+M*d),l.strokeStyle=p,l.lineWidth=1.5,l.stroke()},v=L.t2c(o,1-o,0,s);m(v,r.left.x,r.left.y),n&&(l.fillStyle=b,l.font=y,l.save(),l.translate(v.x-u,v.y-8),l.rotate(-Math.PI/3),l.fillText(c+"",0,0),l.restore());const x=L.t2c(1-o,0,o,s);m(x,r.right.x,r.right.y),n&&(l.fillStyle=b,l.font=y,l.save(),l.translate(x.x+u,x.y-8),l.rotate(Math.PI/3),l.fillText(c+"",0,0),l.restore());const A=L.t2c(0,o,1-o,s);m(A,r.bottom.x,r.bottom.y),n&&(l.fillStyle=b,l.font=y,l.fillText(c+"",A.x,A.y+u))}drawBorder(t,e){const o=this.ctx,{top:i,left:s,right:n}=e,h=(t.side||{}).lineStyle||{color:"rgba(180,210,255,0.1)",width:1.5,type:"solid"};[{f:i,t:s},{f:i,t:n},{f:s,t:n}].forEach(({f:l,t:c})=>{o.beginPath(),o.moveTo(l.x,l.y),o.lineTo(c.x,c.y),o.strokeStyle=h.color||"transparent",o.lineWidth=h.width||1,h.type==="dashed"?o.setLineDash([4,4]):h.type==="dotted"?o.setLineDash([2,4]):o.setLineDash([]),o.stroke()}),o.setLineDash([])}drawSideLabels(t,e){var A;if(((A=t.side)==null?void 0:A.show)===!1)return;const o=this.ctx,{top:i,left:s,right:n}=e,r=t.side||{},h=r.data||["A","B","C"],a=r.labelStyle||{},l=a.fontFamily||"Microsoft YaHei UI, sans-serif",c=a.fontSize||14,d=a.fontWeight||"bold",p=a.color||"#00e5ff",b=a.offset!==void 0?a.offset:40;o.textBaseline="middle",o.textAlign="center",o.fillStyle=p,o.font=`${d} ${c}px ${l}`;const u={x:(i.x+s.x)/2,y:(i.y+s.y)/2},S=s.x-i.x,g=s.y-i.y,f=Math.hypot(S,g);o.save(),o.translate(u.x+-g/f*b,u.y+S/f*b),o.rotate(Math.atan2(g,S)+Math.PI),o.fillText((h[1]||"B")+" (%)",0,0),o.restore();const y={x:(i.x+n.x)/2,y:(i.y+n.y)/2},m=n.x-i.x,v=n.y-i.y,x=Math.hypot(m,v);o.save(),o.translate(y.x+v/x*b,y.y+-m/x*b),o.rotate(Math.atan2(v,m)),o.fillText((h[2]||"C")+" (%)",0,0),o.restore(),o.save(),o.translate((s.x+n.x)/2,(s.y+n.y)/2+b),o.fillText((h[0]||"A")+" (%)",0,0),o.restore()}drawSeries(t,e,o){var h;const i=this.ctx,s=this.ctx.getTransform().a/(window.devicePixelRatio||1),n="Microsoft YaHei UI, sans-serif",r=(h=t.side)==null?void 0:h.data;(t.series||[]).forEach(a=>{const l=a.data;if(!l||l.length===0)return;const c=a.name,d=L.resolveData(l,r);if(!d)return;const p=L.t2c(d[0],d[1],d[2],e),b=p.x,u=p.y,S=o&&o.series===a,g=a.shape||"circle",f=a.color||"#409eff";let y=a.size!==void 0?a.size:5;S&&(y*=1.5);const m=a.itemStyle||{},v=m.borderColor||"#fff",x=m.borderWidth!==void 0?m.borderWidth:1,A=m.opacity!==void 0?m.opacity:1,T=a.textStyle||{},_=T.show!==void 0?T.show:!0,M=T.color||f,k=T.fontSize!==void 0?T.fontSize:12,P=T.fontWeight||"normal",E=T.position||"top",z=T.offset||[0,0],D=a.glowStyle||{},j=D.show!==void 0?D.show:!1,N=D.colors,K=D.blur!==void 0?D.blur:15,H=D.startColor||f,ot=D.endColor||"transparent",F=D.count!==void 0?D.count:3,nt=D.glowDistance!==void 0?D.glowDistance:2;if(i.save(),i.globalAlpha=A,j){i.shadowColor=N?N[0]:H,i.shadowBlur=K;let W=[],O=F;if(Array.isArray(N)&&N.length>0)W=N,O=W.length;else for(let $=0;$<O;$++){const U=O>1?$/(O-1):0;W.push(Ut(H,ot,U))}for(let $=O-1;$>=0;$--){const U=W[$];i.save(),i.fillStyle=U,i.beginPath(),at(i,b,u,g,y,s,($+1)*nt),i.fill(),i.restore()}}if(i.beginPath(),at(i,b,u,g,y,s,0),g==="ring"?(i.strokeStyle=f,i.lineWidth=x*s,i.stroke()):(i.fillStyle=f,i.fill(),x>0&&(i.strokeStyle=v,i.lineWidth=x*s,i.stroke())),i.restore(),_&&c){i.save(),i.globalAlpha=A,i.font=`${P} ${Math.round(k*s)}px ${n}`,i.fillStyle=M;let W="center",O="middle",$=b+z[0]*s,U=u+z[1]*s,q=6*s;g==="circle"||g==="ring"||g==="star"||g==="triangle"?q+=y*s:g==="square"&&(q+=y*s/2),E==="top"?(W="center",O="bottom",U-=q):E==="bottom"?(W="center",O="top",U+=q):E==="left"?(W="right",O="middle",$-=q):E==="right"?(W="left",O="middle",$+=q):E==="center"&&(W="center",O="middle"),i.textAlign=W,i.textBaseline=O,i.fillText(c,$,U),i.restore()}})}}class Gt{constructor(t,e={}){this.initDOM(t),this.renderer=new Zt(this.ctx),this.state={W:0,H:0,dpr:1,scale:1,tx:0,ty:0,option:{},tri:{},zones:[],hoveredPoint:null},this._zoom=new vt(e.zoom),this._bus=new gt,this._initTooltip(),this.bindEvents(),this.ro=new ResizeObserver(()=>this.fitCanvas()),this.ro.observe(this.container),this.fitCanvas(),Object.keys(e).length&&this.setOption(e)}initDOM(t){let e=typeof t=="string"?document.getElementById(t):t;if(!e)throw new Error("DuvalTriangle: container not found");this.container=e.tagName.toLowerCase()==="canvas"&&e.parentElement||e,this.canvas=e.tagName.toLowerCase()==="canvas"?e:document.createElement("canvas"),e.tagName.toLowerCase()!=="canvas"&&(this.container.style.position=this.container.style.position||"relative",this.canvas.style.cssText="display:block;width:100%;height:100%;cursor:default;",this.container.appendChild(this.canvas)),this.ctx=this.canvas.getContext("2d")}_initTooltip(){var e;const t=this.state.option.tooltip||ut.tooltip;this._tooltip=new _t(this.container,{tooltipBg:t.backgroundColor||"rgba(5,13,26,0.95)",tooltipTextColor:((e=t.textStyle)==null?void 0:e.color)||"#c8d8e8",tooltipPadding:t.padding||10,zoneBorderColor:t.borderColor||"#00e5ff",fontFamily:"monospace"}),this._tooltip.el.style.whiteSpace="nowrap",this._tooltip.el.style.lineHeight="1.6"}setOption(t){!this.state.option||!Object.keys(this.state.option).length?this.state.option=X(X({},ut),t):X(this.state.option,t),this._normalizeOptions(),this.computeGeometry(),this.buildZonePaths(),this.render()}setSeries(t){return this.state.option.series=Array.isArray(t)?t:[t],this.render(),this}on(t,e){return this._bus.on(t,e),this}off(t,e){return this._bus.off(t,e),this}_normalizeOptions(){const t=this.state.option;t.side||(t.side={}),(!t.side.data||t.side.data.length<3)&&(t.side.data=["A","B","C"])}computeGeometry(){const t=window.devicePixelRatio||1;this.state.W=this.canvas.width/t,this.state.H=this.canvas.height/t,this.state.dpr=t;const e=this.state.option.padding??45,o=this.state.option.grid||{},i=yt(this.state.W,this.state.H,o,e);this.state.tri=L.computeTri(i)}buildZonePaths(){var i;const{option:t,tri:e}=this.state,o=((i=t.zone)==null?void 0:i.data)||[];this.state.zones=o.map(s=>{const n={...s},r=new Path2D,h=s.coordinates;if(h){if(h.forEach(([a,l,c],d)=>{const p=L.t2c(a,l,c,e);d===0?r.moveTo(p.x,p.y):r.lineTo(p.x,p.y)}),r.closePath(),n.path=r,s.labelAt)n.labelPos={a:s.labelAt[0],b:s.labelAt[1],c:s.labelAt[2]};else{const l=(s.coordinates||[]).map(p=>L.t2c(p[0],p[1],p[2],e)),c=L.polyCentroid(l),d=L.c2t(c.x,c.y,e);n.labelPos={a:d.a,b:d.b,c:d.c}}return n}})}fitCanvas(){const t=window.devicePixelRatio||1,e=this.container.clientWidth||400,o=this.container.clientHeight||400;this.canvas.width=Math.round(e*t),this.canvas.height=Math.round(o*t),this.canvas.style.width=e+"px",this.canvas.style.height=o+"px",this.state.scale=1,this.state.tx=0,this.state.ty=0,this._zoom&&this._zoom.reset(),Object.keys(this.state.option).length&&(this.computeGeometry(),this.buildZonePaths(),this.render())}render(){var o;if(!this.state.option)return;this.state.scale=this._zoom.zoom,this.state.tx=this._zoom.panX,this.state.ty=this._zoom.panY,this.renderer.render(this.state);const t=[],e=(o=this.state.option.side)==null?void 0:o.data;(this.state.option.series||[]).forEach(i=>{const s=i.data;if(!s||s.length===0)return;const n=L.resolveData(s,e);if(!n)return;const r=this.getZoneAt(n[0],n[1],n[2]);t.push({series:i,zone:r,ratio:n})}),t.length>0&&this._bus.emit("diagnose",t)}bindEvents(){const t=this.canvas;this._onWheel=e=>{e.preventDefault();const o=t.getBoundingClientRect(),i=(e.clientX-o.left)*(this.state.W/o.width),s=(e.clientY-o.top)*(this.state.H/o.height);this._zoom.onWheel(e.deltaY,i,s),this._bus.emit("zoom",this._zoom.state),this.render()},this._onDown=e=>{if(e.button!==0)return;const o=t.getBoundingClientRect(),i=this.state.W/o.width,s=this.state.H/o.height;this._zoom.startDrag(e.clientX*i,e.clientY*s),t.style.cursor="grabbing"},this._onMove=e=>{const o=t.getBoundingClientRect(),i=this.state.W/o.width,s=this.state.H/o.height;if(this._zoom.moveDrag(e.clientX*i,e.clientY*s,1)){this.render();return}this.handleMouseMove(e)},this._onUp=()=>{this._zoom.endDrag()&&(t.style.cursor=this.state.hoveredPoint?"pointer":"default",this._bus.emit("zoom",this._zoom.state))},this._onLeave=()=>{this.hideTooltip(),this.state.hoveredPoint=null,this._bus.emit("hover",null),this.render()},this._onDbl=()=>{this.zoomReset()},t.addEventListener("wheel",this._onWheel,{passive:!1}),t.addEventListener("mousedown",this._onDown),t.addEventListener("mousemove",this._onMove),t.addEventListener("mouseleave",this._onLeave),t.addEventListener("dblclick",this._onDbl),t.addEventListener("click",this.handleClick.bind(this)),window.addEventListener("mouseup",this._onUp)}handleMouseMove(t){var u;const e=this.canvas.getBoundingClientRect(),o=this.state.W/e.width,i=this.state.H/e.height,s=(t.clientX-e.left)*o,n=(t.clientY-e.top)*i,r=(s-this._zoom.panX)/this._zoom.zoom,h=(n-this._zoom.panY)/this._zoom.zoom,{a,b:l,c}=L.c2t(r,h,this.state.tri);if(a<-1e-7||l<-1e-7||c<-1e-7){this.hideTooltip(),this.state.hoveredPoint!==null&&(this.state.hoveredPoint=null,this.canvas.style.cursor="default",this.render());return}let d=null,p=14;const b=(u=this.state.option.side)==null?void 0:u.data;(this.state.option.series||[]).forEach(S=>{const g=S.data;if(!g)return;const f=L.resolveData(g,b);if(!f)return;const y=L.t2c(...f,this.state.tri),m=Math.hypot(y.x-r,y.y-h);m<p&&(p=m,d={series:S,raw:f})}),d!==this.state.hoveredPoint&&(this.state.hoveredPoint=d,this.canvas.style.cursor=d?"pointer":"default",this.render()),this.showTooltip(r,h,a,l,c)}handleClick(t){if(this._zoom.isDragging)return;const e=this.canvas.getBoundingClientRect(),o=this.state.W/e.width,i=this.state.H/e.height,s=(t.clientX-e.left)*o,n=(t.clientY-e.top)*i,r=(s-this._zoom.panX)/this._zoom.zoom,h=(n-this._zoom.panY)/this._zoom.zoom,{a,b:l,c}=L.c2t(r,h,this.state.tri);if(a<-1e-7||l<-1e-7||c<-1e-7)return;const d=this.getZoneAt(a,l,c);this._bus.emit("click",{a,b:l,c,zone:d}),this.canvas.dispatchEvent(new CustomEvent("triangle:click",{detail:{a,b:l,c,zone:d},bubbles:!0}))}showTooltip(t,e,o,i,s){var g,f;const n=this.state.option.tooltip||{};if(n.show===!1||!this.state.hoveredPoint){this.hideTooltip();return}const r=this.getZoneAt(o,i,s),a=(this.state.option.side||{}).data||["A","B","C"];if(this._bus.emit("hover",{ratio:[o,i,s],zone:r,point:((g=this.state.hoveredPoint)==null?void 0:g.series)||null}),n.formatter){const y=n.formatter({a:o,b:i,c:s,sNames:a,zone:r,point:(f=this.state.hoveredPoint)==null?void 0:f.series}),m=t*this._zoom.zoom+this._zoom.panX,v=e*this._zoom.zoom+this._zoom.panY;this._tooltip.show(y,m,v,n,{},r);return}const l=this._defaultTooltipHTML(o,i,s,a,r),c=t*this._zoom.zoom+this._zoom.panX,d=e*this._zoom.zoom+this._zoom.panY,p=this.canvas.getBoundingClientRect(),b=this.container.getBoundingClientRect(),u=p.left-b.left,S=p.top-b.top;this._tooltip.show(l,c+u,d+S,n,{},r)}hideTooltip(){this._tooltip&&this._tooltip.hide()}getZoneAt(t,e,o){const i=L.t2c(t,e,o,this.state.tri),s=this.ctx;s.save(),s.setTransform(1,0,0,1,0,0);const n=(this.state.zones||[]).find(r=>r.path&&s.isPointInPath(r.path,i.x,i.y));return s.restore(),n}zoomReset(){this.state.scale=1,this.state.tx=0,this.state.ty=0,this.render(),this._bus.emit("zoom",{scale:this.state.scale,tx:this.state.tx,ty:this.state.ty})}dispose(){var t,e,o,i;(t=this.ro)==null||t.disconnect(),(e=this._tooltip)==null||e.dispose(),(o=this.canvas)==null||o.remove(),window.removeEventListener("mouseup",this._onUp),(i=this._bus)==null||i.dispose()}_defaultTooltipHTML(t,e,o,i,s){var S,g,f;const n=this.state.hoveredPoint,h=`<div style="font-size:14px; font-weight:bold; margin-bottom:4px; color:#fff;">${((S=n==null?void 0:n.series)==null?void 0:S.name)||"Data Point"}</div>`,a={PD:"局部放电",D1:"低能放电",D2:"高能放电",T1:"热故障,t<300℃",T2:"热故障,300℃<t<700℃",T3:"热故障,t>700℃",DT:"热和放电混合故障",S:"温度<200℃时的杂散气体",C:"绝缘纸可能碳化",O:"矿物油过热","T3-H":"仅矿物油过热",ND:"正常"},l=(s==null?void 0:s.title)||(s==null?void 0:s.desc)||(s?a[s.name]:"")||"",c=s?`${s.name||s.id||""} ${l}`.trim():"Outside",d=s&&((g=s.color)==null?void 0:g.replace(/[\d.]+\)$/,"1)"))||"#fff";let p=`
|
|
13
|
+
${h}
|
|
14
|
+
<div style="color:${d}; font-size:13px; font-weight:bold; padding-bottom:8px; margin-bottom:8px; border-bottom:1px solid rgba(255,255,255,0.07);">
|
|
15
|
+
${c}
|
|
16
|
+
</div>
|
|
17
|
+
`;const b=["#00e5ff","#ff6b35","#ffcc02"],u=(f=n==null?void 0:n.series)==null?void 0:f.data;return i.forEach((y,m)=>{const v=b[m%3];let x="-";u&&(Array.isArray(u)?x=u[m]!==void 0?u[m]:"-":typeof u=="object"&&(u.value&&Array.isArray(u.value)?x=u.value[m]!==void 0?u.value[m]:"-":u[y]!==void 0&&(x=u[y]))),p+=`
|
|
16
18
|
<div style="display:flex; align-items:center; margin-bottom:6px; font-size:13px;">
|
|
17
|
-
<span style="display:inline-block; width:8px; height:8px; border-radius:50%; background-color:${
|
|
18
|
-
<span style="color:#cbd5e1; flex-grow:1;">${
|
|
19
|
-
<span style="color:#fff; font-weight:bold; margin-left:20px;">${
|
|
19
|
+
<span style="display:inline-block; width:8px; height:8px; border-radius:50%; background-color:${v}; margin-right:8px;"></span>
|
|
20
|
+
<span style="color:#cbd5e1; flex-grow:1;">${y}</span>
|
|
21
|
+
<span style="color:#fff; font-weight:bold; margin-left:20px;">${x}</span>
|
|
20
22
|
</div>
|
|
21
|
-
`}),f}}function _t(S){const t=S.trim().toLowerCase();if(t.startsWith("#")){let o=t.slice(1);o.length===3&&(o=o[0]+o[0]+o[1]+o[1]+o[2]+o[2]);const s=parseInt(o.substring(0,2),16),i=parseInt(o.substring(2,4),16),n=parseInt(o.substring(4,6),16),l=o.length===8?parseInt(o.substring(6,8),16)/255:1;return[s,i,n,l]}const e=t.match(/rgba?\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\)/);return e?[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),e[4]!==void 0?parseFloat(e[4]):1]:t==="transparent"?[0,0,0,0]:[255,255,255,1]}function jt(S,t,e){const[o,s,i,n]=_t(S),[l,h,a,r]=_t(t),c=Math.round(o+(l-o)*e),d=Math.round(s+(h-s)*e),f=Math.round(i+(a-i)*e),g=n+(r-n)*e;return`rgba(${c},${d},${f},${g})`}const T=Object.freeze({ZONES:Et,AXES:{x:{color:"#ff9a3c",label:"X (C₂H₄/C₂H₆)"},y:{color:"#4ac8ff",label:"Y (CH₄/H₂)"},z:{color:"#70e870",label:"Z (C₂H₂/C₂H₄)"}},THEMES:{dark:{wallFillAlpha:.05,wallGridAlpha:"40",wallEdgeAlpha:"50",outerGrid:"rgba(100,150,220,0.10)",plane2dGrid:"rgba(100,150,220,0.20)",plane2dAxis:"rgba(120,160,220,0.50)",plane2dLabel:"rgba(150,180,220,0.60)",tickAlpha:"cc",pointStroke:"rgba(255,255,255,0.55)"},light:{wallFillAlpha:.06,wallGridAlpha:"28",wallEdgeAlpha:"55",outerGrid:"rgba(80,120,200,0.12)",plane2dGrid:"rgba(80,120,200,0.18)",plane2dAxis:"rgba(80,120,200,0.45)",plane2dLabel:"rgba(60,100,180,0.65)",tickAlpha:"bb",pointStroke:"rgba(0,0,0,0.25)"}},PLANES:{xz:{hAxis:"x",vAxis:"z",hLabel:"X C₂H₄/C₂H₆(热故障)",vLabel:"Z C₂H₂/C₂H₄(高能放电)",bgColor:{dark:"rgba(180,120,60,0.06)",light:"rgba(180,100,40,0.05)"}},yz:{hAxis:"y",vAxis:"z",hLabel:"Y CH₄/H₂(低能放电)",vLabel:"Z C₂H₂/C₂H₄(高能放电)",bgColor:{dark:"rgba(60,160,180,0.06)",light:"rgba(40,140,160,0.05)"}},xy:{hAxis:"x",vAxis:"y",hLabel:"X C₂H₄/C₂H₆(热故障)",vLabel:"Y CH₄/H₂(低能放电)",bgColor:{dark:"rgba(60,100,200,0.06)",light:"rgba(40,80,180,0.05)"}}},TICKS:{vals:[0,1/3,2/3,1],labels:["0","0.1","1.0","10"]},CAM:{elev:-20,yaw:115},PROJ:{fov:4,scaleK:.45,cx:.48,cy:.52},PAD2D:{l:70,r:30,t:50,b:60},DRAG:{rotYSens:.45,rotXSens:.28,rotXMin:-70,rotXMax:85,zoomMin:.3,zoomMax:4,zoomIn:1.08,zoomOut:.92},TWEEN:{step:.045},POINT:{defaultSize:7,defaultColor:"#aaaaaa",glowAlpha:.25,glowRadius:2.2,hlOffset:.35},ZONE_VIS:{fillAlpha:.25,labelAlpha:.9},UNKNOWN:{name:"未分类(需综合判断)",color:"#888899"},TEXT_STYLE:{fontSize:14,fontFamily:"Segoe UI, Courier New",fontWeight:"normal"}});class F{static realToU(t){return t<=0?0:t<=.1?t/.3:t<=1?1/3+(Math.log10(t)+1)/3:t<=10?2/3+Math.log10(t)/3:1}static uToReal(t){return t<=0?0:t<=1/3?t*.3:t<=2/3?Math.pow(10,(t-1/3)*3-1):Math.pow(10,(t-2/3)*3)}static formatVal(t){return t<.01?t.toFixed(4):t.toFixed(3)}}class Bt{constructor(t,e,o,s={}){this.ctx=t,this.opts=s,this.layout=s.layout??"fill",this.resize(e,o),this.updateOptions(s)}updateOptions(t={}){this.opts={...this.opts,...t},(t.layout!==void 0||t.grid!==void 0)&&(t.layout!==void 0&&(this.layout=t.layout),this.resize(this.W,this.H));const e=this.opts.theme??"dark";this.theme=T.THEMES[e]??T.THEMES.dark,this.themeName=e,this.zone=this.processZones(this.opts.zone??T.ZONES);const o={show:!0,fill:{show:!0,alpha:this.theme.wallFillAlpha,colors:{xy:void 0,xz:void 0,yz:void 0}},grid:{show:!0,lineStyle:{lineWidth:.6,alpha:parseInt(this.theme.wallGridAlpha,16)/255,type:"solid"}},border:{show:!0,lineStyle:{lineWidth:.8,alpha:parseInt(this.theme.wallEdgeAlpha,16)/255,type:"solid"}}},s={show:!0,lineStyle:{lineWidth:1.8,arrowSize:9},labelStyle:{show:!0,fontSize:14,fontWeight:"bold",distance:16},tickLabelStyle:{show:!0,fontSize:12,color:"rgba(255, 255, 255, 0.8)"},data:{x:{name:T.AXES.x.label,color:T.AXES.x.color},y:{name:T.AXES.y.label,color:T.AXES.y.color},z:{name:T.AXES.z.label,color:T.AXES.z.color}}},i={show:!0,fade3DAlpha:.03,grid:{show:!0,backgroundColor:void 0,lineStyle:{lineWidth:.5,alpha:.2,type:"solid"}},axis:{show:!0,lineStyle:{lineWidth:1.5,alpha:.9},labelStyle:{show:!0,fontSize:13,distance:25},tickLabelStyle:{show:!0,fontSize:11,distance:8}},zone:{show:!0,alpha:.45,borderStyle:{show:!0,lineWidth:1.4}}};this.opts.wall=E(o,this.opts.wall||{}),this.opts.axis=E(s,this.opts.axis||{}),this.opts.plane2D=E(i,this.opts.plane2D||{})}processZones(t){let e=[],o={};return Array.isArray(t)?e=t:t&&typeof t=="object"&&Array.isArray(t.data)?(e=t.data,o=t.labelStyle||{}):e=T.ZONES,e.map(s=>{const[i,n,l]=ct(s.fill||"#ffffff"),h=s.labelStyle||o,a=h.color||s.fill;let r=[];h.fontWeight&&r.push(h.fontWeight),h.fontSize&&r.push(h.fontSize+"px"),h.fontFamily&&r.push(h.fontFamily);const c=r.length>0?r.join(" "):null;let d=s.edgeColor||s.fill;return s.edgeAlpha!==void 0&&(d=Ct(d,s.edgeAlpha)),{...s,fillBase:`rgba(${i},${n},${l},`,edgeStr:d,x0:F.realToU(s.p1[0]),x1:F.realToU(s.p2[0]),y0:F.realToU(s.p1[1]),y1:F.realToU(s.p2[1]),z0:F.realToU(s.p1[2]),z1:F.realToU(s.p2[2]),labelColor:a,labelFontStr:c}})}getFont(t){var l;const e=T.TEXT_STYLE,o=((l=this.opts.textStyle)==null?void 0:l[t])??this.opts.textStyle??{},s=o.fontSize??e.fontSize,i=o.fontFamily??e.fontFamily;return`${o.fontWeight??(t==="axis"||t==="zone"?"bold":e.fontWeight)} ${s}px ${i}`}setTheme(t){this.updateOptions({theme:t})}resize(t,e){this.W=t,this.H=e;const o=this.opts.grid;if(o&&(o.left!==void 0||o.right!==void 0||o.top!==void 0||o.bottom!==void 0)){const i=dt(t,e,o,0);this.renderW=i.availW,this.renderH=i.availH,this.offsetX=i.left,this.offsetY=i.top}else if(this.layout==="square"){const i=Math.min(t,e);this.renderW=i,this.renderH=i,this.offsetX=(t-i)/2,this.offsetY=(e-i)/2}else this.renderW=t,this.renderH=e,this.offsetX=0,this.offsetY=0;this.CX=this.offsetX+this.renderW*T.PROJ.cx,this.CY=this.offsetY+this.renderH*T.PROJ.cy}proj(t,e,o){const s=t-.5,i=e-.5,n=o-.5,l=this.cam.rotX*Math.PI/180,h=this.cam.rotY*Math.PI/180,a=Math.cos(l),r=Math.sin(l),c=Math.cos(h),d=Math.sin(h),f=s*c+i*d,g=-s*d+i*c,p=n*a-g*r,m=n*r+g*a,y=Math.min(this.renderW,this.renderH)*T.PROJ.scaleK*this.cam.zoomFactor,u=T.PROJ.fov,b=m+u;return{x:this.CX+f/b*y*u,y:this.CY-p/b*y*u,depth:m}}isBackface(t,e,o){const s=this.cam.rotX*Math.PI/180,i=this.cam.rotY*Math.PI/180,n=Math.cos(s),l=Math.sin(s),h=Math.cos(i),a=Math.sin(i),r=-t*a+e*h;return o*l+r*n>0}draw(t,e,o,s){var a;const i=this.ctx;i.clearRect(0,0,this.W,this.H),this.cam=t;const n=((a=this.opts.plane2D)==null?void 0:a.fade3DAlpha)??.03,l=1-s*(1-n);i.globalAlpha=l,this.drawWalls(l),this.drawGrid(l),this.drawZones(l),this.drawAxes(l),this.drawTickLabels(l);const h=Array.isArray(e)?e:[];[...h].sort((r,c)=>this.proj(F.realToU(r.position.x),F.realToU(r.position.y),F.realToU(r.position.z)).depth-this.proj(F.realToU(c.position.x),F.realToU(c.position.y),F.realToU(c.position.z)).depth).forEach(r=>this.drawPoint3D(r,l)),i.globalAlpha=1,s>0&&this.opts.plane2D.show&&this.draw2DOverlay(o,s,h)}face(t,e,o){const s=this.ctx,i=t.map(n=>this.proj(...n));s.beginPath(),s.moveTo(i[0].x,i[0].y);for(let n=1;n<i.length;n++)s.lineTo(i[n].x,i[n].y);s.closePath(),e&&(s.fillStyle=e,s.fill()),o&&(s.strokeStyle=o,s.lineWidth=.8,s.stroke())}line(t,e){const o=this.ctx;o.beginPath(),o.moveTo(t.x,t.y),o.lineTo(e.x,e.y),o.stroke()}box(t,e,o,s,i,n,l,h){[{f:[[t,o,i],[e,o,i],[e,s,i],[t,s,i]],n:[0,0,-1]},{f:[[t,o,n],[e,o,n],[e,s,n],[t,s,n]],n:[0,0,1]},{f:[[t,o,i],[e,o,i],[e,o,n],[t,o,n]],n:[0,-1,0]},{f:[[t,s,i],[e,s,i],[e,s,n],[t,s,n]],n:[0,1,0]},{f:[[t,o,i],[t,s,i],[t,s,n],[t,o,n]],n:[-1,0,0]},{f:[[e,o,i],[e,s,i],[e,s,n],[e,o,n]],n:[1,0,0]}].filter(({n:r})=>!this.isBackface(r[0],r[1],r[2])).map(({f:r})=>({f:r,d:r.reduce((c,d)=>c+this.proj(...d).depth,0)/r.length})).sort((r,c)=>r.d-c.d).forEach(({f:r})=>this.face(r,l,h))}drawWalls(t=1){const e=this.ctx,o=this.opts.wall;if(!o.show)return;const s=this.opts.axis.data,i=T.TICKS.vals,n=[{pts:[[0,0,0],[1,0,0],[1,0,1],[0,0,1]],color:o.fill.colors.xz||s.x.color,segs:l=>[[this.proj(l,0,0),this.proj(l,0,1)],[this.proj(0,0,l),this.proj(1,0,l)]],gridColor:s.x.color},{pts:[[0,0,0],[0,1,0],[0,1,1],[0,0,1]],color:o.fill.colors.yz||s.y.color,segs:l=>[[this.proj(0,l,0),this.proj(0,l,1)],[this.proj(0,0,l),this.proj(0,1,l)]],gridColor:s.y.color},{pts:[[0,0,0],[1,0,0],[1,1,0],[0,1,0]],color:o.fill.colors.xy||s.z.color,segs:l=>[[this.proj(l,0,0),this.proj(l,1,0)],[this.proj(0,l,0),this.proj(1,l,0)]],gridColor:s.z.color}];o.fill.show&&(e.globalAlpha=o.fill.alpha*t,n.forEach(l=>this.face(l.pts,l.color)),e.globalAlpha=t),o.grid.show&&(e.lineWidth=o.grid.lineStyle.lineWidth,e.globalAlpha=o.grid.lineStyle.alpha*t,o.grid.lineStyle.type==="dashed"?e.setLineDash([4,4]):o.grid.lineStyle.type==="dotted"?e.setLineDash([2,2]):e.setLineDash([]),n.forEach(({gridColor:l,segs:h})=>{e.strokeStyle=l,i.forEach(a=>h(a).forEach(([r,c])=>this.line(r,c)))}),e.setLineDash([]),e.globalAlpha=t),o.border.show&&(e.lineWidth=o.border.lineStyle.lineWidth,e.globalAlpha=o.border.lineStyle.alpha*t,o.border.lineStyle.type==="dashed"?e.setLineDash([4,4]):o.border.lineStyle.type==="dotted"?e.setLineDash([2,2]):e.setLineDash([]),n.forEach(({pts:l,gridColor:h})=>{e.strokeStyle=h,l.forEach((a,r)=>this.line(this.proj(...a),this.proj(...l[(r+1)%l.length])))}),e.setLineDash([]),e.globalAlpha=t)}drawGrid(t=1){const e=this.ctx;e.globalAlpha=t,e.strokeStyle=this.theme.outerGrid,e.lineWidth=.4,T.TICKS.vals.forEach(o=>{this.line(this.proj(1,o,0),this.proj(1,o,1)),this.line(this.proj(1,0,o),this.proj(1,1,o))})}drawZones(t){const e=this.ctx,o=T.ZONE_VIS;[...this.zone].sort((s,i)=>this.proj((s.x0+s.x1)/2,(s.y0+s.y1)/2,(s.z0+s.z1)/2).depth-this.proj((i.x0+i.x1)/2,(i.y0+i.y1)/2,(i.z0+i.z1)/2).depth).forEach(s=>{e.globalAlpha=t;const i=s.fillAlpha!==void 0?s.fillAlpha:o.fillAlpha;if(this.box(s.x0,s.x1,s.y0,s.y1,s.z0,s.z1,s.fillBase+i+")",s.edgeStr),t>.05){e.globalAlpha=t*o.labelAlpha;const n=this.proj((s.x0+s.x1)/2,(s.y0+s.y1)/2,(s.z0+s.z1)/2);e.font=s.labelFontStr||this.getFont("zone"),e.textAlign="center",e.fillStyle=s.labelColor,e.fillText(s.name,n.x,n.y)}e.globalAlpha=t})}drawAxes(t=1){const e=this.ctx;e.globalAlpha=t;const o=this.opts.axis;o.show&&[{from:[0,0,0],to:[1.18,0,0],lp:[1.22,0,0],...o.data.x},{from:[0,0,0],to:[0,1.18,0],lp:[0,1.22,0],...o.data.y},{from:[0,0,0],to:[0,0,1.22],lp:[0,0,1.28],...o.data.z}].forEach(s=>{var l;const i=this.proj(...s.from),n=this.proj(...s.to);if(e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(n.x,n.y),e.strokeStyle=s.color,e.lineWidth=o.lineStyle.lineWidth,e.stroke(),o.lineStyle.arrowSize>0){const h=n.x-i.x,a=n.y-i.y,r=Math.hypot(h,a)||1,c=h/r,d=a/r,f=o.lineStyle.arrowSize;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x-c*f+d*(f/2.25),n.y-d*f-c*(f/2.25)),e.lineTo(n.x-c*f-d*(f/2.25),n.y-d*f+c*(f/2.25)),e.closePath(),e.fillStyle=s.color,e.fill()}if(o.labelStyle.show){const h=n.x-i.x,a=n.y-i.y,r=Math.hypot(h,a)||1,c=n.x+h/r*o.labelStyle.distance,d=n.y+a/r*o.labelStyle.distance;e.fillStyle=s.color,e.font=`${o.labelStyle.fontWeight} ${o.labelStyle.fontSize}px ${((l=this.opts.textStyle)==null?void 0:l.fontFamily)||T.TEXT_STYLE.fontFamily}`,e.textAlign="center",e.textBaseline="middle",e.fillText(s.name,c,d)}})}drawTickLabels(t=1){const e=this.ctx;e.globalAlpha=t;const{vals:o,labels:s}=T.TICKS,i=this.theme.tickAlpha;e.font=this.getFont("tick"),o.forEach((n,l)=>{let h=this.proj(n,0,0);e.fillStyle=T.AXES.x.color+i,e.textAlign="center",e.fillText(s[l],h.x,h.y+13),h=this.proj(0,n,0),e.fillStyle=T.AXES.y.color+i,e.textAlign="left",e.fillText(s[l],h.x+7,h.y+4),h=this.proj(0,0,n),e.fillStyle=T.AXES.z.color+i,e.textAlign="right",e.fillText(s[l],h.x-7,h.y+4)}),e.textAlign="center"}drawPoint3D(t,e){const o=F.realToU(t.position.x),s=F.realToU(t.position.y),i=F.realToU(t.position.z);this.drawPointAt(this.proj(o,s,i),t,e)}drawPointAt(t,e,o=1){var p,m;const s=this.ctx,i=T.POINT,n=t.x??t.cx,l=t.y??t.cy,h=((p=e.itemStyle)==null?void 0:p.radius)??i.defaultSize,a=((m=e.itemStyle)==null?void 0:m.color)??e.color,r=e.name,c=e.textStyle||{},d=e.glowStyle!==void 0,f=e.glowStyle||{};if(d&&f.show!==!1){let y=[],u=3,b=f.glowDistance!==void 0?f.glowDistance:4;const w=f.color??a;if(Array.isArray(f.colors)&&f.colors.length>0)y=f.colors,u=y.length;else{const v=f.startColor||Ct(w,.15),x=f.endColor||"transparent";u=f.count!==void 0?parseInt(f.count,10):3,y=[];for(let C=0;C<u;C++){const z=u>1?C/(u-1):0;y.push(Zt(v,x,z))}}for(let v=u-1;v>=0;v--){const x=y[v];s.save(),s.fillStyle=x,s.beginPath(),s.arc(n,l,h+(v+1)*b,0,Math.PI*2),s.fill(),s.restore()}}s.globalAlpha=o,s.beginPath(),s.arc(n,l,h,0,Math.PI*2);const g=s.createRadialGradient(n-h*i.hlOffset,l-h*i.hlOffset,1,n,l,h);g.addColorStop(0,"rgba(255,255,255,0.9)"),g.addColorStop(.4,a+"ee"),g.addColorStop(1,a+"88"),s.fillStyle=g,s.fill(),s.strokeStyle=this.theme.pointStroke,s.lineWidth=1.3,s.stroke(),s.restore(),r&&(s.font=c.bold?`bold ${c.fontSize||12}px ${c.fontFamily||"sans-serif"}`:`${c.fontSize||12}px ${c.fontFamily||"sans-serif"}`,s.fillStyle=c.color??e.color,s.textAlign="left",s.fillText(r,n+h+3,l-2))}draw2DOverlay(t,e,o){var z;const s=T.PLANES[t];if(!s)return;const i=this.ctx,n=this.theme,l=this.opts.plane2D,h=this.opts.axis.data;i.save(),i.globalAlpha=e;let a=this.offsetX,r=this.offsetY,c=this.offsetX+this.renderW,d=this.offsetY+this.renderH;const f=this.opts.grid||{};if(!(f.left!==void 0||f.right!==void 0||f.top!==void 0||f.bottom!==void 0)){const _=T.PAD2D||{l:70,r:30,t:50,b:60};a=_.l,r=_.t,c=this.W-_.r,d=this.H-_.b}const p=c-a,m=d-r,y=Math.min(p,m),u=a+p/2,b=r+m/2;a=u-y/2,c=u+y/2,r=b-y/2,d=b+y/2;const{vals:w,labels:v}=T.TICKS,x=(_,A)=>({cx:a+_*(c-a),cy:d-A*(d-r)}),C=this.themeName??"dark";if(l.grid.show&&(i.fillStyle=l.grid.backgroundColor??s.bgColor[C]??s.bgColor.dark,i.fillRect(a,r,c-a,d-r)),l.zone.show&&this.zone.forEach(_=>{const[A,Y]=[_[s.hAxis+"0"],_[s.hAxis+"1"]],[P,k]=[_[s.vAxis+"0"],_[s.vAxis+"1"]],M=x(A,P),L=x(Y,k),Q=L.cx-M.cx,B=M.cy-L.cy,it=_.fillAlpha!==void 0?_.fillAlpha:l.zone.alpha;i.fillStyle=_.fillBase+it+")",i.fillRect(M.cx,L.cy,Q,B),l.zone.borderStyle.show&&(i.strokeStyle=_.edgeStr,i.lineWidth=l.zone.borderStyle.lineWidth,i.strokeRect(M.cx,L.cy,Q,B));const Z=(M.cx+L.cx)/2,tt=(M.cy+L.cy)/2;i.font=_.labelFontStr||this.getFont("zone"),i.textAlign="center",i.fillStyle=_.labelColor,i.fillText(_.name,Z,tt+4)}),l.grid.show&&(i.strokeStyle=l.grid.lineStyle.color||n.plane2dGrid,i.lineWidth=l.grid.lineStyle.lineWidth,i.globalAlpha=e*l.grid.lineStyle.alpha,l.grid.lineStyle.type==="dashed"?i.setLineDash([4,4]):l.grid.lineStyle.type==="dotted"?i.setLineDash([2,2]):i.setLineDash([]),w.forEach(_=>{const A=x(_,0).cx,Y=x(0,_).cy;i.beginPath(),i.moveTo(A,r),i.lineTo(A,d),i.stroke(),i.beginPath(),i.moveTo(a,Y),i.lineTo(c,Y),i.stroke()}),i.setLineDash([]),i.globalAlpha=e),l.axis.show){const _=h[s.hAxis].color,A=h[s.vAxis].color;i.lineWidth=l.axis.lineStyle.lineWidth,i.globalAlpha=e*l.axis.lineStyle.alpha,i.strokeStyle=_,i.beginPath(),i.moveTo(a,d),i.lineTo(c+10,d),i.stroke(),i.strokeStyle=A,i.beginPath(),i.moveTo(a,d),i.lineTo(a,r-10),i.stroke(),i.globalAlpha=e;const Y=((z=this.opts.textStyle)==null?void 0:z.fontFamily)||T.TEXT_STYLE.fontFamily;if(l.axis.tickLabelStyle.show){i.font=`${l.axis.tickLabelStyle.fontSize}px ${Y}`;const P=l.axis.tickLabelStyle.distance;w.forEach((k,M)=>{i.fillStyle=_,i.textAlign="center",i.fillText(v[M],x(k,0).cx,d+P+l.axis.tickLabelStyle.fontSize/2),i.fillStyle=A,i.textAlign="right",i.fillText(v[M],a-P+2,x(0,k).cy+l.axis.tickLabelStyle.fontSize/3)})}if(l.axis.labelStyle.show){i.font=`bold ${l.axis.labelStyle.fontSize}px ${Y}`;const P=l.axis.labelStyle.distance;i.textAlign="center",i.fillStyle=_,i.fillText(h[s.hAxis].name,(a+c)/2,d+P+l.axis.labelStyle.fontSize),i.save(),i.translate(a-P-l.axis.labelStyle.fontSize,(r+d)/2),i.rotate(-Math.PI/2),i.fillStyle=A,i.fillText(h[s.vAxis].name,0,0),i.restore()}}o.forEach(_=>{const A=x(F.realToU(_.position[s.hAxis]),F.realToU(_.position[s.vAxis]));this.drawPointAt(A,_,e)}),i.restore()}}const st=class st{constructor(t={}){this.series=[],this.opts=t,this.cam={rotX:T.CAM.elev,rotY:T.CAM.yaw,zoomFactor:1},this.view=t.initialView??"3d",this.layout=t.layout??"fill",this.drag={active:!1,lastX:0,lastY:0},this.tween={from:{rotX:0,rotY:0},to:{rotX:0,rotY:0},t:1},this.animId=null,this.pinchDist=null,this.events={viewChange:null,dataChange:null};const e=typeof t.container=="string"?document.querySelector(t.container):t.container;e&&this.buildDOM(e),this.renderer=new Bt(this.ctx,this.W,this.H,t),this.bindEvents(),this.applyView(),this.render()}static init(t,e={}){return new st({container:t,...e})}setOption(t){if(t){if(this.opts={...this.opts,...t},(t.zone||t.textStyle||t.theme||t.wallColors||t.layout!==void 0||t.grid!==void 0||t.axis!==void 0||t.wall!==void 0||t.plane2D!==void 0)&&this.renderer.updateOptions({zone:this.opts.zone,textStyle:this.opts.textStyle,theme:this.opts.theme,wallColors:this.opts.wallColors,layout:this.opts.layout,grid:this.opts.grid,axis:this.opts.axis,wall:this.opts.wall,plane2D:this.opts.plane2D}),t.series!==void 0){const e=Array.isArray(t.series)?t.series:[t.series];this.series=e.map(o=>({name:o.name??"",color:o.color??T.POINT.defaultColor,itemStyle:o.itemStyle??{},textStyle:o.textStyle??{},glowStyle:o.glowStyle,position:o.position??{x:0,y:0,z:0}})),this.emit("dataChange",[...this.series]),this.render()}t.view&&t.view!==this.view&&this.setView(t.view)}}setView(t){if(!st.VIEWS[t])return;this.view=t,cancelAnimationFrame(this.animId);const e=this.getViewTarget(t);this.tween={from:{rotX:this.cam.rotX,rotY:this.cam.rotY},to:e,t:0},this.cv.style.cursor=t==="3d"?"grab":"default",this.runTween(),this.emit("viewChange",t)}setTheme(t){this.renderer.setTheme(t),this.render()}diagnose(t,e,o){if(!this.renderer)return[{...this.opts.unknown??T.UNKNOWN}];const s=this.renderer.zone.filter(i=>t>=i.p1[0]&&t<i.p2[0]&&e>=i.p1[1]&&e<i.p2[1]&&o>=i.p1[2]&&o<i.p2[2]).map(i=>({name:i.name,title:i.title,color:i.edgeColor||i.fill}));return s.length?s:[{...this.opts.unknown??T.UNKNOWN}]}on(t,e){t in this.events&&(this.events[t]=e)}emit(t,...e){typeof this.events[t]=="function"&&this.events[t](...e)}render(){!this.renderer||!this.ctx||this.renderer.draw(this.cam,this.series,this.view,this.flatness())}destroy(){var t,e;cancelAnimationFrame(this.animId),(t=this.resizeObs)==null||t.disconnect(),(e=this.cv)==null||e.remove(),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp)}getViewTarget(t){const e=st.VIEWS[t];return{rotX:typeof e.rotX=="function"?e.rotX():e.rotX,rotY:typeof e.rotY=="function"?e.rotY():e.rotY}}applyView(){if(this.view!=="3d"){const t=this.getViewTarget(this.view);this.cam.rotX=t.rotX,this.cam.rotY=t.rotY,this.cv.style.cursor="default"}}flatness(){if(this.view==="3d")return 0;const t=this.getViewTarget(this.view);return Math.max(0,1-(Math.abs(this.cam.rotX-t.rotX)+Math.abs(this.cam.rotY-t.rotY))/30)}runTween(){this.tween.t=Math.min(1,this.tween.t+T.TWEEN.step);const t=(e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2)(this.tween.t);this.cam.rotX=this.tween.from.rotX+(this.tween.to.rotX-this.tween.from.rotX)*t,this.cam.rotY=this.tween.from.rotY+(this.tween.to.rotY-this.tween.from.rotY)*t,this.render(),this.tween.t<1&&(this.animId=requestAnimationFrame(()=>this.runTween()))}buildDOM(t){const e=t.getBoundingClientRect();this.W=e.width>0?Math.round(e.width):600,this.H=e.height>0?Math.round(e.height):540,this.cv=document.createElement("canvas"),this.cv.className="trc-canvas",this.cv.width=this.W,this.cv.height=this.H,this.cv.style.cssText="width:100%;height:100%;display:block;touch-action:none;",this.ctx=this.cv.getContext("2d"),t.appendChild(this.cv),this.resizeObs=new ResizeObserver(o=>{var n;const{width:s,height:i}=o[0].contentRect;s>0&&i>0&&(this.W=Math.round(s),this.H=Math.round(i),this.cv.width=this.W,this.cv.height=this.H,(n=this.renderer)==null||n.resize(this.W,this.H),this.render())}),this.resizeObs.observe(t)}bindEvents(){const t=T.DRAG,e=this.cv;e.addEventListener("mousedown",o=>{this.view==="3d"&&(this.drag={active:!0,lastX:o.clientX,lastY:o.clientY},e.style.cursor="grabbing",cancelAnimationFrame(this.animId))}),this.onMouseMove=o=>{!this.drag.active||this.view!=="3d"||(this.cam.rotY+=(o.clientX-this.drag.lastX)*t.rotYSens,this.cam.rotX=Math.max(t.rotXMin,Math.min(t.rotXMax,this.cam.rotX+(o.clientY-this.drag.lastY)*t.rotXSens)),this.drag.lastX=o.clientX,this.drag.lastY=o.clientY,this.render())},this.onMouseUp=()=>{this.drag.active=!1,this.view==="3d"&&(e.style.cursor="grab")},window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp),e.addEventListener("touchstart",o=>{this.view==="3d"&&(this.drag={active:!0,lastX:o.touches[0].clientX,lastY:o.touches[0].clientY},o.touches.length===2&&(this.pinchDist=Math.hypot(o.touches[0].clientX-o.touches[1].clientX,o.touches[0].clientY-o.touches[1].clientY)))},{passive:!0}),e.addEventListener("touchmove",o=>{if(this.view==="3d")if(o.touches.length===2&&this.pinchDist!==null){const s=Math.hypot(o.touches[0].clientX-o.touches[1].clientX,o.touches[0].clientY-o.touches[1].clientY);this.cam.zoomFactor=Math.max(t.zoomMin,Math.min(t.zoomMax,this.cam.zoomFactor*s/this.pinchDist)),this.pinchDist=s,this.render()}else this.drag.active&&o.touches.length===1&&(this.cam.rotY+=(o.touches[0].clientX-this.drag.lastX)*t.rotYSens,this.cam.rotX=Math.max(t.rotXMin,Math.min(t.rotXMax,this.cam.rotX+(o.touches[0].clientY-this.drag.lastY)*t.rotXSens)),this.drag.lastX=o.touches[0].clientX,this.drag.lastY=o.touches[0].clientY,this.render())},{passive:!0}),e.addEventListener("touchend",o=>{o.touches.length<2&&(this.pinchDist=null),o.touches.length===0&&(this.drag.active=!1)},{passive:!0}),e.addEventListener("wheel",o=>{this.view==="3d"&&(o.preventDefault(),this.cam.zoomFactor=Math.max(t.zoomMin,Math.min(t.zoomMax,this.cam.zoomFactor*(o.deltaY>0?t.zoomOut:t.zoomIn))),this.render())},{passive:!1})}};K(st,"VIEWS",{"3d":{rotX:()=>T.CAM.elev,rotY:()=>T.CAM.yaw},xz:{rotX:0,rotY:0},yz:{rotX:0,rotY:90},xy:{rotX:90,rotY:0}});let gt=st;function ct(S){const t=S.trim().toLowerCase();if(t.startsWith("#")){let o=t.slice(1);o.length===3&&(o=o[0]+o[0]+o[1]+o[1]+o[2]+o[2]);const s=parseInt(o.substring(0,2),16),i=parseInt(o.substring(2,4),16),n=parseInt(o.substring(4,6),16),l=o.length===8?parseInt(o.substring(6,8),16)/255:1;return[s,i,n,l]}const e=t.match(/rgba?\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\)/);return e?[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),e[4]!==void 0?parseFloat(e[4]):1]:t==="transparent"?[0,0,0,0]:[255,255,255,1]}function Ct(S,t){const[e,o,s,i]=ct(S);return`rgba(${e},${o},${s},${t!==void 0?t:i})`}function Zt(S,t,e){const[o,s,i,n]=ct(S),[l,h,a,r]=ct(t),c=Math.round(o+(l-o)*e),d=Math.round(s+(h-s)*e),f=Math.round(i+(a-i)*e),g=n+(r-n)*e;return`rgba(${c},${d},${f},${g})`}const Gt={theme:"light",backgroundColor:"transparent",grid:{left:72,right:20,top:20,bottom:56,lineStyle:{type:"solid",width:.4,color:null},majorLineStyle:{type:"solid",width:.8,color:null}},zone:{data:Dt,labelStyle:{show:!0,fontSize:12,borderRadius:4},borderStyle:{show:!0,stroke:1,type:"solid",color:null}},xAxis:{title:"",min:-2,max:3,labelStyle:{fontSize:11,fontWeight:"normal",offsetX:0,offsetY:0,color:null},lineStyle:{show:!0,stroke:1.5,type:"solid",color:null},titleStyle:{fontSize:13,color:null,fontWeight:"normal",align:"center",offsetX:0,offsetY:0}},yAxis:{title:"",min:-3,max:3,labelStyle:{fontSize:11,fontWeight:"normal",offsetX:0,offsetY:0,color:null},lineStyle:{show:!0,stroke:1.5,type:"solid",color:null},titleStyle:{fontSize:13,color:null,fontWeight:"normal",align:"center",offsetX:0,offsetY:0}},tooltip:{show:!0,formatter:null},series:[]},Tt={light:{backgroundColor:"#ffffff",text:"#333333",textSecondary:"#666666",gridLine:"rgba(0,0,0,0.12)",gridLineMajor:"rgba(0,0,0,0.22)",axisLine:"rgba(0,0,0,0.5)",zoneBorder:"rgba(0,0,0,0.35)",zoneLabelBg:"rgba(255,255,255,0.75)",tooltipBg:"rgba(255,255,255,0.95)",tooltipBorder:"rgba(0,0,0,0.15)",tooltipTextColor:"#222222"},dark:{backgroundColor:"#1a1a2e",text:"rgba(255,255,255,0.85)",textSecondary:"rgba(255,255,255,0.5)",gridLine:"rgba(255,255,255,0.08)",gridLineMajor:"rgba(255,255,255,0.18)",axisLine:"rgba(255,255,255,0.55)",zoneBorder:"rgba(255,255,255,0.3)",zoneLabelBg:"rgba(0,0,0,0.5)",tooltipBg:"rgba(20,20,40,0.95)",tooltipBorder:"rgba(255,255,255,0.15)",tooltipTextColor:"rgba(255,255,255,0.9)"}};function At(S){const t=Math.round(S);return"10"+String(t).split("").map(o=>({"-":"⁻",0:"⁰",1:"¹",2:"²",3:"³",4:"⁴",5:"⁵",6:"⁶",7:"⁷",8:"⁸",9:"⁹"})[o]||o).join("")}class wt{constructor(t,e={}){if(typeof t=="string"&&(t=document.querySelector(t)),!t)throw new Error("[ETRAChart] Container element not found");this._container=t,this._opt=E(E({},Gt),e),this._bus=new zt,this._initDOM(),this._zoom=new yt(this._opt.zoom||{}),this._tooltipRenderer=new bt(this._container,this._theme),this._hoverZone=null,this._hoverPoint=null,typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(()=>this.resize()),this._ro.observe(this._container)),this._onWheel=s=>{s.preventDefault();const i=this._canvas.getBoundingClientRect(),n=s.clientX-i.left,l=s.clientY-i.top;this._zoom.onWheel(s.deltaY,n,l),this._bus.emit("zoom",this._zoom.state),this._render()},this._onDown=s=>{s.button===0&&(this._zoom.startDrag(s.clientX,s.clientY),this._canvas.style.cursor="grabbing")},this._onMove=s=>{const i=this._canvas.getBoundingClientRect();if(this._zoom.moveDrag(s.clientX,s.clientY,1)){this._render();return}if(!this._coordMap||!this._drawnPoints)return;const n=s.clientX-i.left,l=s.clientY-i.top,{panX:h,panY:a,zoom:r}=this._zoom,c=(n-h)/r,d=(l-a)/r;let f=null,g=1/0;for(const p of this._drawnPoints){const m=Math.hypot(c-p.px,d-p.py),y=p.series.size||6;m<y*2+5&&m<g&&(g=m,f=p)}f!==this._hoverPoint&&(this._hoverPoint=f,this._render(),f?(this._canvas.style.cursor="pointer",this._bus.emit("hover",f)):(this._canvas.style.cursor="default",this._bus.emit("hover",null)))},this._onUp=()=>{this._zoom.endDrag()&&(this._canvas.style.cursor=this._hoverPoint?"pointer":"default",this._bus.emit("zoom",this._zoom.state))},this._onLeave=()=>{this._hoverPoint&&(this._hoverPoint=null,this._canvas.style.cursor="default",this._render(),this._bus.emit("hover",null))},this._onDbl=()=>{this._zoom.reset(),this._bus.emit("zoom",this._zoom.state),this._render()};const o=this._canvas;o.addEventListener("wheel",this._onWheel,{passive:!1}),o.addEventListener("mousedown",this._onDown),o.addEventListener("mousemove",this._onMove),o.addEventListener("mouseleave",this._onLeave),o.addEventListener("dblclick",this._onDbl),window.addEventListener("mouseup",this._onUp),this._render()}static init(t,e){return new wt(t,e)}get _theme(){return Tt[this._opt.theme]||Tt.light}_initDOM(){this._container.style.position="relative",this._container.style.overflow="hidden",this._canvas=document.createElement("canvas"),this._canvas.style.display="block",this._canvas.style.width="100%",this._canvas.style.height="100%",this._container.appendChild(this._canvas),this._ctx=this._canvas.getContext("2d")}setOption(t){return this._opt=E(this._opt,t),this._render(),this}on(t,e){return this._bus.on(t,e),this}off(t,e){return this._bus.off(t,e),this}resize(){return this._render(),this}dispose(){this._ro&&this._ro.disconnect(),this._tooltipRenderer.dispose(),this._canvas&&this._canvas.parentNode&&this._canvas.parentNode.removeChild(this._canvas),this._bus.dispose(),window.removeEventListener("mouseup",this._onUp)}_dims(){const t=this._container.getBoundingClientRect(),e=t.width||600,o=t.height||400,s=window.devicePixelRatio||1;(this._canvas.width!==Math.round(e*s)||this._canvas.height!==Math.round(o*s))&&(this._canvas.width=Math.round(e*s),this._canvas.height=Math.round(o*s));const i=dt(e,o,this._opt.grid,0);return{W:e,H:o,box:i,dpr:s}}_render(){const{W:t,H:e,box:o,dpr:s}=this._dims(),i=this._ctx;if(!i)return;const n=this._theme,l=this._opt;i.setTransform(s,0,0,s,0,0),i.clearRect(0,0,t,e);const h=l.backgroundColor||n.backgroundColor||"transparent";h!=="transparent"&&(i.fillStyle=h,i.fillRect(0,0,t,e));const a=l.xAxis.min,r=l.xAxis.max,c=l.yAxis.min,d=l.yAxis.max,f=o.availW,g=o.availH,p=o.left,m=o.top,y=w=>p+(w-a)/(r-a)*f,u=w=>m+(d-w)/(d-c)*g;this._coordMap={xMin:a,xMax:r,yMin:c,yMax:d,plotW:f,plotH:g,gL:p,gT:m,toPixX:y,toPixY:u},i.save(),this._zoom.applyTransform(i),this._drawGrid(i,y,u,n,l),this._drawZones(i,y,u,n,l);const b=this._drawSeries(i,y,u,n,l);if(this._drawAxes(i,y,u,n,l,t,e,p,m,f,g),i.restore(),l.tooltip.show&&this._hoverPoint){const w=this._hoverPoint,v=y(w.logX)*this._zoom.zoom+this._zoom.panX,x=u(w.logY)*this._zoom.zoom+this._zoom.panY;let C="";typeof l.tooltip.formatter=="function"?C=l.tooltip.formatter({series:w.series,logX:w.logX,logY:w.logY,rawX:Math.pow(10,w.logX),rawY:Math.pow(10,w.logY),zone:w.zone}):C=this._defaultTooltipHTML(w,l),this._tooltipRenderer.show(C,v,x,l.tooltip,n,w.zone)}else this._tooltipRenderer.hide();b.length>0&&this._bus.emit("diagnose",b)}_drawGrid(t,e,o,s,i){const n=i.xAxis.min,l=i.xAxis.max,h=i.yAxis.min,a=i.yAxis.max,r=this._coordMap.gL,c=this._coordMap.gT,d=this._coordMap.plotW,f=this._coordMap.plotH,g=i.grid.lineStyle||{},p=g.color||s.gridLineMajor,m=s.gridLine;for(let y=Math.ceil(n);y<=Math.floor(l);y++){const u=e(y);t.beginPath(),t.moveTo(u,c),t.lineTo(u,c+f),t.strokeStyle=p,t.lineWidth=g.width||.4,g.type==="dashed"?t.setLineDash([4,3]):t.setLineDash([]),t.stroke(),t.setLineDash([]),t.strokeStyle=m,t.lineWidth=.25;for(let b=2;b<=9;b++){const w=y+Math.log10(b);if(w>l)break;const v=e(w);t.beginPath(),t.moveTo(v,c),t.lineTo(v,c+f),t.stroke()}}for(let y=Math.ceil(h);y<=Math.floor(a);y++){const u=o(y);t.beginPath(),t.moveTo(r,u),t.lineTo(r+d,u),t.strokeStyle=p,t.lineWidth=g.width||.4,g.type==="dashed"?t.setLineDash([4,3]):t.setLineDash([]),t.stroke(),t.setLineDash([]),t.strokeStyle=m,t.lineWidth=.25;for(let b=2;b<=9;b++){const w=y+Math.log10(b);if(w>a)break;const v=o(w);t.beginPath(),t.moveTo(r,v),t.lineTo(r+d,v),t.stroke()}}}_drawZones(t,e,o,s,i){const n=i.zone;if(!(!n||!n.data)){for(const l of n.data)if(!(!l.poly||l.poly.length<3)&&(t.beginPath(),l.poly.forEach((h,a)=>{const r=e(h[0]),c=o(h[1]);a===0?t.moveTo(r,c):t.lineTo(r,c)}),t.closePath(),t.fillStyle=l.color||"rgba(128,128,128,0.2)",t.fill(),n.borderStyle.show&&(t.strokeStyle=n.borderStyle.color||l.color||s.zoneBorder,t.lineWidth=n.borderStyle.stroke||1,n.borderStyle.type==="dashed"?t.setLineDash([5,3]):t.setLineDash([]),t.stroke(),t.setLineDash([])),n.labelStyle.show&&(l.title||l.name))){let h=0,a=0;l.poly.forEach(b=>{h+=e(b[0]),a+=o(b[1])});const r=h/l.poly.length,c=a/l.poly.length,d=this._coordMap.gL,f=this._coordMap.gT,g=this._coordMap.plotW,p=this._coordMap.plotH,m=Math.max(d+4,Math.min(d+g-4,r)),y=Math.max(f+4,Math.min(f+p-4,c)),u=n.labelStyle.fontSize||12;if(t.textAlign="center",t.textBaseline="middle",l.title&&l.name&&l.name!==l.title)t.font=`600 ${u+1}px system-ui, sans-serif`,t.fillStyle=l.labelColor||s.text,t.fillText(l.name,m,y-u*.7),t.font=`${u-1}px system-ui, sans-serif`,t.fillStyle=l.labelColor||s.textSecondary,t.fillText(l.title,m,y+u*.9);else{const b=l.title||l.name;t.font=`500 ${u}px system-ui, sans-serif`,t.fillStyle=l.labelColor||s.text,t.fillText(b,m,y)}}}}_drawAxes(t,e,o,s,i,n,l,h,a,r,c){const d=i.xAxis.min,f=i.xAxis.max,g=i.yAxis.min,p=i.yAxis.max;t.beginPath(),t.rect(h,a,r,c),t.strokeStyle=s.axisLine,t.lineWidth=1,t.stroke();const m=i.xAxis.labelStyle.color||s.textSecondary,y=i.yAxis.labelStyle.color||s.textSecondary;t.textAlign="center",t.textBaseline="middle";for(let u=Math.ceil(d);u<=Math.floor(f);u++){const b=e(u),w=i.xAxis.labelStyle;t.font=`${w.fontWeight||"normal"} ${w.fontSize||11}px system-ui, sans-serif`,t.fillStyle=m,t.fillText(At(u),b+(w.offsetX||0),a+c+16+(w.offsetY||0))}t.textAlign="right";for(let u=Math.ceil(g);u<=Math.floor(p);u++){const b=o(u),w=i.yAxis.labelStyle;t.font=`${w.fontWeight||"normal"} ${w.fontSize||11}px system-ui, sans-serif`,t.fillStyle=y,t.fillText(At(u),h-6+(w.offsetX||0),b+(w.offsetY||0))}if(i.xAxis.title){const u=i.xAxis.titleStyle,b={left:h,center:h+r/2,right:h+r},w=(b[u.align]||b.center)+(u.offsetX||0),v=a+c+38+(u.offsetY||0);t.textAlign=u.align==="left"?"left":u.align==="right"?"right":"center",t.font=`${u.fontWeight||"normal"} ${u.fontSize||13}px system-ui, sans-serif`,t.fillStyle=u.color||s.text,t.fillText(i.xAxis.title,w,v)}if(i.yAxis.title){const u=i.yAxis.titleStyle,b={left:a+c,center:a+c/2,right:a},w=b[u.align]||b.center,v=14+(u.offsetX||0),x=w+(u.offsetY||0);t.save(),t.translate(v,x),t.rotate(-Math.PI/2),t.textAlign=u.align==="left"?"right":u.align==="right"?"left":"center",t.font=`${u.fontWeight||"normal"} ${u.fontSize||13}px system-ui, sans-serif`,t.fillStyle=u.color||s.text,t.fillText(i.yAxis.title,0,0),t.restore()}}_drawSeries(t,e,o,s,i){var l,h,a;const n=[];for(const r of i.series||[]){let c=0,d=0;if(Array.isArray(r.data)&&r.data.length>=2){const x=typeof r.data[0]=="object"?r.data[0].value:r.data[0],C=typeof r.data[1]=="object"?r.data[1].value:r.data[1];c=r.logScale===!1?x:Math.log10(x||1e-9),d=r.logScale===!1?C:Math.log10(C||1e-9)}else if(r.dataX!==void 0&&r.dataY!==void 0)c=r.logScale===!1?r.dataX:Math.log10(r.dataX||1e-9),d=r.logScale===!1?r.dataY:Math.log10(r.dataY||1e-9);else continue;const f=e(c),g=o(d);let p=null;if(i.zone&&i.zone.data){for(const x of i.zone.data)if(x.poly&&mt(c,d,x.poly)){p=x;break}}n.push({series:r,zone:p,logX:c,logY:d,px:f,py:g});const m=r.color||"#00e5ff",y=r.size||6,u=r.shape||"circle",b=this._hoverPoint&&this._hoverPoint.series===r;t.save(),t.translate(f,g);const w=r.glowStyle||{};(w.show||b&&w.show!==!1)&&(t.shadowColor=w.color||kt(m,.8),t.shadowBlur=w.blur||15),t.fillStyle=m,t.strokeStyle=((l=r.itemStyle)==null?void 0:l.borderColor)||"none",t.lineWidth=((h=r.itemStyle)==null?void 0:h.borderWidth)||0,(t.strokeStyle==="none"||!((a=r.itemStyle)!=null&&a.borderColor))&&(t.lineWidth=0),t.beginPath(),lt(t,0,0,u,y,1,0),t.fill(),t.lineWidth>0&&t.stroke();const v=r.textStyle;if(v&&v.show&&r.name){t.shadowBlur=0;const x={top:[0,-(y+6)],bottom:[0,y+12],left:[-(y+6),4],right:[y+6,4]},[C,z]=x[v.position]||x.top;t.textAlign=v.position==="left"?"right":v.position==="right"?"left":"center",t.textBaseline="middle",t.font=`${v.fontWeight||"normal"} ${v.fontSize||12}px system-ui, sans-serif`,t.fillStyle=v.color||m,t.fillText(r.name,C,z)}t.restore()}return this._drawnPoints=n,n}_defaultTooltipHTML(t,e){const o=t.series,s=Math.pow(10,t.logX).toPrecision(4),i=Math.pow(10,t.logY).toPrecision(4),n=e.xAxis.title||"X",l=e.yAxis.title||"Y",h=t.zone?t.zone.title||t.zone.name:"Outside",a=t.zone&&t.zone.color||"#fff";return`
|
|
22
|
-
|
|
23
|
-
<div style="font-size:13px; font-weight:bold;
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
`}),p}}function St(w){const t=w.trim().toLowerCase();if(t.startsWith("#")){let o=t.slice(1);o.length===3&&(o=o[0]+o[0]+o[1]+o[1]+o[2]+o[2]);const i=parseInt(o.substring(0,2),16),s=parseInt(o.substring(2,4),16),n=parseInt(o.substring(4,6),16),r=o.length===8?parseInt(o.substring(6,8),16)/255:1;return[i,s,n,r]}const e=t.match(/rgba?\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\)/);return e?[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),e[4]!==void 0?parseFloat(e[4]):1]:t==="transparent"?[0,0,0,0]:[255,255,255,1]}function Dt(w,t=1){const[e,o,i,s]=St(w);return`rgba(${e},${o},${i},${s*t})`}function Ut(w,t,e){const[o,i,s,n]=St(w),[r,h,a,l]=St(t),c=Math.round(o+(r-o)*e),d=Math.round(i+(h-i)*e),p=Math.round(s+(a-s)*e),b=n+(l-n)*e;return`rgba(${c},${d},${p},${b})`}const C=Object.freeze({colors:Q,ZONES:kt,AXES:{x:{color:"#ff9a3c",label:"X (C₂H₄/C₂H₆)"},y:{color:"#4ac8ff",label:"Y (CH₄/H₂)"},z:{color:"#70e870",label:"Z (C₂H₂/C₂H₄)"}},THEMES:{dark:{wallFillAlpha:.05,wallGridAlpha:"40",wallEdgeAlpha:"50",outerGrid:"rgba(100,150,220,0.10)",plane2dGrid:"rgba(100,150,220,0.20)",plane2dAxis:"rgba(120,160,220,0.50)",plane2dLabel:"rgba(150,180,220,0.60)",tickAlpha:"cc",pointStroke:"rgba(255,255,255,0.55)"},light:{wallFillAlpha:.06,wallGridAlpha:"28",wallEdgeAlpha:"55",outerGrid:"rgba(80,120,200,0.12)",plane2dGrid:"rgba(80,120,200,0.18)",plane2dAxis:"rgba(80,120,200,0.45)",plane2dLabel:"rgba(60,100,180,0.65)",tickAlpha:"bb",pointStroke:"rgba(0,0,0,0.25)"}},PLANES:{xz:{hAxis:"x",vAxis:"z",hLabel:"X C₂H₄/C₂H₆(热故障)",vLabel:"Z C₂H₂/C₂H₄(高能放电)",bgColor:{dark:"rgba(180,120,60,0.06)",light:"rgba(180,100,40,0.05)"}},yz:{hAxis:"y",vAxis:"z",hLabel:"Y CH₄/H₂(低能放电)",vLabel:"Z C₂H₂/C₂H₄(高能放电)",bgColor:{dark:"rgba(60,160,180,0.06)",light:"rgba(40,140,160,0.05)"}},xy:{hAxis:"x",vAxis:"y",hLabel:"X C₂H₄/C₂H₆(热故障)",vLabel:"Y CH₄/H₂(低能放电)",bgColor:{dark:"rgba(60,100,200,0.06)",light:"rgba(40,80,180,0.05)"}}},TICKS:{vals:[0,1/3,2/3,1],labels:["0","0.1","1.0","10"]},CAM:{elev:-20,yaw:115},PROJ:{fov:4,scaleK:.45,cx:.48,cy:.52},PAD2D:{l:70,r:30,t:50,b:60},DRAG:{rotYSens:.45,rotXSens:.28,rotXMin:-70,rotXMax:85,zoomMin:.3,zoomMax:4,zoomIn:1.08,zoomOut:.92},TWEEN:{step:.045},POINT:{defaultSize:7,defaultColor:"#aaaaaa",glowAlpha:.25,glowRadius:2.2,hlOffset:.35},ZONE_VIS:{fillAlpha:.25,labelAlpha:.9},UNKNOWN:{name:"未分类(需综合判断)",color:"#888899"},TEXT_STYLE:{fontSize:14,fontFamily:"Segoe UI, Courier New",fontWeight:"normal"}});class Y{static realToU(t){return t<=0?0:t<=.1?t/.3:t<=1?1/3+(Math.log10(t)+1)/3:t<=10?2/3+Math.log10(t)/3:1}static uToReal(t){return t<=0?0:t<=1/3?t*.3:t<=2/3?Math.pow(10,(t-1/3)*3-1):Math.pow(10,(t-2/3)*3)}static formatVal(t){return t<.01?t.toFixed(4):t.toFixed(3)}}class Vt{constructor(t,e,o,i={}){this.ctx=t,this.opts=i,this.layout=i.layout??"fill",this.resize(e,o),this.updateOptions(i)}updateOptions(t={}){this.opts={...this.opts,...t},(t.layout!==void 0||t.grid!==void 0)&&(t.layout!==void 0&&(this.layout=t.layout),this.resize(this.W,this.H));const e=this.opts.theme??"dark";this.theme=C.THEMES[e]??C.THEMES.dark,this.themeName=e,this.zone=this.processZones(this.opts.zone??C.ZONES);const o={show:!0,fill:{show:!0,alpha:this.theme.wallFillAlpha,colors:{xy:void 0,xz:void 0,yz:void 0}},grid:{show:!0,lineStyle:{lineWidth:.6,alpha:parseInt(this.theme.wallGridAlpha,16)/255,type:"solid"}},border:{show:!0,lineStyle:{lineWidth:.8,alpha:parseInt(this.theme.wallEdgeAlpha,16)/255,type:"solid"}}},i={show:!0,lineStyle:{lineWidth:1.8,arrowSize:9},labelStyle:{show:!0,fontSize:14,fontWeight:"bold",distance:16},tickLabelStyle:{show:!0,fontSize:12,color:"rgba(255, 255, 255, 0.8)"},data:{x:{name:C.AXES.x.label,color:C.AXES.x.color},y:{name:C.AXES.y.label,color:C.AXES.y.color},z:{name:C.AXES.z.label,color:C.AXES.z.color}}},s={show:!0,fade3DAlpha:.03,grid:{show:!0,backgroundColor:void 0,lineStyle:{lineWidth:.5,alpha:.2,type:"solid"}},axis:{show:!0,lineStyle:{lineWidth:1.5,alpha:.9},labelStyle:{show:!0,fontSize:13,distance:25},tickLabelStyle:{show:!0,fontSize:11,distance:8}},zone:{show:!0,alpha:.75,borderStyle:{show:!0,width:1.4}}};this.opts.wall=X(o,this.opts.wall||{}),this.opts.axis=X(i,this.opts.axis||{}),this.opts.plane2D=X(s,this.opts.plane2D||{})}processZones(t){let e=[],o={},i,s={},n=this.opts.colors||C.colors||Q;return t&&typeof t=="object"&&Array.isArray(t.data)?(e=t.data,o=t.labelStyle||{},i=t.alpha,s=t.borderStyle||{},t.colors&&(n=t.colors)):e=C.ZONES,e.map((r,h)=>{let a=r.color||n[h%n.length];i!==void 0&&a!=="transparent"&&(a=mt(a,i));const[l,c,d]=pt(a),p=o,b=p.color||a;let u=[];p.fontWeight&&u.push(p.fontWeight),p.fontSize&&u.push(p.fontSize+"px"),p.fontFamily&&u.push(p.fontFamily);const S=u.length>0?u.join(" "):null,g=s;let f=g.color||a;g.alpha!==void 0&&f!=="transparent"&&(f=mt(f,g.alpha));const y=r.coordinates&&r.coordinates[0]?r.coordinates[0]:[0,0,0],m=r.coordinates&&r.coordinates[1]?r.coordinates[1]:[0,0,0];return{...r,fillBase:`rgba(${l},${c},${d},`,edgeStr:f,x0:Y.realToU(y[0]),x1:Y.realToU(m[0]),y0:Y.realToU(y[1]),y1:Y.realToU(m[1]),z0:Y.realToU(y[2]),z1:Y.realToU(m[2]),labelColor:b,labelFontStr:S}})}getFont(t){var r;const e=C.TEXT_STYLE,o=((r=this.opts.textStyle)==null?void 0:r[t])??this.opts.textStyle??{},i=o.fontSize??e.fontSize,s=o.fontFamily??e.fontFamily;return`${o.fontWeight??(t==="axis"||t==="zone"?"bold":e.fontWeight)} ${i}px ${s}`}setTheme(t){this.updateOptions({theme:t})}resize(t,e){this.W=t,this.H=e;const o=this.opts.grid;if(o&&(o.left!==void 0||o.right!==void 0||o.top!==void 0||o.bottom!==void 0)){const s=yt(t,e,o,0);this.renderW=s.availW,this.renderH=s.availH,this.offsetX=s.left,this.offsetY=s.top}else if(this.layout==="square"){const s=Math.min(t,e);this.renderW=s,this.renderH=s,this.offsetX=(t-s)/2,this.offsetY=(e-s)/2}else this.renderW=t,this.renderH=e,this.offsetX=0,this.offsetY=0;this.CX=this.offsetX+this.renderW*C.PROJ.cx,this.CY=this.offsetY+this.renderH*C.PROJ.cy}proj(t,e,o){const i=t-.5,s=e-.5,n=o-.5,r=this.cam.rotX*Math.PI/180,h=this.cam.rotY*Math.PI/180,a=Math.cos(r),l=Math.sin(r),c=Math.cos(h),d=Math.sin(h),p=i*c+s*d,b=-i*d+s*c,u=n*a-b*l,S=n*l+b*a,g=Math.min(this.renderW,this.renderH)*C.PROJ.scaleK*this.cam.zoomFactor,f=C.PROJ.fov,y=S+f;return{x:this.CX+p/y*g*f,y:this.CY-u/y*g*f,depth:S}}isBackface(t,e,o){const i=this.cam.rotX*Math.PI/180,s=this.cam.rotY*Math.PI/180,n=Math.cos(i),r=Math.sin(i),h=Math.cos(s),a=Math.sin(s),l=-t*a+e*h;return o*r+l*n>0}draw(t,e,o,i){var l;const s=this.ctx,n=window.devicePixelRatio||1;s.setTransform(n,0,0,n,0,0),s.clearRect(0,0,this.W,this.H),this.cam=t;const r=((l=this.opts.plane2D)==null?void 0:l.fade3DAlpha)??.03,h=1-i*(1-r);s.globalAlpha=h,this.drawWalls(h),this.drawGrid(h),this.drawZones(h),this.drawAxes(h),this.drawTickLabels(h);const a=Array.isArray(e)?e:[];[...a].sort((c,d)=>this.proj(Y.realToU(c.position.x),Y.realToU(c.position.y),Y.realToU(c.position.z)).depth-this.proj(Y.realToU(d.position.x),Y.realToU(d.position.y),Y.realToU(d.position.z)).depth).forEach(c=>this.drawPoint3D(c,h)),s.globalAlpha=1,i>0&&this.opts.plane2D.show&&this.draw2DOverlay(o,i,a)}face(t,e,o){const i=this.ctx,s=t.map(n=>this.proj(...n));i.beginPath(),i.moveTo(s[0].x,s[0].y);for(let n=1;n<s.length;n++)i.lineTo(s[n].x,s[n].y);i.closePath(),e&&(i.fillStyle=e,i.fill()),o&&(i.strokeStyle=o,i.lineWidth=.8,i.stroke())}line(t,e){const o=this.ctx;o.beginPath(),o.moveTo(t.x,t.y),o.lineTo(e.x,e.y),o.stroke()}box(t,e,o,i,s,n,r,h){[{f:[[t,o,s],[e,o,s],[e,i,s],[t,i,s]],n:[0,0,-1]},{f:[[t,o,n],[e,o,n],[e,i,n],[t,i,n]],n:[0,0,1]},{f:[[t,o,s],[e,o,s],[e,o,n],[t,o,n]],n:[0,-1,0]},{f:[[t,i,s],[e,i,s],[e,i,n],[t,i,n]],n:[0,1,0]},{f:[[t,o,s],[t,i,s],[t,i,n],[t,o,n]],n:[-1,0,0]},{f:[[e,o,s],[e,i,s],[e,i,n],[e,o,n]],n:[1,0,0]}].filter(({n:l})=>!this.isBackface(l[0],l[1],l[2])).map(({f:l})=>({f:l,d:l.reduce((c,d)=>c+this.proj(...d).depth,0)/l.length})).sort((l,c)=>l.d-c.d).forEach(({f:l})=>this.face(l,r,h))}drawWalls(t=1){const e=this.ctx,o=this.opts.wall;if(!o.show)return;const i=this.opts.axis.data,s=C.TICKS.vals,n=[{pts:[[0,0,0],[1,0,0],[1,0,1],[0,0,1]],color:o.fill.colors.xz||i.x.color,segs:r=>[[this.proj(r,0,0),this.proj(r,0,1)],[this.proj(0,0,r),this.proj(1,0,r)]],gridColor:i.x.color},{pts:[[0,0,0],[0,1,0],[0,1,1],[0,0,1]],color:o.fill.colors.yz||i.y.color,segs:r=>[[this.proj(0,r,0),this.proj(0,r,1)],[this.proj(0,0,r),this.proj(0,1,r)]],gridColor:i.y.color},{pts:[[0,0,0],[1,0,0],[1,1,0],[0,1,0]],color:o.fill.colors.xy||i.z.color,segs:r=>[[this.proj(r,0,0),this.proj(r,1,0)],[this.proj(0,r,0),this.proj(1,r,0)]],gridColor:i.z.color}];o.fill.show&&(e.globalAlpha=o.fill.alpha*t,n.forEach(r=>this.face(r.pts,r.color)),e.globalAlpha=t),o.grid.show&&(e.lineWidth=o.grid.lineStyle.lineWidth,e.globalAlpha=o.grid.lineStyle.alpha*t,o.grid.lineStyle.type==="dashed"?e.setLineDash([4,4]):o.grid.lineStyle.type==="dotted"?e.setLineDash([2,2]):e.setLineDash([]),n.forEach(({gridColor:r,segs:h})=>{e.strokeStyle=r,s.forEach(a=>h(a).forEach(([l,c])=>this.line(l,c)))}),e.setLineDash([]),e.globalAlpha=t),o.border.show&&(e.lineWidth=o.border.lineStyle.lineWidth,e.globalAlpha=o.border.lineStyle.alpha*t,o.border.lineStyle.type==="dashed"?e.setLineDash([4,4]):o.border.lineStyle.type==="dotted"?e.setLineDash([2,2]):e.setLineDash([]),n.forEach(({pts:r,gridColor:h})=>{e.strokeStyle=h,r.forEach((a,l)=>this.line(this.proj(...a),this.proj(...r[(l+1)%r.length])))}),e.setLineDash([]),e.globalAlpha=t)}drawGrid(t=1){const e=this.ctx;e.globalAlpha=t,e.strokeStyle=this.theme.outerGrid,e.lineWidth=.4,C.TICKS.vals.forEach(o=>{this.line(this.proj(1,o,0),this.proj(1,o,1)),this.line(this.proj(1,0,o),this.proj(1,1,o))})}drawZones(t){const e=this.ctx,o=C.ZONE_VIS;[...this.zone].sort((i,s)=>this.proj((i.x0+i.x1)/2,(i.y0+i.y1)/2,(i.z0+i.z1)/2).depth-this.proj((s.x0+s.x1)/2,(s.y0+s.y1)/2,(s.z0+s.z1)/2).depth).forEach(i=>{e.globalAlpha=t;const s=i.fillAlpha!==void 0?i.fillAlpha:o.fillAlpha;if(this.box(i.x0,i.x1,i.y0,i.y1,i.z0,i.z1,i.fillBase+s+")",i.edgeStr),t>.05){e.globalAlpha=t*o.labelAlpha;const n=this.proj((i.x0+i.x1)/2,(i.y0+i.y1)/2,(i.z0+i.z1)/2);e.font=i.labelFontStr||this.getFont("zone"),e.textAlign="center",e.fillStyle=i.labelColor,e.fillText(i.name,n.x,n.y)}e.globalAlpha=t})}drawAxes(t=1){const e=this.ctx;e.globalAlpha=t;const o=this.opts.axis;o.show&&[{from:[0,0,0],to:[1.18,0,0],lp:[1.22,0,0],...o.data.x},{from:[0,0,0],to:[0,1.18,0],lp:[0,1.22,0],...o.data.y},{from:[0,0,0],to:[0,0,1.22],lp:[0,0,1.28],...o.data.z}].forEach(i=>{var r;const s=this.proj(...i.from),n=this.proj(...i.to);if(e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(n.x,n.y),e.strokeStyle=i.color,e.lineWidth=o.lineStyle.lineWidth,e.stroke(),o.lineStyle.arrowSize>0){const h=n.x-s.x,a=n.y-s.y,l=Math.hypot(h,a)||1,c=h/l,d=a/l,p=o.lineStyle.arrowSize;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x-c*p+d*(p/2.25),n.y-d*p-c*(p/2.25)),e.lineTo(n.x-c*p-d*(p/2.25),n.y-d*p+c*(p/2.25)),e.closePath(),e.fillStyle=i.color,e.fill()}if(o.labelStyle.show){const h=n.x-s.x,a=n.y-s.y,l=Math.hypot(h,a)||1,c=n.x+h/l*o.labelStyle.distance,d=n.y+a/l*o.labelStyle.distance;e.fillStyle=i.color,e.font=`${o.labelStyle.fontWeight} ${o.labelStyle.fontSize}px ${((r=this.opts.textStyle)==null?void 0:r.fontFamily)||C.TEXT_STYLE.fontFamily}`,e.textAlign="center",e.textBaseline="middle",e.fillText(i.name,c,d)}})}drawTickLabels(t=1){const e=this.ctx;e.globalAlpha=t;const{vals:o,labels:i}=C.TICKS,s=this.theme.tickAlpha;e.font=this.getFont("tick"),o.forEach((n,r)=>{let h=this.proj(n,0,0);e.fillStyle=C.AXES.x.color+s,e.textAlign="center",e.fillText(i[r],h.x,h.y+13),h=this.proj(0,n,0),e.fillStyle=C.AXES.y.color+s,e.textAlign="left",e.fillText(i[r],h.x+7,h.y+4),h=this.proj(0,0,n),e.fillStyle=C.AXES.z.color+s,e.textAlign="right",e.fillText(i[r],h.x-7,h.y+4)}),e.textAlign="center"}drawPoint3D(t,e){const o=Y.realToU(t.position.x),i=Y.realToU(t.position.y),s=Y.realToU(t.position.z);this.drawPointAt(this.proj(o,i,s),t,e)}drawPointAt(t,e,o=1){var u,S;const i=this.ctx,s=C.POINT,n=t.x??t.cx,r=t.y??t.cy,h=((u=e.itemStyle)==null?void 0:u.radius)??s.defaultSize,a=((S=e.itemStyle)==null?void 0:S.color)??e.color,l=e.name,c=e.textStyle||{},d=e.glowStyle!==void 0,p=e.glowStyle||{};if(d&&p.show!==!1){let g=[],f=3,y=p.glowDistance!==void 0?p.glowDistance:4;const m=p.color??a;if(Array.isArray(p.colors)&&p.colors.length>0)g=p.colors,f=g.length;else{const v=p.startColor||mt(m,.15),x=p.endColor||"transparent";f=p.count!==void 0?parseInt(p.count,10):3,g=[];for(let A=0;A<f;A++){const T=f>1?A/(f-1):0;g.push(Kt(v,x,T))}}for(let v=f-1;v>=0;v--){const x=g[v];i.save(),i.fillStyle=x,i.beginPath(),i.arc(n,r,h+(v+1)*y,0,Math.PI*2),i.fill(),i.restore()}}i.globalAlpha=o,i.beginPath(),i.arc(n,r,h,0,Math.PI*2);const b=i.createRadialGradient(n-h*s.hlOffset,r-h*s.hlOffset,1,n,r,h);b.addColorStop(0,"rgba(255,255,255,0.9)"),b.addColorStop(.4,a+"ee"),b.addColorStop(1,a+"88"),i.fillStyle=b,i.fill(),i.strokeStyle=this.theme.pointStroke,i.lineWidth=1.3,i.stroke(),i.restore(),l&&(i.font=c.bold?`bold ${c.fontSize||12}px ${c.fontFamily||"sans-serif"}`:`${c.fontSize||12}px ${c.fontFamily||"sans-serif"}`,i.fillStyle=c.color??e.color,i.textAlign="left",i.fillText(l,n+h+3,r-2))}draw2DOverlay(t,e,o){var T;const i=C.PLANES[t];if(!i)return;const s=this.ctx,n=this.theme,r=this.opts.plane2D,h=this.opts.axis.data;s.save(),s.globalAlpha=e;let a=this.offsetX,l=this.offsetY,c=this.offsetX+this.renderW,d=this.offsetY+this.renderH;const p=this.opts.grid||{};if(!(p.left!==void 0||p.right!==void 0||p.top!==void 0||p.bottom!==void 0)){const _=C.PAD2D||{l:70,r:30,t:50,b:60};a=_.l,l=_.t,c=this.W-_.r,d=this.H-_.b}const u=c-a,S=d-l,g=Math.min(u,S),f=a+u/2,y=l+S/2;a=f-g/2,c=f+g/2,l=y-g/2,d=y+g/2;const{vals:m,labels:v}=C.TICKS,x=(_,M)=>({cx:a+_*(c-a),cy:d-M*(d-l)}),A=this.themeName??"dark";if(r.grid.show&&(s.fillStyle=r.grid.backgroundColor??i.bgColor[A]??i.bgColor.dark,s.fillRect(a,l,c-a,d-l)),r.zone.show&&this.zone.forEach(_=>{var W;const[M,k]=[_[i.hAxis+"0"],_[i.hAxis+"1"]],[P,E]=[_[i.vAxis+"0"],_[i.vAxis+"1"]],z=x(M,P),D=x(k,E),j=D.cx-z.cx,N=z.cy-D.cy,K=_.fillAlpha!==void 0?_.fillAlpha:r.zone.alpha;s.fillStyle=_.fillBase+K+")",s.fillRect(z.cx,D.cy,j,N),r.zone.borderStyle.show&&(s.strokeStyle=_.edgeStr,s.lineWidth=r.zone.borderStyle.width??1.4,s.strokeRect(z.cx,D.cy,j,N));const H=(z.cx+D.cx)/2,ot=(z.cy+D.cy)/2;s.font=_.labelFontStr||this.getFont("zone"),s.textAlign="center",s.fillStyle=_.labelColor;const F=((W=this.opts.zone)==null?void 0:W.labelStyle)||{},nt=typeof F.formatter=="function"?F.formatter(_):_.name;s.fillText(nt,H,ot+4)}),r.grid.show&&(s.strokeStyle=r.grid.lineStyle.color||n.plane2dGrid,s.lineWidth=r.grid.lineStyle.lineWidth,s.globalAlpha=e*r.grid.lineStyle.alpha,r.grid.lineStyle.type==="dashed"?s.setLineDash([4,4]):r.grid.lineStyle.type==="dotted"?s.setLineDash([2,2]):s.setLineDash([]),m.forEach(_=>{const M=x(_,0).cx,k=x(0,_).cy;s.beginPath(),s.moveTo(M,l),s.lineTo(M,d),s.stroke(),s.beginPath(),s.moveTo(a,k),s.lineTo(c,k),s.stroke()}),s.setLineDash([]),s.globalAlpha=e),r.axis.show){const _=h[i.hAxis].color,M=h[i.vAxis].color;s.lineWidth=r.axis.lineStyle.lineWidth,s.globalAlpha=e*r.axis.lineStyle.alpha,s.strokeStyle=_,s.beginPath(),s.moveTo(a,d),s.lineTo(c+10,d),s.stroke(),s.strokeStyle=M,s.beginPath(),s.moveTo(a,d),s.lineTo(a,l-10),s.stroke(),s.globalAlpha=e;const k=((T=this.opts.textStyle)==null?void 0:T.fontFamily)||C.TEXT_STYLE.fontFamily;if(r.axis.tickLabelStyle.show){s.font=`${r.axis.tickLabelStyle.fontSize}px ${k}`;const P=r.axis.tickLabelStyle.distance;m.forEach((E,z)=>{s.fillStyle=_,s.textAlign="center",s.fillText(v[z],x(E,0).cx,d+P+r.axis.tickLabelStyle.fontSize/2),s.fillStyle=M,s.textAlign="right",s.fillText(v[z],a-P+2,x(0,E).cy+r.axis.tickLabelStyle.fontSize/3)})}if(r.axis.labelStyle.show){s.font=`bold ${r.axis.labelStyle.fontSize}px ${k}`;const P=r.axis.labelStyle.distance;s.textAlign="center",s.fillStyle=_,s.fillText(h[i.hAxis].name,(a+c)/2,d+P+r.axis.labelStyle.fontSize),s.save(),s.translate(a-P-r.axis.labelStyle.fontSize,(l+d)/2),s.rotate(-Math.PI/2),s.fillStyle=M,s.fillText(h[i.vAxis].name,0,0),s.restore()}}o.forEach(_=>{const M=x(Y.realToU(_.position[i.hAxis]),Y.realToU(_.position[i.vAxis]));this.drawPointAt(M,_,e)}),s.restore()}}const lt=class lt{constructor(t,e={}){if(this.series=[],this.opts=e,this.cam={rotX:C.CAM.elev,rotY:C.CAM.yaw,zoomFactor:1},this.view=e.initialView??"3d",this.layout=e.layout??"fill",this.drag={active:!1,lastX:0,lastY:0},this.tween={from:{rotX:0,rotY:0},to:{rotX:0,rotY:0},t:1},this.animId=null,this.pinchDist=null,this._bus=new gt,t=typeof t=="string"?document.querySelector(t):t,!t)throw new Error("ThreeRatioChart: container not found");this.buildDOM(t),this.renderer=new Vt(this.ctx,this.W,this.H,e),this.bindEvents(),this.applyView(),this.render()}setOption(t){if(t){if(this.opts={...this.opts,...t},(t.zone||t.textStyle||t.theme||t.wallColors||t.layout!==void 0||t.grid!==void 0||t.axis!==void 0||t.wall!==void 0||t.plane2D!==void 0)&&this.renderer.updateOptions({zone:this.opts.zone,textStyle:this.opts.textStyle,theme:this.opts.theme,wallColors:this.opts.wallColors,layout:this.opts.layout,grid:this.opts.grid,axis:this.opts.axis,wall:this.opts.wall,plane2D:this.opts.plane2D}),t.series!==void 0){const e=Array.isArray(t.series)?t.series:[t.series];this.series=e.map(o=>({name:o.name??"",color:o.color??C.POINT.defaultColor,itemStyle:o.itemStyle??{},textStyle:o.textStyle??{},glowStyle:o.glowStyle,position:o.position??{x:0,y:0,z:0}})),this.emit("dataChange",[...this.series]),this.render()}return t.view&&t.view!==this.view&&this.setView(t.view),this}}setSeries(t){return this.setOption({series:t})}setView(t){if(!lt.VIEWS[t])return;this.view=t,cancelAnimationFrame(this.animId);const e=this.getViewTarget(t);this.tween={from:{rotX:this.cam.rotX,rotY:this.cam.rotY},to:e,t:0},this.cv.style.cursor=t==="3d"?"grab":"default",this.runTween(),this._bus.emit("viewChange",t)}setTheme(t){this.renderer.setTheme(t),this.render()}diagnose(t,e,o){if(!this.renderer)return[{...this.opts.unknown??C.UNKNOWN}];const i=this.renderer.zone.filter(s=>{if(!s.coordinates||s.coordinates.length<2)return!1;const n=s.coordinates[0],r=s.coordinates[1];return t>=n[0]&&t<r[0]&&e>=n[1]&&e<r[1]&&o>=n[2]&&o<r[2]}).map(s=>({name:s.name,title:s.title,color:s.color||"#fff"}));return i.length?i:[{...this.opts.unknown??C.UNKNOWN}]}on(t,e){return this._bus.on(t,e),this}off(t,e){return this._bus.off(t,e),this}emit(t,...e){this._bus.emit(t,...e)}render(){if(!this.renderer||!this.ctx)return;this.renderer.draw(this.cam,this.series,this.view,this.flatness());const t=[];this.series.forEach(e=>{if(e.position){const o=this.diagnose(e.position.x,e.position.y,e.position.z);t.push({series:e,zone:o.length?o[0]:null,position:e.position})}}),t.length>0&&this._bus.emit("diagnose",t)}dispose(){var t,e,o;cancelAnimationFrame(this.animId),(t=this.resizeObs)==null||t.disconnect(),(e=this.cv)==null||e.remove(),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),(o=this._bus)==null||o.dispose()}getViewTarget(t){const e=lt.VIEWS[t];return{rotX:typeof e.rotX=="function"?e.rotX():e.rotX,rotY:typeof e.rotY=="function"?e.rotY():e.rotY}}applyView(){if(this.view!=="3d"){const t=this.getViewTarget(this.view);this.cam.rotX=t.rotX,this.cam.rotY=t.rotY,this.cv.style.cursor="default"}}flatness(){if(this.view==="3d")return 0;const t=this.getViewTarget(this.view);return Math.max(0,1-(Math.abs(this.cam.rotX-t.rotX)+Math.abs(this.cam.rotY-t.rotY))/30)}runTween(){this.tween.t=Math.min(1,this.tween.t+C.TWEEN.step);const t=(e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2)(this.tween.t);this.cam.rotX=this.tween.from.rotX+(this.tween.to.rotX-this.tween.from.rotX)*t,this.cam.rotY=this.tween.from.rotY+(this.tween.to.rotY-this.tween.from.rotY)*t,this.render(),this.tween.t<1&&(this.animId=requestAnimationFrame(()=>this.runTween()))}buildDOM(t){const e=window.devicePixelRatio||1,o=t.getBoundingClientRect();this.W=o.width>0?Math.round(o.width):600,this.H=o.height>0?Math.round(o.height):540,this.cv=document.createElement("canvas"),this.cv.className="trc-canvas",this.cv.width=this.W*e,this.cv.height=this.H*e,this.cv.style.cssText="width:100%;height:100%;display:block;touch-action:none;",this.ctx=this.cv.getContext("2d"),t.appendChild(this.cv),this.resizeObs=new ResizeObserver(i=>{var r;const{width:s,height:n}=i[0].contentRect;if(s>0&&n>0){const h=window.devicePixelRatio||1;this.W=Math.round(s),this.H=Math.round(n),this.cv.width=this.W*h,this.cv.height=this.H*h,(r=this.renderer)==null||r.resize(this.W,this.H),this.render()}}),this.resizeObs.observe(t)}bindEvents(){const t=C.DRAG,e=this.cv;e.addEventListener("mousedown",o=>{this.view==="3d"&&(this.drag={active:!0,lastX:o.clientX,lastY:o.clientY},e.style.cursor="grabbing",cancelAnimationFrame(this.animId))}),this.onMouseMove=o=>{!this.drag.active||this.view!=="3d"||(this.cam.rotY+=(o.clientX-this.drag.lastX)*t.rotYSens,this.cam.rotX=Math.max(t.rotXMin,Math.min(t.rotXMax,this.cam.rotX+(o.clientY-this.drag.lastY)*t.rotXSens)),this.drag.lastX=o.clientX,this.drag.lastY=o.clientY,this.render())},this.onMouseUp=()=>{this.drag.active=!1,this.view==="3d"&&(e.style.cursor="grab")},window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp),e.addEventListener("touchstart",o=>{this.view==="3d"&&(this.drag={active:!0,lastX:o.touches[0].clientX,lastY:o.touches[0].clientY},o.touches.length===2&&(this.pinchDist=Math.hypot(o.touches[0].clientX-o.touches[1].clientX,o.touches[0].clientY-o.touches[1].clientY)))},{passive:!0}),e.addEventListener("touchmove",o=>{if(this.view==="3d")if(o.touches.length===2&&this.pinchDist!==null){const i=Math.hypot(o.touches[0].clientX-o.touches[1].clientX,o.touches[0].clientY-o.touches[1].clientY);this.cam.zoomFactor=Math.max(t.zoomMin,Math.min(t.zoomMax,this.cam.zoomFactor*i/this.pinchDist)),this.pinchDist=i,this.render()}else this.drag.active&&o.touches.length===1&&(this.cam.rotY+=(o.touches[0].clientX-this.drag.lastX)*t.rotYSens,this.cam.rotX=Math.max(t.rotXMin,Math.min(t.rotXMax,this.cam.rotX+(o.touches[0].clientY-this.drag.lastY)*t.rotXSens)),this.drag.lastX=o.touches[0].clientX,this.drag.lastY=o.touches[0].clientY,this.render())},{passive:!0}),e.addEventListener("touchend",o=>{o.touches.length<2&&(this.pinchDist=null),o.touches.length===0&&(this.drag.active=!1)},{passive:!0}),e.addEventListener("wheel",o=>{this.view==="3d"&&(o.preventDefault(),this.cam.zoomFactor=Math.max(t.zoomMin,Math.min(t.zoomMax,this.cam.zoomFactor*(o.deltaY>0?t.zoomOut:t.zoomIn))),this.render())},{passive:!1})}};J(lt,"VIEWS",{"3d":{rotX:()=>C.CAM.elev,rotY:()=>C.CAM.yaw},xz:{rotX:0,rotY:0},yz:{rotX:0,rotY:90},xy:{rotX:90,rotY:0}});let wt=lt;function pt(w){const t=w.trim().toLowerCase();if(t.startsWith("#")){let o=t.slice(1);o.length===3&&(o=o[0]+o[0]+o[1]+o[1]+o[2]+o[2]);const i=parseInt(o.substring(0,2),16),s=parseInt(o.substring(2,4),16),n=parseInt(o.substring(4,6),16),r=o.length===8?parseInt(o.substring(6,8),16)/255:1;return[i,s,n,r]}const e=t.match(/rgba?\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\)/);return e?[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),e[4]!==void 0?parseFloat(e[4]):1]:t==="transparent"?[0,0,0,0]:[255,255,255,1]}function mt(w,t){const[e,o,i,s]=pt(w);return`rgba(${e},${o},${i},${t!==void 0?t:s})`}function Kt(w,t,e){const[o,i,s,n]=pt(w),[r,h,a,l]=pt(t),c=Math.round(o+(r-o)*e),d=Math.round(i+(h-i)*e),p=Math.round(s+(a-s)*e),b=n+(l-n)*e;return`rgba(${c},${d},${p},${b})`}function Et(w,t){return w?w.startsWith("#")?xt(w,t):w.startsWith("rgb")?w.replace(/rgb(a)?\(([^)]+)\)/,(e,o,i)=>{const s=i.split(","),n=s[0].trim(),r=s[1].trim(),h=s[2].trim();return`rgba(${n},${r},${h},${t})`}):w:`rgba(0,0,0,${t})`}const qt={colors:Q,theme:"light",backgroundColor:"transparent",grid:{left:72,right:20,top:20,bottom:56,lineStyle:{type:"solid",width:.4,color:null},majorLineStyle:{type:"solid",width:.8,color:null}},zone:{data:Xt,alpha:.75,labelStyle:{show:!0,fontSize:12,borderRadius:4},borderStyle:{show:!0,stroke:1,type:"solid",color:null}},xAxis:{title:"",min:-2,max:3,labelStyle:{fontSize:11,fontWeight:"normal",offsetX:0,offsetY:0,color:null,scientific:!0,formatter:null},lineStyle:{show:!0,stroke:1.5,type:"solid",color:null},titleStyle:{fontSize:13,color:null,fontWeight:"normal",align:"center",offsetX:0,offsetY:0}},yAxis:{title:"",min:-3,max:3,labelStyle:{fontSize:11,fontWeight:"normal",offsetX:0,offsetY:0,color:null,scientific:!0,formatter:null},lineStyle:{show:!0,stroke:1.5,type:"solid",color:null},titleStyle:{fontSize:13,color:null,fontWeight:"normal",align:"center",offsetX:0,offsetY:0}},tooltip:{show:!0,formatter:null},series:[]},Lt={light:{backgroundColor:"#ffffff",text:"#333333",textSecondary:"#666666",gridLine:"rgba(0,0,0,0.12)",gridLineMajor:"rgba(0,0,0,0.22)",axisLine:"rgba(0,0,0,0.5)",zoneBorder:"rgba(0,0,0,0.35)",zoneLabelBg:"rgba(255,255,255,0.75)",tooltipBg:"rgba(255,255,255,0.95)",tooltipBorder:"rgba(0,0,0,0.15)",tooltipTextColor:"#222222"},dark:{backgroundColor:"#1a1a2e",text:"rgba(255,255,255,0.85)",textSecondary:"rgba(255,255,255,0.5)",gridLine:"rgba(255,255,255,0.08)",gridLineMajor:"rgba(255,255,255,0.18)",axisLine:"rgba(255,255,255,0.55)",zoneBorder:"rgba(255,255,255,0.3)",zoneLabelBg:"rgba(0,0,0,0.5)",tooltipBg:"rgba(20,20,40,0.95)",tooltipBorder:"rgba(255,255,255,0.15)",tooltipTextColor:"rgba(255,255,255,0.9)"}};function Pt(w){const t=Math.round(w);return"10"+String(t).split("").map(o=>({"-":"⁻",0:"⁰",1:"¹",2:"²",3:"³",4:"⁴",5:"⁵",6:"⁶",7:"⁷",8:"⁸",9:"⁹"})[o]||o).join("")}class Tt{constructor(t,e={}){if(typeof t=="string"&&(t=document.querySelector(t)),!t)throw new Error("[ETRAChart] Container element not found");this._container=t,this._opt=X(X({},qt),e),this._bus=new gt,this._initDOM(),this._zoom=new vt(this._opt.zoom||{}),this._tooltipRenderer=new _t(this._container,this._theme),this._hoverZone=null,this._hoverPoint=null,typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(()=>this.resize()),this._ro.observe(this._container)),this._onWheel=i=>{i.preventDefault();const s=this._canvas.getBoundingClientRect(),n=i.clientX-s.left,r=i.clientY-s.top;this._zoom.onWheel(i.deltaY,n,r),this._bus.emit("zoom",this._zoom.state),this._render()},this._onDown=i=>{i.button===0&&(this._zoom.startDrag(i.clientX,i.clientY),this._canvas.style.cursor="grabbing")},this._onMove=i=>{const s=this._canvas.getBoundingClientRect();if(this._zoom.moveDrag(i.clientX,i.clientY,1)){this._render();return}if(!this._coordMap||!this._drawnPoints)return;const n=i.clientX-s.left,r=i.clientY-s.top,{panX:h,panY:a,zoom:l}=this._zoom,c=(n-h)/l,d=(r-a)/l;let p=null,b=1/0;for(const u of this._drawnPoints){const S=Math.hypot(c-u.px,d-u.py),g=u.series.size||6;S<g*2+5&&S<b&&(b=S,p=u)}p!==this._hoverPoint&&(this._hoverPoint=p,this._render(),p?(this._canvas.style.cursor="pointer",this._bus.emit("hover",p)):(this._canvas.style.cursor="default",this._bus.emit("hover",null)))},this._onUp=()=>{this._zoom.endDrag()&&(this._canvas.style.cursor=this._hoverPoint?"pointer":"default",this._bus.emit("zoom",this._zoom.state))},this._onLeave=()=>{this._hoverPoint&&(this._hoverPoint=null,this._canvas.style.cursor="default",this._render(),this._bus.emit("hover",null))},this._onDbl=()=>{this._zoom.reset(),this._bus.emit("zoom",this._zoom.state),this._render()};const o=this._canvas;o.addEventListener("wheel",this._onWheel,{passive:!1}),o.addEventListener("mousedown",this._onDown),o.addEventListener("mousemove",this._onMove),o.addEventListener("mouseleave",this._onLeave),o.addEventListener("dblclick",this._onDbl),window.addEventListener("mouseup",this._onUp),this._render()}static init(t,e){return new Tt(t,e)}get _theme(){return Lt[this._opt.theme]||Lt.light}_initDOM(){this._container.style.position="relative",this._container.style.overflow="hidden",this._canvas=document.createElement("canvas"),this._canvas.style.display="block",this._canvas.style.width="100%",this._canvas.style.height="100%",this._container.appendChild(this._canvas),this._ctx=this._canvas.getContext("2d")}setOption(t){return this._opt=X(this._opt,t),t.series!==void 0&&(this._opt.series=Array.isArray(t.series)?t.series:[t.series]),this._coordMap=null,this._canvas&&this._canvas.width>0&&this._render(),this}setSeries(t){return this._opt.series=Array.isArray(t)?t:[t],this._render(),this}diagnose(t,e){if(!this._opt.zone||!this._opt.zone.data)return null;for(const o of this._opt.zone.data)if(o.coordinates&&dt(t,e,o.coordinates))return o;return null}on(t,e){return this._bus.on(t,e),this}off(t,e){return this._bus.off(t,e),this}resize(){return this._render(),this}dispose(){this._ro&&this._ro.disconnect(),this._tooltipRenderer.dispose(),this._canvas&&this._canvas.parentNode&&this._canvas.parentNode.removeChild(this._canvas),this._bus.dispose(),window.removeEventListener("mouseup",this._onUp)}_dims(){const t=this._container.getBoundingClientRect(),e=t.width||600,o=t.height||400,i=window.devicePixelRatio||1;(this._canvas.width!==Math.round(e*i)||this._canvas.height!==Math.round(o*i))&&(this._canvas.width=Math.round(e*i),this._canvas.height=Math.round(o*i));const s=yt(e,o,this._opt.grid,0);return{W:e,H:o,box:s,dpr:i}}_render(){const{W:t,H:e,box:o,dpr:i}=this._dims(),s=this._ctx;if(!s)return;const n=this._theme,r=this._opt;s.setTransform(i,0,0,i,0,0),s.clearRect(0,0,t,e);const h=r.backgroundColor||n.backgroundColor||"transparent";h!=="transparent"&&(s.fillStyle=h,s.fillRect(0,0,t,e));const a=r.xAxis.min,l=r.xAxis.max,c=r.yAxis.min,d=r.yAxis.max,p=o.availW,b=o.availH,u=o.left,S=o.top,g=m=>u+(m-a)/(l-a)*p,f=m=>S+(d-m)/(d-c)*b;this._coordMap={xMin:a,xMax:l,yMin:c,yMax:d,plotW:p,plotH:b,gL:u,gT:S,toPixX:g,toPixY:f},s.save(),this._zoom.applyTransform(s),this._drawGrid(s,g,f,n,r),this._drawZones(s,g,f,n,r);const y=this._drawSeries(s,g,f,n,r);if(this._drawAxes(s,g,f,n,r,t,e,u,S,p,b),s.restore(),r.tooltip.show&&this._hoverPoint){const m=this._hoverPoint,v=g(m.logX)*this._zoom.zoom+this._zoom.panX,x=f(m.logY)*this._zoom.zoom+this._zoom.panY;let A="";typeof r.tooltip.formatter=="function"?A=r.tooltip.formatter({series:m.series,logX:m.logX,logY:m.logY,rawX:Math.pow(10,m.logX),rawY:Math.pow(10,m.logY),zone:m.zone}):A=this._defaultTooltipHTML(m,r),this._tooltipRenderer.show(A,v,x,r.tooltip,n,m.zone)}else this._tooltipRenderer.hide();y.length>0&&this._bus.emit("diagnose",y)}_drawGrid(t,e,o,i,s){const n=s.xAxis.min,r=s.xAxis.max,h=s.yAxis.min,a=s.yAxis.max,l=this._coordMap.gL,c=this._coordMap.gT,d=this._coordMap.plotW,p=this._coordMap.plotH,b=s.grid.lineStyle||{},u=b.color||i.gridLineMajor,S=i.gridLine;for(let g=Math.ceil(n);g<=Math.floor(r);g++){const f=e(g);t.beginPath(),t.moveTo(f,c),t.lineTo(f,c+p),t.strokeStyle=u,t.lineWidth=b.width||.4,b.type==="dashed"?t.setLineDash([4,3]):t.setLineDash([]),t.stroke(),t.setLineDash([]),t.strokeStyle=S,t.lineWidth=.25;for(let y=2;y<=9;y++){const m=g+Math.log10(y);if(m>r)break;const v=e(m);t.beginPath(),t.moveTo(v,c),t.lineTo(v,c+p),t.stroke()}}for(let g=Math.ceil(h);g<=Math.floor(a);g++){const f=o(g);t.beginPath(),t.moveTo(l,f),t.lineTo(l+d,f),t.strokeStyle=u,t.lineWidth=b.width||.4,b.type==="dashed"?t.setLineDash([4,3]):t.setLineDash([]),t.stroke(),t.setLineDash([]),t.strokeStyle=S,t.lineWidth=.25;for(let y=2;y<=9;y++){const m=g+Math.log10(y);if(m>a)break;const v=o(m);t.beginPath(),t.moveTo(l,v),t.lineTo(l+d,v),t.stroke()}}}_drawZones(t,e,o,i,s){const n=s.zone;if(!n||!n.data)return;const r=n.alpha,h=n.colors||s.colors||Q;for(let a=0;a<n.data.length;a++){const l=n.data[a];if(!l.coordinates||l.coordinates.length<3)continue;t.beginPath(),l.coordinates.forEach((d,p)=>{const b=e(d[0]),u=o(d[1]);p===0?t.moveTo(b,u):t.lineTo(b,u)}),t.closePath();let c=l.color||h[a%h.length];if(r!==void 0&&c!=="transparent"&&(c=Et(c,r)),t.fillStyle=c,t.fill(),n.borderStyle.show){let d=n.borderStyle.color||c;n.borderStyle.alpha!==void 0&&d!=="transparent"&&(d=Et(d,n.borderStyle.alpha)),t.strokeStyle=d,t.lineWidth=n.borderStyle.width??1,n.borderStyle.type==="dashed"?t.setLineDash([5,3]):t.setLineDash([]),t.stroke(),t.setLineDash([])}if(n.labelStyle.show&&l.name){let d=0,p=0;l.coordinates.forEach(T=>{d+=e(T[0]),p+=o(T[1])});const b=d/l.coordinates.length,u=p/l.coordinates.length,S=this._coordMap.gL,g=this._coordMap.gT,f=this._coordMap.plotW,y=this._coordMap.plotH,m=Math.max(S+4,Math.min(S+f-4,b)),v=Math.max(g+4,Math.min(g+y-4,u)),x=n.labelStyle.fontSize||12;t.textAlign="center",t.textBaseline="middle";const A=typeof n.labelStyle.formatter=="function"?n.labelStyle.formatter(l):l.name;t.font=`${n.labelStyle.fontWeight||"500"} ${x}px system-ui, sans-serif`,t.fillStyle=n.labelStyle.color||i.text,t.fillText(A,m,v)}}}_drawAxes(t,e,o,i,s,n,r,h,a,l,c){const d=s.xAxis.min,p=s.xAxis.max,b=s.yAxis.min,u=s.yAxis.max;t.beginPath(),t.rect(h,a,l,c),t.strokeStyle=i.axisLine,t.lineWidth=1,t.stroke();const S=s.xAxis.labelStyle.color||i.textSecondary,g=s.yAxis.labelStyle.color||i.textSecondary;t.textAlign="center",t.textBaseline="middle";for(let f=Math.ceil(d);f<=Math.floor(p);f++){const y=e(f),m=s.xAxis.labelStyle;t.font=`${m.fontWeight||"normal"} ${m.fontSize||11}px system-ui, sans-serif`,t.fillStyle=S;const v=typeof m.formatter=="function"?m.formatter(f,Math.pow(10,f)):m.scientific===!1?String(Number(Math.pow(10,f).toPrecision(4))):Pt(f);t.fillText(v,y+(m.offsetX||0),a+c+16+(m.offsetY||0))}t.textAlign="right";for(let f=Math.ceil(b);f<=Math.floor(u);f++){const y=o(f),m=s.yAxis.labelStyle;t.font=`${m.fontWeight||"normal"} ${m.fontSize||11}px system-ui, sans-serif`,t.fillStyle=g;const v=typeof m.formatter=="function"?m.formatter(f,Math.pow(10,f)):m.scientific===!1?String(Number(Math.pow(10,f).toPrecision(4))):Pt(f);t.fillText(v,h-6+(m.offsetX||0),y+(m.offsetY||0))}if(s.xAxis.title){const f=s.xAxis.titleStyle,y={left:h,center:h+l/2,right:h+l},m=(y[f.align]||y.center)+(f.offsetX||0),v=a+c+38+(f.offsetY||0);t.textAlign=f.align==="left"?"left":f.align==="right"?"right":"center",t.font=`${f.fontWeight||"normal"} ${f.fontSize||13}px system-ui, sans-serif`,t.fillStyle=f.color||i.text,t.fillText(s.xAxis.title,m,v)}if(s.yAxis.title){const f=s.yAxis.titleStyle,y={left:a+c,center:a+c/2,right:a},m=y[f.align]||y.center,v=14+(f.offsetX||0),x=m+(f.offsetY||0);t.save(),t.translate(v,x),t.rotate(-Math.PI/2),t.textAlign=f.align==="left"?"right":f.align==="right"?"left":"center",t.font=`${f.fontWeight||"normal"} ${f.fontSize||13}px system-ui, sans-serif`,t.fillStyle=f.color||i.text,t.fillText(s.yAxis.title,0,0),t.restore()}}_drawSeries(t,e,o,i,s){var r,h,a;const n=[];for(const l of s.series||[]){let c=0,d=0;if(Array.isArray(l.data)&&l.data.length>=2){const x=typeof l.data[0]=="object"?l.data[0].value:l.data[0],A=typeof l.data[1]=="object"?l.data[1].value:l.data[1];c=l.logScale===!1?x:Math.log10(x||1e-9),d=l.logScale===!1?A:Math.log10(A||1e-9)}else if(l.dataX!==void 0&&l.dataY!==void 0)c=l.logScale===!1?l.dataX:Math.log10(l.dataX||1e-9),d=l.logScale===!1?l.dataY:Math.log10(l.dataY||1e-9);else continue;const p=e(c),b=o(d);let u=null;if(s.zone&&s.zone.data){for(const x of s.zone.data)if(x.coordinates&&dt(c,d,x.coordinates)){u=x;break}}n.push({series:l,zone:u,logX:c,logY:d,px:p,py:b});const S=l.color||"#00e5ff";let g=l.size||6;const f=l.shape||"circle",y=this._hoverPoint&&this._hoverPoint.series===l;y&&(g*=1.5),t.save(),t.translate(p,b);const m=l.glowStyle||{};(m.show||y&&m.show!==!1)&&(t.shadowColor=m.color||xt(S,.8),t.shadowBlur=m.blur||15),t.fillStyle=S,t.strokeStyle=((r=l.itemStyle)==null?void 0:r.borderColor)||"none",t.lineWidth=((h=l.itemStyle)==null?void 0:h.borderWidth)||0,(t.strokeStyle==="none"||!((a=l.itemStyle)!=null&&a.borderColor))&&(t.lineWidth=0),t.beginPath(),at(t,0,0,f,g,1,0),t.fill(),t.lineWidth>0&&t.stroke();const v=l.textStyle;if(v&&v.show&&l.name){t.shadowBlur=0;const x={top:[0,-(g+6)],bottom:[0,g+12],left:[-(g+6),4],right:[g+6,4]},[A,T]=x[v.position]||x.top;t.textAlign=v.position==="left"?"right":v.position==="right"?"left":"center",t.textBaseline="middle",t.font=`${v.fontWeight||"normal"} ${v.fontSize||12}px system-ui, sans-serif`,t.fillStyle=v.color||S,t.fillText(l.name,A,T)}t.restore()}return this._drawnPoints=n,n}_defaultTooltipHTML(t,e){const o=t.series,i=Math.pow(10,t.logX).toPrecision(4),s=Math.pow(10,t.logY).toPrecision(4),n=e.xAxis.title||"X",r=e.yAxis.title||"Y",a=`<div style="font-size:14px; font-weight:bold; margin-bottom:4px; color:#fff;">${(o==null?void 0:o.name)||t.name||"Data Point"}</div>`,l=t.zone?`${t.zone.name||""} ${t.zone.title||t.zone.desc||""}`.trim():"Outside",c=t.zone&&t.zone.color||"#fff";return`
|
|
24
|
+
${a}
|
|
25
|
+
<div style="color:${c}; font-size:13px; font-weight:bold; padding-bottom:8px; margin-bottom:8px; border-bottom:1px solid rgba(255,255,255,0.07);">
|
|
26
|
+
${l}
|
|
27
|
+
</div>
|
|
28
|
+
<div style="display:flex; align-items:center; margin-bottom:6px; font-size:13px;">
|
|
29
|
+
<span style="display:inline-block; width:8px; height:8px; border-radius:50%; background-color:#00e5ff; margin-right:8px;"></span>
|
|
30
|
+
<span style="color:#cbd5e1; flex-grow:1;">${n}</span>
|
|
31
|
+
<span style="color:#fff; font-weight:bold; margin-left:20px;">${i}</span>
|
|
26
32
|
</div>
|
|
27
|
-
<div style="
|
|
28
|
-
<span
|
|
33
|
+
<div style="display:flex; align-items:center; margin-bottom:6px; font-size:13px;">
|
|
34
|
+
<span style="display:inline-block; width:8px; height:8px; border-radius:50%; background-color:#ff6b35; margin-right:8px;"></span>
|
|
35
|
+
<span style="color:#cbd5e1; flex-grow:1;">${r}</span>
|
|
36
|
+
<span style="color:#fff; font-weight:bold; margin-left:20px;">${s}</span>
|
|
29
37
|
</div>
|
|
30
|
-
`}}exports.DiagnosticTools=
|
|
38
|
+
`}}exports.DiagnosticTools=Ot;exports.DuvalPentagon=bt;exports.DuvalTriangle=Gt;exports.ETRAChart=Tt;exports.ETRA_ZONES_A=Xt;exports.ETRA_ZONES_B=Nt;exports.PENTAGON_ZONES_1=it;exports.PENTAGON_ZONES_2=rt;exports.THREE_RADIO_ZONES=kt;exports.TRIANGLE_ZONES_1=Wt;exports.TRIANGLE_ZONES_4=$t;exports.TRIANGLE_ZONES_5=It;exports.ThreeRatioChart=wt;exports.computedPercent=ht;
|
|
31
39
|
//# sourceMappingURL=index.cjs.map
|