plotly / plotly/plotly.R

[Feature request]: change height sizing policy of plotly htmlwidget to 100%

Open
#1,567 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

wontfix
Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

Can we change the default widget height sizing policy set in as_widget to 100%. Right now it is 400px and this makes it hard to make a plot to fill its container along the height.

For example, I am hoping to use the following simplified example to change my plot to height 5in. It does not work (for me), because the style of the resulting htmlwidget is set to the default "400px"

tags$div(style="width: 100%; height: 5in", 
  plot_ly(x=1, y=1, type="scatter", mode="markers")
)

The following on the other hand does the job.

tags$div(style="width: 100%; height: 5in", 
   plot_ly(x=1, y=1, type="scatter", mode="markers") %T>% {
     .$sizingPolicy$defaultHeight<-"100%"
 }
)

It seems to me that a default height of "100%", like the default for width, makes more sense (allowing for the container to control the size) than the arbitrary "400px" used right now.

I really would like to control the height of my plots in a R markdown html document and this was the only solution I could come up with: R plotly seems to deal fine with "px" units, but setting inches and % did not work. Perhaps I am missing something...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the as_widget entry point and inspect how the default sizingPolicy height is assigned. Reproduce the tags$div example with a 5in container, then verify that the widget uses the container height when the default height is 100%.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.