From 18449ae8814d95eb4ea7b594b103b8d0e937c45b Mon Sep 17 00:00:00 2001 From: Yanyan-Wang Date: Tue, 8 Aug 2023 20:27:12 +0800 Subject: [PATCH] chore: refine --- packages/g6/src/runtime/controller/data.ts | 2 +- packages/g6/tests/demo/tree/tree-graph.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/g6/src/runtime/controller/data.ts b/packages/g6/src/runtime/controller/data.ts index 72807528e1..52e27ead13 100644 --- a/packages/g6/src/runtime/controller/data.ts +++ b/packages/g6/src/runtime/controller/data.ts @@ -505,7 +505,7 @@ export class DataController { data = treeData2GraphData(value); } else if (type === 'fetch') { // TODO: fetch - } else { + } else if (!(data as GraphData).nodes) { console.warn( 'Input data type is invalid, the type shuold be "graphData", "treeData", or "fetch".', ); diff --git a/packages/g6/tests/demo/tree/tree-graph.ts b/packages/g6/tests/demo/tree/tree-graph.ts index 2d97c9dd39..2851ea3f7b 100644 --- a/packages/g6/tests/demo/tree/tree-graph.ts +++ b/packages/g6/tests/demo/tree/tree-graph.ts @@ -55,7 +55,7 @@ const graphDataCfg = { type: 'graphData', value: { nodes: [ - { id: 'node1', data: { isRoot: true, collapsed: true } }, + { id: 'node1', data: { isRoot: true } }, // , collapsed: true { id: 'node2', data: {} }, { id: 'node3', data: {} }, { id: 'node4', data: {} }, @@ -64,9 +64,9 @@ const graphDataCfg = { edges: [ { id: 'edge1', source: 'node1', target: 'node2', data: {} }, { id: 'edge2', source: 'node1', target: 'node3', data: {} }, - { id: 'edge3', source: 'node1', target: 'node4', data: {} }, - // { id: 'edge4', source: 'node2', target: 'node3', data: {} }, - // { id: 'edge5', source: 'node3', target: 'node4', data: {} }, + // { id: 'edge3', source: 'node1', target: 'node4', data: {} }, + { id: 'edge4', source: 'node2', target: 'node3', data: {} }, + { id: 'edge5', source: 'node3', target: 'node4', data: {} }, { id: 'edge6', source: 'node4', target: 'node5', data: {} }, ], }, @@ -206,8 +206,8 @@ export default async () => { // }, // }, // }, - data: treeDataCfg, - // data: graphDataCfg, + // data: treeDataCfg, + data: graphDataCfg, modes: { default: [ 'drag-canvas', @@ -239,9 +239,9 @@ export default async () => { /** === change layout === */ // graph.layout({ type: 'compactBox' }); /** === collapse / expand === */ - const ids = ['root2', 'root']; //['root']; //['node1']; // - collapsed ? graph.expand(ids) : graph.collapse(ids); - collapsed = !collapsed; + // const ids = ['root2', 'root']; //['root']; //['node1']; // + // collapsed ? graph.expand(ids) : graph.collapse(ids); + // collapsed = !collapsed; }); graph.on('canvas:contextmenu', (e) => {