Published
Edited
Sep 3, 2020
Fork of Click Events
1 fork
Insert cell
Insert cell
svg = {
const svg = html`<svg id = "svg"></svg>`
const container = d3.select(svg)
container.append("circle")
.attr("r",50)
.attr("fill","cornflowerblue")
.attr("stroke","black")
.attr("cx",300)
.attr("cy",150)
.on("click",function(){
const target = d3.select(this)
const currentColor = target.attr("fill")
if(currentColor == "cornflowerblue"){
target.attr("fill","tomato")
}else{
target.attr("fill","cornflowerblue")
}

})
return svg
}
Insert cell
Insert cell
Insert cell
Insert cell
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