My goal is to create bar graphs where the width of each bar represents a person's age. However, I am having trouble applying the width attribute to the bars using the style method in d3 (I checked this by inspecting the elements in the browser). Other attributes that are applied using style seem to be working fine.
function showData(clients){
let max = d3.max(clients, (d) => {
return (parseInt(d.age));
})
//console.log(max);
let scale = d3.scaleLinear().domain([0, parseInt(max)]).range([0, 100]);
//console.log(scale);
let join = container.selectAll('div').data(clients);
join.enter().append('div')
.text((d) => {
return d.name + ' : ' + scale(parseInt(d.age));
})
.style('background-color', 'blue')
.style('margin', '5px')
.style('color', 'white')
.style('width', (d) => {
return parseInt(d.age)
});
}