-2

I am trying to load data from a CSV file to a list and then to use that list as data to render the D3 chart. The original chart just has an array with objects and passes these as data to the graph.

This is what I currently have:

var links=[];
d3.csv("C:\Users\user\Desktop\tv.csv", function(data){
    links=data;
    doThisWithData(links);
});

The doThisWithData() function appends the data to the chart. I bounded a few variables who did that independently with a var links=[]; and now I am substituting the links variable for a CSV originated links array instead.

This doesn't work for me. Anyone sees any flaws?

Gerardo Furtado
  • 100,839
  • 9
  • 121
  • 171

1 Answers1

-2

From the documentation:

Returns a new request for the CSV file at the specified url

You are passing a file path on the client computer, not a URL. You need to pass a URL.


Your declaration of links outside the callback functions suggests that you are also trying to return the value of an asynchronous call. You can't do that.


It is also worth pointing out that a \ is an escape character in JavaScript string literals.

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335