0

I'm trying to build a data viz in d3 using jsfiddle but I don't think it's reading my local csv file despite giving it the correct path. Here is my code

d3.csv("/Users/Downloads/bar-data.csv", 
function(error, data) {

data.forEach(function(d) {
    d.date = parseDate(d.date);
    d.value = +d.value;
});

Am I doing something wrong here? Do I need to store the data somewhere else?

will
  • 511
  • 2
  • 11
  • 21
  • do you have a link to your fiddle – shadow2020 May 07 '19 at 17:43
  • @shadoe2020 https://jsfiddle.net/0z6bh4mt/ – will May 07 '19 at 17:44
  • According to the documentation, you need to provide a URL. In general, you can not access local files through JavaScript -- easiest option for you is to get your CSV from a live URL but maybe you can find a way around (ej. https://stackoverflow.com/questions/371875/local-file-access-with-javascript) – ludovico May 07 '19 at 17:52

1 Answers1

0

This is a CORS issue. You will need to move this file to a location that is on the same domain as your code. Thus you wont be able to continue in jsfiddle. You will need to work on the files locally entirely or on a domain of some sort.

shadow2020
  • 1,315
  • 1
  • 8
  • 30