Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive plots do not fill the plot area until redrawn by switching focus #4245

Closed
jthomasmock opened this issue Aug 5, 2024 · 6 comments
Assignees
Labels
area: plots Issues related to Plots category. bug Something isn't working theme: app builder

Comments

@jthomasmock
Copy link
Contributor

System details:

Positron Version: 2024.07.0 (Universal) build 125

Code - OSS Version: 1.91.0
Commit: cae4905
Date: 2024-08-01T00:27:06.019Z
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.5.0

Interpreter details:

Python 3.12.0

Describe the issue:

Interactive graphics like plotly do not resize/redraw to fit the space until a plot other than Session pane is loaded.

Steps to reproduce the issue:

  1. In a Python script run the following code
import plotly.express as px
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
fig
  1. Note that the dimensions of the JavaScript/HTML output are essentially fixed, even with resizing of the plot-pane.
  2. Change the overall height and width of the Plot pane, then move focus away from the Session pane to the Viewer pane or Help pane, and then return to the Session > Plot pane.
  3. Notice that the interactive plot has redrawn to fit the new dimensions.
Screen.Cast.2024-08-05.at.1.56.12.PM.mp4

Expected or desired behavior:

Given interactive graphics can be dynamic to the size, for example in RStudio's plot pane or in a web browser, it should also fit to the Plot pane.

Screen.Cast.2024-08-05.at.2.03.22.PM.mp4

Were there any error messages in the UI, Output panel, or Developer Tools console?

@jthomasmock jthomasmock added bug Something isn't working area: plots Issues related to Plots category. labels Aug 5, 2024
@seeM seeM self-assigned this Aug 6, 2024
@petetronic petetronic added this to the 2024.10.0 Pre-Release milestone Aug 12, 2024
@seeM seeM removed their assignment Aug 19, 2024
@timtmok timtmok self-assigned this Sep 17, 2024
@timtmok
Copy link
Contributor

timtmok commented Sep 23, 2024

The plot height seems to be stuck at 450px, which I think is the default for Plotly when no height is specified. The width seems to be set to the view's width when first showing the plot. Plotly won't resize when it has a set size on the container.

It should be triggering the resize event but that doesn't seem to happen. Rendering the plot with the responsive option will make the width resize but not the height (still stuck at 450px).

fig.show(
	config={'responsive': True}
)

Plotly generates a container where the width is 100% and height is 450px.

fig.show()

Plotly generates a container where the width is the plot view's width and height is 450px.

sharon-wang added a commit that referenced this issue Oct 2, 2024
### Description

A follow-up to #4806 to revert
`src/vs/workbench/services/languageRuntime/common/languageRuntimeUiClient.ts`
back to using a proxy for interactive plots. A generic HTTP proxy was
added via #4855, so server plots can be proxied appropriately in Server
Web and Workbench.

Related to
- #4804
- #4274
- #4245

### QA Notes

On Server Web and Workbench, running the following in the corresponding
consoles:

##### Python

`pip install plotly nbformat pandas`

```python
import plotly.express as px
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
fig.show()
```

##### R

`install.packages('plotly')`

```r
library(plotly)
fig <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
fig
```

#### Expected Result

The corresponding interactive plots should display in the plots pane and
be interact-able!
@midleman
Copy link
Contributor

midleman commented Oct 4, 2024

@timtmok , despite toggling Interactive Plots in Viewer it appears the plot is always rendering in the viewer and never in plots. I tried running against build 2024.10.0-13 and 2024.11.0-3 and both exhibited this behavior.

Screen.Recording.2024-10-04.at.10.43.08.AM.mov

@timtmok
Copy link
Contributor

timtmok commented Oct 4, 2024

I'm going to take a closer look. I don't think any of these changes affected it but there seems to be something wrong with reading the preference value. I couldn't reproduce until I toggled the preference on/off. Then I couldn't open in the Plots view no matter what was set with the preference.

@jonvanausdeln
Copy link
Contributor

I see the same behavior as @midleman , no matter the setting the plotly plots always show in the viewer.

Windows 11
2024.10.0-13

Note, I also restarted Positron after playing with the setting and no change in behavior

@timtmok
Copy link
Contributor

timtmok commented Oct 4, 2024

I'll create a new issue for this regression. It occurs when showing the figure with fig instead of fig.show().

#4909

@midleman
Copy link
Contributor

midleman commented Oct 7, 2024

Verified Fixed

Positron Version(s) : 2024.10.0-13
OS Version(s) : MacOS

Test scenario(s)

Confirmed expected behavior by using fig.show(). Issue will be re-tested when linked regression bug is resolved.

Link(s) to TestRail test cases run or created:

n/a

@midleman midleman closed this as completed Oct 7, 2024
isabelizimm pushed a commit that referenced this issue Oct 16, 2024
### Description

A follow-up to #4806 to revert
`src/vs/workbench/services/languageRuntime/common/languageRuntimeUiClient.ts`
back to using a proxy for interactive plots. A generic HTTP proxy was
added via #4855, so server plots can be proxied appropriately in Server
Web and Workbench.

Related to
- #4804
- #4274
- #4245

### QA Notes

On Server Web and Workbench, running the following in the corresponding
consoles:

##### Python

`pip install plotly nbformat pandas`

```python
import plotly.express as px
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
fig.show()
```

##### R

`install.packages('plotly')`

```r
library(plotly)
fig <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
fig
```

#### Expected Result

The corresponding interactive plots should display in the plots pane and
be interact-able!
isabelizimm pushed a commit that referenced this issue Oct 16, 2024
### Description

A follow-up to #4806 to revert
`src/vs/workbench/services/languageRuntime/common/languageRuntimeUiClient.ts`
back to using a proxy for interactive plots. A generic HTTP proxy was
added via #4855, so server plots can be proxied appropriately in Server
Web and Workbench.

Related to
- #4804
- #4274
- #4245

### QA Notes

On Server Web and Workbench, running the following in the corresponding
consoles:

##### Python

`pip install plotly nbformat pandas`

```python
import plotly.express as px
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
fig.show()
```

##### R

`install.packages('plotly')`

```r
library(plotly)
fig <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
fig
```

#### Expected Result

The corresponding interactive plots should display in the plots pane and
be interact-able!
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: plots Issues related to Plots category. bug Something isn't working theme: app builder
Projects
None yet
Development

No branches or pull requests

6 participants