Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Dynamic tooltip based on pixel coordinates
  • Loading branch information
csw11004 committed Aug 17, 2015
1 parent fc9e4cc commit c4c7dba
Showing 1 changed file with 98 additions and 56 deletions.
154 changes: 98 additions & 56 deletions VQI_GenomeBrowser.js
Expand Up @@ -850,17 +850,22 @@ function VQI_GenomeBrowser(id, serviceURL) {
return offset;//height / 2 + margin + offset return offset;//height / 2 + margin + offset
}) })


addTooltip($(trackScalableGroup.selectAll("rect") addTooltip(trackScalableGroup.selectAll("rect")
.filter(function (d) { .filter(function (d) {
return d[indexArray.type] == "cpg";})[0]), name, "cpg"); return d[indexArray.type] == "cpg";}), name, "cpg");


addTooltip($(trackScalableGroup.selectAll("rect") addTooltip(trackScalableGroup.selectAll("rect")
.filter(function (d) { .filter(function (d) {
return d[indexArray.type] == "shore";})[0]), name, "shore"); return d[indexArray.type] == "shore";}), name, "shore");


addTooltip($(trackScalableGroup.selectAll("rect") addTooltip(trackScalableGroup.selectAll("rect")
.filter(function (d) { .filter(function (d) {
return d[indexArray.type] == "shelve";})[0]), name, "shelve"); return d[indexArray.type] == "shelve";}), name, "shelve");

/*$(trackScalableGroup.selectAll("rect")[0]).mousemove(function(event){
$(this).mouseenter();
});*/

} }


var addBEDTrack = function (data, name, exons) { var addBEDTrack = function (data, name, exons) {
Expand Down Expand Up @@ -921,9 +926,9 @@ function VQI_GenomeBrowser(id, serviceURL) {
.style("vector-effect", "non-scaling-stroke") .style("vector-effect", "non-scaling-stroke")
.attr("class", "scalable") .attr("class", "scalable")


addTooltip($(trackScalableGroup.selectAll("rect") addTooltip(trackScalableGroup.selectAll("rect")
.data(data, function (d) { .data(data, function (d) {
return d;})[0]), name, "gene") return d;}), name, "gene")


if (exons) if (exons)
{ {
Expand Down Expand Up @@ -958,9 +963,9 @@ function VQI_GenomeBrowser(id, serviceURL) {
.style("vector-effect", "non-scaling-stroke") .style("vector-effect", "non-scaling-stroke")
.attr("class", "scalable") .attr("class", "scalable")


addTooltip($(trackScalableGroup.selectAll("rect") addTooltip(trackScalableGroup.selectAll("rect")
.data(exons, function (d) { .data(exons, function (d) {
return d;})[0]), name, "exon") return d;}), name, "exon")


} }
} }
Expand Down Expand Up @@ -992,54 +997,91 @@ function VQI_GenomeBrowser(id, serviceURL) {
} }
} }
} }
selection.qtip({ selection.each(
content: { function(d){
text: function(event, api) { $(this).qtip({
var min,max; content: {
if(type === "exon"){ text: function(event, api) {
min = $( this ).prop("__data__")[0]; var min,max;
max = $( this ).prop("__data__")[1]; if(type === "exon"){
} min = d[0];
else max = d[1];
{ }
min = $( this ).prop("__data__")[indexArray.start]; else
max = $( this ).prop("__data__")[indexArray.end]; {
} min = d[indexArray.start];
return $.ajax({ max = d[indexArray.end];
url: serviceURL, }
type: 'POST', $.ajax({
dataType: "json", url: serviceURL,
data: { type: 'POST',
"loadTooltip": "", dataType: "json",
"chrom": chrom_curr, data: {
"trackName" : name, "loadTooltip": "",
"type" : type, "chrom": chrom_curr,
"min" : min, "trackName" : name,
"max": max, "type" : type,
'fileHandle': fileHandle "min" : min,
"max": max,
'fileHandle': fileHandle
}
})
.then(function(content) {
// Set the tooltip content upon successful retrieval
api.set('content.text', content);
}, function(xhr, status, error) {
// Upon failure... set the tooltip content to the status and error value
api.set('content.text', status + ': ' + error);
});

} }
}) },
.then(function(content) { position: {
// Set the tooltip content upon successful retrieval my: 'top center',
return content; at: 'top center',
}, function(xhr, status, error) { target: 'mouse',
// Upon failure... set the tooltip content to the status and error value adjust: {
api.set('content.text', status + ': ' + error); mouse: true, // Can be omitted (e.g. default behaviour)
}); y: 10
}
}
})
});


} selection.each(function(){
}, var selected = $(this);
position: { var hoverTimeout = 0;
my: 'top center', $(this).mousemove(function(event) {
at: 'top center', clearTimeout(hoverTimeout);
target: 'mouse', hoverTimeout = setTimeout(function(){
adjust: { var pixelWidth = (xScale.domain()[1] - xScale.domain()[0])/1000
mouse: true, // Can be omitted (e.g. default behaviour) var min = (event.pageX - 59) * pixelWidth + xScale.domain()[0];
y: 10 var max = (event.pageX - 58) * pixelWidth + xScale.domain()[0];
} $.ajax({
} url: serviceURL,
}); type: 'POST',
} dataType: "json",
data: {
"loadTooltip": "",
"chrom": chrom_curr,
"trackName" : name,
"type" : type,
"min" : min,
"max": max,
'fileHandle': fileHandle
}
})
.then(function(content) {
// Set the tooltip content upon successful retrieval
selected.qtip('option', 'content.text', content);
}, function(xhr, status, error) {
// Upon failure... set the tooltip content to the status and error value
selected.qtip('option', 'content.text', status + ': ' + error);
});
} , 200);
});
});
}


this.addTrackFromDatabase = function(){ this.addTrackFromDatabase = function(){
var chrom = "chr1"; var chrom = "chr1";
Expand Down

0 comments on commit c4c7dba

Please sign in to comment.