Public
Edited
Mar 28
Insert cell
Insert cell
Insert cell
state = FileAttachment("himachal-pradesh.geojson").json()
Insert cell
{
const width = 500;
const height = 500;

const stateGeoJSON = {
type: "FeatureCollection",
features: state.features
};

const projection = d3.geoEquirectangular()
.fitExtent([[0, 0], [width, height]], stateGeoJSON);

const geoGenerator = d3.geoPath().projection(projection);

const svg = d3.create("svg")
.attr("width", width)
.attr("height", height);

svg.selectAll("path")
.data(stateGeoJSON.features)
.enter()
.append("path")
.attr("d", geoGenerator)
.attr("fill", "#cce5df")
.attr("stroke", "#333")
.attr("fill", "black")
.attr("stroke", "white")
.attr("stroke-width", 1); ;

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