1
我有這些呼籲,當鼠標在開/關的節點如何讓一個事件調用多個函數? D3/JavaScript的
.on("mouseover", highlightImage)
.on("mouseout", unhighlightImage)
.on("mouseover", showTextToolTip)
.on("mouseout", hideTextToolTip)
現在,JavaScript是異步只讀底部的兩個函數被調用。我環顧四周,發現了幾個例子:
.on("mouseover", "highlightImage(); showTextToolTip()") //- doesnt work
.on("mouseover", mouseOverFunctions) //- calls a function>
function mouseOverFunctions(){
showTextToolTip();
highlightImage();
} //- also doesnt work.
我推測,這是因爲「鼠標懸停」只能在同一時間撥打一個對象。
如何同時調用兩個函數?我希望顯示文字和突出節點
添加代碼
function showTextToolTip(d){
if(textButtonPressed==false){
d3.select(this).append("text")
.attr("dx", "2")
.attr("dy", "-24")
.style("text-anchor", "start")
.text(function(d) { return d.identifier; });
showToolTip="true";
}}
function highlightImage(d){
d3.select(this).classed("highlighted", true);
highlightedNode = d.coreId;
//console.log("Highlighted node : " + highlightedNode);
}
類型錯誤:e.getAttribute不是一個函數? :/ @lars kotthoff – rekoDolph 2014-12-05 16:00:44
錯誤來自哪裏? – 2014-12-05 16:05:24
javascript - d3.v3.min.js(line 1,col 3091) – rekoDolph 2014-12-05 16:09:46