html`<div style="display: flex; flex-direction: column; gap: 2rem; font-family: sans-serif;">
<!-- Filters -->
<div style="display: flex; gap: 2rem;">
<div>${viewof gender}</div>
<div>${viewof ageGroup}</div>
</div>
<!-- Row 1: Return Rate + Popularity Index -->
<div style="display: flex; flex-wrap: wrap; gap: 2rem;">
<!-- Box Plot: Return Rate by Shipping Method -->
<div style="flex: 1 1 400px;">
<h4 style="margin-bottom: 0.5rem;">📦 Return Rate by Shipping Method</h4>
${Plot.plot({
x: { label: "Shipping Method" },
y: { label: "Return Rate (%)" },
height: 300,
marks: [
Plot.boxY(
filtered
.filter(d => d["Shipping Method"] && d["Return Rate"])
.map(d => ({
method: d["Shipping Method"],
returnRate: +d["Return Rate"]
})),
{
x: "method",
y: "returnRate",
tip: true
}
)
]
})}
</div>
<!-- Box Plot: Popularity Index by Category -->
<div style="flex: 1 1 400px;">
<h4 style="margin-bottom: 0.5rem;">🔥 Popularity Index by Category</h4>
${Plot.plot({
x: { label: "Category" },
y: { label: "Popularity Index" },
height: 300,
marks: [
Plot.boxY(
filtered
.filter(d => d["Category"] && d["Popularity Index"])
.map(d => ({
category: d["Category"],
popularity: +d["Popularity Index"]
})),
{
x: "category",
y: "popularity",
tip: true
}
)
]
})}
</div>
</div>
<!-- Row 2: Average Return Rate Full Width -->
<div>
<h4 style="margin-bottom: 0.5rem;">📊 Average Return Rate by Shipping Method</h4>
${Plot.plot({
x: { label: "Shipping Method" },
y: { label: "Average Return Rate (%)" },
height: 300,
width: 800,
marks: [
Plot.barY(
Array.from(
d3.rollup(
filtered,
v => d3.mean(v, d => +d["Return Rate"]),
d => d["Shipping Method"]
),
([method, avgRate]) => ({ method, avgRate })
),
{
x: "method",
y: "avgRate",
fill: "method",
tip: true
}
)
]
})}
</div>
</div>`