chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, chart_width, chart_height]);
svg.selectAll('rect')
.data(data)
.enter()
.append('rect')
.attr( 'x', function( d, i ){
return x_scale(i);
})
.attr( 'y', function(d ){
return chart_height - y_scale( d );
})
.attr( 'width', x_scale.bandwidth() )
.attr( 'height', function( d ){
return y_scale( d );
})
.attr( 'fill', '#7ED26D' )
.on('mouseover', function(){
d3.select(this)
.transition()
.attr('fill', '#0C9CDF');
})
.on('mouseout', function(){
d3.select(this)
.transition()
.attr('fill', '#7ED26D');
})
.attr('fill', '#7ED26D')
.append('title')
.text(function(d){
return d;
})
return svg.node();
}