【问题标题】:jquery tipsy tooltip not working with d3.js circlesjquery Tipsy 工具提示不适用于 d3.js 圈子
【发布时间】:2012-11-26 16:19:10
【问题描述】:

这是我的 d3.js 代码

var circles = vis.selectAll("circle").data(data)
circles
    .enter()
        .append("svg:circle")
            .attr("stroke", "black")
            .attr("cx", function (d) { return xRange(d.year); })
            .attr("cy", function (d) { return yRange(d.count); })
            .style("fill", function(d,i){return color(i);})
        .append("svg:title")
            .text(function (d) { return d.corpus; })

最后我在圈子上附加了一个工具提示。我试图将 jquery Tipsy 工具提示附加到圈子上,但没有用。我是这样做的(我关注了http://bl.ocks.org/1373263

var circles = vis.selectAll("circle").data(data)
circles
    .enter()
        .append("svg:circle")
            .attr("stroke", "black")
            .attr("cx", function (d) { return xRange(d.year); })
            .attr("cy", function (d) { return yRange(d.count); })
            .style("fill", function(d,i){return color(i);})
        $('svg circle').tipsy({ 
                            gravity: 'w', 
                            html: true, 
                            title: function (d) {
                            return d.corpus;
                          }
                       });

但它不起作用。

【问题讨论】:

  • 您收到了哪些错误消息(如果有)?你有JSFiddle我们可以看看吗?
  • 没有错误信息。我无法 c 工具提示
  • @socialrel8 这是没有工具提示的 jsfiddle jsfiddle.net/RPGPL/3。你能告诉我如何向它添加 jquery Tipsy 工具提示
  • 我只是将这个问题中的代码与您指出的示例进行了比较。这就是示例中的完成方式: $('svg circle').tipsy({ Gravity: 'w', html: true, title: function () { var d = this.__data__, c = colors(d.i) ; return d.corpus; } });
  • @TJ- 我的错误你 r rite thnks,问题解决了

标签: javascript jquery canvas d3.js tipsy


【解决方案1】:

你错过了这个。数据

$('svg circle').tipsy({ 
                            gravity: 'w', 
                            html: true, 
                            title: function (d) {
                               var d = this.__data__;
                               return d.corpus;
                          }
                       });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-09
    • 1970-01-01
    • 2022-08-14
    • 1970-01-01
    相关资源
    最近更新 更多