<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
meta
name
=
"viewport"
content="
width
=
device
-width,
initial-scale
=
1
.0">
<
title
>Document</
title
>
</
head
>
<
style
>
.originalColor{
height: 100px;
width: 100px;
}
.darkerColor{
height: 100px;
width: 100px;
}
</
style
>
<
body
>
<
script
type
=
"text/javascript"
src
=
</
script
>
<
script
>
let collection=[
{val:"val1", data:"data1", anotherData:"data1"},
{val:"val2", data:"data2", anotherData:"data2"},
{val:"val3", data:"data3", anotherData:"data3"},
{val:"val4", data:"data4", anotherData:"data4"}
]
//key is added
let data=d3.nest().key((d)=>{return d.val})
//another key is nested and added
.key((d)=>{return d.data})
//another key is added and nested
.key((d)=>{return d.anotherData})
.entries(collection)
console.log(data);
</
script
>
</
body
>
</
html
>