From 3900a580e04d69a2e88992ae0ffe3fe20e9ee2e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sunny=20=28SunJae=29=20Lee=20=EC=9D=B4=EC=84=A0=EC=9E=AC?= Date: Mon, 6 Jan 2025 16:11:55 +0900 Subject: [PATCH 1/6] Removed unneeded code and added hide class --- frontend/SankeyDiagram.vue | 58 ++++++-------------------------------- 1 file changed, 8 insertions(+), 50 deletions(-) diff --git a/frontend/SankeyDiagram.vue b/frontend/SankeyDiagram.vue index 1ab60b0..beea391 100644 --- a/frontend/SankeyDiagram.vue +++ b/frontend/SankeyDiagram.vue @@ -1,6 +1,6 @@ @@ -89,7 +89,7 @@ export default { }); }, // Function for processing/parsing data - parseData(data, isFullGraph = true) { + parseData(data, isFullGraph = false) { const nodes = []; const unclassifiedNodes = []; const allNodes = []; @@ -151,49 +151,6 @@ export default { currentLineage.push(node); node.lineage = [...currentLineage]; } - } else if (this.isUnclassifiedTaxa(d)) { - // lineage tracking for unclassified taxa - let currentLineageCopy = [...currentLineage]; - const parentName = d.name.replace("unclassified ", ""); - let lastLineageNode = currentLineageCopy[currentLineageCopy.length - 1]; - - if (lastLineageNode) { - while (lastLineageNode && lastLineageNode.name !== parentName) { - currentLineageCopy.pop(); - lastLineageNode = currentLineageCopy[currentLineageCopy.length - 1]; - } - } - - // Find the previous node in the lineage that is in rankOrder - const parentNode = currentLineageCopy.find((n) => n.name === parentName); - if (parentNode && parentNode === lastLineageNode) { - const lineage = currentLineageCopy; - - let previousNode = null; - for (let i = lineage.length - 1; i >= 0; i--) { - // Start from the last item - if (this.rankOrder.includes(lineage[i].rank)) { - previousNode = lineage[i]; - break; - } - } - - // Determine the rank immediately to the right of this node - const parentRankIndex = this.rankOrder.indexOf(previousNode.rank); - - // Edit properties for unclassified taxa - const nextRank = this.rankOrder[parentRankIndex + 1]; - - node.id = `dummy-${d.taxon_id}`; - node.rank = nextRank; - node.type = "unclassified"; - - // Add unclassified node to currentLineage and save lineage data - currentLineageCopy.push(node); - node.lineage = [...currentLineageCopy]; - - unclassifiedNodes.push(node); - } } }); @@ -290,7 +247,8 @@ export default { const svg = d3.select(container) .attr("viewBox", `0 0 ${width} ${height}`) .attr("width", "100%") - .attr("height", height); + .attr("height", height) + .classed("hide", false); const sankeyGenerator = sankey() .nodeId((d) => d.id) @@ -431,7 +389,7 @@ export default { .style("opacity", 1) .html(`
-

#${d.id}

+

#${d.taxon_id}

${d.name}
${d.rank} @@ -483,7 +441,7 @@ export default { // Function to collect all IDs of the current node and its descendants const collectIds = (node) => { - let childrenIds = [node.id]; + let childrenIds = [node.taxon_id]; childrenIds = childrenIds.concat(this.findChildren(this.rawData, node)); return childrenIds; }; @@ -495,7 +453,7 @@ export default { this.currentSelectedNode = d; // Emit the IDs array - this.$emit("selectTaxon", { nodeId: d.id, descendantIds: allNodeIds }); + this.$emit("selectTaxon", { nodeId: d.taxon_id, descendantIds: allNodeIds }); }); ; @@ -574,7 +532,7 @@ export default { for (let i = 0; i < rawData.length; i++) { const d = rawData[i]; - if (d.taxon_id === selectedNode.id) { + if (d.taxon_id === selectedNode.taxon_id) { // Start adding child nodes from here startAdding = true; continue; // Move to the next iteration to skip the current node From 23cab470bf1eabd548f339b9de9648e608fc77b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sunny=20=28SunJae=29=20Lee=20=EC=9D=B4=EC=84=A0=EC=9E=AC?= Date: Mon, 6 Jan 2025 16:25:10 +0900 Subject: [PATCH 2/6] Fixed error of show/hide button toggling all sankeys at once --- frontend/ResultView.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/ResultView.vue b/frontend/ResultView.vue index 448ba23..ece6d63 100644 --- a/frontend/ResultView.vue +++ b/frontend/ResultView.vue @@ -98,8 +98,8 @@ - - {{ isSankeyVisible ? 'Hide Sankey' : 'Show Sankey' }} + + {{ isSankeyVisible[entry.db] ? 'Hide Sankey' : 'Show Sankey' }} @@ -112,7 +112,7 @@ - + @@ -281,7 +281,7 @@ export default { activeTarget: null, alnBoxOffset: 0, selectedDatabases: 0, - isSankeyVisible: false, + isSankeyVisible: {}, // Track visibility for each entry.db selectedTaxId: null, filteredHitsTaxIds: [], tableMode: 0, @@ -376,6 +376,10 @@ export default { this.menuActivator.click(event); } }, + toggleSankeyVisibility(db) { + // Toggle visibility for the specific entry.db + this.$set(this.isSankeyVisible, db, !this.isSankeyVisible[db]); + }, handleSankeySelect({ nodeId, descendantIds }) { this.selectedTaxId = nodeId; this.filteredHitsTaxIds = descendantIds ? descendantIds.map(Number) : null; From 61926594eb640e1f0e15595c421ffd035708155c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sunny=20=28SunJae=29=20Lee=20=EC=9D=B4=EC=84=A0=EC=9E=AC?= Date: Mon, 6 Jan 2025 16:49:31 +0900 Subject: [PATCH 3/6] Fixed error of node click on one sankey affecting filtering of hits on the other databases --- frontend/ResultView.vue | 17 ++++++++++++----- frontend/SankeyDiagram.vue | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/frontend/ResultView.vue b/frontend/ResultView.vue index ece6d63..7b421f8 100644 --- a/frontend/ResultView.vue +++ b/frontend/ResultView.vue @@ -113,7 +113,7 @@ - +
@@ -185,7 +185,7 @@ -