Skip to content

Commit

Permalink
fix GOC text hide/show
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthieuBarba committed Mar 17, 2024
1 parent a0238fa commit 0a9f4a0
Showing 1 changed file with 69 additions and 72 deletions.
141 changes: 69 additions & 72 deletions js/dotplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,8 @@ function draw_plot() {
if (get_par( 'show_goc' ) == false) {
gocx_container.style({ "display": "none" });
gocy_container.style({ "display": "none" });
}

// FIlter data
} else {
// Filter data
const goc1 = data.gocs[get_par("sp1")].filter(function(d) { return d.pos >= get_par( 'start1' ) && d.pos <= get_par( 'end1' ) });
const goc2 = data.gocs[get_par("sp2")].filter(function(d) { return d.pos >= get_par( 'start2' ) && d.pos <= get_par( 'end2' ) });

Expand Down Expand Up @@ -517,71 +516,70 @@ function draw_plot() {
.attr("stroke-width", "2")
.attr("fill", "none");

// Add GOC X axes
const gocx_axes = gocx_container.append("g")
.attr( "name", "gocx_axes" )
.attr( "class", "svg_axes" )

const gocx_xAxis = d3.svg.axis().scale( scales.x ).orient( "bottom" );
gocx_axes.append("g")
.attr("transform", "translate(" + 0 + "," + goc.height + ")")
.attr("class", "x axis")
.call(gocx_xAxis);

const gocx_yAxis = d3.svg.axis().scale( gocx_scale ).orient( "left" );
gocx_axes.append("g")
.attr("class", "y axis")
.call(gocx_yAxis);
const gocx_yAxis_right = d3.svg.axis().scale( gocx_scale ).orient( "right" );
gocx_axes.append("g")
.attr("transform", "translate(" + (win_width - margin.left - margin.right) + "," + 0 + ")")
.attr("class", "y axis")
.call(gocx_yAxis_right);

// Add GOC Y axes
const gocy_axes = gocy_container.append("g")
.attr( "name", "gocy_axes" )
.attr( "class", "svg_axes" )

const gocy_yAxis = d3.svg.axis().scale( scales.y ).orient( "left" );
gocy_axes.append("g")
.attr("class", "y axis")
.call(gocy_yAxis);

const gocy_xAxis = d3.svg.axis().scale( gocy_scale ).orient( "bottom" );
gocy_axes.append("g")
.attr("transform", "translate(" + 0 + "," + (win_height - margin.top - margin.bottom) + ")")
.attr("class", "y axis")
.call(gocy_xAxis);

const gocy_xAxis_top = d3.svg.axis().scale( gocy_scale ).orient( "top" );
gocy_axes.append("g")
.attr("class", "y axis")
.call(gocy_xAxis_top);

// #### EDIT IN PROGRESS
// Add GOC labels
var texts = svg.append("g");

// Horizontal GOC label
texts.append("text")
.attr("class", "y_goc label")
.attr("text-anchor", "middle")
.attr("x", (margin.left * 0.8))
.attr("y", win_height - margin.bottom * 0.2)
.text( "GOC" );

// Vertical GOC label
texts.append("text")
.attr("class", "x_goc label")
.attr("text-anchor", "middle")
.attr("y", -margin.left * 0.3)
.attr("x", win_height - margin.bottom * 0.8)
.attr("transform", "rotate(90)")
.text( "GOC" );
// #####
// Add GOC X axes
const gocx_axes = gocx_container.append("g")
.attr( "name", "gocx_axes" )
.attr( "class", "svg_axes" )

const gocx_xAxis = d3.svg.axis().scale( scales.x ).orient( "bottom" );
gocx_axes.append("g")
.attr("transform", "translate(" + 0 + "," + goc.height + ")")
.attr("class", "x axis")
.call(gocx_xAxis);

const gocx_yAxis = d3.svg.axis().scale( gocx_scale ).orient( "left" );
gocx_axes.append("g")
.attr("class", "y axis")
.call(gocx_yAxis);
const gocx_yAxis_right = d3.svg.axis().scale( gocx_scale ).orient( "right" );
gocx_axes.append("g")
.attr("transform", "translate(" + (win_width - margin.left - margin.right) + "," + 0 + ")")
.attr("class", "y axis")
.call(gocx_yAxis_right);

// Add GOC Y axes
const gocy_axes = gocy_container.append("g")
.attr( "name", "gocy_axes" )
.attr( "class", "svg_axes" )

const gocy_yAxis = d3.svg.axis().scale( scales.y ).orient( "left" );
gocy_axes.append("g")
.attr("class", "y axis")
.call(gocy_yAxis);

const gocy_xAxis = d3.svg.axis().scale( gocy_scale ).orient( "bottom" );
gocy_axes.append("g")
.attr("transform", "translate(" + 0 + "," + (win_height - margin.top - margin.bottom) + ")")
.attr("class", "y axis")
.call(gocy_xAxis);

const gocy_xAxis_top = d3.svg.axis().scale( gocy_scale ).orient( "top" );
gocy_axes.append("g")
.attr("class", "y axis")
.call(gocy_xAxis_top);

// Add GOC labels
var texts = goc_container.append("g");

// Horizontal GOC label
texts.append("text")
.attr("class", "y_goc label")
.attr("text-anchor", "middle")
.attr("x", (margin.left * 0.8))
.attr("y", win_height - margin.bottom * 0.2)
.text( "GOC" );

// Vertical GOC label
texts.append("text")
.attr("class", "x_goc label")
.attr("text-anchor", "middle")
.attr("y", -margin.left * 0.3)
.attr("x", win_height - margin.bottom * 0.8)
.attr("transform", "rotate(90)")
.text( "GOC" );
}

// When the graph is drawn, prepare a file to dowload it
// When the graph is drawn, prepare a file to download it
update_download_link( svg_style );
update_stats( stats );
}
Expand Down Expand Up @@ -953,11 +951,10 @@ function show_hide_button( parname, elementid, label ) {
}
update_permalink();

if (elementid == "goc_lines") {
console.log("Rebuild dotplot after after toggling GOC");
draw_plot();
}

if (elementid == "goc_lines") {
console.log("Rebuild dotplot after after toggling GOC");
draw_plot();
}
});
}

Expand Down

0 comments on commit 0a9f4a0

Please sign in to comment.