2021-07-31 16:43:01 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>DEMO</title>
|
|
|
|
<style>
|
|
|
|
* {
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.container {
|
|
|
|
background-color: #fafafa;
|
|
|
|
border: 1px solid #ccc;
|
2021-08-10 16:10:37 +00:00
|
|
|
position: relative;
|
2021-07-31 16:43:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.down {
|
|
|
|
display: flex;
|
|
|
|
margin-top: 20px;
|
|
|
|
}
|
|
|
|
|
2021-08-10 16:10:37 +00:00
|
|
|
#container {
|
|
|
|
width: 100%;
|
2021-10-29 07:46:18 +00:00
|
|
|
height: 500px;
|
|
|
|
position: relative;
|
|
|
|
overflow: hidden;
|
2021-08-10 16:10:37 +00:00
|
|
|
}
|
|
|
|
|
2021-10-29 07:46:18 +00:00
|
|
|
#leak {
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
opacity: 0;
|
2021-12-09 08:59:44 +00:00
|
|
|
top: 100px;
|
2021-10-29 07:46:18 +00:00
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
padding: 4px;
|
|
|
|
border-top: 1px dashed #000;
|
|
|
|
pointer-events: none;
|
|
|
|
transition: opacity 0.75s ease-in-out;
|
2021-07-31 16:43:01 +00:00
|
|
|
}
|
|
|
|
|
2021-10-29 07:46:18 +00:00
|
|
|
#leak>span {
|
|
|
|
color: #000;
|
2021-07-31 16:43:01 +00:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
2021-10-29 07:46:18 +00:00
|
|
|
<div class="container" id="container">
|
|
|
|
<div id="leak">
|
|
|
|
<span>泄漏区</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-31 16:43:01 +00:00
|
|
|
|
|
|
|
<button id="btn-prev">prev</button>
|
|
|
|
<button id="btn-next">next</button>
|
2021-10-29 07:46:18 +00:00
|
|
|
<button id="resize">resize</button>
|
2021-12-09 08:59:44 +00:00
|
|
|
<button id="relayout">relayout</button>
|
2021-07-31 16:43:01 +00:00
|
|
|
<span id="pos"></span>
|
|
|
|
|
|
|
|
<script src="./../dist/sv.js"></script>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
const Group = SV.Group,
|
|
|
|
Bound = SV.Bound,
|
|
|
|
G6 = SV.G6,
|
|
|
|
Vector = SV.Vector;
|
|
|
|
|
|
|
|
</script>
|
|
|
|
<script src="./Layouter/LinkList.js"></script>
|
|
|
|
<script src="./Layouter/BinaryTree.js"></script>
|
|
|
|
<script src="./Layouter/Stack.js"></script>
|
|
|
|
<script src="./Layouter/LinkQueue.js"></script>
|
|
|
|
<script src="./Layouter/GeneralizedList.js"></script>
|
|
|
|
<script src="./Layouter/ChainHashTable.js"></script>
|
|
|
|
<script src="./Layouter/Array.js"></script>
|
|
|
|
<script src="./Layouter/HashTable.js"></script>
|
|
|
|
<script src="./Layouter/LinkStack.js"></script>
|
2021-08-30 15:57:05 +00:00
|
|
|
<script src="./Layouter/AdjoinMatrixGraph.js"></script>
|
|
|
|
<script src="./Layouter/AdjoinTableGraph.js"></script>
|
2021-07-31 16:43:01 +00:00
|
|
|
<script>
|
|
|
|
|
2021-09-13 13:35:59 +00:00
|
|
|
const curSelectData = { element: null, style: null };
|
2021-07-31 16:43:01 +00:00
|
|
|
|
|
|
|
let cur = SV(document.getElementById('container'), {
|
2021-08-17 15:44:28 +00:00
|
|
|
view: {
|
2021-12-09 08:59:44 +00:00
|
|
|
leakAreaHeight: 130,
|
2021-08-17 15:44:28 +00:00
|
|
|
groupPadding: 40,
|
|
|
|
},
|
2021-07-31 16:43:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2021-08-10 16:10:37 +00:00
|
|
|
let data = [{
|
2021-09-13 13:35:59 +00:00
|
|
|
"LinkList0": {
|
|
|
|
"data": [
|
2021-12-09 08:59:44 +00:00
|
|
|
{ id: 0, data: 'A', index: 1 },
|
|
|
|
{ id: 1, data: 'B', index: 2 },
|
2021-10-29 07:46:18 +00:00
|
|
|
{ id: 2, data: 'C' }
|
|
|
|
],
|
2021-12-09 08:59:44 +00:00
|
|
|
"layouter": "Array"
|
|
|
|
},
|
|
|
|
"LinkList1": {
|
2021-10-29 07:46:18 +00:00
|
|
|
"data": [
|
2021-12-09 08:59:44 +00:00
|
|
|
{ id: 10, data: 'A', next: 11 },
|
|
|
|
{ id: 11, data: 'B', next: 12 },
|
|
|
|
{ id: 12, data: 'C', next: 13 },
|
|
|
|
{ id: 13, data: 'D' }
|
2021-10-29 07:46:18 +00:00
|
|
|
],
|
|
|
|
"layouter": "LinkList"
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
"LinkList0": {
|
2021-09-13 13:35:59 +00:00
|
|
|
"data": [
|
2021-12-09 08:59:44 +00:00
|
|
|
{ id: 10, data: 'A', next: 11, external: 'true' },
|
|
|
|
{ id: 11, next: 12, freed: true }
|
2021-10-29 07:46:18 +00:00
|
|
|
],
|
|
|
|
"layouter": "LinkList"
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
"LinkList0": {
|
|
|
|
"data": [
|
|
|
|
{ id: 0, data: 'A' }
|
2021-08-10 16:10:37 +00:00
|
|
|
],
|
2021-09-13 13:35:59 +00:00
|
|
|
"layouter": "LinkList"
|
2021-08-10 16:10:37 +00:00
|
|
|
}
|
|
|
|
}];
|
|
|
|
|
2021-08-30 15:57:05 +00:00
|
|
|
|
2021-08-10 16:10:37 +00:00
|
|
|
|
2021-07-31 16:43:01 +00:00
|
|
|
let dataIndex = 0,
|
|
|
|
curData = data[dataIndex];
|
|
|
|
|
|
|
|
cur.render(curData);
|
|
|
|
|
|
|
|
document.getElementById('btn-next').addEventListener('click', e => {
|
|
|
|
curData = data[++dataIndex];
|
|
|
|
cur.render(curData);
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById('btn-prev').addEventListener('click', e => {
|
2021-09-13 13:35:59 +00:00
|
|
|
curData = data[--dataIndex];
|
2021-07-31 16:43:01 +00:00
|
|
|
cur.render(curData);
|
|
|
|
});
|
|
|
|
|
|
|
|
const container = document.getElementById('container'),
|
|
|
|
pos = document.getElementById('pos');
|
|
|
|
|
|
|
|
container.addEventListener('mousemove', e => {
|
|
|
|
let x = e.offsetX, y = e.offsetY;
|
|
|
|
pos.innerHTML = `${x},${y}`;
|
|
|
|
});
|
|
|
|
|
2021-10-29 07:46:18 +00:00
|
|
|
document.getElementById('resize').addEventListener('click', e => {
|
|
|
|
container.style.height = 400 + 'px';
|
|
|
|
cur.resize(container.offsetWidth, container.offsetHeight);
|
2021-09-09 15:22:11 +00:00
|
|
|
});
|
2021-07-31 16:43:01 +00:00
|
|
|
|
2021-12-09 08:59:44 +00:00
|
|
|
document.getElementById('relayout').addEventListener('click', e => {
|
|
|
|
console.log();
|
|
|
|
cur.reLayout();
|
|
|
|
});
|
|
|
|
|
2021-10-29 07:46:18 +00:00
|
|
|
const leak = document.getElementById('leak');
|
2021-09-13 13:35:59 +00:00
|
|
|
|
2021-10-29 07:46:18 +00:00
|
|
|
cur.on('onLeakAreaUpdate', payload => {
|
2021-12-09 08:59:44 +00:00
|
|
|
leak.style.opacity = payload.hasLeak? 1: 0;
|
2021-10-29 07:46:18 +00:00
|
|
|
leak.style.top = payload.leakAreaY - 40 + 'px';
|
|
|
|
});
|
2021-09-13 13:35:59 +00:00
|
|
|
|
2021-10-29 07:46:18 +00:00
|
|
|
// -------------------------------------------------------------------------------------------------------
|
2021-09-13 13:35:59 +00:00
|
|
|
|
2021-07-31 16:43:01 +00:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|