caged / d3-tip

d3 tooltips
http://labratrevenge.com/d3-tip
MIT License
1.22k stars 349 forks source link

Looks like tip.offset() receive array but expect swapped x vs. y values #217

Closed alundiak closed 6 years ago

alundiak commented 6 years ago

In line https://github.com/Caged/d3-tip/blob/master/index.js#L139 it says // v - Array of [x, y] offset

I tried my code changes, and assumed I was changing x value, in fact I was changing y value. I'm using v0.6.8 version for d3 v3.5.7

And my code to set the offset:

 var tip = d3Tip()
        .attr('class', 'd3-tip')
        .offset([-10, 0])

So this code gives my -10 up by y axis, and x axis still remain 0, so that my tip rendered for 10px above.

Is this correct behavior? Is it wrong comment? Have I done smth wrong?

PS. I see, that even in live demo/example, there is also -10 applied: http://bl.ocks.org/Caged/6476579

var tip = d3.tip()
  .attr('class', 'd3-tip')
  .offset([-10, 0])
  .html(function(d) {
    return "<strong>Frequency:</strong> <span style='color:red'>" + d.frequency + "</span>";
  })

UPD: Looks like all is ok, because in fact if y = 10, then it goes down (for SVG, rect), not as original coordinate systsem.

stale[bot] commented 6 years ago

Hey there! It looks like this issue has been automatically marked as stale because it has not had recent activity. To help the maintainers stay focused, it will be closed if no further activity occurs. Thank you for your contributions.