I wrote somecode in Shiny with R. However, whatever I'm trying, my pieChart is not showing. Is it my data or the code that is wrong? The data for the chart looks like this:
value name
dbl chr
17 Species
10 Movies
8 Tv Series
6 Games
5 Food
46 Random
library(shiny)
library(shinydashboard)
library(dplyr)
ui <- dashboardPage(
dashboardHeader(title = "Catnames in Europe"),
skin = "red",
dashboardSidebar(
img(src = "cats_looking.jpg", height = 100, width = 150, align = "left"),
selectInput("countries",
"Choose country:",
choices = c("Netherlands","Germany","Turkey","Ireland",
"England","Belgium","Spain","Portugal",
"United Sates","Denmark","Sweden",
"Switzerland","Italy"),
selected = "Netherlands",
multiple = FALSE,
width = '400px'),
selectInput("years",
"Choose Year:",
choices = c("2017","2018","2019","2020"),
selected = "2019",
multiple = FALSE,
width = '400px'),
actionButton("button","Update view",style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
tags$div(div_id= "distPie", class ="plot-Output")
),
dashboardBody(fluidRow(
tabBox(
tabPanel("Countries",tableOutput("catnametable"),
style = "background-color: #ffffff;")),
tabBox(
tabPanel("Years",tableOutput("years"),
style = "background-color: #ffffff;"),
tabPanel("Trends in 2019",deliverChart(div_id = "pieChart", running_in_shiny = TRUE),
style = "background-color: #ffffff;"))
)))
server <- function(input, output) {
output$catnametable <- renderTable({
countrylist <- CatnamesEurope %>%
filter(Country %in% input$countries)
})
output$years <- renderTable({
yearlist <- Years2 %>%
filter(Years_ordered %in% input$years)
})
output$pieChart <- renderPieChart(
div_id = "pieChart",
data = Trends,
radius = '75%',
center_x = '50%',
center_y = '50%',
show.label = TRUE,
show.legend = TRUE, show.tools = TRUE,
font.size.legend= 12
)
}
shinyApp(ui = ui, server = server)