当前位置:网站首页>Antv X6 canvas zoom
Antv X6 canvas zoom
2022-04-21 08:11:00 【Laugh until the world is embarrassed】
First, I found the knowledge about canvas scaling on the official website , As shown in the screenshot below :

Next, zoom the canvas here , I wrote two buttons , Click the button to zoom in and out accordingly
The code layout is as follows :

Main code :
<div>
<button @click="zoomInFn"> Zoom in </button>
<button @click="zoomOutFn"> narrow </button>
<div id="container"></div>
</div>
zoomInFn () { // Zoom in
this.graph.zoom(0.2)
},
zoomOutFn () { // narrow
this.graph.zoom(-0.2)
},
The effect is as follows :

Complete code :
<template>
<div>
<button @click="zoomInFn"> Zoom in </button>
<button @click="zoomOutFn"> narrow </button>
<div id="container"></div>
</div>
</template>
<script>
import { Graph } from '@antv/x6'
import { GridLayout } from '@antv/layout' // umd In mode , const { GridLayout } = window.layout
export default {
name: 'X6',
mounted () {
this.initComponent()
},
data () {
return {
data: {}, // X6 data
graph: undefined, // new X6
gridLayout: undefined, // new GridLayout
newModel: undefined
}
},
methods: {
zoomInFn () { // Zoom in
this.graph.zoom(0.2)
},
zoomOutFn () { // narrow
this.graph.zoom(-0.2)
},
initComponent () {
this.data = {
nodes: [// node
{
id: 'node1', // String, Optional , Unique identification of the node
width: 80, // Number, Optional , Node size width value
height: 40, // Number, Optional , Node size height value
label: 'hello' // String, Node labels
},
{
id: 'node2', // String, Unique identification of the node
width: 80, // Number, Optional , Node size width value
height: 40, // Number, Optional , Node size height value
label: 'world' // String, Node labels
}
],
edges: [// edge
{
source: 'node1', // String, must , Start node id
target: 'node2' // String, must , The target node id
}
]
}
this.graph = new Graph({
container: document.getElementById('container'),
width: 800,
height: 600,
panning: true // Drag translation
})
this.gridLayout = new GridLayout({
type: 'grid',
width: 600,
height: 400,
center: [300, 200],
rows: 4,
cols: 4
})
this.newModel = this.gridLayout.layout(this.data)
this.graph.fromJSON(this.newModel)
this.graph.centerContent() // Center the canvas
}
}
}
</script>
<style scoped>
</style>
版权声明
本文为[Laugh until the world is embarrassed]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210722285892.html
边栏推荐
- 数据探索性分析(EDA)常用方法大合集
- 【MATLAB】绘制泽尼克多项式
- 类与对象的详解(构造方法的详解)
- 386字典序排数,学会用递归的思想
- Couchdb-垂直越权
- 数据探索性分析(EDA)之数据分布、相关性分析及可视化方法
- An error occurred when VMware prompted to restore the snapshot. The required file could not be found
- Basic concept and storage structure of tree
- 【一、xxx病虫害检测项目】2、网络结构尝试改进:Resnet50、SE、CBAM、Feature Fusion
- set集合
猜你喜欢

【项目】小帽外卖(五)

Usage of go ini

無意中發現了一比特清華妹子的資料庫!

Picture material free material picture material website picture material where to find some picture material download the purpose of picture material picture material product picture material website

【2022DASCTF X SU】 三月春季挑战赛 web复现

Replication of Apache Solr Remote Code Execution Vulnerability (cve-2019-0193)

antv x6画布内容居中

Set set

【C语言入门系列(8)(9)】第八、九章、指针、结构体

Access-Control-Allow-Credentials:true 和 预检请求
随机推荐
跨域是什么和如何解决跨域问题的三种方法
亿级流量多级缓存架构
Display selection reference ladder
photoshop ps 测量角度 简介
Mysql双主双从+Atlas数据测试
Antv X6画布缩放
Basic concept and storage structure of tree
Capturing plaintext password with mimikatz in win10 system
Accidentally found a Tsinghua sister's database!
Installer mongodb
Is int not supported in analyticdb MySQL?
大家在深圳的一天是怎样度过的呢?
[Ethernet switching security] - port security and MAC address drift prevention and detection
Swift memory management
Yolov5.0 calling local camera
[talkative cloud native] load balancing - the passenger flow of small restaurants has increased
图片素材 免费素材 图片素材网站 图片素材在哪里找 哪里有的图片素材下载 图片素材的用途 图片素材 产品图片素材网站 什么的素材可以 PPT素材
数据库实验一、数据库的创建及基本查询
Actual JDBC connection to MySQL database
可以下载到跑LOAM的数据集