Skip to content

Conversation

TZZack
Copy link
Contributor

@TZZack TZZack commented Apr 15, 2025

@TZZack TZZack force-pushed the chore-custom-behavior-doc-zzz branch from 6ab8070 to be034d3 Compare April 16, 2025 06:51
@TZZack TZZack changed the title doc: 改造自定义交互的文档 docs: 改造自定义交互的文档 Apr 16, 2025
@@ -5,57 +5,119 @@ order: 3

## 概述

交互的执行逻辑通常为:1. 监听用户交互事件 2. 根据事件更新画布或执行其他操作。例如 `DragCanvas` 交互监听指针拖拽事件,根据拖拽的距离更新相机的位置
自定义交互允许用户基于 G6 提供的完善的事件机制,把一个或多个相关的交互行为定义为一个完整的交互,以此实现符合业务场景的交互逻辑
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加一个跳转链接吧 [事件机制](/api/event)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

- 但基于可视化的概念区分,交互通常用于处理用户交互事件,而插件通常用于处理画布的渲染逻辑、额外组件渲染等

:::info{title=提示}
因概念上的区分,交互实例不可获取,插件实例可获取( [getPluginInstance](/api/) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里也链到 /api/plugin#graphgetplugininstancekey

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed(漏了,自检时没看到哈)


- `目的`:当用户在实现符合业务场景的交互逻辑时,我们通常需要配合 G6 的事件系统,对相关事件作出响应,执行需要的交互逻辑。
- `不使用自定义交互`:如果不使用自定义交互,用户需要在创建 Graph 实例后,通过 `graph.on` 进行一系列的事件监听和响应处理,代码逻辑处理和编排会显得异常艰难。
- `交互的优势`:每个交互行为都是独立的代码模块,交互系统的存在方便用户解耦业务逻辑、避免代码臃肿以及方便用户后续维护等。
Copy link
Contributor

@yvonneyx yvonneyx Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里最好再加一个自定义交互的情况附带示例教程,当内置交互无法完全满足业务需求时,用户可以通过继承内置交互并进行调整和修改来自定义,比如说 #7032

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed
image

@yvonneyx yvonneyx added the OSCP label Apr 16, 2025
@TZZack TZZack force-pushed the chore-custom-behavior-doc-zzz branch from be034d3 to 5f11568 Compare April 16, 2025 13:26
@yvonneyx yvonneyx merged commit 7680243 into antvis:v5 Apr 17, 2025
1 check passed
@TZZack TZZack deleted the chore-custom-behavior-doc-zzz branch April 18, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Docs]: 改造文档「交互 - 自定义交互」
2 participants