{
const svg = DOM.svg(petalSize * 2,petalSize * 2);
const ratingMinMax = d3.extent(data, d=> +d.imdbRating);
console.log(ratingMinMax)
const votesMinMax = d3.extent(data, d=> +d.imdbVotes.replace(',',''));
const sizeScale = d3.scaleLinear().domain(ratingMinMax).range([0.25,1]);
const numPetalScale = d3.scaleQuantize().domain(votesMinMax).range([3,6,9,12,15,18])
const flowersData = _.map(data, d =>{
const numPetals = numPetalScale(+d.imdbVotes.replace(',',''));
const petSize = sizeScale(+d.imdbRating);
return {
petSize,
petals: _.times(numPetals, i=> {return{angle: 360 * i / numPetals, petalPath}})
}
});
console.log(flowersData)
const flowers = d3.select(svg)
.selectAll ('g')
.data(flowersData)
.enter()
.append('path')
flowers.selectAll('path')
.data(d => d.petals).enter().append('path')
.attr('d', d => d.petalPath)
.attr('transform', d => `rotate(${d.angle})`);
return svg;
}