TradingView widget in R-Shiny is not displayed in the dashboard but can be seen in the browser

Viewed 138

I'm trying to include a TradingView widget in Shiny, but all I see is a small blank window (of the correct size for the widget) followed by a "EURUSD Rates by TradingView" message. However, when I click on "Open in Browser," the correct information is displayed in the window that was blank in Shiny.

The same happens with other widgets from TradingView and other sites.

If I inspect the element in the Shiny UI I can see the following ...

<iframe ...>
 #document
  <html>
   <head></head>
   <body></body>
  </html>
</iframe>

... which shows that the head and body are empty. However, the Console shows no errors. But if I inspect the same window of the browser, the correct information (that generated the widget) is displayed.

How to make the code below work and display the widget in the Shiny window? Also, how to make it display at a specific location on the screen (instead of the top left corner)?

Thanks

# From https://www.tradingview.com/widget/single-ticker/
library(shiny)

ui <- fluidPage(
  tags$div(
    HTML('
  <div class="tradingview-widget-container">
    <div class="tradingview-widget-container__widget"></div>
    <div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/EURUSD/?exchange=FX" rel="noopener" target="_blank"><span class="blue-text">EURUSD Rates</span></a> by TradingView</div>
    <script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-single-quote.js" async>
    {
     "symbol": "FX:EURUSD",
     "width": 350,
     "colorTheme": "dark",
     "isTransparent": false,
     "locale": "en"
    }
    </script>
  </div>')))
         

server <- function(input, output, session) {}

shinyApp(ui, server)
0 Answers
Related