From e59a2a186760910e3e0549b16e33a1fd153b4b5c Mon Sep 17 00:00:00 2001
From: Remi  PLANEL <rplanel@pasteur.fr>
Date: Thu, 2 May 2024 11:17:06 +0200
Subject: [PATCH] same title within operon

---
 components/OperonStructure.vue | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/components/OperonStructure.vue b/components/OperonStructure.vue
index a1a31799..87631009 100644
--- a/components/OperonStructure.vue
+++ b/components/OperonStructure.vue
@@ -332,7 +332,7 @@ function drawStructure(operonGroup: d3.Selection<SVGGElement, any, SVGElement |
         .attr("width", d => d.width)
         .attr("height", d => d.height)
         .attr("preserveAspectRatio", "xMidYMid meet")
-    structureSelection.select("title").text(d => `${d.gene} | ${d.size} aa`)
+    structureSelection.select("title").text(d => operonTitle(d))
 
 
 }
@@ -392,7 +392,7 @@ function drawGenes(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null
     genePathSelection
         .attr("d", d => drawGene(d).toString())
 
-    genesSelection.select("title").text(d => `${d.gene} | ${d.size} aa${geneTitle(d)}`)
+    genesSelection.select("title").text(d => operonTitle(d))
     function drawGene({ width, height }) {
         const context = d3.path()
         context.moveTo(0, 0)
@@ -404,6 +404,11 @@ function drawGenes(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null
     }
 }
 
+
+function operonTitle(d: StructureOperonGeneWithCoordinate) {
+    return `${d.gene} | ${d.size} aa${geneTitle(d)}`
+}
+
 function geneTitle(d: StructureOperonGeneWithCoordinate) {
     if (d?.exchangeables && d.exchangeables?.length > 0) {
         return `\nExchangeables: ${d.exchangeables.map(d => d.split("__")[1]).join(", ")}`
@@ -447,7 +452,6 @@ function drawGenesLabel(operonGroup: d3.Selection<SVGGElement, any, SVGElement |
         )
 
     updateSelection
-
         .attr("cursor", d => d.highlight ? "pointer" : null)
         .select<SVGTextElement>("text")
         .attr("transform", function (d) {
@@ -460,26 +464,13 @@ function drawGenesLabel(operonGroup: d3.Selection<SVGGElement, any, SVGElement |
                 return `translate(${d.x + d.width / 2 - toValue(width) / 2},${d.y}) rotate(${toValue(rotate)}) `
             }
             return null
-
         })
         .attr("style", d => d.highlight ? "font-weight: 700" : null)
         .text(d => d.gene)
-    updateSelection.select("title").text(d => d.gene)
+    updateSelection.select("title").text(d => operonTitle(d))
 
 }
 
-
-
-
-function adjacentlinks(nodes: Record<string, any>) {
-    const links = []
-    for (let i = 0; i < nodes.length; i++) {
-        if (i < nodes.length - 1) {
-            links.push({ index: i, source: nodes[i], target: nodes[+1] })
-        }
-    }
-    return links
-}
 </script>
 <template>
     <div ref="gbContainer">
-- 
GitLab