Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8217401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:27:20+00:00 2026-06-07T12:27:20+00:00

I am trying to use D3 with a JSON file to create and display

  • 0

I am trying to use D3 with a JSON file to create and display a tree map. Very simple, just trying out D3 for fun. However, after I have put together both my tree.js and ran the script, I get a blank page. Console says

XMLHttpRequest cannot load file:///Users/aczre/Desktop/d3TestApp/shreleases.json.
Cross origin requests are only supported for HTTP.

Uncaught TypeError: Cannot read property 'children' of null d3.v2.js:6081
d3_layout_hierarchyChildren d3.v2.js:6081
 recurse d3.v2.js:5990
 hierarchy d3.v2.js:6033
 tree d3.v2.js:6384
 object.nodes d3.v2.js:6074
 (anonymous function) tree.js:17
 d3.json d3.v2.js:514
 ready d3.v2.js:504
 d3.xhr.req.onreadystatechange d3.v2.js:497
 d3.xhr d3.v2.js:500
 d3.text d3.v2.js:510
 d3.json d3.v2.js:513
 (anonymous function) tree.js:16

Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101 d3.v2.js:500
 d3.xhr d3.v2.js:500
 d3.text d3.v2.js:510
 d3.json d3.v2.js:513
 (anonymous function) tree.js:16

Not sure what I did wrong… here’s my tree.js

var width = 960,
    height = 2000;

var tree = d3.layout.tree()
    .size([height, width - 160]);

var diagonal = d3.svg.diagonal()
    .projection(function(d) { return [d.y, d.x]; });

var vis = d3.select("#chart").append("svg")
    .attr("width", width)
    .attr("height", height)
    .append("g")
    .attr("transform", "translate(40, 0)");

d3.json("shreleases.json", function(json) { // Line 16
  var nodes = tree.nodes(json);

  var link = vis.selectAll("path.link")
  .data(tree.links(nodes))
.enter().append("path")
  .attr("class", "link")
  .attr("d", diagonal);

  var node = vis.selectAll("g.node")
      .data(nodes)
     .enter().append("g")
      .attr("class", "node")
      .attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })

  node.append("circle")
      .attr("r", 4.5);

  node.append("text")
      .attr("dx", function(d) { return d.children ? -8 : 8; })
      .attr("dy", 3)
      .attr("text-anchor", function(d) { return d.children ? "end" : "start"; })
      .text(function(d) { return d.name; });
});

I tried to stick to the examples listed on the D3 website, https://github.com/mbostock/d3/wiki/Gallery
but I’m not sure if I completely understand the syntax.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:27:22+00:00Added an answer on June 7, 2026 at 12:27 pm

    You probably need to make the request for the JSON file from a web server. The error message is complaining that it is not an http request, since your file is stored locally.

    You could throw your JSON file onto your web host, if you have one. Or you could create a local server setup using something like WAMP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Json.NET to serialize and deserialze a tree structure for jsTree.
I am trying to use the NETFx Json.NET MediaTypeFormatter nuget package to swap out
Trying to use Jbuilder to create some JSON views for my app, but the
I'm trying to use Sencha Touch 2 to load a local json file into
I'm trying to write/create a JSON file from a AIR app, I'm trying not
I'm trying to use a yui plugin that pulls from a json file and
When trying to create a simple service to return a simple JSON string by
I've been having some issues trying to use cURL and JSON to print out
I'm trying to use json for my web page's globalization options.. id like to
I am trying to use JSON to populate a div, so I basically run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.