vl.markBoxplot({extent: "min-max"})
.data(diamonds)
.transform([
{bin: {step: 0.25}, field: "carat", as: "carat_bin"},
{filter: "datum.carat < 3"}
])
.encode(
vl.x().fieldN("carat_bin").title("Carat Range"),
vl.y().fieldQ("price").scale({type: "log"}).title("Price ($) - Log Scale"),
vl.color().fieldN("carat_bin").legend(null),
vl.tooltip([
{field: "carat_bin", title: "Carat Range"},
{aggregate: "min", field: "price", title: "Min Price", format: ",.0f"},
{aggregate: "q1", field: "price", title: "25th Percentile", format: ",.0f"},
{aggregate: "median", field: "price", title: "Median Price", format: ",.0f"},
{aggregate: "q3", field: "price", title: "75th Percentile", format: ",.0f"},
{aggregate: "max", field: "price", title: "Max Price", format: ",.0f"}
])
)
.width(700)
.height(400)
.title("Diamond Price Distribution by Carat Range (Log Scale)")
.render()