AntV G6按照图形大小百分比进行缩放

编程入门 行业动态 更新时间:2024-10-08 18:31:50

AntV G6按照图形大小<a href=https://www.elefans.com/category/jswz/34/1760575.html style=百分比进行缩放"/>

AntV G6按照图形大小百分比进行缩放

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>图形大小百分比缩放</title><style>::-webkit-scrollbar{display:none;}html,body{overflow:hidden;}</style>
</head>
<body>
<div id="mountNode"></div>
<script>/*Fixing iframe window.innerHeight 0 issue in Safari*/document.body.clientHeight;</script>
<script src=".0.0/g6.js"></script>
<script src=".0.0/g6.js"></script>
<script src=".2.1.min.js"></script>
<script>
$('body').html('<button class="zoom" data-ratio="0.2">20%</button><button class="zoom" data-ratio="0.5">50%</button><button class="zoom" data-ratio="1">100%</button><button class="zoom" data-ratio="1.5">150%</button><button class="zoom" data-ratio="2">200%</button><div id="mountNode"></div>');
var data = {nodes: [{id: 'node1',x: 100,y: 200}, {id: 'node2',x: 300,y: 200}],edges: [{id: 'edge1',target: 'node2',source: 'node1'}]
};
var graph = new G6.Graph({container: 'mountNode',fitView: 'cc',height: window.innerHeight
});
graph.read(data);var buttons = document.getElementsByClassName('zoom');var _loop = function _loop(index) {var button = buttons[index];button.onclick = function() {graph.zoom(Number(button.dataset.ratio));};
};for (var index = 0; index < buttons.length; index++) {_loop(index);
}
</script></body>
</html>

图形结果展示

初始大小

20%大小

50%大小

100%大小

150%大小

200%大小


更多推荐

AntV G6按照图形大小百分比进行缩放

本文发布于:2024-02-27 17:44:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1707607.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:百分比   缩放   图形   大小   AntV

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!