【问题标题】:d3 title tspan text not going to new lined3 标题 tspan 文本不会换行
【发布时间】:2019-01-26 01:48:54
【问题描述】:

我有 d3 标题文本,其中包含两个 tspan。最后一个 tspan 有 display:block 属性,但它仍然不会换行。

这里是链接:https://codepen.io/anon/pen/exJROb

JavaScript

var ttl = nodeg.append("title");
  ttl.append("tspan").text(function(d) { return d.data.name })
  ttl.append("tspan").text(function(d) { return "Records: " + d.data.count });

CSS

tspan:nth-child(2n) {
              display: block;
            }

知道如何解决这个问题,以便工具提示的第二部分转到新行吗?

谢谢

【问题讨论】:

    标签: d3.js tooltip title tspan


    【解决方案1】:

    我找到了使用“\n”换行符而不是使用 tspan 和 css 的解决方案。

    https://codepen.io/anon/pen/jdWLyO

    nodeg.append("title")
            .text(function(d) {
                return d.data.name + "\n" + "test";
            });
    

    【讨论】:

      猜你喜欢
      • 2019-07-25
      • 1970-01-01
      • 2017-07-02
      • 2017-05-29
      • 2015-09-28
      • 1970-01-01
      • 2018-11-28
      • 2012-11-05
      • 1970-01-01
      相关资源
      最近更新 更多