Graph hhas disappeared in D3 bar chart project

Tell us what’s happening:
I can’t get my graph to render, and I can’t figure out why. It stopped rendering when I transitioned from having the data saved as a variable, to when I accessed that data from the JSON object

Your code so far
https://codepen.io/seth-alan-burleson/pen/XWjjrGP?editors=1011
I made a backup before I started really using the JSON data, and haven’t changed too much. you can find that here https://codepen.io/seth-alan-burleson/pen/xxEVBQE

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36.

Challenge: Visualize Data with a Bar Chart

Link to the challenge:

Since you are using d3v6, d3.json() actually returns a promise. Using a .then() works (this is what I used) and and according to my notes when I did this, callbacks worked in d3v4. I haven’t tried the async/await route, but see this on SO.

Good luck.

1 Like

ok, that makes a little more sense but this is my first time using promises. I thought I set it up right,

let jsonPromise = d3.json('https://raw.githubusercontent.com/freeCodeCamp/ProjectReferenceData/master/GDP-data.json');


  jsonPromise.then((data)=>{
  var gDP = data.data.map(function(i){
    return i[1];
  // rest of function continues after this

The data is being imported successfully, but I can’t get the graph to show up and I’m not sure where I went wrong .

I figured out my problem once I opened chrome’s dev console. I had the .scaletime method called without parentheses after it.