This example shows how to a second numeric value to a node with myChart.nodeBar(). This example also shows:
Acknowledgements:
<!DOCTYPE html>
<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">
level1;level2;level3;size1;size2;size3;color
Eve;Cain;;1;2;4;rgb(100 23 80)
Eve;Seth;;-45;20;4;rgb(100 23 80)
Eve;Seth;Enos;3;2;4;rgb(100 23 80)
Eve;Seth;Noam;3;2;4;rgb(100 23 80)
Eve;Abel;;32;2;4;rgb(100 23 80)
Eve;Awan;Enoch;-2333.3;2;5;rgb(100 23 80)
Eve;Azura;;;2;4;rgb(100 23 80)
Eve;;;-88883;2;4;rgb(100 23 80)
</aside>
<script>
const dataSpec = {
source: "aside#data",
hierarchyLevels: ["$", "level1", "level2", "level3"],
delimiter: ";",
};
const myChart = d3.indentedTree(dataSpec)
.linkWidth("size1", {range: [100, 300]})
.linkLabel("size1", {unit: " cust"})
.nodeSort("size1")
.nodeBar("size1", {translateX: 1, unit: " customers", labelInside: true})
;
showChart(myChart);
function showChart(_chart) {
d3.select("body")
.append("div")
.attr("class", "chart")
.call(_chart);
}
</script>
</body>
</html>