From 0c92a362e36d4177d2d69440e5b489a58bba616e Mon Sep 17 00:00:00 2001 From: susiwen8 Date: Mon, 11 Apr 2022 22:43:21 +0800 Subject: [PATCH 1/2] fix(graph): user cursor has higher priority --- src/chart/graph/GraphSeries.ts | 1 + src/chart/graph/GraphView.ts | 2 +- src/chart/helper/Symbol.ts | 4 ++-- test/graph-symbol.html | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/chart/graph/GraphSeries.ts b/src/chart/graph/GraphSeries.ts index 51e34314b8..d6c84687af 100644 --- a/src/chart/graph/GraphSeries.ts +++ b/src/chart/graph/GraphSeries.ts @@ -106,6 +106,7 @@ export interface GraphNodeItemOption extends SymbolOptionMixin, GraphNodeStateOp category?: number | string draggable?: boolean + cursor?: string } export interface GraphEdgeStateOption { diff --git a/src/chart/graph/GraphView.ts b/src/chart/graph/GraphView.ts index 3b2d0cf3ca..37d0086927 100644 --- a/src/chart/graph/GraphView.ts +++ b/src/chart/graph/GraphView.ts @@ -150,7 +150,7 @@ class GraphView extends ChartView { } }); } - el.setDraggable(draggable && !!forceLayout); + el.setDraggable(draggable && !!forceLayout, !!itemModel.get('cursor')); const focus = itemModel.get(['emphasis', 'focus']); diff --git a/src/chart/helper/Symbol.ts b/src/chart/helper/Symbol.ts index efb45428ae..bd7c980509 100644 --- a/src/chart/helper/Symbol.ts +++ b/src/chart/helper/Symbol.ts @@ -141,10 +141,10 @@ class Symbol extends graphic.Group { symbolPath.z = z; } - setDraggable(draggable: boolean) { + setDraggable(draggable: boolean, hasCursorOption?: boolean) { const symbolPath = this.childAt(0) as ECSymbol; symbolPath.draggable = draggable; - symbolPath.cursor = draggable ? 'move' : symbolPath.cursor; + symbolPath.cursor = hasCursorOption ? symbolPath.cursor : draggable ? 'move' : symbolPath.cursor; } /** diff --git a/test/graph-symbol.html b/test/graph-symbol.html index 61f9276fe5..0c023aca01 100644 --- a/test/graph-symbol.html +++ b/test/graph-symbol.html @@ -81,6 +81,8 @@ }, } }, + draggable: true, + cursor: 'help', force: { repulsion: 1000 }, From 71271099182e6e5902c6a5a07c5953e4a64fd6be Mon Sep 17 00:00:00 2001 From: susiwen8 Date: Tue, 12 Apr 2022 13:40:22 +0800 Subject: [PATCH 2/2] fix(graph): simplify code --- src/chart/helper/Symbol.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chart/helper/Symbol.ts b/src/chart/helper/Symbol.ts index bd7c980509..9295f306d8 100644 --- a/src/chart/helper/Symbol.ts +++ b/src/chart/helper/Symbol.ts @@ -144,7 +144,7 @@ class Symbol extends graphic.Group { setDraggable(draggable: boolean, hasCursorOption?: boolean) { const symbolPath = this.childAt(0) as ECSymbol; symbolPath.draggable = draggable; - symbolPath.cursor = hasCursorOption ? symbolPath.cursor : draggable ? 'move' : symbolPath.cursor; + symbolPath.cursor = !hasCursorOption && draggable ? 'move' : symbolPath.cursor; } /**