Thursday, January 31, 2019

csv - Blank screen with d3js

I am fairly new to computer programming and d3js. I am trying to replicate this bar graph found on the d3js website http://bl.ocks.org/mbostock/b2fee5dae98555cf78c9e4c5074b87c3.
I copied the code exactly and created a CSV file with the necessary data to create the bar graph. But whenever I try running the code the axis is the only thing that comes up. I am not sure if the error is within the CSV file or how I try to call the data. I just know the error is somewhere on my part.



Here's a sample of the CSV file (condensed):




    id,case,date
10097071,HY285524,06/02/2015 09:41:19 PM
21907,HY291065,06/07/2015 03:50:00 AM
21908,HY291065,06/07/2015 03:50:00 AM
10156667,HY345298,07/18/2015 03:17:00 AM


Here's how I have been trying to call it:



    d3.csv("homicides.csv", type, function(error, data) {

if (error) throw error;

var bins = histogram(data);

y.domain([0, d3.max(bins, function(d) { return d.length; })]);


Any help would be appreciated!

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...