How to debug D3.js using Firefox

2,685 views
Skip to first unread message

Kenneth Zhang

unread,
May 24, 2012, 6:03:17 PM5/24/12
to d3-js
I am relatively new to D3.js and I am running it with Firefox on
Linux. I had a hard time debugging my code. Many times I couldn't get
the right figure, but there is no error shown in the Error Console. I
have tried Firebug and found that not all the code is shown in the
console.

Could someone please advise what is an efficient way to debug D3.js?
Thanks in advance!

Nelson

unread,
May 24, 2012, 6:16:14 PM5/24/12
to d3-js
Hey Kenneth,

I would recommend you installing the Firefox Plugin "Firebug" and
using the
built in console.log("hello world") function, to log your variables
and objects.

Best Nelson

Ian Johnson

unread,
May 24, 2012, 6:17:36 PM5/24/12
to d3...@googlegroups.com
One thing that helps is to inspect the DOM elements with Firebug. Perhaps you appended some elements (like a <rect>) but somehow you didn't bind the data properly, or you appended the elements and messed up the attributes. These things can go wrong without showing any errors (because the code still executes properly, it's just not what you expected). So to get a better idea if the code matches your expectations you can see if the proper elements show up in the page.

--
Ian Johnson

Nelson

unread,
May 24, 2012, 6:19:18 PM5/24/12
to d3-js
Sorry I missed your last sentence :)

Can you give a specific example? Something which doesn"t show up?

Kenneth Zhang

unread,
May 25, 2012, 6:21:04 PM5/25/12
to d3...@googlegroups.com
Thank you Nelson for your kind help - now the Firebug works fine! It really saves me a lot of time.

Kenneth Zhang

unread,
May 25, 2012, 6:22:05 PM5/25/12
to d3...@googlegroups.com
Thank you Ian for your kind suggestion - it works now!
Reply all
Reply to author
Forward
0 new messages