Random Man
Random Man

Reputation: 115

Cannot read property 'pack' of undefined

I use d3.js (latest version - v4). In v3 it is work. I have read documantation about layout.pack. Where is my mistake?

var bubble = d3.layout.pack()
    .sort(null)
    .size([diameter, diameter])
    .padding(2);

Upvotes: 1

Views: 1734

Answers (2)

Nima Bastani
Nima Bastani

Reputation: 305

For the newer versions d3.pack() doesn't have a sort method, so the proper usage for pack() with these versions is to call size and padding, and instead of using sort in here, sort the hierarchy. these are all discussed in here: Uncaught TypeError: d3.pack(…).sort is not a function

var bubble = d3.pack()
.size([diameter, diameter])
.padding(2);

Upvotes: 0

Random Man
Random Man

Reputation: 115

Drop the "layout". Thanks to @GerardoFurtado

var bubble = d3.pack()
    .sort(null)
    .size([diameter, diameter])
    .padding(2);

Upvotes: 3

Related Questions