This example shows how to embed csv data in a hierarchical format into your document und use a different key. This option can be used without a web server.
Acknowledgements:
xxxxxxxxxx
<meta charset="utf-8">
<head>
<script src="https://d3js.org/d3.v6.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/ee2dev/d3-indented-tree/dist/latest/d3-indented-tree.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/EE2dev/d3-indented-tree/dist/latest/d3-indented-tree.css">
</head>
<body>
<!-- paste data in aside tag -->
<aside id="data">
myKey,parent,color
Eve,,2
Cain,Eve,3
Seth,Eve,3
Enos,Seth,4
Noam,Seth,5
Abel,Eve,4
Awan,Eve,3
Enoch,Awan,7
Azura,Eve,2
</aside>
<script>
const dataSpec = {
source: "aside#data",
key: "myKey",
};
const myChart = d3.indentedTree(dataSpec)
;
showChart(myChart);
window.setTimeout(function() {
myChart.linkWidth(100);
}, 2000);
function showChart(_chart) {
d3.select("body")
.append("div")
.attr("class", "chart")
.call(_chart);
}
</script>
</body>
</html>
Updated missing url https://cdn.jsdelivr.net/gh/EE2dev/d3-indented-tree/dist/latest/d3-indented-tree.min.js to https://cdn.jsdelivr.net/gh/ee2dev/d3-indented-tree/dist/latest/d3-indented-tree.min.js
https://d3js.org/d3.v6.min.js
https://cdn.jsdelivr.net/gh/EE2dev/d3-indented-tree/dist/latest/d3-indented-tree.min.js