Closed yurivish closed 1 month ago
Yep that’s a bug. The percent transform is currently (x) => x * 100
but I agree it should preserve nulls or coerce them to NaN rather than zero. As a workaround, you can represent values as NaN or undefined instead of null and it will work, or could set the transform option explicitly to something like (x) => x == null ? NaN : x * 100
.
Plot.dot(time, { x: time, y: value }).plot({ y: { percent: true, transform: (x) => x == null ? NaN : x * 100 } })
Plotting data with
null
s normally causes those data points to be omitted from the plot. But if you use apercent
channel option, it will plot them at zero.https://observablehq.com/@yurivish/null-percent
I'm not entirely sure this is a bug but the behavior does seem quite surprising.