fix: create collection report error (#2953)
This commit is contained in:
parent
ac8828196a
commit
93bf86d931
@ -77,7 +77,7 @@ const getGridData = (num, arr) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//初始布局
|
//初始布局
|
||||||
async function layout(createPositions) {
|
async function layout(createPositions, isSaveLayput) {
|
||||||
const { positions } = targetGraph;
|
const { positions } = targetGraph;
|
||||||
let graphPositions = [];
|
let graphPositions = [];
|
||||||
const nodes: any[] = targetGraph.getNodes();
|
const nodes: any[] = targetGraph.getNodes();
|
||||||
@ -126,7 +126,7 @@ async function layout(createPositions) {
|
|||||||
} else {
|
} else {
|
||||||
targetGraph.positionCell(nodes[0], 'top-left', { padding: 100 });
|
targetGraph.positionCell(nodes[0], 'top-left', { padding: 100 });
|
||||||
}
|
}
|
||||||
if (graphPositions.length > 0) {
|
if (graphPositions.length > 0 && isSaveLayput) {
|
||||||
await createPositions(graphPositions);
|
await createPositions(graphPositions);
|
||||||
graphPositions = [];
|
graphPositions = [];
|
||||||
}
|
}
|
||||||
@ -725,14 +725,14 @@ export const GraphDrawPage = React.memo(() => {
|
|||||||
m2mEdge && lightUp(m2mEdge);
|
m2mEdge && lightUp(m2mEdge);
|
||||||
};
|
};
|
||||||
// 全量渲染
|
// 全量渲染
|
||||||
const renderInitGraphCollection = (rawData) => {
|
const renderInitGraphCollection = (rawData, isSaveLayput = true) => {
|
||||||
targetGraph.clearCells();
|
targetGraph.clearCells();
|
||||||
const { nodesData, edgesData, inheritEdges } = formatData(rawData);
|
const { nodesData, edgesData, inheritEdges } = formatData(rawData);
|
||||||
targetGraph.data = { nodes: nodesData, edges: edgesData };
|
targetGraph.data = { nodes: nodesData, edges: edgesData };
|
||||||
targetGraph.fromJSON({ nodes: nodesData });
|
targetGraph.fromJSON({ nodes: nodesData });
|
||||||
targetGraph.addEdges(edgesData);
|
targetGraph.addEdges(edgesData);
|
||||||
targetGraph.addEdges(inheritEdges);
|
targetGraph.addEdges(inheritEdges);
|
||||||
layout(saveGraphPositionAction);
|
layout(saveGraphPositionAction, isSaveLayput);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 增量渲染
|
// 增量渲染
|
||||||
@ -1073,11 +1073,11 @@ export const GraphDrawPage = React.memo(() => {
|
|||||||
if (selectedCollections && collectionList.length) {
|
if (selectedCollections && collectionList.length) {
|
||||||
const selectKeys = selectedCollections?.split(',');
|
const selectKeys = selectedCollections?.split(',');
|
||||||
const data = collectionList.filter((v) => selectKeys.includes(v.name));
|
const data = collectionList.filter((v) => selectKeys.includes(v.name));
|
||||||
renderInitGraphCollection(data);
|
renderInitGraphCollection(data, false);
|
||||||
handelResetLayout(true);
|
handelResetLayout(true);
|
||||||
targetGraph.selectedCollections = selectedCollections;
|
targetGraph.selectedCollections = selectedCollections;
|
||||||
} else {
|
} else {
|
||||||
!selectedCollections && renderInitGraphCollection(collections);
|
!selectedCollections && renderInitGraphCollection(collections, false);
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
cleanGraphContainer();
|
cleanGraphContainer();
|
||||||
|
Loading…
Reference in New Issue
Block a user