fix:力导向

This commit is contained in:
廖威敬 2022-04-06 11:59:24 +08:00
parent 7b9fffe0ab
commit a9e5bcd224
5 changed files with 150 additions and 20 deletions

View File

@ -62,10 +62,7 @@ SV.registerLayout('Force', {
},
layout(e) {
console.log("here is the layout of Force")
// e.forEach((item, index) => {
// console.log(item.getBound());
// })
}
});

View File

@ -289,4 +289,140 @@ const SOURCES_DATA = [{
"isEnterFunction": false,
"isFirstDebug": false
}
}, {
"force0": {
"data": [
{
"id": "0x617eb1",
"data": "A",
"next": "0x617eb2"
},
{
"id": "0x617eb2",
"data": "B",
"next": "0x617eb3"
},
{
"id": "0x617eb3",
"data": "C",
"next": "0x617eb5"
},
{
"id": "0x617eb5",
"data": "D",
"next": "0x617eb3"
},
{
"id": "0x617eb6",
"data": "D",
"next": "0x617eb5"
},
{
"id": "0x617eb7",
"data": "D",
"next": "0x617eb6"
},
{
"id": "0x617eb8",
"data": "D",
"next": "0x617eb7"
},
{
"id": "0x617eb9",
"data": "D",
"next": "0x617eb8"
},
{
"id": "0x617eba",
"data": "D",
"next": "0x617eb9"
},
{
"id": "0x617ebb",
"data": "D",
"next": "0x617eba"
},
{
"id": "0x617ebc",
"data": "D",
"next": "0x617ebb"
},
{
"id": "0x617ebd",
"data": "D",
"next": "0x617ebc"
},
{
"id": "0x617ebe",
"data": "D",
"next": "0x617ebd"
},
{
"id": "0x627ebe",
"data": "D",
"next": "0x617ebe"
},
{
"id": "0x637ebe",
"data": "D",
"next": "0x627ebe"
},
{
"id": "0x647ebe",
"data": "D",
"next": "0x637ebe"
},
{
"id": "0x657ebe",
"data": "D",
"next": "0x647ebe"
},
{
"id": "0x667ebe",
"data": "D",
"next": "0x657ebe"
},
{
"id": "0x677ebe",
"data": "D",
"next": "0x667ebe"
},
{
"id": "0x687ebe",
"data": "D",
"next": "0x677ebe"
},
{
"id": "0x697ebe",
"data": "D",
"next": "0x687ebe"
},
{
"id": "0x6a7ebe",
"data": "D",
"next": "0x697ebe"
},
{
"id": "0x6b7ebe",
"data": "D",
"next": "0x6a7ebe"
},
{
"id": "0x6c7ebe",
"data": "D",
"next": "0x6b7ebe"
},
{
"id": "0x6d7ebe",
"data": "X",
"next": "0x6c7ebe"
},
{
"id": "0x6e7ebe",
"data": "Y",
"next": "0x6d7ebe"
},
],
"layouter": "Force"
}
}];

View File

@ -86,18 +86,24 @@
<script src="./Layouter/SqQueue.js"></script>
<script src="./Layouter/PTree.js"></script>
<script src="./Layouter/PCTree.js"></script>
<script src="./Layouter/Force.js"></script>
<script src="./data.js"></script>
<script>
let isForce = false;
let dataIndex = 3;
curData = SOURCES_DATA[dataIndex];
// 判断是否需要力导向布局
Object.keys(curData).forEach(key => {
if(curData[key].layouter === "Force") isForce = true;
});
let cur = SV(document.getElementById('container'), {
view: {
leakAreaHeight: 130,
groupPadding: 40,
},
});
let dataIndex = 0,
curData = SOURCES_DATA[dataIndex];
}, isForce);
let enableBrushSelect = false;

View File

@ -38,7 +38,7 @@ export class Renderer {
this.shadowG6Instance = new Graph({
container: DOMContainer.cloneNode() as HTMLElement
});
// 力导向的配置选项
const forceOption = {
type: 'force',
linkDistance: 100, // 边长
@ -51,6 +51,7 @@ export class Renderer {
},
center: [DOMContainer.offsetWidth / 2, DOMContainer.offsetHeight / 3],
};
// 布局配置
const layout = isForce ? forceOption : null;
// 初始化g6实例
this.g6Instance = new Graph({
@ -65,7 +66,7 @@ export class Renderer {
},
modes: behaviorsModes,
plugins: [tooltip],
layout,
layout, // 布局配置
});
/**
*

View File

@ -53,15 +53,6 @@ export class Engine {
* @param prevStep
*/
public render(source: Sources) {
<<<<<<< HEAD
if (source === undefined || source === null) {
return;
}
``
let stringSource = JSON.stringify(source);
if (this.prevStringSource === stringSource) {
return;
=======
let isSameSources: boolean = false,
layoutGroupTable: LayoutGroupTable;
@ -74,7 +65,6 @@ export class Engine {
if (this.prevStringSource === stringSource) {
isSameSources = true;
>>>>>>> eac9d007bcc1b52fe573ddf6cb97030c9b2d3a6d
}
this.prevStringSource = stringSource;