0
我想通過d3plus.js構建一個小應用程序。其目的是使用網絡可視化來顯示一系列代表pdf文件的節點。點擊節點時,會出現一個顯示PDF的窗口。我想了解如何使用window.open()函數,如果我直接將路徑寫入window.open()函數(fx「docs/somepdf.pdf」),它就可以工作。如何在d3plus/javascript中傳遞open.window()onclick事件的路徑?
我的問題是現在將路徑字符串從sample_data傳遞到window.open函數。
任何人都可以請求告訴我我在做什麼錯在這裏?
<script src="//d3plus.org/js/d3.js"></script>
<script src="//d3plus.org/js/d3plus.js"></script>
<div id="viz"></div>
<script>
// create list of node positions
var sample_data = [
{"name": "alpha", "size": 10, "path": "docs/Tan - 1999 - Text mining The state of the art and the challeng.pdf"},
{"name": "beta", "size": 12, "path": ""},
{"name": "gamma", "size": 30, "path": ""},
{"name": "delta", "size": 26, "path": ""},
{"name": "epsilon", "size": 12, "path": ""},
{"name": "zeta", "size": 26, "path": ""},
{"name": "theta", "size": 11, "path": ""},
{"name": "eta", "size": 24, "path": ""}
]
var connections = [
{"source": "alpha", "target": "beta"},
{"source": "alpha", "target": "gamma"},
{"source": "beta", "target": "delta"},
{"source": "beta", "target": "epsilon"},
{"source": "zeta", "target": "gamma"},
{"source": "theta", "target": "gamma"},
{"source": "eta", "target": "gamma"}
]
// instantiate d3plus
var visualization = d3plus.viz()
.container("#viz")
.type("network")
.edges(connections)
.size("size")
.id("name")
.tooltip(["name", "size"]).mouse({
"move": false, // key will also take custom function
"click": function(){window.open("path", '_blank', 'fullscreen=yes')}
})
.draw()
</script>
非常感謝!我可以看到你是一名研究生,擔任軟件開發人員。我很快就要完成應用機器學習和文本挖掘方面的博士學位,並且我對軟件開發有很多想法。您是否有興趣交流想法和想法,作爲未來合作的出發點? –