@syhr/dga-charts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -0
- package/dist/index.cjs +31 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +2796 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +31 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @syhr/dga-charts
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
基于 IEC 60599 标准的**变压器溶解气体分析(DGA)可视化诊断图表库**。专为电力物联网、变压器状态监测及运维平台打造,提供专业、直观、高性能的故障诊断可视化方案。
|
|
7
|
+
|
|
8
|
+
## ✨ 核心特性
|
|
9
|
+
|
|
10
|
+
- 📦 **开箱即用**:内置标准的诊断区域定义,免去繁琐的坐标计算。
|
|
11
|
+
- 🎨 **极致交互**:支持 Canvas 原生绘制,包含辉光(Glow)特效、多层嵌套区域悬浮交互。
|
|
12
|
+
- 📊 **多维视图**:包含平面的五边形、三角形、ETRA 对数直角坐标图,以及支持多视角无缝切换(3D/主视/侧视/俯视)的三比值法空间图。
|
|
13
|
+
- 🌗 **主题适配**:原生支持 `dark` 与 `light` 模式无缝切换。
|
|
14
|
+
- 🚀 **无依赖**:底层完全使用原生 Canvas 2D 构建,极致轻量,无需依赖 ECharts 或 Three.js。
|
|
15
|
+
|
|
16
|
+
## 📦 安装
|
|
17
|
+
|
|
18
|
+
使用您常用的包管理工具进行安装:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @syhr/dga-charts
|
|
22
|
+
# 或者
|
|
23
|
+
pnpm add @syhr/dga-charts
|
|
24
|
+
# 或者
|
|
25
|
+
yarn add @syhr/dga-charts
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 📈 支持图表类型
|
|
29
|
+
|
|
30
|
+
本图表库包含业界最主流的四大 DGA 诊断流派:
|
|
31
|
+
|
|
32
|
+
1. **Duval Pentagon (Duval 五边形)**
|
|
33
|
+
- 包含 `五边形 1`(通用诊断)和 `五边形 2`(OLTC及充油套管专版)。
|
|
34
|
+
2. **Duval Triangle (Duval 三角形)**
|
|
35
|
+
- 包含 `三角形 1`(常规诊断)、`三角形 4`(低温与局放)、`三角形 5`(热故障细分)。
|
|
36
|
+
3. **IEC 三比值法**
|
|
37
|
+
- 创新的伪 3D 可视化,将比值映射在立体空间中,支持视角无极旋转及 2D 正交投影切换。
|
|
38
|
+
4. **ETRA 对数图 (ETRA Chart)**
|
|
39
|
+
- 日本电气协同研究会(ETRA)对数直角坐标系诊断图,自动适应极端数量级差异跨度。
|
|
40
|
+
|
|
41
|
+
## 🚀 基础用法
|
|
42
|
+
|
|
43
|
+
以 **Duval 五边形**为例:
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<!-- 准备一个具备宽高尺寸的 DOM 容器 -->
|
|
47
|
+
<div id="chart-container" style="width: 100%; height: 400px;"></div>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
import { DuvalPentagon } from '@syhr/dga-charts'
|
|
52
|
+
// 也可以引入内置的 IEC 诊断区域坐标数据
|
|
53
|
+
// import { DUVAL_PENTAGON_ZONES1 } from '@syhr/dga-charts'
|
|
54
|
+
|
|
55
|
+
// 初始化图表实例
|
|
56
|
+
const chart = new DuvalPentagon('#chart-container', {
|
|
57
|
+
theme: 'dark',
|
|
58
|
+
// 支持纯数组数据 [H2, C2H2, C2H4, CH4, C2H6]
|
|
59
|
+
series: [
|
|
60
|
+
{
|
|
61
|
+
name: '主变压器 A相',
|
|
62
|
+
itemStyle: { color: '#00e5ff', radius: 6 },
|
|
63
|
+
glowStyle: { show: true, color: '#00e5ff', blur: 15 },
|
|
64
|
+
data: [120, 5, 80, 40, 10]
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// 监听诊断结果
|
|
70
|
+
chart.on('diagnose', (results) => {
|
|
71
|
+
console.log('故障诊断结果:', results)
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 📖 官方文档
|
|
76
|
+
|
|
77
|
+
详细的 API 参考、进阶配置(如坐标网格自定义、独立气泡样式、交互式 Formatter)以及所有图表的 Live Demo,请查阅我们的官方文档网站。
|
|
78
|
+
|
|
79
|
+
*(建议将此处替换为您部署后的文档实际网址,如 https://shr.dga-chart.ccwu.cc/ )*
|
|
80
|
+
|
|
81
|
+
## 📄 License
|
|
82
|
+
|
|
83
|
+
[MIT](./LICENSE) © SYHR
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
${h}
|
|
3
|
+
<div style="color:${r}; font-size:13px; font-weight:bold; padding-bottom:8px; margin-bottom:8px; border-bottom:1px solid rgba(255,255,255,0.07);">
|
|
4
|
+
${a}
|
|
5
|
+
</div>
|
|
6
|
+
`;return s.forEach((f,g)=>{var y,u,b,w;const p=((u=(y=n[g])==null?void 0:y.labelStyle)==null?void 0:u.color)||((w=(b=o.vertex)==null?void 0:b.labelStyle)==null?void 0:w.color)||"#fff";let m="-";if(l)if(Array.isArray(l)){const v=l[g];if(v&&typeof v=="object"){const x=l.find(C=>C.name===f);m=x&&x.value!==void 0?x.value:"-"}else m=l[g]!==void 0?l[g]:"-"}else typeof l=="object"&&(m=l[f]!==void 0?l[f]:"-");c+=`
|
|
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:${p}; margin-right:8px;"></span>
|
|
9
|
+
<span style="color:#cbd5e1; flex-grow:1;">${f}</span>
|
|
10
|
+
<span style="color:#fff; font-weight:bold; margin-left:20px;">${m}</span>
|
|
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
|
+
${r}
|
|
14
|
+
${c?`<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);">${c}</div>`:""}
|
|
15
|
+
`;const g=["#00e5ff","#ff6b35","#ffcc02"],p=n==null?void 0:n.item;return(h||!h&&!a)&&s.forEach((u,b)=>{const w=g[b%3];let v="-";p&&(Array.isArray(p)?v=p[b]!==void 0?p[b]:"-":typeof p=="object"&&(p.value&&Array.isArray(p.value)?v=p.value[b]!==void 0?p.value[b]:"-":p[u]!==void 0&&(v=p[u]))),f+=`
|
|
16
|
+
<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:${w}; margin-right:8px;"></span>
|
|
18
|
+
<span style="color:#cbd5e1; flex-grow:1;">${u}</span>
|
|
19
|
+
<span style="color:#fff; font-weight:bold; margin-left:20px;">${v}</span>
|
|
20
|
+
</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
|
+
<div style="font-weight:bold; font-size:14px; margin-bottom:6px; color:#fff;">${o.name||"Data Point"}</div>
|
|
23
|
+
<div style="font-size:13px; font-weight:bold; color:${a}; border-bottom:1px solid rgba(255,255,255,0.1); padding-bottom:6px; margin-bottom:8px;">${h}</div>
|
|
24
|
+
<div style="font-size:13px; color:#cbd5e1; display:flex; justify-content:space-between; margin-bottom:4px;">
|
|
25
|
+
<span>${n}:</span><span style="font-weight:bold; color:#fff; margin-left:12px;">${s}</span>
|
|
26
|
+
</div>
|
|
27
|
+
<div style="font-size:13px; color:#cbd5e1; display:flex; justify-content:space-between;">
|
|
28
|
+
<span>${l}:</span><span style="font-weight:bold; color:#fff; margin-left:12px;">${i}</span>
|
|
29
|
+
</div>
|
|
30
|
+
`}}exports.DiagnosticTools=Rt;exports.DuvalPentagon=ut;exports.DuvalTriangle=Nt;exports.ETRAChart=wt;exports.ETRA_ZONES_A=Dt;exports.ETRA_ZONES_B=Yt;exports.PENTAGON_ZONES_1=ot;exports.PENTAGON_ZONES_2=nt;exports.THREE_RADIO_ZONES=Et;exports.TRIANGLE_ZONES_1=Mt;exports.TRIANGLE_ZONES_4=Xt;exports.TRIANGLE_ZONES_5=Ft;exports.ThreeRatioChart=gt;exports.computedPercent=rt;
|
|
31
|
+
//# sourceMappingURL=index.cjs.map
|