Git Product home page Git Product logo

Comments (2)

Aarebecca avatar Aarebecca commented on July 2, 2024 1

首先非常感谢你的贡献,针对你提到的问题:

  1. 分层渲染是 G6 5.0 的初步设想,但并未完全实现,因此当前所有插入到画布中的节点都位于主画布(即 graph.getCanvas().main)。因此你可以先通过 graph.getCanvas().main.removeChild(line); 进行删除。
  2. 如果要获取节点的尺寸,比较准确的方式是直接从元素中获取,以下是相关步骤

假定你的开发的 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.

k644606347 avatar k644606347 commented on July 2, 2024

首先非常感谢你的贡献,针对你提到的问题:

  1. 分层渲染是 G6 5.0 的初步设想,但并未完全实现,因此当前所有插入到画布中的节点都位于主画布(即 graph.getCanvas().main)。因此你可以先通过 graph.getCanvas().main.removeChild(line); 进行删除。
  2. 如果要获取节点的尺寸,比较准确的方式是直接从元素中获取,以下是相关步骤

假定你的开发的 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.