chart = {
const svg = d3.select(DOM.svg(width, height));
const defs = svg.append('defs');
defs.append('filter').attr('id', 'shadow')
.append('feDropShadow')
.attr('dx', 2)
.attr('dy', 2)
.attr('stdDeviation', 2);
const g = svg.append('g');
const gLegend = svg.append('g').classed('legend', true);
g.selectAll('path.ea')
.data(ea.features)
.join(s => s.append('path').classed('ea', true))
.attr('fill', 'white')
.attr('stroke-width', 2)
.attr('stroke', '#eee')
.attr('d', path);
const getAttr = (s) => (d) => d[s] || '';
const attr = [
getAttr('LOC_STREET'),
d => (d = d['USEDASCODE'], d && d[0] || ''),
getAttr('PROP_CLASS'),
][1];
const propClasses = eaParcels.features
.map(d => attr(d.properties))
.filter((el, i, arr) => el && arr.indexOf(el) === i)
.sort(d3.ascending);
const colorScale = d3.scaleOrdinal()
.domain(propClasses)
.range(d3.quantize(d3.interpolateRainbow, propClasses.length));
const eaStreetCategories = d3.group(eaStreets.features, d => d.properties.highway);
const primaryStreets = {type: 'FeatureCollection', features: [
...eaStreetCategories.get('primary'),
//...eaStreetCategories.get('secondary'),
]};
const filteredStreets = {
type: 'FeatureCollection',
features: Array.from(eaStreetCategories).reduce((acc, e) => [
'primary', 'secondary', 'tertiary', 'residential'].includes(e[0]) ? acc.concat(e[1]) : acc, []),
};
const b = turf.buffer(primaryStreets, 1000, {units: 'feet'})
defs.append('mask').attr('id', 'main-clip')
.call(s => s.append('rect')
.attr('fill', 'white')
.attr('opacity', 0.1)
.attr('width', width)
.attr('height', height))
.call(s => s.append('path')
.attr('fill', 'white')
.attr('d', path(b))
)
//g.append('g').classed('.ea-parcels', true).selectAll('g.parcel')
// .data(eaParcels.features)
// .join(s => s.append('g')
// .classed('parcel', true)
// .call(s => s.append('path'))
// )
// .call(s => s.select('path')
// .attr('d', path)
// .attr('stroke', 'black')
// .attr('stroke-width', 0.1)
// .attr('fill', d => {
// let group = attr(d.properties);
// return group ? colorScale(group) : '#ececec';
// })
// )
// .on('click', d => console.log(d));
//g.append('g').classed('voronoi', true)
// .selectAll('path')
// .data(d3.geoVoronoi().x(d => d.x).y(d => d.y)(eaParcelCentroids).polygons().features)
// .join('path')
// .attr('d', path)
// .attr('fill', (_, i) => d3.schemeCategory10[i % 10])
g.attr('mask', 'url(#main-clip)').append('g').classed('ea-buildings', true)
.selectAll('path')
.data(eaBuildings.features)
.join('path')
.attr('d', path)
.on('click', d => console.log('d', d))
g.append('path').classed('streets', true)
.attr('fill', 'none')
.attr('stroke', 'grey')
.datum(filteredStreets).attr('d', path);
svg.call(d3.zoom().on('zoom', () => g.attr('transform', d3.event.transform)));
return svg.node();
}