Выбор объектов на основе определенного атрибута в d3Jquery

Программирование на jquery
Ответить
Гость
 Выбор объектов на основе определенного атрибута в d3

Сообщение Гость »


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')
I have a time filter, which makes certain features invisible if I don't want them visible on the map (code not shown here). The way I do this is by setting those features' opacity to zero.
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")
})
I've also tried to add a "classed" attribute, and select based on that. While I can get the classed attribute to update successfully, nothing happens with mouseover.

Код: Выделить всё

 //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]
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Jquery»