Skip to content

Commit

Permalink
Merge pull request #4759 from solgenomics/topic/d3_rebind
Browse files Browse the repository at this point in the history
Fieldmap: use legacy v3 of d3
  • Loading branch information
lukasmueller authored Dec 12, 2023
2 parents 9ae4885 + b2390cf commit 5dc670e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions js/source/entries/fieldmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,14 @@ export function init() {
this.meta_data.num_cols = this.meta_data.num_rows;
this.meta_data.num_rows = tempNumCols;

d3.select("svg").remove();
d3v3.select("svg").remove();
this.add_borders();
this.render();

}

clickcancel() {
var event = d3.dispatch('click', 'dblclick');
var event = d3v3.dispatch('click', 'dblclick');
function cc(selection) {
var down,
tolerance = 5,
Expand All @@ -390,33 +390,33 @@ export function init() {
return Math.sqrt(Math.pow(a[0] - b[0], 2), Math.pow(a[1] - b[1], 2));
}
selection.on('mousedown', function() {
down = d3.mouse(document.body);
down = d3v3.mouse(document.body);
last = +new Date();
});
selection.on('mouseup', function() {
if (dist(down, d3.mouse(document.body)) > tolerance) {
if (dist(down, d3v3.mouse(document.body)) > tolerance) {
return;
} else {
if (wait) {
window.clearTimeout(wait);
wait = null;
event.dblclick(d3.event);
event.dblclick(d3v3.event);
} else {
wait = window.setTimeout((function(e) {
return function() {
event.click(e);
wait = null;
};
})(d3.event), 300);
})(d3v3.event), 300);
}
}
});
};
return d3.rebind(cc, event, 'on');
return d3v3.rebind(cc, event, 'on');
}

heatmap_plot_click(plot, heatmap_object, trait_name) {
if (d3.event && d3.event.detail > 1) {
if (d3v3.event && d3v3.event.detail > 1) {
return;
} else if (trait_name in heatmap_object && heatmap_object[trait_name][plot.observationUnitDbId]) {
let val, plot_name, pheno_id;
Expand All @@ -432,7 +432,7 @@ export function init() {
}

fieldmap_plot_click(plot) {
if (d3.event && d3.event.detail > 1) {
if (d3v3.event && d3v3.event.detail > 1) {
return;
} else {
function btnClick(n){
Expand Down Expand Up @@ -513,7 +513,7 @@ export function init() {
for (let obs_unit of Object.values(plots_with_selected_trait)) {
trait_vals.push(obs_unit.val);
}
var colorScale = d3.scale.quantile()
var colorScale = d3v3.scale.quantile()
.domain(trait_vals)
.range(colors);
}
Expand Down Expand Up @@ -602,7 +602,7 @@ export function init() {

var handle_mouseover = function(d) {
if (d.observationUnitPosition.observationLevel) {
d3.select(`#fieldmap-plot-${d.observationUnitDbId}`)
d3v3.select(`#fieldmap-plot-${d.observationUnitDbId}`)
.style('fill', 'green')
.style('cursor', 'pointer')
.style("stroke-width", 3)
Expand All @@ -615,7 +615,7 @@ export function init() {
}

var handle_mouseout = function(d) {
d3.select(`#fieldmap-plot-${d.observationUnitDbId}`)
d3v3.select(`#fieldmap-plot-${d.observationUnitDbId}`)
.style('fill', !isHeatMap ? get_fieldmap_plot_color(d) : get_heatmap_plot_color(d))
.style('cursor', 'default')
.style("stroke-width", 2)
Expand Down Expand Up @@ -688,12 +688,12 @@ export function init() {
var num_rows = this.meta_data.num_rows;
var isHeatMap = this.heatmap_selected;

var grid = d3.select("#fieldmap_chart")
var grid = d3v3.select("#fieldmap_chart")
.append("svg")
.attr("width", width * 50 + 20 + "px")
.attr("height", height * 50 + 20 + "px")

var tooltip = d3.select("#fieldmap_chart")
var tooltip = d3v3.select("#fieldmap_chart")
.append("rect")
.attr("id", "tooltip")
.attr("class", "tooltip")
Expand All @@ -718,11 +718,11 @@ export function init() {
.call(cc);

cc.on("click", (el) => {
var plot = d3.select(el.srcElement).data()[0];
var plot = d3v3.select(el.srcElement).data()[0];
plot_click(plot, heatmap_object, trait_name)
});
cc.on("dblclick", (el) => {
var me = d3.select(el.srcElement);
var me = d3v3.select(el.srcElement);
var d = me.data()[0];
if (d.observationUnitDbId) {
window.open('/stock/'+d.observationUnitDbId+'/view');
Expand Down Expand Up @@ -815,7 +815,7 @@ export function init() {


load() {
d3.select("svg").remove();
d3v3.select("svg").remove();
this.change_dimensions(this.meta_data.num_cols, this.meta_data.num_rows);
this.add_borders();
this.render();
Expand Down
Loading

0 comments on commit 5dc670e

Please sign in to comment.