I've built a force node layout and I want to filter the nodes using the slider directly beneath it. jsfiddle here - https://jsfiddle.net/cavvzvjn/
I know I can read in the value of the handle being moved (utilising the 'this' keyword)
function brushed() {
var value = x.invert(d3.mouse(this)[0])
}
but because the handles can overlap I want to be able to read in values of both handles when one is being moved (on brush) so I can compare which has the higher/lower value and ultimately filter the nodes accordingly with something like
array.forEach(function(d) {
if (handle1.val < handle2.val) {
if (d.x < handle1.val || d.x > handle2.val) {
array[d].splice
}
else {
if (d.x > handle1.val || d.x < handle2.val) {
array[d].splice
}
}
})
So ultimately the question is (as the title says) how do I retrieve x coordinates of DOM elements relative to their container?