score:1
Accepted answer
firstly your json string should be like:
var datajson = '[ { "x": 100, "y": 110 },
{ "x": 83, "y": 43 }, { "x": 92, "y": 28 },
{ "x": 49, "y": 74 },
{ "x": 51, "y": 10 }, { "x": 25, "y": 98 },
{ "x": 77, "y": 30 }, { "x": 20, "y": 83 },
{ "x": 11, "y": 63 }, { "x": 4, "y": 55 },
{ "x": 0, "y": 0 }, { "x": 85, "y": 100 },
{ "x": 60, "y": 40 }, { "x": 70, "y": 80 },
{ "x": 10, "y": 0 }, { "x": 40, "y": 50 },
{ "x": 25, "y": 31 } ]';
note the double codes(") on the key.
next
you are setting the domain like:
var x = d3.scale.linear()
.domain([0, d3.max(data, function(d) {
return d.x + 10;
})])
.range([margin.left, w - margin.right]); //
but data is defined much below this line.
so please move the below lines above:
var data = json.parse(datajson);
data.foreach(function(d) {
d.x = d.x;
d.y = +d.y;
});
working code here
Source: stackoverflow.com
Related Query
- Uncaught TypeError: Cannot read property 'length' of undefined in line chart with json data
- NVD3 Line Chart Uncaught TypeError: Cannot read property 'x' of undefined
- D3 Line Chart - Uncaught TypeError: Cannot read property 'length' of undefined
- Uncaught TypeError: Cannot read property 'type' of undefined with d3.js
- Displaying SVG elements with D3 and d3.slider: Uncaught TypeError: Cannot read property 'length' of undefined
- Error when generating line Chart, Uncaught TypeError: Cannot read property 'each' of undefined
- d3plus with Svelte: Uncaught TypeError: Cannot read property 'document' of undefined
- nvd3 cumulative line doesn't work: Uncaught TypeError: Cannot read property 'map' of undefined
- Uncaught TypeError: Cannot read property 'linear' of undefined
- d3.svg.line() error: Uncaught TypeError: Cannot read property 'line' of undefined
- D3.js : Uncaught TypeError: Cannot read property 'document' of undefined
- Uncaught TypeError: Cannot read property 'arc' of undefined in AngularJS and D3
- topojson.js:187: Uncaught TypeError: Cannot read property 'type' of undefined
- Uncaught TypeError: Cannot read property 'axis' of undefined
- Uncaught TypeError: Cannot read property 'albersUsa' of undefined
- d3.js - Uncaught TypeError: Cannot read property 'data' of undefined
- topojson/d3.js: Uncaught (in promise) TypeError: Cannot read property 'type' of undefined
- Uncaught TypeError: Cannot read property 'length' of undefined in d3.js
- D3 - Uncaught TypeError: Cannot read property 'length' of undefined
- Creating links between nodes d3.js currently returning Uncaught TypeError: Cannot read property 'weight' of undefined
- Uncaught TypeError: Cannot read property 'length' of undefined in d3
- D3 error - Uncaught TypeError: Cannot read property 'children' of undefined
- Getting Uncaught TypeError: Cannot read property 'length' of undefined on leafletjs
- Uncaught TypeError: Cannot read property 'y' of undefined in NV D3 StackedLine
- JS;D3 Barchart UNDEFINED Error : Uncaught TypeError, Cannot read property
- Uncaught TypeError: Cannot read property 'arc' of undefined
- Cannot read property 'length' of undefined in a pie chart
- variable with .select method returns null - Uncaught TypeError: Cannot read property 'append' of null
- d3 json loading error Uncaught TypeError: Cannot read property 'length' of undefined
- D3 JS - Uncaught TypeError: Cannot read property 'length' of undefined - seems related to data issue
More Query from same tag
- d3 js expandable and collapsable tree structure
- How to use D3 hierarchical edge bundling graph with Plotly
- Set position of polygons and paths in d3
- Custom time interval in bar chart has no gaps between bars
- d3 draw once on mouseover
- D3 - Multiple line chart, Second line circles not showing
- d3js bar graph with x+y axes: x axis value distribution
- d3.js force directed interactive coloring for groups
- DC.js barchart bars disappear on brush and total amount for date range problems
- d3v4 why are my line elements not appearing?
- Title does not appear on my D3js radar chart
- D3 bar chart bar text labels not visible properly
- is the d3.js api object structure always the same
- D3 Responsive chart
- Having issue with translate function
- d3js get corner coordinates of rect
- Freeze Y-Axis label in d3.js
- Marimekko Chart: x axis ticks with irregular column width
- Why is .delay() not iterating properly?
- How to use 'this' in Angular with D3?
- responsive d3 area graph stretches circle interaction points
- Data is not matching y-axis domain
- D3 selective Zoom
- Iterating over objects in Javascript
- Do I have to re-join the whole data set even if only one property in one item changed?
- Making a responsive angled svg shape with pattern
- Plotting aggregated data with sub-columns in dc.js
- How do I translate d3.js nodes?
- How to create semi circle with d3.shape that start at 9pm and ends at 6am
- D3 LineGraph Circles Remove Overlap && Sort dates