Legend = {
let seriesLabels = OptionSeries.map(x => {
let obj = d3.timeFormat('%y-%b-%d')(d3.timeParse('%s')(x.expirationDate));
return obj;
});
let seriesScale = d3
.scaleOrdinal()
.range(expirations.map(x => color(x)))
.domain(expirations);
let view = html`<svg style="width:100%; height:auto;">`;
let h = 50;
const svg = d3
.select(view)
.attr('viewBox', [0, 0, w, h])
.style('background', '#222');
yield svg.node();
let legend = svg.append("g").classed('custom-legend', true);
legend
.selectAll('.legend-key')
.data(expirations, d => d)
.join('circle')
.attr('class', d => d + ' legend-key')
.attr('cx', (d, i) => (w / expirations.length) * i + 25)
.attr('cy', 25)
.attr('fill', d => color(d))
.attr('r', 5);
legend
.selectAll('.legend-value')
.data(expirations, d => d)
.join('text')
.attr('class', d => 'legend-value ' + d)
.attr('x', (d, i) => (w / expirations.length) * i + 25)
.attr('y', 35)
.attr('stroke', 'white')
.attr('font-size', '15px')
.text((d, i) => d3.timeFormat('%d %b %Y')(d3.timeParse('%s')(d)))
.attr('text-anchor', 'middle')
.attr('dominant-baseline', 'middle');
}