observablehq / observablehq/plot
Shorthand singleton marks
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 5.4k
- Forks
- 244
- PR merge metrics
- No merged PRs in 30d
Description
For single-instance marks, it’d be neat if you could just pass options without data. For example:
Plot.text({
text: "Hello, world!"
x: new Date("2016-05-01"),
y: 100,
dx: -10,
dy: 40,
frameAnchor: "top-left"
})
Could be equivalent to:
Plot.text({length: 1}, {
text: ["Hello, world!"],
x: [new Date("2016-05-01")],
y: [100],
dx: -10,
dy: 40,
frameAnchor: "top-left"
})
It feels like the helper would need to know which options possibly represent channels, though. And there would potentially be ambiguity with alternative representations of data (such as Arquero objects #449); though that could be addressed by checking the number of arguments and whether the first is a plain object (Object.getPrototypeOf === Object.prototype).
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
Start at the Plot.text entry point and inspect how its arguments are currently interpreted. Compare the proposed one-object form with the existing two-argument form, including plain-object and alternative data representations. Done means singleton marks accept the shorthand without making existing calls ambiguous, with coverage for the new and existing forms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100