-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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(graph): make graph node draggable in none
and circular
layout
#15428
Conversation
Thanks for your contribution! |
This reverts commit 78b2475.
src/data/Graph.ts
Outdated
@@ -333,6 +333,9 @@ class GraphNode { | |||
// Used in traverse of Graph | |||
__visited: boolean; | |||
|
|||
// NOTE: only use in circular layout | |||
private _fixed: boolean = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a better place to store the fixed
status rather than the very basic graph structure. In fact, series-graph.node
has fixed
option. But currently it's only for force layout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently store in the fixed
option of nodeModel
@@ -163,11 +184,55 @@ const _layoutNodesBasedOn: Record<'value' | 'symbolSize', LayoutNode> = { | |||
const radianHalf = halfRemainRadian + _symbolRadiansHalf[node.dataIndex]; | |||
|
|||
angle += radianHalf; | |||
node.setLayout([ | |||
// auto circular layout for not dragged node | |||
!node.getFixed() && node.setLayout([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the circularLayout, perhaps using
node !== draggingNode
Can also do the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only automatically set circular layout for the node not dragged yet, so should check node's fixed state, not only the dragging node. 😂
I have a try: Old: New: I think the "New" one is better. But what's your opinion about it? |
I agree with u 😂, the "new" one is more controllable. |
Thx~ I use the same approach, u could review the latest code. 😂 |
Hi, has there been any update on this? Dragging nodes without force mode enabled would be a very helpful feature! |
This is also an essential feature for me. If I can help in any way with this pull request please let me know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Congratulations! Your PR has been merged. Thanks for your contribution! 👍 |
@pissang @kongmoumou how one is supposed to grab the new coordinates of the node, after it was dragged? I checked the source and I see that pre-defined event handlers for We need to grab new coordinates and sync them with the backend. |
Maybe try this 😂 @jayarjo echarts.getInstanceByDom($0)._chartsViews[0]._model.getData().getItemLayout(0) // dragged node index |
Hi @Ovilia , is there any plan when to release this feature~😂 |
none
and circular
layout
This comment was marked as outdated.
This comment was marked as outdated.
@kongmoumou Thanks for your work! But we are sorry this feature was not mentioned in the release note of v5.4.0 and it can't work due to some unexpected reason. I've listed this feature in |
Thx a lot 🎉~ |
Brief Information
This pull request is in the type of:
What does this PR do?
make graph node draggable when
layout: 'none'
andlayout: 'circular'
Fixed issues
Details
Before: What was the problem?
Currently,
draggable
only work inlayout: 'force'
After: How is it fixed in this PR?
Misc
Related test cases or examples to use the new APIs
test/graph-draggable.html
Others
Merging options
Other information