使用d3.js添加到另一个页面的链接 [英] Add a link to another page with d3.js
本文介绍了使用d3.js添加到另一个页面的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这可能是很直接的。我想添加一个链接到另一个页面。我试图通过d3添加它。我在JS中添加另一个属性? Iv尝试了.attr(src,newPage.html)和.attr(url,newPage.html)但都不工作。
This is probably really straight forward. I'm looking to add a link to another page. I'm trying to add it through d3. Do I add another attribute in the JS? Iv tried .attr("src", "newPage.html") and .attr("url", "newPage.html") but neither work.
将不胜感激。谢谢。
//JS
var newLink = d3.select(".chart")
.append("div")
.html("Trend Graph")
.attr("class", "populationTrend")
//CSS
.populationTrend{
font-weight:400;
margin-top:-15%;
cursor:pointer;
padding-left:70%;
background-color:#039;
}
推荐答案
链接(即锚标签),你可以简单地做
To add a "normal" link (i.e. anchor tag), you can simply do
d3.select(".chart")
.append("a")
.attr("href", "newPage.html")
.html("new page");
或甚至
d3.select(".chart")
.append("div")
.html("<a href='newPage.html'>new page</a>");
这篇关于使用d3.js添加到另一个页面的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文