I have done something more complicated before using d3.histogram and bins, but in the following situation, I am not sure why the domain() would not give back the array but only the first element? Can't we use the data array and each element in it as the "key" for the domain?
const data = [
{ name: "A", value: 1 },
{ name: "B", value: 5 },
{ name: "C", value: 7 },
{ name: "D", value: 3 },
{ name: "E", value: 9 },
];
const scaleX = d3
.scaleBand()
.domain(data)
.range([0, 1000]);
console.log("scaleX.domain()", scaleX.domain());
console.log("scaleX.range()", scaleX.range());
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/6.6.2/d3.js" integrity="sha512-6G9G63qZLxEcLqVyklArI/2ZgWK1HdKMU9yWbQUJC/eSsLsaY0NZKv4JDW4ltw1Z9sEvFB3DP54GzOIkIJjyLg==" crossorigin="anonymous"></script>