Skip to content

Commit

Permalink
fixed an issue where a deleted node was not reflected on the export o…
Browse files Browse the repository at this point in the history
…f the uploaded glm files
  • Loading branch information
itsMando committed Jan 29, 2025
1 parent 3d68d81 commit 87db5df
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 6 additions & 2 deletions glimpse/config/appConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"bold": "20px arial black"
},
"scaling": {
"min": 5,
"max": 75
"min": 10,
"max": 55
}
},
"interaction": {
Expand Down Expand Up @@ -131,6 +131,10 @@
"size": 30,
"strokeWidth": 5,
"strokeColor": "white"
},
"smooth": {
"enabled": false,
"type": "continuous"
}
},
"interaction": {
Expand Down
13 changes: 12 additions & 1 deletion glimpse/renderer/src/components/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,21 @@ const Graph = ({ dataToVis, theme, isGlm }) => {
* @param {string} nodeID the ID of a node to delete
*/
const deleteNode = (nodeID) => {
// delete from file data
Object.keys(dataToVis).forEach((filename) => {
console.log(filename);
const objects = dataToVis[filename].objects;

dataToVis[filename].objects = objects.filter((obj) => obj.attributes.name !== nodeID);
});

const nodeObject = graphData.nodes.get(nodeID);
// get node obj and subtract from that node type's count
objectTypeCount.nodes[nodeObject.group]--;

const edgesToDelete = [];
for (let edge of graphData.edges.get()) {
const graphEdges = graphData.edges.get();
for (let edge of graphEdges) {
if (edge.from === nodeID || edge.to === nodeID) {
edgesToDelete.push(edge.id);
objectTypeCount.edges[edge.type]--;
Expand All @@ -604,6 +613,8 @@ const Graph = ({ dataToVis, theme, isGlm }) => {
graphData.nodes.remove(nodeID);
graphData.edges.remove(edgesToDelete);

console.log("DELETED: " + nodeID);

getLegendData(objectTypeCount, theme, edgeOptions, legendData);
};

Expand Down
3 changes: 2 additions & 1 deletion glimpse/renderer/src/utils/graphUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ export const getLegendData = (typeCounts, theme, edgeOptions, legendData) => {
});

let x_increment = null;
if (currentNodeTypes.length < 6) x_increment = 800 / 6;
if (currentNodeTypes.length === 5) x_increment = 800 / 5;
else if (currentNodeTypes.length === 2) x_increment = 400;
else x_increment = 1100 / 6;

let farthest_x = 0;
Expand Down

0 comments on commit 87db5df

Please sign in to comment.