score:8

Accepted answer

Date,DAX,CAC40,FTSE,NASDAQ,Other

JavaScript variable names are case sensitive, so when parsing CSV file with headers as above you need to refer to fields with:

d.Date // note the uppercase D
d.DAX // note all uppercase

Here's an example from d3 wiki https://github.com/mbostock/d3/wiki/CSV#wiki-parse

Year,Make,Model,Length

1997,Ford,E350,2.34

2000,Mercury,Cougar,2.38

When parsed with d3's CSV parser, the resulting data will be represented by the following array:

[
  {"Year": "1997", "Make": "Ford", "Model": "E350", "Length": "2.34"},
  {"Year": "2000", "Make": "Mercury", "Model": "Cougar", "Length": "2.38"}
]

Note the uppercase object keys. To access the year of the first entry, a "Year" with an uppercase Y in data[0].Year would be necessary.

Thus in your forEach function you'll need:

data.forEach(function (d) {
    d.Date = parseDate(d.Date);
});

... and later on:

return {date: d.Date, index: +d[name]};