{
const element = this || scrollSVG(html`<svg width=${width} height=${svgHeight}></svg>`)
const t = d3.transition().duration(1000)
const svg = d3.select(element).select('svg')
const g = svg.selectAll('g')
.data(filteredFlowers, d => d.title)
.join(
enter => {
const g = enter.append('g')
.attr('opacity', 0)
.attr('transform', d => `translate(${d.translate})`)
g.selectAll('path')
.data(d=> _.times(d.numPetals, i => {
return { rotate: i * 360 / d.numPetals, ...d }
})).join('path')
.attr('transform', d => `rotate(${d.rotate})scale(${d.scale})`)
.attr('d', d => d.path)
.attr('fill', d => d.color)
.attr('stroke', d => d.color)
.attr('fill-opacity', 0.5)
.attr('stroke-width', 2)
g.append('text')
.attr('text-anchor', 'middle')
.attr('dy', '.35em')
.style('font-size', '.7em')
.text(d => _.truncate(d.title, { length: 20 }))
return g
},
update => update,
exit => {
exit.transition(t)
.attr('opacity', 0)
.remove()
}
).transition(t)
.attr('opacity', 1)
.attr('transform', d => `translate(${d.translate})`)
return element
}