Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sankey): add nodeDraggable interaction configure #2521

Merged
merged 8 commits into from
Apr 29, 2021

Conversation

hustcc
Copy link
Member

@hustcc hustcc commented Apr 27, 2021

PR includes

  • 增加 桑基图 节点可拖拽的交互,交互配置化的尝试
  • add / modify test cases
  • documents, demos

Screenshot

Before After
Apr-27-2021 20-41-57

@hustcc
Copy link
Member Author

hustcc commented Apr 27, 2021

  1. 将交互变成配置的形式,降低用户去理解 Interaction 的成本(nodeDraggable),其他图形也可以参考,比如说 treemap、scatter 的 drag-move
  2. 实现原理:
  • 新增一个特殊的 action,仅仅对 sankey 有效(耦合 view 的层级结构)
  • 在 mousemove 过程中,获取 drag 的 x y offset
  • 除以 coordinate 的 width height,得到最后归一化的数据
  • 因为 sankey 是布局算法之后,形成的规划化布局数据,所以直接修改这个布局数据,增加 x y offset 即可
  • 修改 node 的布局位置、以及节点相关的 edge 布局信息
  • render(true)

@hustcc hustcc requested review from lxfu1 and visiky April 27, 2021 12:54
@visiky visiky merged commit 6ae79bb into master Apr 29, 2021
@visiky visiky deleted the feat-sankey-node-draggable branch April 29, 2021 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants