Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed d3.js to a Jekyll Post

Exactly as this question, I want to embed this particular example on my blog.

I tried using <iframe> but bl.ocks.org isn't supporting it anymore. I tried with <iframe> using rawgit but this too didn't work. I tried using the method given here and it works! but for my example it doesn't.

I have inspected both of these sites (this one) and (this too), and found out that in my case the d3 script isn't appending any svg element in my custom div. ( Please look at this answer for the method I used )

Please suggest me how to proceed with this.

like image 212
Ankit Panda Avatar asked Dec 16 '25 13:12

Ankit Panda


1 Answers

I solved this by:

  1. creating another folder in _includes in the main Jekyll directory and placing my custom .js files in it.
  2. Then change d3.select("body").selectAll("svg") to d3.select("div#example").append("svg").

Finally it renders the custom .js files alright.

like image 165
Ankit Panda Avatar answered Dec 19 '25 06:12

Ankit Panda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!