From 4468cc62358423a21797b5946af82f2d8ed64619 Mon Sep 17 00:00:00 2001 From: "yilin.qyl" Date: Wed, 13 Feb 2019 10:47:10 +0800 Subject: [PATCH] fix(util): fix tree layout demo --- demos/tree-graph.html | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/demos/tree-graph.html b/demos/tree-graph.html index 282f1e0825..ef3a61ee4b 100644 --- a/demos/tree-graph.html +++ b/demos/tree-graph.html @@ -125,10 +125,10 @@ graph.render(); graph.fitView(); document.getElementById('radial').addEventListener('change', e => { - if (e.target.checked) { + radial = e.target.checked; + if (radial) { graph.set('layout', (data) => { data = layouts[currentLayout](data); - console.log(data.x, data.y); G6.Util.radialLayout(data); return data; }); @@ -145,11 +145,16 @@ const layout = e.target.value; if (currentLayout !== layout) { currentLayout = layout; - graph.set('layout', layouts[currentLayout]); - graph.render(); if (radial) { - G6.Util.radialLayout(graph, 'LR'); + graph.set('layout', (data) => { + data = layouts[currentLayout](data); + G6.Util.radialLayout(data); + return data; + }); + } else { + graph.set('layout', layouts[currentLayout]); } + graph.render(); graph.fitView(); } });