Skip to content

Commit 4e51cdf

Browse files
committed
Fixed clusters highlight lost when using next button
1 parent 568e9ae commit 4e51cdf

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ <h3>Near real-time visualization of SARS-CoV-2 genomic variation</h3>
206206
const point = stats.points[stats.current_point - 1];
207207
// TODO: Select the accession with a more general approach
208208
const accn = point.accessions[0];
209-
select_bead_by_accession(accn);
209+
select_bead_by_accession(accn, false);
210210
});
211211

212212
$('#previous_button').click(function(){

js/search.js

+23-20
Original file line numberDiff line numberDiff line change
@@ -140,37 +140,40 @@ function select_by_points(points){
140140
/**
141141
* Highlight and jump to node in beadplot by sample accession number.
142142
* @param {string} accn: accession number to search for
143+
* @param {Boolean} reset_clusters_tree: when false, the cluster tree remain unchanged
143144
*/
144-
function select_bead_by_accession(accn) {
145+
function select_bead_by_accession(accn, reset_clusters_tree = true) {
145146
// switch to cluster beadplot
146147
var cid = accn_to_cid[accn];
147148

148149
if (cid !== undefined) {
149-
// if (d3.selectAll('.clicked').empty()) {
150150

151-
d3.selectAll("#svg-timetree > svg > g > rect:not(.clickedH)").attr("class", "not_SelectedCluster");
152-
var rect = d3.selectAll("#svg-timetree > svg > g > rect:not(.clickedH)")
153-
.filter(function(d) { return(d.cluster_idx === cid); })
154-
.attr("class", "clicked");
151+
if (reset_clusters_tree === true) {
152+
d3.selectAll("#svg-timetree > svg > g > rect:not(.clickedH)").attr("class", "not_SelectedCluster");
153+
}
154+
155+
var rect = d3.selectAll("#svg-timetree > svg > g > rect:not(.clickedH)")
156+
.filter(function(d) { return(d.cluster_idx === cid); })
157+
.attr("class", "clicked");
155158

156-
d3.select(rect.nodes().pop()).each(function(d) {
157-
create_clusterH(d, this);
158-
});
159+
d3.select(rect.nodes().pop()).each(function(d) {
160+
create_clusterH(d, this);
161+
});
159162

160-
beadplot(cid);
163+
beadplot(cid);
161164

162-
var bead = d3.selectAll("circle").filter(function(d) {
163-
return d.accessions.includes(accn);
164-
});
165+
var bead = d3.selectAll("circle").filter(function(d) {
166+
return d.accessions.includes(accn);
167+
});
165168

166-
create_selection(bead);
167-
bead.node().scrollIntoView({block: "center"});
169+
create_selection(bead);
170+
bead.node().scrollIntoView({block: "center"});
168171

169-
// Update information panel
170-
const datum = bead.datum();
171-
gentable(datum);
172-
draw_region_distribution(table(datum.region));
173-
gen_details_table(datum);
172+
// Update information panel
173+
const datum = bead.datum();
174+
gentable(datum);
175+
draw_region_distribution(table(datum.region));
176+
gen_details_table(datum);
174177

175178
}
176179
}

0 commit comments

Comments
 (0)