Public
Edited
Mar 3, 2024
Insert cell
Insert cell
hrvecdf(ecdf_data, ecdf_mean);
Insert cell
function hrvecdf(data, mean, { width } = {}) {
const lines = new Map(); // from id to mark
const plot = Plot.plot({
grid: true,
width: width,
inset: 10,
x: { tickFormat: d3.format(".2f"), domain: [0, 0.3] },
marks: [
Plot.lineY(data, {
x: "the_value",
y: "proportion",
z: "session_id",
stroke: "session_id",
render: (index, scales, values, dimensions, context, next) => {
const g = next(index, scales, values, dimensions, context);
for (const line of g.childNodes) {
line.setAttribute("opacity", 0.3);
lines.set(values.z[line.__data__[0]], line);
}
return g;
},
tip: true
}),
Plot.lineY(mean, {
x: "the_value",
y: "proportion",
stroke: "black",
strokeWidth: 2
})
]
});

plot.addEventListener("input", () => {
const z = plot.value?.["session_id"];
for (const [id, line] of lines) {
line.setAttribute("opacity", z ? id === z ? 1 : 0.1 : 0.3);
}
});
return plot;
}
Insert cell
selected_sid = null;
Insert cell
parquetWasm = import("https://cdn.jsdelivr.net/npm/parquet-wasm@0.1.1/web.js")
Insert cell
async function getDataTable(file) {
await init();
const arrayBuffer = await file.arrayBuffer();
const arr = new Uint8Array(arrayBuffer);
const arrowIPC = readParquet(arr);
const dt = aq.fromArrow(arrowIPC);
return dt;
}
Insert cell
ecdf_data = getDataTable(FileAttachment("ecdf.parquet"))
Insert cell
ecdf_mean = getDataTable(FileAttachment("ecdf_mean.parquet"))
Insert cell
readParquet = parquetWasm.readParquet
Insert cell
init = parquetWasm.default
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