'Plotly:: gauge plot does not render in Shiny Dashboard

I am trying to make a shiny app based on historical data. I am using a multiple shiny page approach.

For some reason when I run app, my output gets outputted only in the Viewer of RStudio and not on the main panel of the Shiny popup.

Here's the code:

Code in UI:

body <- dashboardBody(
  tabItems(
    tabItem(tabName = "dashboard",
            fluidRow(
              plotlyOutput(outputId="chart1")
            ),
            fluidRow(
              gaugeOutput(outputId="gauge")
            )

            )
  ))

Code in Server:

output$gauge <- renderPlotly({

    plot_ly(
      domain = list(x = c(0, 1), y = c(0, 1)),
      value = fatality_rate,
      number= list(valueformat=".2f", suffix = "%"),
      title = list(text = "Fatality Rate", font = list(size = 24, color = "black")),
      type = "indicator",
      mode = "gauge+number",
      gauge = list(
        axis = list(range=list(NULL, 50)),
        bar= list(color="darkorange"),
        borderwidth = 2,
        bordercolor = "black",
        threshold = list(
          line = list(color="red", width = 4),
          thickness = 0.75,
          value = 49
        )
      )) 
})


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source