我已经查看了与上述类似的问题,但没有一个有帮助.
这是我的脚本
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="network.json"></script>
<script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
<link type="text/css" href="http://code.jquery.com/ui/1.9.1/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<body>
<link href="ajs_network1.css" rel="stylesheet" type="text/css" />
<script src="ajs_network1.js" type="text/javascript"></script>
</body>
Run Code Online (Sandbox Code Playgroud)
这是试图调用JQuery的函数
$(function () {
$("#search").autocomplete({
source: optArray
});
});
Run Code Online (Sandbox Code Playgroud)
由于某种原因,它带来了错误
TypeError: $(...).autocomplete is not a function.
Run Code Online (Sandbox Code Playgroud)
我猜我已经做了一些错误的脚本?
当鼠标悬停在节点上时,我有这些要求
.on("mouseover", highlightImage)
.on("mouseout", unhighlightImage)
.on("mouseover", showTextToolTip)
.on("mouseout", hideTextToolTip)
Run Code Online (Sandbox Code Playgroud)
现在,由于javascript是异步读取的,因此仅调用了底部的两个函数。我环顾四周,发现了一些示例:
.on("mouseover", "highlightImage(); showTextToolTip()") //- doesnt work
.on("mouseover", mouseOverFunctions) //- calls a function>
function mouseOverFunctions(){
showTextToolTip();
highlightImage();
} //- also doesnt work.
Run Code Online (Sandbox Code Playgroud)
我认为这是因为“ mouseover”一次只能调用一个对象。
如何同时调用这两个函数?我希望显示文本并突出显示节点
添加代码
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);
}
Run Code Online (Sandbox Code Playgroud)