From 6e8dd48d4c5d6599dfa796107137b3a26c3acaa7 Mon Sep 17 00:00:00 2001 From: shellway <413209390@qq.com> Date: Thu, 6 Aug 2026 17:22:43 +0800 Subject: [PATCH] =?UTF-8?q?v8:=20=E8=8A=82=E7=82=B9=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=82=A1=E6=9D=83=E6=AF=94=E4=BE=8B=E6=A0=87=E7=AD=BE=20+=20?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E4=BC=81=E4=B8=9A=E6=94=BE=E5=A4=A7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=95=B4=E6=9D=A1=E7=BA=BF=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- viewer/股权架构查看器.html | 55 ++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/viewer/股权架构查看器.html b/viewer/股权架构查看器.html index 6b2981d..807fd62 100644 --- a/viewer/股权架构查看器.html +++ b/viewer/股权架构查看器.html @@ -135,8 +135,20 @@ var baseOption = { top:'4%', bottom:'4%', left:'2%', right:'2%', symbol:'circle', symbolSize:7, initialTreeDepth:1, expandAndCollapse:true, roam:true, - label:{ position:'bottom', fontSize:11, color:'#333', formatter:'{b}', distance:4 }, - leaves:{ label:{ position:'bottom', fontSize:11, color:'#333' } }, + label:{ position:'bottom', fontSize:11, color:'#333', + formatter:function(p){ + var nm = p.data ? p.data.name : ''; + var rt = p.data && p.data.ratio; + if (rt != null && rt > 0) return nm + ' (' + Math.round(rt*100) + '%)'; + return nm; + }, distance:4 }, + leaves:{ label:{ position:'bottom', fontSize:11, color:'#333', + formatter:function(p){ + var nm = p.data ? p.data.name : ''; + var rt = p.data && p.data.ratio; + if (rt != null && rt > 0) return nm + ' (' + Math.round(rt*100) + '%)'; + return nm; + } } }, emphasis:{ focus:'descendant' }, edgeShape:'polyline', lineStyle:{ color:'#999', width:1.2, curveness:0 }, @@ -157,7 +169,19 @@ function setZoom(z) { } document.getElementById('btnZoomIn').onclick = function(){ setZoom(zoom * 1.25); }; document.getElementById('btnZoomOut').onclick = function(){ setZoom(zoom / 1.25); }; -document.getElementById('btnReset').onclick = function(){ zoom = 1.0; applySize(); showTip('已重置视图'); }; +document.getElementById('btnReset').onclick = function(){ + zoom = 1.0; + chart.setOption({ series:[{ data: [rootNode], initialTreeDepth:1, + label:{ position:'bottom', fontSize:11, color:'#333', + formatter:function(p){ + var nm = p.data ? p.data.name : ''; + var rt = p.data && p.data.ratio; + if (rt != null && rt > 0) return nm + ' (' + Math.round(rt*100) + '%)'; + return nm; + }, distance:4 } }] }); + applySize(); + showTip('已重置视图'); +}; function collectParents(n, arr) { if (n.children && n.children.length) { arr.push(n.name); n.children.forEach(function(c){ collectParents(c, arr); }); } @@ -263,9 +287,30 @@ clearBtn.onclick = function(){ chart.setOption({ series:[{ data: [rootNode], initialTreeDepth:1, label:{formatter:'{b}', rich:{}} }] }); }; +// 点击节点 → 放大显示整条股权路径(剪枝 + 自动 fit) chart.on('click', function(p){ - if (p.data && p.data.children && p.data.children.length) { - showTip('「'+p.data.name+'」共 ' + p.data.children.length + ' 家子公司'); + if (!p.data || !p.data.name) return; + var nm = p.data.name; + var path = findPath(nm, rootNode, []); + if (path && path.length) { + var pruned = prunePath(nm); + if (pruned) { + chart.setOption({ + series: [{ + data: pruned, + initialTreeDepth: 99, + label: { + formatter: function(p2){ + var n2 = p2.data ? p2.data.name : ''; + var rt = p2.data && p2.data.ratio; + if (rt != null && rt > 0) return n2 + ' (' + Math.round(rt*100) + '%)'; + return n2; + } + } + }] + }); + showTip('已放大显示「'+nm+'」的完整股权线路,点击🔄重置或搜索框清除返回全貌'); + } } });