observablehq / observablehq/plot
Auto mark isMonotonic should distinguish sorted within series
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 5.4k
- Forks
- 244
- PR merge metrics
- No merged PRs in 30d
Description
If data is monotonic in X or Y, the auto mark may draw a line. But we have a longstanding TODO in isMonotonic:
For example, this data:
const data = [
{date: new Date(2020, 0, 1), value: 5, series: 1},
{date: new Date(2020, 0, 1), value: 50, series: 2},
{date: new Date(2020, 0, 1), value: 500, series: 3},
{date: new Date(2020, 0, 2), value: 6, series: 1},
{date: new Date(2020, 0, 2), value: 60, series: 2},
{date: new Date(2020, 0, 2), value: 600, series: 3},
{date: new Date(2020, 0, 3), value: 7, series: 1},
{date: new Date(2020, 0, 3), value: 70, series: 2},
{date: new Date(2020, 0, 3), value: 700, series: 3}
]
return Plot.auto(data, {x: "date", y: "value"}).plot();
Produces a weird line:
If two points have the same value (so order === 0), should isMonotonic be false? There are fancier things we could do, like trying to infer a z channel, but…
(Idk if this is a bug or enhancement!)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read src/marks/auto.js at lines 246-263, then reproduce the issue with the supplied Plot.auto data containing three series. Determine how equal or interleaved values should affect isMonotonic, and verify that the example no longer produces a misleading line when the behavior is corrected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- d3, javascript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100