Skip to content

Commit

Permalink
Merge pull request #69 from chaliya96/highlight-feature
Browse files Browse the repository at this point in the history
Highlight feature
  • Loading branch information
kwsamarasinghe authored Oct 10, 2022
2 parents bb6e719 + b1ac9a1 commit 4cb9491
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions src/feature-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,18 @@ function createFeature(sequence, div, options) {
object.data.sort(function (a, b) {
return a.x - b.x;
});
if (object.highlight && Array.isArray(object.highlight)) {
object.highlight.forEach(highlight => {
for (var i in object.data) {
if (highlight.x == object.data[i].x && highlight.y == object.data[i].y){
object.data[i].highlight = true;
object.data[i].color = highlight.color;
object.data[i].description = highlight.highlightText;
}

}
})
}
level = addLevel(object.data);
pathLevel = level * 10 + 5;
}
Expand Down Expand Up @@ -995,6 +1007,7 @@ function createFeature(sequence, div, options) {
rectangle: function (object, position) {
//var rectShift = 20;
if (!object.height) object.height = 12;
if(typeof object.showDescriptionRect === 'undefined' || object.showDescriptionRect === null) object.showDescriptionRect = true;
var rectHeight = object.height;

var rectShift = rectHeight + rectHeight/3;
Expand Down Expand Up @@ -1052,25 +1065,27 @@ function createFeature(sequence, div, options) {
.style("z-index", "13")
.call(d3.helper.tooltip(object));

rectsProGroup
.append("text")
.attr("class", "element " + object.className + "Text")
.attr("y", function (d) {
return d.level * rectShift + rectHeight/2
})
.attr("dy", "0.35em")
.style("font-size", "10px")
.text(function (d) {
return d.description
})
.style("fill", "black")
.style("z-index", "15")
.style("visibility", function (d) {
if (d.description) {
return (scaling(d.y) - scaling(d.x)) > d.description.length * 8 && rectHeight > 11 ? "visible" : "hidden";
} else return "hidden";
})
.call(d3.helper.tooltip(object));
if(object.showDescriptionRect){
rectsProGroup
.append("text")
.attr("class", "element " + object.className + "Text")
.attr("y", function (d) {
return d.level * rectShift + rectHeight/2
})
.attr("dy", "0.35em")
.style("font-size", "10px")
.text(function (d) {
return d.description
})
.style("fill", "black")
.style("z-index", "15")
.style("visibility", function (d) {
if (d.description) {
return (scaling(d.y) - scaling(d.x)) > d.description.length * 8 && rectHeight > 11 ? "visible" : "hidden";
} else return "hidden";
})
.call(d3.helper.tooltip(object));
}


//rectsPro.selectAll("." + object.className)
Expand Down

0 comments on commit 4cb9491

Please sign in to comment.