chart={
const col1='#36ff36',col2='#3636ff';
const svg=d3.create('svg').attr('style','background:whitesmoke')
.attr('viewBox',[0,0,1.2*width,1.2*height]);
svg.append('g').append('text').attr('text-anchor','middle')
.attr('x',(width+margin.left)/2)
.attr('y',height+margin.bottom+margin.top)
.style('font-size','24px')
.text('Median & Mean Values');
svg.append('g').call(xAxis).style('font-size','12px');
svg.append('g').call(yAxis).style('font-size','12px');
const lines=svg.append('g').attr('class','lines')
.attr('transform',`translate(0,${margin.top})`)
.selectAll('line').data(db_data).join('line')
.attr('stroke','#363636').attr('stroke-width',4)
.attr('opacity','.7')
.attr('x1',d=>x(d.median_mean[0]))
.attr('x2',d=>x(d.median_mean[1]))
.attr('y1',d=>y(d.name)).attr('y2',d=>y(d.name));
const dots=svg.append('g').attr('class','dots')
.attr('transform',`translate(0,${margin.top})`)
.selectAll('circle').data(db_data).join('circle')
.attr('fill',col1).attr('r',8)
.attr('cx',d=>x(d.median_mean[0]))
.attr('cy',d=>y(d.name))
.clone(true)
.attr('cx',d=>x(d.median_mean[1]))
.attr('fill',col2);
const legend_trans=`translate(${width+margin.right}`
.concat(`,${height/2-margin.bottom})`);
const legend=svg.append('g').attr('class','legend')
.attr('transform',legend_trans)
.call(d3Legend.legendColor()
.shape('circle').shapeRadius(8)
.shapePadding(60).orient('vertical')
.labelAlign('center').labelOffset('20')
.scale(d3.scaleOrdinal()
.domain(['median','mean'])
.range([col1, col2])));
yield svg.node();}