制作按照您的代码更改添加作者,标题和出版年细节势必节点JSON数据。
var repeats = Object.keys(bib).reduce((a, v) => {
bib[v].keywords.split(/\s*,\s*/).forEach(kw => {
a[kw] = a[kw] || {
repeat: 0
};
a[kw].test = (a[kw.id])
a[kw].repeat++;
a[kw].title = bib[v].title;
a[kw].author = bib[v].author;
a[kw].year = bib[v].year;
});
return a;
}, {});
要在点击节点时在div中显示发布详情,请尝试如下所示。
node.on("click", function(d) {
//Clear existing details if any
d3.select("#selection_details")
.select("*")
.remove();
//Show publication details
var html = "<P><B>Author:</B> " + d.author + "</P> <P><B>Title:</B> " + d.title + "</P> <P><B>Year of Publication:</B> " + d.year + "</P>";
d3.select("#selection_details")
.html(html);
});
更新小提琴:https://jsfiddle.net/ofcncsfL/2/
TNX这么多,但我怎么能显示每个关键字的所有出版物? 在你的例子中只显示一个出版物! – vahidsamimi
好的。你需要这样的东西吗? https://jsfiddle.net/ofcncsfL/3/预期的格式是什么? – Gilsha