나는 대답을 알아 냈다. 주된 문제는 D3에는 jQuery처럼 명시적인 trigger
함수가 없다는 것입니다. 그러나이를 시뮬레이션 할 수 있습니다.
는
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);
});
를 통해 구축 된 D3 경로와
var mapMouseOver(d){
d3.selectAll($("#" + d.id))
.style("fill", "red")
.style("stroke", "blue");
}
는 일반적으로 대부분의 튜토리얼이 사용하는 말을 채우기 및 스트로크 색상을 변경하는 마우스 오버 이벤트 핸들러가 말
d3.select(this)...
하지만 실제로이 값을 사용하면 효과가 있습니다. 당신이 당신에게 노드의 ID를 취득하는 이벤트 핸들러를 가지고 있고,
를 통해 그것을 실행할 경우
$("#someDropdownSelect").change(someEventHandler)
function someEventHandler(){
//get node ID value, sample
var key = $(this)
.children(":selected")
.val();
//trigger mouseover event handler
mapMouseOver({id : key});
}
가 드롭 다운 선택에 따라 마우스 오버 이벤트를 실행합니다
완벽하게 작동합니다. –