mirror of
https://gitee.com/antv/g6.git
synced 2024-12-16 02:21:25 +08:00
50 lines
1.3 KiB
HTML
50 lines
1.3 KiB
HTML
<!doctype html>
|
|
<html itemscope="" itemtype="http://schema.org/SearchResultsPage" lang="en">
|
|
|
|
<head>
|
|
<meta content="origin" name="referrer">
|
|
<title>plugin-fisheye</title>
|
|
<script src="../build/g6.js"></script>
|
|
<script src="./assets/jquery-3.2.1.min.js"></script>
|
|
<script src="../build/plugin.tool.fisheye.js"></script>
|
|
<script src="../build/plugin.util.randomData.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<div id='mountNode'></div>
|
|
<script>
|
|
const Util = G6.Util;
|
|
const data = Util.createNodesData(30);
|
|
const width = window.innerWidth;
|
|
const height = window.innerHeight;
|
|
const FisheyePlugin = G6.Plugins['tool.fisheye'];
|
|
const graph = new G6.Graph({
|
|
container: 'mountNode',
|
|
width,
|
|
height,
|
|
plugins: [new FisheyePlugin()],
|
|
layout(nodes) {
|
|
const col = 30;
|
|
const hgap = 30;
|
|
const vgap = 30;
|
|
|
|
nodes.forEach((node, index) => {
|
|
if (parseInt(index / col) % 2 === 0) {
|
|
node.x = (col - index % col) * hgap;
|
|
node.ori_x = node.x;
|
|
} else {
|
|
node.x = index % col * hgap + hgap;
|
|
node.ori_x = node.x;
|
|
}
|
|
node.y = parseInt(index / col) * vgap + vgap / 2;
|
|
node.ori_y = node.y;
|
|
});
|
|
}
|
|
});
|
|
graph.node({size: 20});
|
|
graph.read(data);
|
|
|
|
</script>
|
|
</body>
|