From ee116a0f79327b2e915dcb5767aaf07d59f35302 Mon Sep 17 00:00:00 2001 From: susiwen8 Date: Wed, 13 Apr 2022 22:14:33 +0800 Subject: [PATCH] fix(graph): user cursor has higher priority (#16867) * fix(graph): user cursor has higher priority * fix(graph): simplify code --- 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..9295f306d8 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 && 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 },