更新数据 #5333
laibin-wang posted onGitHub
G6 Version
5.x
Describe the bug
第一次根据查询条件查出数据正常渲染,修改查询条件,使用新数据,报错!
v4的版本正常
Your Example Website or App
无
Steps to Reproduce the Bug or Issue
` import { Graph, Extensions, extend } from '@antv/g6';
let data = { "edges": [], "nodes": [ { "id": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "label": "172.23.100.124", "type": null, "depth": 0, "businessName": "", "businessId": null, "assetName": "", "assetType": 7, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "92cc227532d17e56e07902b254dfad10", "label": "默认系统", "type": null, "depth": 0, "businessName": "", "businessId": 2, "assetName": "", "assetType": 9, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null } ], "graphId": "914efebc5162429e9a28be39fcdbade4:0498749b7a644a7e9f690f1e930fac70", "next": true };
let data2 = { "edges": [ { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "c392c5869d8dc3a305386d1c5468a16b", "targetName": "/SendSms", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "934a079a69581f60e75080c23aa3dcbd", "targetName": "/api/upload", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "a54db30c602a9a1497cf468384bbbfed", "targetName": "/upload", "count": 1, "sensitiveTag": null }, { "source": "b6ee7abdecbb43241f599ffebeb036ce", "sourceName": "timeout=5", "target": "ee05a9e798ab519e02b6bdb5c72728e2", "targetName": "/server/info", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "b6ee7abdecbb43241f599ffebeb036ce", "targetName": "timeout=5", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "1e20fefaaa4487eef0f209a4cbe06c46", "targetName": "/windows/command", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "105a48d1562094cfecdf8d7f4dfb7691", "targetName": "/infoname", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "8cc6453b4d59eabdeecf8e508233a8ab", "targetName": "/v2/login", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "136954a351bb5180eabd843f1687abaa", "targetName": "/linux/command", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "13376099d0869838e9640f4a296fc385", "targetName": "/command/run", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "ee05a9e798ab519e02b6bdb5c72728e2", "targetName": "/server/info", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "d78f245b3c1e5672762d33498c542d5c", "targetName": "/data/download", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "206b207cde887e4e58dfc50ed962c602", "targetName": "/user/id", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "323367a3f6b47e77d2bd6abf08cf5888", "targetName": "/user/name", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "de83fac28aaf5682b930a8c0dbed7aed", "targetName": "/file/download", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "02d5f98af9f5aad307546000829efa82", "targetName": "/login/oauth", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "c0efc6938d2806d225985a0aa96a25c8", "targetName": "/api/sys/download", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "65b0a44427c1466ea1e5e8b69a977368", "targetName": "/login", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "9c69f4df7b4243ab366c9fe6a7cbd902", "targetName": "/user/mobile", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "f20bba7017ad52d4d4921a2c77bcfea9", "targetName": "/interface2", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "d7008aa8bd38dc2359fba08ac6656c5f", "targetName": "/importfile", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "a9ecea5f7b28cfb5110a47bbc4ded10c", "targetName": "/api/sys/login", "count": 1, "sensitiveTag": null }, { "source": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "sourceName": "172.23.100.124", "target": "4fe67a4d200216c0b3e991cfac710d9e", "targetName": "/Send_Sms", "count": 1, "sensitiveTag": null } ], "nodes": [ { "id": "ee05a9e798ab519e02b6bdb5c72728e2", "label": "/server/info", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "d78f245b3c1e5672762d33498c542d5c", "label": "/data/download", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "8cc6453b4d59eabdeecf8e508233a8ab", "label": "/v2/login", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "d7008aa8bd38dc2359fba08ac6656c5f", "label": "/importfile", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "1e20fefaaa4487eef0f209a4cbe06c46", "label": "/windows/command", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "02d5f98af9f5aad307546000829efa82", "label": "/login/oauth", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "206b207cde887e4e58dfc50ed962c602", "label": "/user/id", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "c0efc6938d2806d225985a0aa96a25c8", "label": "/api/sys/download", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "934a079a69581f60e75080c23aa3dcbd", "label": "/api/upload", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "c392c5869d8dc3a305386d1c5468a16b", "label": "/SendSms", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "f20bba7017ad52d4d4921a2c77bcfea9", "label": "/interface2", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "13376099d0869838e9640f4a296fc385", "label": "/command/run", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "4fe67a4d200216c0b3e991cfac710d9e", "label": "/Send_Sms", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "136954a351bb5180eabd843f1687abaa", "label": "/linux/command", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "105a48d1562094cfecdf8d7f4dfb7691", "label": "/infoname", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "a9ecea5f7b28cfb5110a47bbc4ded10c", "label": "/api/sys/login", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "6e9ff4b0abffa0c41eb0a8cf2c981da7", "label": "172.23.100.124", "type": null, "depth": 0, "businessName": "", "businessId": null, "assetName": "", "assetType": 7, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "b6ee7abdecbb43241f599ffebeb036ce", "label": "timeout=5", "type": null, "depth": 1, "businessName": "", "businessId": null, "assetName": "", "assetType": 8, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "de83fac28aaf5682b930a8c0dbed7aed", "label": "/file/download", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "9c69f4df7b4243ab366c9fe6a7cbd902", "label": "/user/mobile", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "65b0a44427c1466ea1e5e8b69a977368", "label": "/login", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "92cc227532d17e56e07902b254dfad10", "label": "默认系统", "type": null, "depth": 0, "businessName": "", "businessId": 2, "assetName": "", "assetType": 9, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "323367a3f6b47e77d2bd6abf08cf5888", "label": "/user/name", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null }, { "id": "a54db30c602a9a1497cf468384bbbfed", "label": "/upload", "type": null, "depth": 3, "businessName": "", "businessId": null, "assetName": "", "assetType": 6, "dataType": null, "count": null, "sensitiveTag": null, "method": "", "apiUri": null, "apiId": null, "appId": null, "dbAssetId": null, "serverIp": null, "serverPort": null, "eventType": null, "hostname": null, "entityPrimaryId": null, "entityParentPrimaryId": null } ], "graphId": "914efebc5162429e9a28be39fcdbade4:73c53b904a944fb3b439d0fcbe7a8668", "next": true }; const ExtGraph = extend(Graph, { layouts: { forceAtlas2: Extensions.ForceAtlas2Layout, }, });
const container = document.getElementById('container'); const width = container.scrollWidth; const height = container.scrollHeight || 500;
const graph = new ExtGraph({
container: 'container',
width,
height,
transforms: [
{
type: 'transform-v4-data',
activeLifecycle: ['read'],
},
], modes: { default: ['zoom-canvas', 'drag-canvas', 'drag-node', 'click-select'], }, layout: { type: 'forceAtlas2', preventOverlap: true, kr: 20, center: [250, 250], }, autoFit: 'view', data, }); window.graph = graph;
setTimeout(() => { console.log('数据变化', graph) graph.changeData(data2) }, 1000 * 8 )
// fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/relations.json') // .then((res) => res.json()) // .then((data) => { // });
`
Expected behavior
上面代码
Screenshots or Videos
上面代码
Platform
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
Additional context
No response