the hello world of d3

After getting stuck on getting a squishy collision, I decided to go back to basics by following step by step this blog.

So far so good, because it’s not looking for files – I think my file linking is the problem.

Yes! OK, so the file calling from the media library seems to work. It must be the format of calling the file from some other place, and perhaps how the code relates or something that’s a problem. This is encouraging. Now, for interactivity (or squishiness)

And, nope. *Weeps*. In this tut's code, it says

// Load dataset
var dataset = d3.csv.parse("pre#data").text());
// this just grabs the text from the preformatted block
// and parses it as if it was a csv file
// in your real code, you would use d3.csv(filename, callbackFunction)
// and the rest would be inside your callback function:

So the ONE place where I need help it leaves me hanging. Darnit. Now I have to actually think about this.

I would think the correct alternative is

d3.csv("", function(d) );

but that makes the plugin ask for an identifier, which I think means it needs the date/temperature info which is in there too, so I can add that, but then where do I stop adding stuff from the previous example? If I add everything it gives the text list, so that's obvs too much.

I need to go learn about variables (or functions? variables are functions? ? ) First, let's digress to capture my current thinking on foam flush toilets. Catcha later.

Next day: trying
var dataset = d3.csv("", function(data, temperature) {
and the }); in various places, but no luck so far.

Let's go have a look at some other example that doesn't ask for the d3.js yet but that does call a data file. Ambitiously, the miserables one again (which does use d3). Whole big load of nope. I tried to just use the second example above to show the list of temperatures, but with the miserables file (renamed to csv, and also tried the txt version). This didn't work, even after lots of tweaking. I think an issue may be that the temperature file has simple data pairs, like "date,temperature, 20150101,57", whereas the .json file (in it;s csv or txt form) has "{ "nodes":[ {"name":"Myriel","group":1}, ... ], "links":[ {"source":1,"target":0,"value":1}, ...  ] }.

Hmmm. OK, back to calling a data file.

Actually (yes, focus is hard) ... looking for stuff I found the Raw HTML plugin that may be better (because one can edit the html directly rather than upload a new one every time as I lamented in a previous post). Thanks Nat Kale! Also found what could have been a very useful example but the link to the original tut has broken. It had a nifty way to make the urls better - upload directly via ftp (doh 🙂 ) Some other interesting posts on that blog too. I think I'm going to try the raw html (in a new post) because I suspect it's the d3 plugin that's breaking the more sophisticated d3 stuff. Ugh, this makes me feel so dumb.

Leave a Reply

Your email address will not be published. Required fields are marked *

HTML Snippets Powered By :