Skip to content

style the figure element? #397

Open
Open
@Fil

Description

@Fil

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions