score:1
Accepted answer
d3.json()
expects a url as its first parameter, not a json string. this will in turn request the specified file at that particular url to load the json from.
in your case, however, it might be easier to directly assign the json to the data
variable.
var data = json.parse("<?php echo json_encode($viewmodel) ?>");
data.foreach(function(d) {
//...
});
Source: stackoverflow.com
Related Query
- Error when passing JSON data to d3.json
- D3 - V3: Scope error when using data loaded from a json file
- No 'Access-Control-Allow-Origin' header is present on the requested resource Error when loading JSON file
- Passing JSON data from server to client with Flask
- d3 returns error `e is not a function` while passing nest data to d3.stack
- D3 v4 returning error for scaleTime when passing in Date object
- Basic JSON Formatting for C3.js when data loaded via URL using Rails
- Passing AJAX json data to D3
- D3.JS Histogram: error aligning bars when updating data
- How to load data to D3 chart from JSON when there are only tuples
- Links not visible when loading json data dynamically into D3 Network Visualization
- D3 - passing JSON data through AJAX call
- Error parsing data when drawing d3 line chart
- Error parsing d3 line chart JSON data
- Typeerror when pulling json data from Github
- Passing arbitrary column values to D3 visualization when reading data file
- Error when drawing a d3.js line with no data
- D3JS passing in a JSON object returns an error
- D3.js json error when making tree
- passing json data to html template using d3.js in django view
- Uncaught error reading in json data to d3 force-directed graph
- 404 error - unable to find JSON file when making a map but it looks like it's in the right place
- How to use translate in d3 when data is loaded from external json
- Error while plotting line chart from JSON data
- Loading D3.js data from a simple JSON string
- D3 - how to deal with JSON data structures?
- Updating links on a force directed graph from dynamic json data
- Passing data from Django to D3
- Generate (multilevel) flare.json data format from flat json
- d3 - reading JSON data instead of CSV file
More Query from same tag
- D3.js treemap wrong rectangle size
- Creating a D3 line graph with points
- Formatting the jquery slider tool tip text
- Multiple lines in D3 line graph (rollup data)
- D3 - Select element in this svg?
- Remove Stroke Border from SVG within HTML/CSS/JS Web App
- Changes to forceSimulation disable drag
- Error: <path> attribute d: Expected number D3
- d3plus: how to flip order of drawn boxplots?
- D3.js bar chart - axis and labels not working / transitioning
- Issue with D3 multi-line chart
- How can you access data that's nested like this in a csv file?
- D3 tooltip not following the mouse
- d3.js: grid lines displayed out of the charts
- d3 drag in pane and position
- d3.time.format.multi is not a function
- How to make a color scale in D3 JS to use in fill attribute?
- d3 add multiple classes with function
- How do I externalize my d3 v4 pie chart labels?
- I can't see my svg shape even though it exists in DOM
- Dynamically resize a div when it is used as a node in a d3 force-directed graph
- TopoJSON map not rendering properly using D3
- JSON summing multiple objects where values contain a string
- d3 trigger mouseover on path underlying other path?
- Angular 2 D3 Event, Change Detection and Context
- TypeError: svg.append(...).attrs is not a function when creating charts using D3.js
- Plotting points on a bell curve in D3
- d3js svg not visible in chrome
- Inline D3 sparklines in a table alongside text
- watchTransition() is not a function in nv.d3.js with angular.js