posit-dev / positron

Positron, a next-generation data science IDE
Other
2.37k stars 69 forks source link

Dynamic plot using dygraphs and htmltools failed to generate #4215

Closed arianacabral closed 1 month ago

arianacabral commented 1 month ago

System details:

Positron and OS details:

Positron Version: 2024.07.0 (system setup) build 2024.07.0-27 Code - OSS Version: 1.90.0 Commit: 6f3a5c852bf96a85e7cd6c7a4477ed3852e3c38f Date: 2024-07-10T03:19:46.344Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.22631

Interpreter details:

R 4.2.3 (2023-03-15 ucrt)

Describe the issue:

Dynamic plots are not generated when using tools for HTML generation and output (htmltools)

Steps to reproduce the issue:

In a R Script

  1. Load the dygraphs package
  2. Create a variable with more than one synthetic sinusoidal signal
    
    xx <- data.frame(
    time = seq(0, 30, 1 / 1000)
    ) |>
    dplyr::mutate(
    sine2Hz = sin(4 * pi * time),
    sine10Hz = sin(20 * pi * time),
    sine60Hz = sin(120 * pi * time)
    )
3. Combine the graphs of each time series, using `htmltools`

htmltools::browsable( htmltools::tagList( list( htmltools::tags$div( style = "width:100%;display:block;float:left;", dygraph(xx |> dplyr::select(1:2), group = "ensync", height = 200, width = "100%") |> dyOptions(colors = "black"), dygraph(xx |> dplyr::select(1, 3), group = "ensync", height = 200, width = "100%") |> dyOptions(colors = "black"), dygraph(xx |> dplyr::select(1, 4), group = "ensync", height = 200, width = "100%") |> dyOptions(colors = "black") |> dyRangeSelector(dateWindow = c(0, 0.5)) ) ) ) )



## Expected or desired behavior:

https://github.com/user-attachments/assets/c035f8c0-d64b-45c1-b3ef-2ad3a863b1b0

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

There were no error messages. The console only displayed the message: `<R HTML Widget>`, but no graph appeared in the plot panel.

https://github.com/user-attachments/assets/21a1be31-685f-48f2-800f-b4b20a1610a4

<!--

- Open the Developer Tools console by running the `Developer: Toggle Developer Tools` command from the Command Palette
- Open the relevant Output Channel logs by utilizing this guide https://github.com/posit-dev/positron/wiki/Troubleshooting

-->
juliasilge commented 1 month ago

It looks like you may have an older version of Positron. With Positron 2024.07.0 (Universal) build 125, this will currently go to the Viewer, rather than Plots (since it is a Shiny tagList):

htmltools

Can you download the latest Positron and try it out?

arianacabral commented 1 month ago

I tested with the latest Positron and it worked very well. Thank you very much for your feedback and attention.