antvis / antvis/Graphin

G6有 create-edge 内置的 Behavior,但是 Graphin 没有

Open
#260 6 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
1.1k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

Graphin 版本:2.0.7

描述:G6有 create-edge 内置的 Behavior,但是 Graphin 没有

下边是我自己写(勿喷):

```ts
import { FC } from 'react'
import useBehaviorHook from '@antv/graphin/es/behaviors/useBehaviorHook'
import { EdgeConfig, GraphEvent } from '@antv/graphin'

interface IConfig {
disabled?: boolean
trigger?: 'click' | 'drag'
bindKey?: 'shift' | 'ctrl' | 'control' | 'alt' | 'meta'
edgeConfig?: EdgeConfig
shouldBegin?: (e: GraphEvent) => void
shouldEnd?: (e: GraphEvent) => void
}

const defaultConfig = {
disabled: false,
}

const CreateEdge: FC = ({ bindKey, ...other }) => {
useBehaviorHook({
type: 'create-edge',
userProps: { ...other, key: bindKey },
defaultConfig,
})
return null
}

export default CreateEdge
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.