82 lines
1.7 KiB
HTML
82 lines
1.7 KiB
HTML
<!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 {
|
|
width: 100%;
|
|
height: 600px;
|
|
background-color: #fafafa;
|
|
}
|
|
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container" id="container"></div>
|
|
<button id="btn">change</button>
|
|
<button id="btn-next">reLayout</button>
|
|
<button id="btn-set">set</button>
|
|
<span id="pos"></span>
|
|
|
|
|
|
<script src="./../dist/sv.js"></script>
|
|
<script>
|
|
|
|
const Engine = SV.Engine,
|
|
Group = SV.Group,
|
|
Bound = SV.Bound,
|
|
G6 = SV.G6;
|
|
|
|
</script>
|
|
<script src="./dataStruct/BinaryTree.js"></script>
|
|
<script src="./dataStruct/LinkList.js"></script>
|
|
<script src="./dataStruct/Array.js"></script>
|
|
<script src="./dataStruct/ChainHashTable.js"></script>
|
|
<script src="./dataStruct/Stack.js"></script>
|
|
<script src="./dataStruct/LinkStack.js"></script>
|
|
<script>
|
|
|
|
const engines = [BTree, LList, A, CHT, St, LStack];
|
|
|
|
let cur = engines[5](document.getElementById('container'));
|
|
|
|
cur.engine.render(cur.data[0]);
|
|
|
|
document.getElementById('btn').addEventListener('click', e => {
|
|
cur.engine.render(cur.data[1]);
|
|
});
|
|
|
|
document.getElementById('btn-next').addEventListener('click', e => {
|
|
cur.engine.reLayout();
|
|
});
|
|
|
|
document.getElementById('btn-set').addEventListener('click', e => {
|
|
let els = cur.engine.getElements();
|
|
|
|
els.map(item => {
|
|
item.set('style', { fill: 'red' });
|
|
});
|
|
});
|
|
|
|
|
|
const container = document.getElementById('container'),
|
|
pos = document.getElementById('pos');
|
|
|
|
container.addEventListener('mousemove', e => {
|
|
let x = e.offsetX, y = e.offsetY;
|
|
pos.innerHTML = `${x},${y}`;
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html> |