jasondavies / d3-cloud

Create word clouds in JavaScript.
https://www.jasondavies.com/wordcloud/
Other
3.82k stars 1.07k forks source link

Cant' get it to work with Browserify #100

Closed pdechery closed 8 years ago

pdechery commented 8 years ago

Hi,

I'm struggling to get this nice plugin to work with my app.

I've installed it with npm and My browserify dependencies are set up like so:

jQuery = require('jquery')
require('../vendor/jquery.fullpage.min')

require('perfect-scrollbar/jquery')(jQuery)

global.d3 = require('../vendor/d3')

d3tip_module = require('d3-tip')
d3tip_module(d3)

d3cloud_module = require('d3-cloud')
d3cloud_module(d3)

When I run nothing appears and I get a 'd3.layout.cloud is not a function' in console.

Any help would be much appreciated.

Pierre

jasondavies commented 8 years ago

I’m not sure why you are initialising it using d3cloud_module(d3) (and presumably later with d3.layout.cloud), perhaps you should start with the sample in examples/browserify.js?

Using d3.layout.cloud is the non-browserify way of doing things; with browserify it’s a module loaded directly using require(…).

pdechery commented 8 years ago

Hi Jason, thank you.

I didn't see the examples but now it makes sense to me and it's working!

http://dapp.fgv.br/esportes/olimpiadas-2016/#ferramenta/time-brasil-vis