🏠 back to Observable

D3 GITHUB commit history in a hericatical data structure

Was thinking about doing some trees of the D3 GITHUB commit history and so converted the data into a hericatical data structure and tested it using a couple of code examples from D3.

But now I don’t know what visual of my own to make using this data for D3 Parade 2021 – D3.js Community Sooo, I thought I would share it here.

Comments welcome, especially on other ways this code could be written because after 3 levels it gets confusing when adding on the children.

  let hd={name:'D3',
          children:[]}
  
  data.forEach( (v,k) => {
    hd.children.push({name:k,children:[]})
    v.forEach( (v1,k1) => {
      hd.children[hd.children.length-1].children.push({name:k1,children:[]})
      v1.forEach( (v2,k2) => {
        hd.children[hd.children.length-1].children[hd.children[hd.children.length-1].children.length-1].children.push({name:v2.subject})
      })
    })
  })
1 Like