Skip to content

Commit 45415fe

Browse files
authored
fix: guard single-value continuous col width (#41)
2 parents d4ce0f9 + f3ded61 commit 45415fe

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- feat: `labs()` fields default to `auto`; pass `none` to suppress an axis or legend title and reclaim the space it reserved. (#12)
1313
- feat: `element-blank()` on a text surface (axis, plot, or legend title) collapses the space the text would reserve. (#12)
1414
- feat: `width`/`height` accept `auto` to fill the available space of a bounded container. (#10)
15+
- fix: `geom-col()` on a continuous x with a single distinct value no longer panics when inferring the bar width. (#41)
1516
- fix: `log10`/`sqrt` scales validate user `limits` and report a clear error for non-positive bounds. (#40)
1617
- fix: `geom-smooth()` honours the `level` argument when sizing the confidence band instead of always using 95%. (#39)
1718
- fix: binning geoms reject a non-positive `bins` with a clear error instead of dividing by zero. (#38)

src/geom/col.typ

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,10 @@
295295
.map(r => parse-number(r.at(cat-col, default: none)))
296296
.filter(v => v != none)
297297
let (d-lo, d-hi) = cat-trained.domain
298-
if xs.len() < 2 or d-hi == d-lo {
298+
let sorted = xs.dedup().sorted()
299+
if sorted.len() < 2 or d-hi == d-lo {
299300
(cat-hi - cat-lo) / 10
300301
} else {
301-
let sorted = xs.dedup().sorted()
302302
let panel-gaps = range(sorted.len() - 1).map(i => calc.abs(
303303
map-axis(cat-trained, sorted.at(i + 1), cat-range)
304304
- map-axis(cat-trained, sorted.at(i), cat-range),

0 commit comments

Comments
 (0)