plot
plot copied to clipboard
The interval option for line and area perhaps should round down rather than center
Say you have an activity table that has active users by date and login. You might want to draw stacked dots, and then draw a line between active users. But if you use the interval option, you might be surprised that the line is shifted to the right to the middle of the day (noon) rather than the start of the day (midnight).
It’s the difference between this
Plot.lineY(activity, Plot.stackY({x: "date", interval: "day", z: "login"}))
and this
Plot.lineY(activity, Plot.binX({x: "x1", y: "first", filter: null}, Plot.stackY({x: "date", interval: "day", z: "login"})))
might be related, a comment on https://observablehq.com/@d3/line-chart-missing-data/2#cell-329 the filter indeed makes gap disappear, but when an interval option is given with missing data, it will be broken line with gaps:
Plot.lineY(aaplMissing, {x: "date", y: "close", stroke: "steelblue", interval: d3.utcMonth, }),
Plot.lineY(aaplMissing, {x: "date", y: "close", stroke: "steelblue", interval: "month", }),
and the missing data is not just undefined or NaN, but completely missing of some months like aapl.filter(...):
aaplMissing1 = aapl.filter(d => d.date.getUTCMonth() >= 3) // simulate gaps