Closed vinaychuri closed 2 weeks ago
The same error when using plotly library
library(plotly)
plot_ly(economics, x = ~date, y = ~pop,type="scatter",mode="markers")
Thanks for the report! I can also repro the "[object Object]" is not valid JSON
error in Python notebooks with IPyWidgets.
Note that highcharter widgets don't seem to work in console sessions at the moment so that'll need more work.
However, plotly widgets do work in the console, so we should be able fix them for notebooks too.
There are three parts to fixing this:
We're failing to load the required resources in our htmlwidgets notebook renderer inside notebooks (it works in consoles). We currently set the resource roots via the output message before creating our webview here: https://github.com/posit-dev/positron/blob/9979b182c632ad89904c48bb6b440eba6112a6c6/src/vs/workbench/contrib/positronOutputWebview/browser/notebookOutputWebviewServiceImpl.ts#L160-L165
But that doesn't affect notebooks. We need to figure out a way to get those resource roots for the notebook back layer webview here: https://github.com/posit-dev/positron/blob/9979b182c632ad89904c48bb6b440eba6112a6c6/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts#L1207-L1221
This will at least fix plotly.
Some discussion about these highcharter errors in: https://github.com/posit-dev/positron/issues/1742.
Positron Version(s) : 2024.07.0-107
OS Version : OSX
library(highcharter) hchart(mtcars, "scatter", hcaes(wt, mpg, z = drat, color = hp))
Link(s) to TestRail test cases run or created: N/A
Is this released or still under testing? I tried the same on Positron Version: 2024.07.0 (Universal) build 125 and still no output in Notebook
I use the default Dark theme in Positron Version: 2024.07.0 (Universal) build 125 and in R Notebook execute the following code. There is no output but the background of the entire notebook changes!
https://github.com/user-attachments/assets/364b1da8-dc1c-4bfa-b588-a7fae40e9129
library(highcharter)
hchart(mtcars, "scatter", hcaes(wt, mpg, z = drat, color = hp))
Hi @vinaychuri,
Thanks for pointing this out! I am able to reproduce what you are seeing.
I verified this with the 107 release but it no longer appears to work. I will reopen.
@seeM In light mode I am seeing this for the cell output (build 125):
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
I don't believe any R HTML Widgets are currently supported in ipynb notebooks. I've created https://github.com/posit-dev/positron/issues/4219 to track that. They should work via the console though.
-Positron Version: 2024.07.0 (Universal) build 21 -MacOS Ventura 13.6.7 -R 4.4.1
No chart is displayed inline in the notebook and the following message is displayed. Error rendering output item using 'positron.r.htmlwidget' "[object Object]" is not valid JSON