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

add some transition

parent a9d28f57
No related branches found
No related tags found
No related merge requests found
Pipeline #129701 failed
...@@ -20,9 +20,9 @@ const { genes: genesProps } = toRefs(props) ...@@ -20,9 +20,9 @@ const { genes: genesProps } = toRefs(props)
const height = ref<number>(200) const height = ref<number>(200)
const svgRef = ref<SVGElement | null>(null) const svgRef = ref<SVGElement | null>(null)
const margin = ref<PlotMargin>({ const margin = ref<PlotMargin>({
marginTop: 50, marginTop: 5,
marginRight: 7, marginRight: 7,
marginBottom: 1, marginBottom: 50,
marginLeft: 7, marginLeft: 7,
}) })
...@@ -40,7 +40,7 @@ const domain = computed(() => { ...@@ -40,7 +40,7 @@ const domain = computed(() => {
return genes?.map(d => { return d.gene }) return genes?.map(d => { return d.gene })
}) })
const innerPadding = ref<number>(5) const innerPadding = ref<number>(8)
const totalGeneLength = computed(() => { const totalGeneLength = computed(() => {
const genes = toValue(computedGenes) const genes = toValue(computedGenes)
...@@ -200,16 +200,16 @@ function draw() { ...@@ -200,16 +200,16 @@ function draw() {
if (svgRef.value !== null) { if (svgRef.value !== null) {
const svg = d3.select<SVGElement, undefined>(svgRef.value); const svg = d3.select<SVGElement, undefined>(svgRef.value);
const { marginLeft, marginTop } = toValue(margin) const { marginLeft, marginTop } = toValue(margin)
const xAxis = d3.axisTop(xScale.value) const xAxis = d3.axisBottom(xScaleGenes.value)
const gx = createOrSelect(svg, 'g', 'x-axis') const gx = createOrSelect(svg, 'g', 'x-axis')
gx gx
.attr("transform", `translate(${marginLeft},${marginTop})`) .attr("transform", `translate(${marginLeft},${toValue(height) + marginTop})`)
.call(xAxis) .call(xAxis)
gx.call(g => g.select(".domain") gx.call(g => g.select(".domain")
.remove()) .remove())
.selectAll("text") .selectAll("text")
.attr("transform", 'rotate(-20)') .attr("transform", 'rotate(20)')
.attr("text-anchor", "start") .attr("text-anchor", "start")
let gOperon = createOrSelect(svg, "g", "operon") let gOperon = createOrSelect(svg, "g", "operon")
...@@ -236,15 +236,19 @@ function drawLinks(operonGroup: d3.Selection<SVGElement, any, SVGElement, any>) ...@@ -236,15 +236,19 @@ function drawLinks(operonGroup: d3.Selection<SVGElement, any, SVGElement, any>)
const stroke = "#555" // stroke for links const stroke = "#555" // stroke for links
const strokeWidth = 1.5 // stroke width for links const strokeWidth = 1.5 // stroke width for links
const strokeOpacity = 0.4 // stroke opacity for links const strokeOpacity = 0.4 // stroke opacity for links
operonGroup const updateSelection = operonGroup
.selectAll("path.link") .selectAll("path.link")
.data(linksGenesStruct.value) .data(linksGenesStruct.value)
.join("path") .join("path")
.classed("link", true) .classed("link", true)
.attr("fill", "none") .attr("fill", "none")
.attr("stroke", "currentColor") .attr("stroke", "currentColor")
updateSelection
.transition()
.attr("stroke-opacity", d => d.highlight ? 0.6 : strokeOpacity) .attr("stroke-opacity", d => d.highlight ? 0.6 : strokeOpacity)
.attr("stroke-width", d => d.highlight ? strokeWidth + 2 : strokeWidth) .attr("stroke-width", d => d.highlight ? strokeWidth + 2 : strokeWidth)
.attr("d", d3.link(d3.curveBumpY)) .attr("d", d3.link(d3.curveBumpY))
} }
...@@ -355,12 +359,17 @@ function drawGenes(operonGroup: d3.Selection<SVGElement, any, SVGElement, any>) ...@@ -355,12 +359,17 @@ function drawGenes(operonGroup: d3.Selection<SVGElement, any, SVGElement, any>)
genesSelection.select("g.gene-grp") 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)
.attr("transform", d => `translate(0, ${d.y})`) .attr("transform", d => `translate(0, ${d.y})`)
genePathSelection
.transition()
.attr("fill", d => d?.highlight ? d3.color(color(d.system))?.brighter() : color(d.system)) .attr("fill", d => d?.highlight ? d3.color(color(d.system))?.brighter() : color(d.system))
genePathSelection
.attr("d", d => drawGene(d).toString()) .attr("d", d => drawGene(d).toString())
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment