antvis / Graphin

🌌 A React toolkit for graph visualization based on G6.
https://github.com/antvis/graphin
MIT License
1.02k stars 266 forks source link

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

Open ZangYuSong opened 3 years ago

ZangYuSong commented 3 years ago

Graphin 版本:2.0.7

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

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

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<IConfig> = ({ bindKey, ...other }) => {
  useBehaviorHook({
    type: 'create-edge',
    userProps: { ...other, key: bindKey },
    defaultConfig,
  })
  return null
}

export default CreateEdge
ZangYuSong commented 3 years ago

突然发现他在,分析组件内部。

ZangYuSong commented 3 years ago

试了下,Graphin 内置的功能太少了。不如G6 的功能。没有 trigger bindKey shouldBegin shouldEnd 这些功能。能否丰富一下。或者说本身支持只是没有相关的用法示例,麻烦提供一下

pomelo-nwu commented 3 years ago

@ZangYuSong 升级Graphin到最新的2.1.0,里面依赖的G6的最新版本4.3.4,通过context可以拿到G6的实例,更多的功能可以自定义组件实现,比如CreateEdge DEMO

msnyder-msft commented 1 year ago

@pomelo-nwu That demo link doesn't seem to work anymore, is there an updated one? I'm also seeing the code for Create-Edge in the repo but not in the documentation site and I don't see it showing up when I go to consume the package. The create-edge functionality is one of our major requirements for adoption and this library seems really great so I'd love to use it if we can figure that part out. image image

pomelo-nwu commented 1 year ago

@msnyder-msft We were going to drop the @antv/graphin-components package because only components that bind to a specific UI component library will do the job better. For example: https://insight.antv.antgroup.com/#/open/assets-list?assetKey=FilterPanel there are nearly 60 analysis components here.

so we put the non-UI components that only rely on G6 canvas rendering and interaction in graphin/src/components, the migration process may have missed some components, createEdge should be among them.

pomelo-nwu commented 1 year ago

增加 CreateEdge 并且文档中做出说明