d3js:`xlink:href`不起作用
d3js: `xlink:href` is not working
我正在尝试实现href
到d3js图表,如本文和此处所述。我在这个d3js条形图中添加了一个简单的href
,但它不起作用。这是我的代码:
我在html
:中导入了xlink
<myatr xmlns:xlink="http://www.w3.org/1999/xlink">
</myatr>
这是我的d3js代码
svg.selectAll(".bar")
.data(data)
.enter().append("rect")
.attr("class", "bar")
.attr("x", function(d) { return x(d.letter); })
.attr("width", x.rangeBand())
.attr("y", function(d) { return y(d.frequency); })
.attr("height", function(d) { return height - y(d.frequency); })
.attr("xlink:href",function(d){return "www.google.com";});
看起来您也需要附加a
标记。试试这个:
svg.selectAll(".bar")
.data(data)
.enter().append("a")
.attr("xlink:href", "www.google.com")
.append("rect")
.attr("class", "bar")
.attr("x", function(d) { return x(d.letter); })
.attr("width", x.rangeBand())
.attr("y", function(d) { return y(d.frequency); })
.attr("height", function(d) { return height - y(d.frequency); })
相关文章:
- Javascript-将变量传递给php页面,window.location.href不起作用
- 使用 Div 标签的 location.href 属性时,Eval 不起作用
- 使用self.location.href重定向不会'不起作用
- 检查window.location.href.indexOf是否'不起作用
- JS:数据href中指定的链接在转盘中不起作用
- 点击 href 事件不起作用
- 我的 href 点击事件不起作用
- 当在 img 标签中提到类时,Href 不起作用
- jQuery this.href 字符串比较不起作用
- 使用 href=“#” JQuery 工作,但使用 href=“page.jsp” 不起作用
- window.location.href 在 Meteor 中不起作用
- 输入框上的 Href 不起作用
- JavaScript window.location.href 不起作用
- window.location.href 不起作用,无法重定向
- ng-href 从 JSON 打开页面在应用程序中不起作用
- Javascript在href中工作,但在JS文件中不起作用
- 带有 onclick 的 href 在 Safari 中不起作用
- 在 mvc 应用程序中使用 href 属性重定向 asp.net 不起作用
- 为什么ajax不起作用,除非我刷新或使用location.href
- 使用变量的 Href 属性不起作用