Nick Such's Blog

home about

Testing d3 with Markdown

26 Mar 2014

This is from a Stack Overflow question about embedding a d3.js example in a Jekyll blog post (written in Markdown).

This should work, but it looks like the challenge from the referenced d3 example is have a proper target element in the document. The example uses an <iframe> element, which embeds another HTML document where the target element is <body>. Here, I’ve embedded the same iframe:

And here, I’ve used d3 to target an element <div id="example"> in this document:

To do this, I made the following changes:

Check out the code for this post on GitHub to see how I did it!