dedupeLabelsDemo = (allDedupeLabels) => {
const getOverlapFromTwoExtents = (l, r) => {
var overlapPadding = 0
l.left = l.x - overlapPadding
l.right = l.x + l.width + overlapPadding
l.top = l.y - overlapPadding
l.bottom = l.y + l.height + overlapPadding
r.left = r.x - overlapPadding
r.right = r.x + r.width + overlapPadding
r.top = r.y - overlapPadding
r.bottom = r.y + r.height + overlapPadding
var a = l
var b = r
if (a.left >= b.right || a.top >= b.bottom ||
a.right <= b.left || a.bottom <= b.top ){
return false
} else {
return true
}
}
allDedupeLabels.each(function(d, i) {
var thisBBox = this.getBBox()
allDedupeLabels.filter((k, j) => j > i).each(function(d){
var underBBox = this.getBBox()
if(getOverlapFromTwoExtents(thisBBox, underBBox) && d3.select(this).attr('class').match('dedupe-always-show') == null){
d3.select(this)
.style('opacity', 1)
.transition().delay(500).duration(1000)
.style('opacity', 0)
}
})
})
}