如何使用d3-tip向移动对象添加工具提示

时间:2017-04-05 22:33:23

标签: javascript d3.js tooltip

我正在尝试向此using this page中的源代码添加工具提示(link)。 我在html文件中添加了d3.tip.v0.6.3.js链接。然后,我在flightanimation.js中定义了工具提示功能,如下所示:

<div>responsive height</div>

我在html文件中添加了相应类的样式,如下所示:

var tip = d3.tip()
           .attr('class', 'd3-tip')
           .offset([-10, 0])
           .html(function(d) {return "<span> hi </span>"});
svg.call(tip);

我还添加了

d3-tip {
        line-height: 1;
        font-weight: bold;
        padding: 12px;
        background: rgba(0, 0, 0, 0.8);
        color: #fff;
        border-radius: 2px;
       }

到flightanimation.js的飞机末端如下:

 .on('mouseover', tip.show)
 .on('mouseout', tip.hide)

当我运行它时,将光标移动到平面对象上它没有显示任何内容。

有没有人有任何想法如何解决这个问题? 任何建议或建议将不胜感激。

谢谢。

0 个答案:

没有答案