Appendix D. Sharing Your Code
The D3 community is big on sharing code, whether for showing off new projects and techniques or for asking for help. And let me tell you: people want to help you! But when asking questions, it’s essential to share your code. (Have you ever tried to debug a project without the project itself?)
You are free to publish and share your code however you like, but the most common venues are:
-
bl.ocks.org
-
Bl.ock Builder
-
Gistup
-
Codepen, JS Bin, or similar
-
Normal web server
I’ll walk through each of these options.
bl.ocks.org
Mike Bostock is a big fan of examples. He can’t get enough of them. In 2013, he even gave a great talk making the case for examples titled, yes, “For Example”.
In fact, to encourage us all to create and share our own examples, he built a web service called bl.ocks.org. The blocks service (as I will refer to it, because it is so annoying to type the period in “bl.ocks”) makes it very easy to share your D3 code and projects with others. You can use it to share any kind of code, not just JavaScript and D3, but because Mike built it, it’s sort of optimized for D3 purposes.
Thus, blocks are very popular in the D3 community. Posting a block and sharing the link is a great way to show off your latest project, share a work-in-progress with others, or—most importantly—to get help troubleshooting when you’re at your wit’s end. Before you even begin writing your question on StackOverflow or the D3 Google Group, post a block! Because the ...
Get Interactive Data Visualization for the Web, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.