1
votes

I am evaluating various ways of installing dc.js for my RoR application. npm seems very convenient, as it installs dc.js with its dependencies: d3.js and crossfilter. I run npm install dc

It works a few seconds and returns:

$ npm install dc

[email protected] /home/fred/55Projets/development/Stairs
└─┬ [email protected] 
  ├── [email protected] 
  └── [email protected] 

Unfortunately, the first function called in my home page is

var ndx = crossfilter(data); // Instanciate Crossfilter

Which raises the error: ReferenceError: crossfilter is not defined in the console.

On the Github pages, there is mention about a place where the reference should be manually added ... any idea ? Thanks for your help!

1

1 Answers

0
votes

I don't know how you have Javascript dependencies set up for your page (and don't know anything about RoR).

However, npm only deals with the problem of installing modules. It does not deal with the problem of how you load Javascript modules in your page. dc.js depends on crossfilter2 (crossfilter.js), but it won't automatically load that library unless you are using a module loader or bundler which will do that for you.

The most common solution is just to manually load crossfilter.js in the same place you load dc.js, i.e. in another <script> tag.

Ways to deal with this automatically include (in chronological order of popularity) requireJS, browserify, webpack.

Et cetera. It's a notoriously exhausting topic, with new loaders and bundlers replacing the old ones pretty much every year.