I have a map: d3 vectors (circles) placed over a leaflet map.
Код: Выделить всё
// read in data, draw circles in d3, and append to Leaflet map
var feature = mapG.selectAll("circle")
.data(SFData)
.enter().append("circle")
.style("stroke", "black")
.style("fill", function(d) { return type(d.properties.Tenant)})
.attr("r", function(d) { return radius(d.properties.Lease_Size)})
.attr("class", 'features')
The issue is that I want popups to show up for only visible map features on mouse-over. Currently the features which have opacity set to zero still can still be activated by mouse-over which is screwing things up. So, I want to select only features which currently have opacity set to .7 (a time slider will dynamically change the opacity).
This doesn't seem to work:
Код: Выделить всё
// select d3 features of the class 'features', that have attribute opacity = .7
d3.selectAll('.features[style = "opacity: .7;"]')
.on("mouseover", function(d) {
console.log(" do something here")
})
Код: Выделить всё
//build function to change attribute 'classed'
function ClassMatch(data, value) {
if (year
Источник: [url]https://stackoverflow.com/questions/53016437/selecting-features-based-on-specific-attribute-in-d3[/url]
Мобильная версия