Public
Edited
Dec 17, 2023
Insert cell
Koyambedu Market
Insert cell
d3 = require("d3@6")
Insert cell
chart = {
const width = 960,
height = 450;
const svg = d3.create("svg")
.attr("viewBox", [-100, -100, width+200, height+200]);

// Use Mercator projection
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], bbox);

var path1 = d3.geoPath().projection(projection);
var path2 = d3.geoPath().projection(projection);
var path3 = d3.geoPath().projection(projection);
var path4 = d3.geoPath().projection(projection);

var g = svg.append("g").attr("id", "paths");


var p = svg.selectAll("polyline") //d3 geopath
.data(test1)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})
.style('fill','white')
.style("stroke", 'white')

p.enter().append("polyline") //d3 geopath
.data(Border)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})
.style('fill','none')
.style("stroke", 'white')
p.enter().append("polyline") //d3 geopath
.data(Base)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})
.style('fill','none')
.style("stroke", 'black')
p.enter().append("polyline") //d3 geopath
.data(Trucks)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})
.style('fill','none')
.style("stroke", 'black')
p.enter().append("polyline") //d3 geopath
.data(Proposal)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})
.style('fill','cyan')
.style("stroke", 'black')
.on('mouseover',proposalText)
.on('mouseout',deltext)
svg
.append("text")
.attr('x','-15')
.attr('y','-40')
.text('Koyambedu Market Layout')
.style('font-size','25px')
.style('font-weight','bold')
.style('background-color','white')

function proposalText(event,d){
svg
.append("text")
.attr('x','10')
.attr('y','40')
.attr('class','hydrant_info')
.text('Proposed Refrigerated/Ventilated Storage')
.style('font-size','12px')
}
function deltext(){
d3.selectAll("text.hydrant_info").remove()
}
return svg.node();
}
Insert cell
Base = FileAttachment("base.txt").tsv({array:true})
Insert cell
Proposal = FileAttachment("proposal.txt").tsv({array:true})
Insert cell
bbox = FileAttachment("site_boundary@1.geojson").json()
Insert cell
Trucks = FileAttachment("trucks.txt").tsv({array:true})
Insert cell
Insert cell
hydrants = d3.csv(hydrant_link,d3.autoType)
Insert cell
import {wrap_text, wrap_text_nchar} from "@ben-tanen/svg-text-and-tspan-word-wrapping"
Insert cell
test1 = FileAttachment("Border.txt").tsv({array:true})
Insert cell
Border = FileAttachment("BlackBorder.txt").tsv({array:true})
Insert cell
hLine = FileAttachment("HydrantLine.txt").tsv({array:true})
Insert cell
hMask = FileAttachment("HydrantMask.txt").tsv({array:true})
Insert cell
hide = FileAttachment("Sometimes.txt").tsv({array:true})
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