score:2
make sure that your files are being served properly by an http server. the main question here is whether or not you're pasting the json directly into the index.html that you're creating or if you're using a separate json file.
d3.json makes an ajax call to load the json file. in order to make this json request you must have an http server serving the directory that contains the separate json file. this could very well be why when you change directories (perhaps to a directory that is being served by some server) the expected chart appears. if instead you replace the d3.json call with a reference to the json in an inline manner, you do not need a server. instead you should be able to view the example statically from your file system with your browser no matter the directory it is in.
the reason for needing a server is due to the same origin policy that is described in w3c standards. you can find out a simple solution in this s.o. post: d3 bar graph example not working locally. it offers two solutions, to either spawn a http server for the directories that the files are being served or to modify the same origin policies in your browser. i recommend the server approach due to safety standards.
Source: stackoverflow.com
Related Query
- An html file doesn't run from within my templates folder
- How to run R script from HTML webpage
- How to pass input file parameter from html page to a Javascript
- Javascript: calling function within D3 from another file
- External JS file not working within my HTML file
- Include javascript and html code from another file
- load JSON from rails controller to d3 .defer() function within javascript file
- d3.json does not load file from App_Data folder of ASP.NET MVC
- Javascript callback in JavaFX from within a HTML page (using D3)
- D3js take data from an array instead of a file
- How to load data from a CSV file in D3 v5
- Cannot import data from csv file in d3
- D3.js loading local data file from file:///
- Render D3 graph from a string of JSON instead of a JSON file
- d3.js filter from csv file using multiple columns
- How to load data from an internal JSON array rather than from an external resource / file for a collapsible tree in d3.js?
- Prevent Templates From Discarding DOM Elements
- D3.js - load csv file from chrome
- Export an SVG from DOM to file
- Trying to add ID to svg path from json file
- How to update elements of an HTML that the elements are created using data from a CSV file?
- I want to run d3 from a Cakefile
- How to assign the x-axis position of a node in a Sankey Diagram (D3) from the json file
- Drawing voronoi diagram from a csv file with d3.js
- d3.js: Drawing arcs between two points on map from file
- D3.js from HTML table
- How can I use an Angularjs filter within the html element of a d3 tooltip?
- How can I efficiently convert data from string to int within a d3 method chain?
- Pass variables from one file to another
- How to stop Angular handling a click event from within d3
More Query from same tag
- How to draw double circles?
- How can I center the text in a node?
- How to update the d3js - graph data alone without re-appending `svg` element
- D3.js data() method with json data
- D3 scatter plot coming out wrong
- Histogram using d3js
- X scale function in D3.js keeps returning undefined
- JS Equivalent of Linking to a Font File
- Performance issue: HTML file size too big and slow rendering because of d3 visualization
- Why is initial drag position incorrect when using a scale?
- How to trigger an angular change from a non-angular context e.g. from a D3 event?
- d3.js - Autoscroll for pie chart legend
- Effective way to display the data in the chart
- Animating data motion between nodes in d3
- How to display one million in dimple measure axis as 1000k instead of 1m?
- Defining a category axis using c3.js
- Double click event not working on D3 version 6.1
- How do I get d3 to treat missing values as null instead of zero?
- wkhtmltopdf - Converting SVG created by AJAX to PDF
- How to change a circle into a square with d3.js
- D3.js Drawing rectangles around a circle
- Make the svg follow a hierarchical structure
- Javascript library d3 call function
- D3 function for gauge-like scale to produce: [-2, -1, 0, 0, 1, 2]
- How to use highchart boost library with D3?
- D3 - get number of dimensions in radial chart
- D3 Force Nodes Clustering at Top Left
- Include javascript and html code from another file
- D3: How to show large dataset
- D3 adds path for geojson but not topojson