Comments (2)
首先非常感谢你的贡献,针对你提到的问题:
- 分层渲染是 G6 5.0 的初步设想,但并未完全实现,因此当前所有插入到画布中的节点都位于主画布(即
graph.getCanvas().main
)。因此你可以先通过graph.getCanvas().main.removeChild(line);
进行删除。 - 如果要获取节点的尺寸,比较准确的方式是直接从元素中获取,以下是相关步骤
假定你的开发的 snapline 是一个插件(Plugin),那么你应该可以访问到 Graph 上下文(即 context,或者你可以先临时通过 graph.context) 访问。
const { element } = context; // element 是一个用于管理元素绘制的模块
const node = element.getElement('xxx'); // 参数为元素 ID
针对节点的尺寸有两种情况:
a. 如果期望是对节点整体对齐(包括节点的标签文本、徽标等),那么你可以直接通过 node.getBounds()
获取其尺寸
b. 如果期望对节点的主图形(key)进对齐,那么可以使用 node.getShape('key').getBounds()
获取主图形尺寸
from g6.
首先非常感谢你的贡献,针对你提到的问题:
- 分层渲染是 G6 5.0 的初步设想,但并未完全实现,因此当前所有插入到画布中的节点都位于主画布(即
graph.getCanvas().main
)。因此你可以先通过graph.getCanvas().main.removeChild(line);
进行删除。- 如果要获取节点的尺寸,比较准确的方式是直接从元素中获取,以下是相关步骤
假定你的开发的 snapline 是一个插件(Plugin),那么你应该可以访问到 Graph 上下文(即 context,或者你可以先临时通过 graph.context) 访问。
const { element } = context; // element 是一个用于管理元素绘制的模块 const node = element.getElement('xxx'); // 参数为元素 ID针对节点的尺寸有两种情况: a. 如果期望是对节点整体对齐(包括节点的标签文本、徽标等),那么你可以直接通过
node.getBounds()
获取其尺寸 b. 如果期望对节点的主图形(key)进对齐,那么可以使用node.getShape('key').getBounds()
获取主图形尺寸
感谢回复,好使!
from g6.
Related Issues (20)
- G6 4.8.21 官方示例决策树中增加内置behavior(click-select)无效
- v4.7.9 使用focusItem方法移动节点至视口中心,节点水平位置始终偏右
- 删除组报组id不存在 HOT 1
- 缩小后,调用fitView或fitCenter 效果不正确 HOT 1
- 浏览器中执行耗时问题 HOT 2
- [v5] layout 方法报不存在 HOT 2
- V5 给node添加一个角度 则连接桩的点会径向往外移动 HOT 1
- 背景图插件:背景色和背景图切换问题-影响使用 HOT 1
- Dragging a combo hides edges HOT 1
- V5 选中状态bug
- dagre布局问题 HOT 1
- [v5] behaviors [collapse-expand] 报错 HOT 1
- polyline 连接线不正确的问题 HOT 1
- [v5]无法复现4.8.1中的comboCombined布局效果
- combo缩略的时候无法高亮,并且无法给缩略图片添加动画
- 【v5】手动拖动画布到任意位置后,使用focusElement接口聚焦元素,元素显示的位置不对 HOT 2
- 【v5】根据节点的画布坐标,获取画布上节点的浏览器坐标数值不对
- combo缩略的时候展示的图片是否可以通过状态动态更改
- 首页3d大图点击下面视频进入连接后报错,页面显示不出来
- [V5] 自定义元素如何设置子元素id和name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from g6.