gka / d3-jetpack

🚀 Nifty convenience wrappers that speed up your daily work with d3.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to actually use?

yunyu opened this issue · comments

The information isn't present at all in the readme. Here's what I've tried:

var d3 = require('d3');
require('d3-jetpack');
var sel = d3.select('body');

After Webpacking, I get Uncaught TypeError: d3.select is not a function. I have both d3 and d3-jetpack modules installed.

If I do

var d3 = require('d3');
var jetpack = require('d3-jetpack');
// ...
c.svg.append('rect').at({width: c.width, height: c.height, opacity: 0})

I get Uncaught TypeError: c.svg.append(...).at is not a function.

The same also occurs with

var d3 = Object.assign({}, require('d3'), require('d3-jetpack'));
// ...
c.svg.append('rect').at({width: c.width, height: c.height, opacity: 0})

Managed to get it working with:

var d3 = Object.assign({}, require('d3-selection'), require('d3-shape'), require('d3-drag'), require('d3-array'), require('d3-jetpack'));

Maybe put this in the readme?

If I try this, then I get the error Uncaught ReferenceError: require is not defined. How do I fix this?

@pujaarajan Use webpack or browserify