score:0

you need to load the file through an asynchronous request with d3.csv. example code:

d3.csv("datafile.csv", function(error, data) {
  // do something exciting with data
}

score:2

your drawing code needs to stay inside csv callback:

d3.csv("testdata.csv", function(data){
    // this converts data to number
    data.foreach(function(d) {
        d.x = +d.x;
        d.y = +d.y;
    });

    // rest of drawing code
    ...
});

see another example here:

http://vida.io/documents/qzztrhk7smfchczyp

it's easier to debug if you can post link to working code.


Related Query