(graph: G6.Graph)
| 81 | |
| 82 | /** 获取图表状态 */ |
| 83 | export function getGraphState(graph: G6.Graph): GraphState { |
| 84 | let graphState: GraphState = GraphState.MultiSelected; |
| 85 | |
| 86 | const selectedNodes = getSelectedNodes(graph); |
| 87 | const selectedEdges = getSelectedEdges(graph); |
| 88 | |
| 89 | if (selectedNodes.length === 1 && !selectedEdges.length) { |
| 90 | graphState = GraphState.NodeSelected; |
| 91 | } |
| 92 | |
| 93 | if (selectedEdges.length === 1 && !selectedNodes.length) { |
| 94 | graphState = GraphState.EdgeSelected; |
| 95 | } |
| 96 | |
| 97 | if (!selectedNodes.length && !selectedEdges.length) { |
| 98 | graphState = GraphState.CanvasSelected; |
| 99 | } |
| 100 | |
| 101 | return graphState; |
| 102 | } |
| 103 | |
| 104 | /** 设置选中元素 */ |
| 105 | export function setSelectedItems(graph: G6.Graph, items: G6.Item[] | string[]) { |
no test coverage detected