Treemap in d3.js

hello every one ,why do we use data for accessing key value pair in json in the building process of a treemap.
by the way i am very exhausted by freecodecamp projects because they are very hard and need a lot to read.can any one give me any motivation or advice i really appreciate.

Hello Anyuan!

I can’t answer your data question, but keep you motivated.

First: Get used to this job being hard. Just the access has become easier through online recources. The big challenge is that there’s too much to keep in mind, too many things changing every year, learning on the fly and from project to project is the norm.

The big motivator: It will be easier with time and when you can pull software development off, you are in for a well paying career with many directions to grow.
This is my first year and I’m still in training, banged my head on the table many times. The progress I have made so far both in developer skills and personal growth (my memory has improved for example) plus the great people I already conneted with in tech are worth it.

I’m not sure what you mean here. If you mean the d3.selectAll(...).data(...) method, then that is just how you tell D3 to iterate over some data like all the other D3 visualizations. If you mean something different, you’ll have post some code and be specific. I suggest putting your project in a codepen and posting the link to it.

for example if you want to access the name key value in the json data you use in building treemap using d3.js
and here is the link to the project:-

hello Daniel !
thanks for the advice.what keeps me going is that i spent almost half of my life learning in school just you know learning about numbers and theory but have acheived or gained nothing(i mean no money,and with out money no Happiness).but learning programing is worthy as i will have well payment and very good opportunities.
thanks for the reply.

You’ve chosen the right field.

Also don’t let the current headlines about Big Tech layoffs, recession etc. discourage you.

Almost every company / organization/ party etc nowadays needs websites, servers and data bases and will for a long time. We are the people writing the software to keep the lights on.

Always keep the eye on the goal!

I’m still not sure what you mean, but this bit of your code is closest to what you mention:

.then(data => {
  var root = d3.hierarchy(data)
             .eachBefore(function (d) { = (d.parent ? + '.' : '') +;
  .sum(d => d.value)
  .sort(function(a,b) {
    return b.height - a.height || b.value - a.value;

Are you asking why you used this code?

i forget to see data parameter part in the then method when i revised it.i sometimes get confusion,sorry for wasting your time.