function lineLegend(){
let color = (d, i) => d3.schemeSet2[i];
let entries = [];
let key = d => d.key;
function legend(sel){
const items = sel.selectAll(".item")
.data(entries)
.enter().append("div")
.attr("class", "item")
.style("display", "inline-block")
.style("margin-right", "8px");
items.append("div")
.attr("class", "swatch")
.style("background", color)
.style("display", "inline-block")
.style("height", "10px")
.style("margin-right", "4px")
.style("vertical-align", "middle")
.style("width", "10px");
items.append("div")
.attr("class", "key")
.style("display", "inline-block")
.style("font-family", "sans-serif")
.style("font-size", "14px")
.style("vertical-align", "middle")
.text(key);
return legend;
}
legend.color = function(fn){ return arguments.length ? (color = fn, legend) : color; };
legend.entries = function(arr){ return arguments.length ? (entries = arr, legend) : entries; };
legend.key = function(fn){ return arguments.length ? (key = fn, legend) : key; };
return legend;
}