function plotBusinesses(visual) {
visual.selectAll('.businesses')
.data(techData, d=>d.name)
.join('circle')
.attr('r', 2)
.attr('class', 'businesses')
.style('fill', 'gray')
.attr('cx', d => {
var projectedLocation = projection([d.longitude, d.latitude]);
return projectedLocation[0] + plotVars.margin;
})
.attr('cy', d => {
var projectedLocation = projection([d.longitude, d.latitude]);
return projectedLocation[1] + plotVars.margin;
})
.on('mouseover', function (event, d) {
var projectedLocation = projection([d.longitude, d.latitude]);
d3.select(this)
.style('fill', 'lightpink');
visual.append('text')
.attr('class', 'nameLabel')
.attr('x', projectedLocation[0] + plotVars.margin - 10)
.attr('y', projectedLocation[1] + plotVars.margin - 10)
.text(d.name)
.style('fill', 'crimson');
if (d.avg_rating != 0) {
visual.append('text')
.attr('class', 'ratingLabel')
.attr('x', projectedLocation[0] + plotVars.margin - 10)
.attr('y', projectedLocation[1] + plotVars.margin + 12)
.style('fill', 'crimson')
.text(d.avg_rating);
}
})
.on('mouseout', function(event, d) {
visual.selectAll('.nameLabel').remove()
visual.selectAll('.ratingLabel').remove()
d3.select(this).style('fill', 'gray')
});
}