Published
Edited
Jan 6, 2022
7 stars
Insert cell
Insert cell
Plot.plot({
width: width,
inset: 12,
x: {
label: "Width (cm)",
domain: [0, 200]
},
y: {
label: "Height (cm)",
domain: [0, 200]
},

facet: {
data: data,
y: (d) => Math.floor(categories.indexOf(d.category) / cols),
x: (d) => categories.indexOf(d.category) % cols
},
fy: {
tickFormat: null
},
fx: {
tickFormat: null
},
marks: [
Plot.rect(data, {
filter: (d) => d.width < 200 && d.height < 200, //note: the data goes beyond 200cm x 200cm just reproducing the original chart limit(0,200)
opacity: 0.1,
x1: 0,
x2: "width",
y1: 0,
y2: "height",
strokeWidth: 4,
fill: "#FFDA1A",
stroke: "#0051BA"
}),
Plot.text(
data,
Plot.selectLast({
text: "category",
textAnchor: "start",
fontWeight: "bold",
x: () => 0,
y: () => 0,
dy: 10
})
)
]
})
Insert cell
categories = [...d3.group(data, (d) => d.category).keys()]
Insert cell
cols = width > 700 ? 4 : 2
Insert cell
data = FileAttachment("IKEA_SA_Furniture_Web_Scrapings_sss.csv").csv({
typed: true
})
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more