mirror of
https://gitee.com/antv/g6.git
synced 2024-12-04 20:59:15 +08:00
fix(util): fix radial layout when tree has root only
This commit is contained in:
parent
004cb3ce56
commit
7557c6a2b1
@ -3,7 +3,6 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<script src="../test/unit/graph/tree-graph-spec.js"></script>
|
||||
</head>
|
||||
<style>
|
||||
</style>
|
||||
@ -27,7 +26,14 @@
|
||||
rankSep: 100
|
||||
})},
|
||||
compactBox: function(data) {
|
||||
return Hierarchy.compactBox(data, { direction: 'LR' });
|
||||
return Hierarchy.compactBox(data, {
|
||||
direction: 'LR',
|
||||
getId(d) { return d.id; },
|
||||
getHeight() { return 16 },
|
||||
getWidth() { return 16 },
|
||||
getVGap() { return 50 },
|
||||
getHGap() { return 50 }
|
||||
});
|
||||
}
|
||||
};
|
||||
const graph = new G6.TreeGraph({
|
||||
@ -122,6 +128,7 @@
|
||||
if (e.target.checked) {
|
||||
graph.set('layout', (data) => {
|
||||
data = layouts[currentLayout](data);
|
||||
console.log(data.x, data.y);
|
||||
G6.Util.radialLayout(data);
|
||||
return data;
|
||||
});
|
||||
|
@ -83,6 +83,9 @@ const GraphicUtil = {
|
||||
});
|
||||
const avgRad = Math.PI * 2 / count;
|
||||
const radDiff = max[radScale] - min[radScale];
|
||||
if (radDiff === 0) {
|
||||
return data;
|
||||
}
|
||||
this.traverseTree(data, node => {
|
||||
const radial = (node[radScale] - min[radScale]) / radDiff * (Math.PI * 2 - avgRad) + avgRad;
|
||||
const r = node[rScale];
|
||||
|
Loading…
Reference in New Issue
Block a user