MG
const data = [12, 23, 34, 56, 67, 89, 90, 09, 87, 65, 43, 21,]
const params = {
width: 800,
height: 400,
barWidth: 20,
barPadding: 2,
barColor: 'forestgreen',
margin: 20,
duration: 800
}
const scaleX = d3.scaleLinear().domain([0, d3.max(data)]).range([0, data.length]);
const graph = d3.select('body')
.append('svg')
.attr('width', params.width)
.attr('height', params.height)
.attr('class', 'graph');
graph.selectAll('.bar')
.data(data)
.enter()
.append('rect')
.attr('fill', params.barColor)
.attr('x', (d, i) => (params.barWidth + params.barPadding) * i + params.margin)
.attr('y', (d, i) => params.height - d - params.margin)
.attr('width', params.barWidth);
graph
.transition()
.duration(params.duration)
.attr('height', d => d);
why I got nothing instead of
height
?