Challenge writing HTML UI with a plotlyOutput

I've been trying to write an RShiny UI in HTML, and am unable to add an interactive plolty graph to my app. I generate the plotly graph as shown:

#shiny app
df <- data.frame(x = c(1,2,3),
                 y = c(4,5,6))

server <- function(input,output){
  output$fig <- renderPlotly({
    fig <- ggplot(df, aes(x = x, y = y)) +
      geom_line(color = "green") +

shinyApp(ui = htmlTemplate("www/index.html") , server)

and then calling the id in my index.HTML like this:

        <script src="shared/jquery.js" type="text/javascript"></script>
        <script src="shared/shiny.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="shared/shiny.css"/>
    <div id = "fig" class = "shiny-plot-output" style = "width: 100%; height: 400px;"></div>

But my plot does not appear on the app. Any tips? I know the plotlyOutput is rendered as a combo of HTML js and CSS but am unsure how I would call this "class" in HTML or how to embed this in a page

I'm not offering a guaranteed solution, but I do see a mistake that will keep you from your goal.
the HTML you have for fig is as if it were a plotOutput and not a plotlyOutput, which would be:

<div id="fig" style="width:100%; height:400px; " class="plotly html-widget html-widget-output shiny-report-size"></div>

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.