iJade
iJade

Reputation: 23801

jquery tipsy tooltip not working with d3.js circles

Here is my d3.js code

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; })

In the end i have appended a tooltip to the circles.I tried to attach jquery tipsy tooltip to the circles but did'nt work.Here is how i did it(i followed 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;
                          }
                       });

But its not working.

Upvotes: 1

Views: 1611

Answers (1)

David Dehghan
David Dehghan

Reputation: 24785

You are missing this.data

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

Upvotes: 1

Related Questions