// code to project circle from Assignment 3 page for rendering circle
var projectedLocation = projection([d.longitude, d.latitude]);
var circle = svg.append('circle')
.attr('cx', projectedLocation[0])
.attr('cy', projectedLocation[1])
.attr('r', 3)
.attr('class', 'restaurant')
.attr('visibility', 'visible')
.attr('fill', 'gray')
.attr('opacity', 0.5)
.datum(d) // this method works because of datum
.on('mouseover', function (event, d) { // HOVER
postInformation(); // adds Restaurant Information label
svg.append('text') // adds hover NAME text label next to data point
.attr('class', 'ptText') //Set class to 'ptLabel' so can remove easily later
.attr('x', projectedLocation[0] + 7) //Set label position near its circle
.attr('y', projectedLocation[1] - 7) //Set label position near its circle
.html(d.restaurant);
})
.on('mouseout', function (event, d) { //STOP HOVER
svg.selectAll('text').remove(); // remove NAME text label
container.selectAll('p').remove(); //remove Restaurant Information Label
postHoverLabel();
})
.on('click', function(event, d) {
postInformation();
});
updateRestaurants(); // function for draggable CIRCLES
});
});
return container.node();
}
printTable(data)
import{printTable}from"@uwdata/data-utilities"
d3=require('d3@7')
import{slider}from"@jashkenas/inputs";//imported function to have the slider bars for the radius of each circle
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.