updateChart = {
const gX = d3.select(chart).select('.x-axis')
const gY = d3.select(chart).select('.y-axis')
const gBars = d3.select(chart).select('.bars')
const y0 = height - margin.bottom
const t = d3.transition().duration(2000)
const bars = gBars
.selectAll('rect')
.data(
chromosomesSorted,
d => d.name
)
.join(
enter => enter
.append('rect')
.attr('x', d => x(d.name))
.attr('y', y0)
.attr('height', 0)
.attr('width', x.bandwidth())
.call(
enter => enter
.transition(t)
.attr('y', d => y(d.length))
.attr('height', d => y0 - y(d.length))
),
update => update
.call(
update => update
.transition(t)
.attr('x', d => x(d.name))
.attr('y', d => y(d.length))
.attr('height', d => y0 - y(d.length))
.attr('width', x.bandwidth())
),
exit => exit
.call(
exit => exit
.transition(t)
.attr('y', height - margin.bottom)
.attr('height', 0)
.remove()
)
);
gX.transition(t).call(xAxis);
gY.transition(t).call(yAxis);
}