Richard
Richard

Reputation: 65540

Can't get D3 particles example to work?

I'm looking at Mike Bostock's particles example for D3.js.

I have copied and pasted the code locally, without changing anything at all. I'm running the code using SimpleHTTPServer, so there shouldn't be any security issues to do with running locally.

Whenever I mouseover the body, I see the following error in the console:

Uncaught TypeError: Object #<Object> has no method 'mouse' 

Does anyone know what might be going on? Can anyone get it to work locally?

Thanks.

Upvotes: 0

Views: 655

Answers (2)

Evelyn
Evelyn

Reputation: 41

There's a way to fix the code, so that you can reference the latest release of D3 at http://d3js.org/d3.v3.min.js

The error you're getting is caused by the line var m = d3.svg.mouse(this); Change it to var m = d3.mouse(this); and you should be fine.

See the release notes here, on the changes from D3 v2 to v3: https://github.com/mbostock/d3/wiki/Upgrading-to-3.0

Specifically:

"SVG: The aliases d3.svg.mouse and d3.svg.touches have been removed; use d3.mouse and d3.touches instead. These methods are identical, and were moved in an earlier minor release that added support for HTML as well as SVG elements."

Upvotes: 1

Chris
Chris

Reputation: 7855

Did you actually hardcopied the entire referenced library? It could be an inter-domain referencing issue. Did you do a reference directly to http://mbostock.github.com/d3/d3.js?1.25.0 ? it could be, that this is not possible from outside that domain.

Upvotes: 1

Related Questions