

How to utilize D3.js with Rails partials?  - tommaxwell

Hi HN,<p>I&#x27;m building a Rails app that needs some visualizations, but I have a problem. In the app, users have folders which contain entries that they create. When you visit the site (logged in), you are shown a list of all your folders, and clicking on one loads up a partial with all the submissions contained inside.<p>What I&#x27;d like to do is something different: When the user opens the folder, I&#x27;d like to load a partial with all the &lt;svg&gt; and &lt;circle&gt; HTML for D3, and size them based on the character count of each submission. However, I&#x27;m lost on how to do it and have been trying to get it working all day.<p>I have placed all the D3 code inside my show.html.erb file for the folder, which injects the partial into the body of the site. It doesn&#x27;t work, and my D3 code needs to know which folder has been opened to load the correct JSON data; I&#x27;m using a d3.json call to get the JSON for the folder, which contains a sub-array for submissions.<p>Is my approach wrong? I&#x27;m sort of a Rails newbie, so I&#x27;m not sure how else to do this. Any help is greatly appreciated.
======
jdc
That sounds complicated. Why not just make an SVG partial that draws circles
that accepts the quantity, sizes and positions as parameters?

