1

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.

iJade
  • 23,144
  • 56
  • 154
  • 243
  • What error messages (if any) are you getting? Do you have a [JSFiddle](http://jsfiddle.net) we could look at? – ajtrichards Nov 26 '12 at 16:20
  • no error message.I'm not able to c the tooltip – iJade Nov 26 '12 at 16:22
  • @socialrel8 here is the jsfiddle http://jsfiddle.net/RPGPL/3/ without the tooltip.Can u let me know how to add jquery tipsy tooltip to it – iJade Nov 26 '12 at 16:46
  • 2
    I just compared the code in this question to the sample you have pointed out. This is how it is done in the example : $('svg circle').tipsy({ gravity: 'w', html: true, title: function () { var d = this.__data__, c = colors(d.i); return d.corpus; } }); – TJ- Nov 26 '12 at 16:49
  • @TJ- my mistake u r rite thnks,Issue solved – iJade Nov 26 '12 at 16:58
  • Cool. Glad it is fixed now. – TJ- Nov 26 '12 at 17:12

1 Answers1

1

You are missing this.data

$('svg circle').tipsy({ 
                            gravity: 'w', 
                            html: true, 
                            title: function (d) {
                               var d = this.__data__;
                               return d.corpus;
                          }
                       });
David Dehghan
  • 22,159
  • 10
  • 107
  • 95