observablehq / observablehq/plot
style the figure element?
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 5.4k
- Forks
- 244
- PR merge metrics
- No merged PRs in 30d
Description
The use case (at the bottom of this notebook) is a Plot that we want to make 2800px wide, and which should scroll horizontally in Observable.
My suggestion was to create a figure parent by adding a caption, then setting max-width + scroll overflow styles to the parent, like so:
Object.assign(
Plot.plot({
width: 2800, height: 700, // sets the viewBox of the .plot svg
caption: "", // wraps the plot in a figure element
style: {maxWidth: "2800px"}, // overrides max-width: 100%; of the .plot default css
… rest of the plot definition
}),
{ style: `max-width: ${width}px; overflow: scroll` } // overrides the figure/max-width style of observable and adds scrolling
)
it looks like there should be a better way at least to set styles on the figure element
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 with the Plot.plot call and the linked Observable notebook, focusing on how caption causes a figure wrapper and how figure styles are currently applied. Trace the existing style options and wrapper behavior, then define and test a clearer way to style the figure so a 2800px plot can scroll horizontally without manually assigning styles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100