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]};
Source: stackoverflow.com
Related Query
- d3js - TypeError: string is undefined
- D3JS or Jquery: convert JSON string to integer
- TypeError with d3js tree
- d3js gives typeError "d is undefined"
- D3js d.x is undefined
- d3js / epochjs Cannot read property 'length' of undefined
- D3js undefined variable creating fill color
- D3JS Plotting Line Graph From Array Data (Data is undefined error)
- TypeError: string is undefined (var c, p, i = 0, n = template.length, m = string.length;)
- d3js plotting linecharts undefined is not iterable
- Undefined .call() in D3js bar chart
- Undefined is not a function error d3js
- Catch undefined TypeError from use of 'eval' in Angular?
- d3js user of String and Math.Sqrt with no parameters
- Uncaught TypeError: Cannot read property 'linear' of undefined
- D3js take data from an array instead of a file
- d3js Tree square
- Loading D3.js data from a simple JSON string
- d3.svg.line() error: Uncaught TypeError: Cannot read property 'line' of undefined
- C3JS - Cannot read property 'category10' of undefined
- Get one element from d3js selection, by index
- D3.js - Cannot read property 'axis' of undefined
- Getting d3.scale is undefined - works in codepen
- Create database E-R diagram with D3js
- Do AngularJS Directives for D3JS exist?
- IE10 d3.v3.js error: Unable to get property 'prototype' of undefined or null reference
- D3js how to append 2 children at the same level in .enter context
- Extending d3js hierarchical tree for representing topology
- D3js within Java application
- d3js - d3.scale.category10() not working?
More Query from same tag
- SVG D3 image resize issue
- What is the updating chart pattern with queue()?
- Two data sets one component , ngx-charts , angular 2
- Rotate label text of bar chart by 90deg
- Add data to server-side SVG with D3
- D3 creating a selector from this inside each
- D3: + operator before object call
- d3js nice() not rounding up axis domain
- Having problems getting variable values in rotate function in javascript/svg/d3
- Transitioning a path more than once
- Object key value destructuring in array arguments
- Loading external csv file in jsfiddle
- How to set a d3Plus Timeline with only Certain years?
- Maximum value of the second column of an array
- looping over a url
- Labels issue in D3.js
- d3 x-axis has issue when there are duplicate values
- How to append data to a path or object in D3 and JavaScript?
- Arrow marker shaded in SVG d3
- nvd3 discrete bar chart doesnot take entire svg area
- Colorbrewer scale only returning lightest values on D3 map
- Export SVG with external CSS to server
- D3.js defs and url() does not work
- How to calculate (SVG) X/Y coordinates out of translation and rotation (in JS/D3.js)?
- Reset or Clear Cubism Graph
- Client side module can not access dependent module when using webpack
- How to draw a vertical area chart?
- Changing fill/stroke of svg path elements in d3.js tick event shows no effect
- How to point intersection of lines in svg and d3.js?
- d3 chart is showing some decimal value in the X axis tick, instead of showing the date and time