D3: No code inside d3.json is running? Help plz

D3: No code inside d3.json is running? Help plz
0

#1

I’m so confused to the reason but none of the code inside my d3.json() seems to be running and I cannot figure out why. It’s almost identical to working code from a past project. I’ve read it 100 times and cannot pick up a typo or anything. Please help me.


#2

Hello Nathan,

As I checked your code, it seems the first fault line is following

[d3.min(dataset.Seconds), d3.max(dataset.Seconds)]

This is becasue dataset itself is an array, and Seconds is a attribute of each index of dataset element.

As I checked the d3 API, it seems the d3 min and max expected an array as argument. but hopefully there is another solution to cover when items are object(like your case) rather primitives, please check following.

var min_=d3.min(dataset,function(item){return item.Seconds;})

This tells the d3 for each item of dataset(array) call the function given, and it will calculate an number and return it for you.
Same thing about your max value.

No beside the seconds, you should do the same thing for year too.

Now I think you may debug the drawing part, seems broken which I believe you can of course.

Keep going on great work, happy programming.


#3

Thanks @NULL_dev,

I knew it was going to be somethine stupid i missed. On a bit of a sleep deprived coding session and really just hit a wall. Thanks as always for the help.

Happy coidng