observablehq / plot

A concise API for exploratory data visualization implementing a layered grammar of graphics
https://observablehq.com/plot/
ISC License
4.36k stars 176 forks source link

The interval option makes line broken with gaps #2015

Closed tx0c closed 7 months ago

tx0c commented 7 months ago

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

Originally posted by @tx0c in https://github.com/observablehq/plot/issues/1931#issuecomment-1977266336

mbostock commented 7 months ago

That’s largely the point of the interval option — you’re specifying the expected interval of the data, so if the data is missing, you want to see a gap. If you want to interpolate across the missing data, then you can use the filter option instead. If you have more questions, please reply to this issue.