加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

twitter-bootstrap – d3.js:用glyphicon类附加一个span

发布时间:2020-12-18 00:19:51 所属栏目:安全 来源:网络整理
导读:以下代码正常工作.它画了一个圆圈.我想要的是在这个圆圈里面绘制一个bootstrap glyphicon: span class =“glyphicon glyphicon-zoom-in” / span d3.json("relations",function(error,graph) { var links = svg.selectAll() .data(graph.links).enter(); li
以下代码正常工作.它画了一个圆圈.我想要的是在这个圆圈里面绘制一个bootstrap glyphicon:< span class =“glyphicon glyphicon-zoom-in”>< / span>
d3.json("relations",function(error,graph) {
    var links = svg.selectAll()
        .data(graph.links).enter();

    links        
      .append("circle")
      .attr("class","circle")
      .attr("r",circle_r)
      .attr("cx",function(d) { return d.x; })
      .attr("cy",function(d) { return d.y; });

我试图做以下继续前面的代码:

链接
.append( “跨度”)
.attr(“class”,“glyphicon glyphicon-zoom-in”)

但符号不呈现.我想有一些关于定位它的东西,因为使用firebug / inspector我可以看到< span>入驻.

有谁知道怎么做?谢谢

解决方法

我通过添加像这样的glyphicons来实现这个目的:
link.append("svg:foreignObject")
    .attr("width",20)
    .attr("height",20)
    .attr("y","-7px")
    .attr("x","-7px")
  .append("xhtml:span")
    .attr("class","control glyphicon glyphicon-zoom-in");

通过使.glyphicon的位置静态:

.control.glyphicon {
  position: static;
}

Plnkr example here

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读