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

Positron Web: Various R plot packages don't work (similar issue between packages) #4804

Closed
testlabauto opened this issue Sep 24, 2024 · 3 comments
Assignees
Labels
area: plots Issues related to Plots category. area: workbench Issues related to Workbench category. lang: r

Comments

@testlabauto
Copy link
Contributor

System details:

Positron and OS details:

Dev build on Sep 24, 24

Interpreter details:

R 4.3.3

Describe the issue:

Highcharter, leaflet and plotly plots not working in web version. Plot view shows:

Cannot GET /

Steps to reproduce the issue:

Highcharter

library(highcharter)

data("mpg", "diamonds", "economics_long", package = "ggplot2")

hchart(mpg, "point", hcaes(x = displ, y = cty, group = year))

Leaflet

library(leaflet)
m = leaflet() %>% addTiles()
m = m %>% setView(-93.65, 42.0285, zoom = 17)
m %>% addPopups(-93.65, 42.0285, 'Here is the <b>Department of Statistics</b>, ISU')

Plotly

library(plotly)
fig <- plot_ly(midwest, x = ~percollege, color = ~state, type = "box")
fig

Expected or desired behavior:

Plots generated

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

image

from VSCode

Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'postMessage')
    at <anonymous> (<eval>/VM46947592:36:21)
    --- setTimeout ---
    at <anonymous> (<eval>/VM46947592:35:6)
    at <anonymous> (/Users/christophermead/posit/positron/out/vs/workbench/contrib/webview/browser/pre/index.html:1070:23)
    --- setTimeout ---
    at onFrameLoaded (/Users/christophermead/posit/positron/out/vs/workbench/contrib/webview/browser/pre/index.html:1068:6)
    at <anonymous> (/Users/christophermead/posit/positron/out/vs/workbench/contrib/webview/browser/pre/index.html:1099:7)
VM46947592:36
<anonymous> @ <eval>/VM46947592:36:21
@testlabauto testlabauto added area: plots Issues related to Plots category. area: workbench Issues related to Workbench category. lang: r labels Sep 24, 2024
@sharon-wang
Copy link
Member

➕1️⃣ I was trying out the following in Positron on Workbench and I saw the same issue and console errors:

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

image

@sharon-wang sharon-wang self-assigned this Sep 30, 2024
@sharon-wang sharon-wang added this to the 2024.10.0 Pre-Release milestone Sep 30, 2024
@sharon-wang
Copy link
Member

I'm fixing this while working on #4274

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

- part of #4274
- addresses #4804
- should unblock #4806, where the new plotly rendering method relies on
a proxy server instead of an HTML file proxy

#### Changes

- add a new command to create a generic proxy server
`positronProxy.startHttpProxyServer`
- rename the command `positronProxy.stopHelpProxyServer` to
`positronProxy.stopProxyServer` since it is not help-specific
- rename `resources/scripts.html` to `resources/scripts_help.html` since
it is help-specific
- move the src/href rewriting to a private reusable function
`rewriteUrlsWithProxyPath`, which is now used by the generic http proxy
and the help proxy `contentRewriter`
- update `src/vs/code/browser/workbench/workbench.ts` to resolve the uri
while maintaining the uri's original path, query string and fragment
strings (NOTE: needs to be contributed upstream)
- update
`src/vs/workbench/services/languageRuntime/common/languageRuntimeUiClient.ts`
to choose between starting an HTML file proxy if a file is being served
or a generic http proxy if the content is not a file

### 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!
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!
@testlabauto
Copy link
Contributor Author

Verified Fixed

Positron Version(s) : 2024.10.0-5
OS Version          : OSX

Test scenario(s)

All scenarios in ticket now work!

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

isabelizimm pushed a commit that referenced this issue Oct 16, 2024
### Description

- part of #4274
- addresses #4804
- should unblock #4806, where the new plotly rendering method relies on
a proxy server instead of an HTML file proxy

#### Changes

- add a new command to create a generic proxy server
`positronProxy.startHttpProxyServer`
- rename the command `positronProxy.stopHelpProxyServer` to
`positronProxy.stopProxyServer` since it is not help-specific
- rename `resources/scripts.html` to `resources/scripts_help.html` since
it is help-specific
- move the src/href rewriting to a private reusable function
`rewriteUrlsWithProxyPath`, which is now used by the generic http proxy
and the help proxy `contentRewriter`
- update `src/vs/code/browser/workbench/workbench.ts` to resolve the uri
while maintaining the uri's original path, query string and fragment
strings (NOTE: needs to be contributed upstream)
- update
`src/vs/workbench/services/languageRuntime/common/languageRuntimeUiClient.ts`
to choose between starting an HTML file proxy if a file is being served
or a generic http proxy if the content is not a file

### 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!
isabelizimm pushed a commit that referenced this issue Oct 16, 2024
### Description

- part of #4274
- addresses #4804
- should unblock #4806, where the new plotly rendering method relies on
a proxy server instead of an HTML file proxy

#### Changes

- add a new command to create a generic proxy server
`positronProxy.startHttpProxyServer`
- rename the command `positronProxy.stopHelpProxyServer` to
`positronProxy.stopProxyServer` since it is not help-specific
- rename `resources/scripts.html` to `resources/scripts_help.html` since
it is help-specific
- move the src/href rewriting to a private reusable function
`rewriteUrlsWithProxyPath`, which is now used by the generic http proxy
and the help proxy `contentRewriter`
- update `src/vs/code/browser/workbench/workbench.ts` to resolve the uri
while maintaining the uri's original path, query string and fragment
strings (NOTE: needs to be contributed upstream)
- update
`src/vs/workbench/services/languageRuntime/common/languageRuntimeUiClient.ts`
to choose between starting an HTML file proxy if a file is being served
or a generic http proxy if the content is not a file

### 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 18, 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. area: workbench Issues related to Workbench category. lang: r
Projects
None yet
Development

No branches or pull requests

2 participants