मुझे जवाब पता चला। मुख्य समस्या यह है कि डी 3 के पास jQuery के रूप में एक स्पष्ट trigger
फ़ंक्शन नहीं है। हालांकि, आप इसे अनुकरण कर सकते हैं।
आप एक डी 3 पथ
d3.json("us-counties.json", function(json){
thisObj._svg.selectAll("path")
.data(json.features)
.enter().append("path")
.attr("d", thisObj._path)
.attr("class", "states")
.attr("id", function(d){
return d.id; //<-- Sets the ID of this county to the path
})
.style("fill", "gray")
.style("stroke", "black")
.style("stroke-width", "0.5px")
.on("dblclick", mapZoom)
.on("mouseover", mapMouseOver)
.on("mouseout", mapMouseOut);
});
के माध्यम से बनाया गया है और माउसओवर ईवेंट हैंडलर बदलता है कि भरण और स्ट्रोक रंग
var mapMouseOver(d){
d3.selectAll($("#" + d.id))
.style("fill", "red")
.style("stroke", "blue");
}
आमतौर पर, सबसे ट्यूटोरियल उपयोग करने के लिए कहते हैं कि है कहो
d3.select(this)...
लेकिन वास्तव में मूल्य का उपयोग भी करता है। आप एक ईवेंट हैंडलर कि आप नोड के आईडी हो जाता है, और
के माध्यम से यह ट्रिगर करते
$("#someDropdownSelect").change(someEventHandler)
function someEventHandler(){
//get node ID value, sample
var key = $(this)
.children(":selected")
.val();
//trigger mouseover event handler
mapMouseOver({id : key});
}
माउसओवर एक ड्रॉपडाउन चयन के आधार पर घटना को निष्पादित करेंगे
यह पूरी तरह से काम करता है। –