Public
Edited
May 22
Insert cell
Insert cell
workbook = FileAttachment("GlobalSuperstore.xlsx").xlsx()
Insert cell
store = workbook.sheet(0, {
headers: true,
// range: "A1:J10"
})
Insert cell
store
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
function removeOutliers(arr, accessor) {
const values = arr.map(accessor).filter(x => !isNaN(x)).sort((a, b) => a - b);
const q1 = d3.quantile(values, 0.25);
const q3 = d3.quantile(values, 0.75);
const iqr = q3 - q1;
const lower = q1 - 1.5 * iqr;
const upper = q3 + 1.5 * iqr;
return arr.filter(d => {
const value = accessor(d);
return value >= lower && value <= upper;
});
}

Insert cell
filteredData = removeOutliers(store, d => d.Sales)
Insert cell
Insert cell
Plot.plot({
x: {axis: null},
y: {tickFormat: "s", grid: true},
color: {scheme: "spectral", legend: true},
marks: [
Plot.barY(filteredData, {
x: "Category",
y: "Sales",
fill: "Category",
fx: "Market",
sort: {x: null, color: null, fx: {value: "-y", reduce: "sum"}}
}),
Plot.ruleY([0])
]
})
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