{
const margin = ({top: 10, bottom: 70, left: 140, right: 10});
const visWidth = width - margin.left - margin.right;
const visHeight = 500 - margin.top - margin.bottom;
const x = d3.scaleBand()
.domain(Clist)
.range([0, visWidth])
.padding(0.2)
const y = d3.scaleLinear()
.domain([0, maxh])
.range([visHeight,0])
const xAxis = d3.axisBottom(x)
const yAxis = d3.axisLeft(y)
const svg = d3.create('svg')
.attr('width', visWidth + margin.left + margin.right)
.attr('height', visHeight + margin.top + margin.bottom);
const g = svg.append("g")
.attr('transform', `translate(${margin.left}, ${margin.top})`);
g.selectAll('rect')
.data(evpercap)
.join('rect')
.attr('x', d => x(d.Country))
.attr('y', d => y(d.EVperCap))
.attr('width', x.bandwidth)
.attr('height', d=>(visHeight - y(d.EVperCap)))
.attr('fill', 'steelblue');
g.append('g')
.call(yAxis);
g.append('g')
.attr('transform', `translate(0, ${visHeight})`)
.call(xAxis)
.append('text')
.attr('fill', 'black')
.attr('font-family', 'sans-serif')
.attr('x', visWidth / 2)
.attr('y', 40)
.text("Category");
g.append('g')
.attr('transform', `translate(-10, 0)`)
.append('text')
.attr('fill', 'black')
.attr('font-family', 'sans-serif')
.attr('x', -100)
.attr('y', visHeight/2)
.style("font-size", "10px")
.text("Total Duration");
return svg.node();
}