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

Merge branch 'operon-struct-type' into operon-struct-type-article

parents 0b447dbd 6152ec91
No related branches found
No related tags found
No related merge requests found
Pipeline #129452 waiting for manual action
...@@ -24,7 +24,7 @@ const margin = ref<PlotMargin>({ ...@@ -24,7 +24,7 @@ const margin = ref<PlotMargin>({
}) })
const snackbar = ref(false) const snackbar = ref(false)
const color = d3.scaleOrdinal(d3.schemeCategory10);
const plotHeight = computed(() => { const plotHeight = computed(() => {
const { marginTop, marginBottom } = toValue(margin) const { marginTop, marginBottom } = toValue(margin)
return toValue(height) + marginTop + marginBottom return toValue(height) + marginTop + marginBottom
...@@ -44,7 +44,7 @@ const xScale = computed(() => { ...@@ -44,7 +44,7 @@ const xScale = computed(() => {
const yScale = ref(d3.scaleBand() const yScale = ref(d3.scaleBand()
.domain(['1']) .domain(['img', 'gene'])
.range([toValue(margin).marginTop, toValue(height)])); .range([toValue(margin).marginTop, toValue(height)]));
const gbContainer = ref(null) const gbContainer = ref(null)
const computedContainerWidth = computed(() => { const computedContainerWidth = computed(() => {
...@@ -91,7 +91,7 @@ const genesWithCoord = computed<StructureOperonGeneWithCoordinate[]>(() => { ...@@ -91,7 +91,7 @@ const genesWithCoord = computed<StructureOperonGeneWithCoordinate[]>(() => {
...d, ...d,
width: xScaleVal.bandwidth(), width: xScaleVal.bandwidth(),
x: xScaleVal(d.gene), x: xScaleVal(d.gene),
y: yScaleVal('1'), y: yScaleVal('gene'),
height: yScaleVal.bandwidth() height: yScaleVal.bandwidth()
} }
}) })
...@@ -122,10 +122,10 @@ function draw() { ...@@ -122,10 +122,10 @@ function draw() {
const xAxis = d3.axisBottom(xScale.value) const xAxis = d3.axisBottom(xScale.value)
const gx = createOrSelect(svg, 'g', 'x-axis') const gx = createOrSelect(svg, 'g', 'x-axis')
gx gx
.attr("transform", `translate(${marginLeft},${toValue(height)})`) .attr("transform", `translate(${marginLeft},${toValue(height) + 5})`)
.call(xAxis) .call(xAxis)
.selectAll("text") .selectAll("text")
.attr("transform", 'rotate(45)') .attr("transform", 'rotate(20)')
.attr("text-anchor", "start") .attr("text-anchor", "start")
const gxTitle = createOrSelect(gx, "text", "x-axis-title") const gxTitle = createOrSelect(gx, "text", "x-axis-title")
...@@ -152,12 +152,15 @@ function drawGenes(genesGroup: d3.Selection<SVGElement, any, SVGElement, any>) { ...@@ -152,12 +152,15 @@ function drawGenes(genesGroup: d3.Selection<SVGElement, any, SVGElement, any>) {
.data<StructureOperonGeneWithCoordinate>(data) // sync them with our data .data<StructureOperonGeneWithCoordinate>(data) // sync them with our data
.join( .join(
enter => { enter => {
const g = enter.append("g")
const gGene = enter.append("g")
.classed("gene", true); .classed("gene", true);
g.append("path")
gGene.append("path")
.classed("gene", true) .classed("gene", true)
g.append("image") gGene.append("image")
.on("mouseover", function (event) { .on("mouseover", function (event) {
d3.select(event.srcElement.previousSibling) d3.select(event.srcElement.previousSibling)
.attr("stroke-width", 4) .attr("stroke-width", 4)
...@@ -170,19 +173,20 @@ function drawGenes(genesGroup: d3.Selection<SVGElement, any, SVGElement, any>) { ...@@ -170,19 +173,20 @@ function drawGenes(genesGroup: d3.Selection<SVGElement, any, SVGElement, any>) {
.attr("stroke", null) .attr("stroke", null)
d3.select(event.srcElement).attr("cursor", "unset") d3.select(event.srcElement).attr("cursor", "unset")
}) })
g.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")
g.append("title") gGene.append("title")
return g return gGene
}, },
update => update, update => update,
exit => exit.remove() exit => exit.remove()
) )
genesSelection.attr("transform", d => `translate(${d.x},${d.y})`) genesSelection.attr("transform", d => `translate(${d.x}, 0)`)
genesSelection.select("image") genesSelection.select("image")
.attr("transform", d => `translate(0, ${toValue(yScale)("img")})`)
.attr("href", d => d?.structImg ?? null) .attr("href", d => d?.structImg ?? null)
.attr("width", d => d.width) .attr("width", d => d.width)
.attr("height", d => d.height) .attr("height", d => d.height)
...@@ -192,6 +196,8 @@ function drawGenes(genesGroup: d3.Selection<SVGElement, any, SVGElement, any>) { ...@@ -192,6 +196,8 @@ function drawGenes(genesGroup: d3.Selection<SVGElement, any, SVGElement, any>) {
}) })
genesSelection.select("path.gene") genesSelection.select("path.gene")
.attr("transform", d => `translate(0, ${d.y})`)
.attr("fill", d => color(d.gene))
.attr("d", d => drawGene(d).toString()) .attr("d", d => drawGene(d).toString())
} }
......
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