Skip to content Skip to sidebar Skip to footer

Using D3-tip With Npm: "uncaught Typeerror: Cannot Read Property 'node' Of Undefined"?

I've installed d3': '^3.5.17' and 'd3-tip': '^0.7.1' using npm (d3-tip documentation). Then in my index.js file I have this code: var d3 = require('d3'); var d3tip = require('d3-ti

Solution 1:

This was happening because I was trying to use the latest version of d3-tip (which requires v4 of D3) with v3 of D3.

Reverting to older versions of both fixed things:

"d3":"^3.5.17","d3-tip":"^0.6.7"

Solution 2:

Your line

var tip = d3tip().attr('class', 'd3-tip').html(function(d) { return"hello world"; })

must be

var tip = d3.tip().attr('class', 'd3-tip').html(function(d) { return"hello world"; })

You can check my implementation @:

Source (Lines: 17, 91, 333-339, 685-692)

Demo

Solution 3:

The problem is your line:

var d3tip = require('d3-tip')(d3);

You should not be calling d3.tip(foo) with the d3 reference itself, but with a d3 selection (which it can then invoke .node() on).

I think this should probably be:

d3.tip = require('d3-tip');

Post a Comment for "Using D3-tip With Npm: "uncaught Typeerror: Cannot Read Property 'node' Of Undefined"?"