Public
Edited
Feb 3, 2023
Insert cell
Insert cell
asst3_yelp.csv
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
attachment = FileAttachment("asst3_yelp.csv").csv()
Insert cell
restaurantData = attachment.map((res) => {
return {id: res.id,
name:res.name,
img: res.image_url,
category:res.categories,
rating:res.rating,
coordinates:res.coordinates}
});
Insert cell
Insert cell
height = 580;
Insert cell
width = 800;
Insert cell
{
// Create SVG
let svg = d3.select( "body" )
.append( "svg" )
.attr( "width", width )
.attr( "height", height );

// Append empty placeholder g element to the SVG
// g will contain geometry elements
let g = svg.append( "g" );
return svg.node();
}
Insert cell
bosProjection = d3.geoAlbers()
.scale( 50 )
.rotate( [122.221921,0] )
.center( [0, 37.600329] )
.translate( [width/2,height/2] );
Insert cell
bos_geoPath = d3.geoPath()
.projection( bosProjection );
Insert cell
bosNeighborhoods = FileAttachment("bayarea-neighborhoods.geo.json").json()
Insert cell
{
// Create SVG
let svg = d3.select(DOM.svg(width, height));

// Append empty placeholder g element to the SVG
// g will contain geometry elements
let g = svg.append("g");
// Classic D3... Select non-existent elements, bind the data, append the elements, and apply attributes
g.selectAll( "path" )
.data( bosNeighborhoods.features )
.enter()
.append( "path" )
.attr( "fill", "#ccc" )
.attr( "stroke", "#333")
.attr( "d", bos_geoPath );
return svg.node();
}
Insert cell

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.
Learn more