Skip to content
Snippets Groups Projects
Commit 453233ba authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

add some title to display

parent 6b07cb1a
No related branches found
No related tags found
No related merge requests found
Pipeline #129759 failed
...@@ -220,19 +220,8 @@ function draw() { ...@@ -220,19 +220,8 @@ function draw() {
if (svgRef.value !== null) { if (svgRef.value !== null) {
const svg = d3.select<SVGElement, any>(svgRef.value); const svg = d3.select<SVGElement, any>(svgRef.value);
const { marginLeft, marginTop } = toValue(margin) const { marginLeft, marginTop } = toValue(margin)
// const xAxis = d3.axisBottom(xScaleGenes.value)
const gx = createOrSelect<SVGGElement, SVGElement>(svg, 'g', 'x-axis') const gx = createOrSelect<SVGGElement, SVGElement>(svg, 'g', 'x-axis')
// gx const gOperon = createOrSelect<SVGGElement, SVGElement>(svg, "g", "operon")
// .attr("transform", `translate(${marginLeft},${toValue(height) + marginTop})`)
// .call(xAxis)
// gx.call(g => g.select(".domain")
// .remove())
// .selectAll("text")
// .attr("transform", 'rotate(20)')
// .attr("text-anchor", "start")
let gOperon = createOrSelect<SVGGElement, SVGElement>(svg, "g", "operon")
gOperon gOperon
.attr("transform", `translate(${marginLeft},0)`) .attr("transform", `translate(${marginLeft},0)`)
.call(drawLinks) .call(drawLinks)
...@@ -266,17 +255,6 @@ function drawLinks(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null ...@@ -266,17 +255,6 @@ function drawLinks(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null
function drawStructure(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null, any>) { function drawStructure(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null, any>) {
const structureNodeVal = toValue(structureNodes) const structureNodeVal = toValue(structureNodes)
// const totalSize = domainGenes.value[1]
// const structureLinks = adjacentlinks(structures)
// const sim = d3.forceSimulation(structureNodeVal)
// .force("link", d3.forceLink(structureLinks))
// .force("collide", d3.forceCollide((d) => d.r))
// .stop()
// .tick(10);
// sim.tick()
const structureSelection = operonGroup const structureSelection = operonGroup
.selectAll("g.structure") // get all "existing" lines in svg .selectAll("g.structure") // get all "existing" lines in svg
.data<StructureOperonGeneWithCoordinate>(structureNodeVal) // sync them with our data .data<StructureOperonGeneWithCoordinate>(structureNodeVal) // sync them with our data
...@@ -324,12 +302,12 @@ function drawGenes(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null ...@@ -324,12 +302,12 @@ function drawGenes(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null
const genesWithCoordVal = toValue(geneNodes) const genesWithCoordVal = toValue(geneNodes)
const genes = genesWithCoordVal const genes = genesWithCoordVal
const genesSelection = operonGroup const genesSelection = operonGroup
.selectAll("g.operon-item") // get all "existing" lines in svg .selectAll("g.gene-grp") // get all "existing" lines in svg
.data<StructureOperonGeneWithCoordinate>(genes) // sync them with our data .data<StructureOperonGeneWithCoordinate>(genes) // sync them with our data
.join( .join(
enter => { enter => {
const gOperonItem = enter.append("g") const gGene = enter.append("g")
.classed("operon-item", true) .classed("gene-grp", true)
.on("click", function (event) { .on("click", function (event) {
const data = d3.select<SVGElement, StructureOperonGeneWithCoordinate>(this).data() const data = d3.select<SVGElement, StructureOperonGeneWithCoordinate>(this).data()
structureBasket.set(data.map(s => s?.structPath ?? '')) structureBasket.set(data.map(s => s?.structPath ?? ''))
...@@ -339,41 +317,32 @@ function drawGenes(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null ...@@ -339,41 +317,32 @@ function drawGenes(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null
const node = srcSelection.data() const node = srcSelection.data()
geneToHighlight.value = node[0].gene geneToHighlight.value = node[0].gene
}) })
.on("mouseout", function (event) { .on("mouseout", function (event) {
geneToHighlight.value = null geneToHighlight.value = null
}) })
// gene grp
const gGene = gOperonItem.append("g")
.classed("gene-grp", true)
gGene gGene
.append("path") .append("path")
.classed("gene", true) .classed("gene", true)
gGene.append("title")
gOperonItem.append("text") gGene.append("text")
// .attr("fill", "white") // .attr("fill", "white")
.classed("gene-label", true) .classed("gene-label", true)
.attr("fill", "currentColor") .attr("fill", "currentColor")
.attr("dominant-baseline", "middle") .attr("dominant-baseline", "middle")
gOperonItem.append("line")
gOperonItem.append("title") return gGene
return gOperonItem
}, },
update => update, update => update,
exit => exit.remove() exit => exit.remove()
) )
genesSelection genesSelection
.select("g.gene-grp")
.attr("cursor", d => d.highlight ? "pointer" : null) .attr("cursor", d => d.highlight ? "pointer" : null)
.attr("transform", d => `translate(${d.x}, 0)`) .attr("transform", d => `translate(${d.x}, 0)`)
const genePathSelection = genesSelection const genePathSelection = genesSelection
.select("g.gene-grp")
.select("path.gene") .select("path.gene")
// .attr("stroke", d => d?.highlight ? d3.color(color(d.system))?.darker() : null) // .attr("stroke", d => d?.highlight ? d3.color(color(d.system))?.darker() : null)
.attr("stroke-width", d => d?.highlight ? 4 : 0) .attr("stroke-width", d => d?.highlight ? 4 : 0)
...@@ -385,7 +354,7 @@ function drawGenes(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null ...@@ -385,7 +354,7 @@ function drawGenes(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null
genePathSelection genePathSelection
.attr("d", d => drawGene(d).toString()) .attr("d", d => drawGene(d).toString())
genesSelection.select("title").text(d => `${d.gene} | ${d.size} aa${geneTitle(d)}`)
function drawGene({ width, height }) { function drawGene({ width, height }) {
const context = d3.path() const context = d3.path()
context.moveTo(0, 0) context.moveTo(0, 0)
...@@ -397,6 +366,13 @@ function drawGenes(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null ...@@ -397,6 +366,13 @@ function drawGenes(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null
} }
} }
function geneTitle(d: StructureOperonGeneWithCoordinate) {
if (d?.exchangeables && d.exchangeables?.length > 0) {
return `\nExchangeables: ${d.exchangeables.map(d => d.split("__")[1]).join(", ")}`
}
return ''
}
function drawGenesLabel(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null, any>) { function drawGenesLabel(operonGroup: d3.Selection<SVGGElement, any, SVGElement | null, any>) {
const genes = toValue(genesLabel) const genes = toValue(genesLabel)
const updateSelection = operonGroup const updateSelection = operonGroup
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment