Skip to content

Commit

Permalink
gravando videos
Browse files Browse the repository at this point in the history
  • Loading branch information
williamorim committed Apr 26, 2024
1 parent 24e6ace commit 4d6eef9
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 33 deletions.
16 changes: 8 additions & 8 deletions curso_gravado/scripts/21-bslib-elementos.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ ui <- bslib::page_fillable(
bslib::value_box(
title = "Número de carros",
value = nrow(mtcars),
showcase = bsicons::bs_icon("car-front")
showcase = bsicons::bs_icon(name = "car-front")
),
bslib::value_box(
title = "Maior consumo",
value = max(mtcars$mpg),
showcase = bsicons::bs_icon("fuel-pump")
value = glue::glue("{max(mtcars$mpg)} milhas/galão"),
showcase = bsicons::bs_icon(name = "fuel-pump")
),
uiOutput("vb_menor_consumo", fill = TRUE),
uiOutput(outputId = "vb_menor_consumo", fill = TRUE),
bslib::card(
bslib::card_header(
bslib::card_title("Consumo vs peso")
Expand All @@ -29,7 +29,7 @@ ui <- bslib::page_fillable(
bslib::card_title("Consumo vs potência")
),
bslib::card_body(
plotOutput("grafico_hp")
plotOutput("grafico_potencia")
)
)
)
Expand All @@ -40,8 +40,8 @@ server <- function(input, output, session) {
output$vb_menor_consumo <- renderUI({
bslib::value_box(
title = "Menor consumo",
value = min(mtcars$mpg),
showcase = bsicons::bs_icon("Speedometer")
value = glue::glue("{min(mtcars$mpg)} milhas/galão"),
showcase = bsicons::bs_icon(name = "speedometer2")
)
})

Expand All @@ -53,7 +53,7 @@ server <- function(input, output, session) {
theme_minimal()
})

output$grafico_hp <- renderPlot({
output$grafico_potencia <- renderPlot({
mtcars |>
ggplot(aes(x = hp, y = mpg)) +
geom_point() +
Expand Down
37 changes: 19 additions & 18 deletions curso_gravado/scripts/22-bslib-sidebar.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ library(ggplot2)

ui <- bslib::page_sidebar(
sidebar = bslib::sidebar(
h5("Filtros"),
h4("Filtros"),
selectInput(
inputId = "cyl",
inputId = "num_cilindros",
label = "Número de cilindros",
choices = sort(unique(mtcars$cyl))
)
),
titlePanel("Elementos bslib"),
bslib::layout_columns(
col_widths = c(4, 4, 4, 6, 6),
uiOutput("vb_carros", fill = TRUE),
uiOutput("vb_num_carros", fill = TRUE),
uiOutput("vb_maior_consumo", fill = TRUE),
uiOutput("vb_menor_consumo", fill = TRUE),
uiOutput(outputId = "vb_menor_consumo", fill = TRUE),
bslib::card(
bslib::card_header(
bslib::card_title("Consumo vs peso")
Expand All @@ -29,54 +29,55 @@ ui <- bslib::page_sidebar(
bslib::card_title("Consumo vs potência")
),
bslib::card_body(
plotOutput("grafico_hp")
plotOutput("grafico_potencia")
)
)
)
)

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

dados_filtrados <- reactive({
mtcars_filtrada <- reactive({
mtcars |>
dplyr::filter(cyl == input$cyl)
dplyr::filter(cyl == input$num_cilindros)
})

output$vb_carros <- renderUI({
output$vb_num_carros <- renderUI({
bslib::value_box(
title = "Número de carros",
value = nrow(dados_filtrados()),
showcase = bsicons::bs_icon("car-front")
value = nrow(mtcars_filtrada()),
showcase = bsicons::bs_icon(name = "car-front")
)
})

output$vb_maior_consumo <- renderUI({
valor <- max(mtcars_filtrada()$mpg)
bslib::value_box(
title = "Maior consumo",
value = max(dados_filtrados()$mpg),
showcase = bsicons::bs_icon("fuel-pump")
value = glue::glue("{valor} milhas/galão"),
showcase = bsicons::bs_icon(name = "fuel-pump")
)
})

output$vb_menor_consumo <- renderUI({
valor <- min(mtcars_filtrada()$mpg)
bslib::value_box(
title = "Menor consumo",
value = min(dados_filtrados()$mpg),
showcase = bsicons::bs_icon("Speedometer")
value = glue::glue("{valor} milhas/galão"),
showcase = bsicons::bs_icon(name = "speedometer2")
)
})

output$grafico_peso <- renderPlot({
dados_filtrados() |>
mtcars_filtrada() |>
ggplot(aes(x = wt, y = mpg)) +
geom_point() +
geom_smooth(se = FALSE) +
theme_minimal()
})

output$grafico_hp <- renderPlot({
dados_filtrados() |>
dplyr::filter(cyl == input$cyl) |>
output$grafico_potencia <- renderPlot({
mtcars_filtrada() |>
ggplot(aes(x = hp, y = mpg)) +
geom_point() +
geom_smooth(se = FALSE) +
Expand Down
14 changes: 7 additions & 7 deletions curso_gravado/scripts/23-bslib-navbar.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ ui <- bslib::page_navbar(
title = "bslib Navbar",
bslib::nav_panel(
title = "Página 1",
titlePanel("Conteúdo página 1")
titlePanel("Conteúdo da página 1")
),
bslib::nav_panel(
title = "Página 2",
bslib::layout_sidebar(
sidebar = bslib::sidebar(
h5("Sidebar página 2")
h4("Sidebar da página 2")
),
titlePanel("Conteúdo página 2")
titlePanel("Conteúdo da página 2")
)
),
bslib::nav_menu(
title = "Várias páginas",
bslib::nav_panel(
title = "Página 3",
titlePanel("Conteúdo página 3")
titlePanel("Conteúdo da página 3")
),
bslib::nav_panel(
title = "Página 4",
titlePanel("Conteúdo página 4")
titlePanel("Conteúdo da página 4")
),
bslib::nav_panel(
title = "Página 5",
titlePanel("Conteúdo página 5")
)
titlePanel("Conteúdo da página 5")
),
)
)

Expand Down
91 changes: 91 additions & 0 deletions curso_gravado/scripts/24-bs4Dash.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
library(shiny)

ui <- bs4Dash::bs4DashPage(
help = NULL,
header = bs4Dash::bs4DashNavbar(
title = "bs4Dash"
),
sidebar = bs4Dash::bs4DashSidebar(
bs4Dash::bs4SidebarMenu(
bs4Dash::bs4SidebarMenuItem(
text = "Página 1",
tabName = "pagina_1",
icon = icon("user")
),
bs4Dash::bs4SidebarMenuItem(
text = "Página 2",
tabName = "pagina_2",
icon = icon("car-side")
),
bs4Dash::bs4SidebarMenuItem(
text = "Várias páginas",
bs4Dash::bs4SidebarMenuSubItem(
text = "Página 3",
tabName = "pagina_3"
),
bs4Dash::bs4SidebarMenuSubItem(
text = "Página 4",
tabName = "pagina_4"
),
bs4Dash::bs4SidebarMenuSubItem(
text = "Página 5",
tabName = "pagina_5"
)
)
)
),
body = bs4Dash::bs4DashBody(
bs4Dash::bs4TabItems(
bs4Dash::bs4TabItem(
tabName = "pagina_1",
titlePanel("Conteúdo página 1")
),
bs4Dash::bs4TabItem(
tabName = "pagina_2",
titlePanel("Conteúdo página 2"),
plotOutput("pg_2_grafico")
),
bs4Dash::bs4TabItem(
tabName = "pagina_3",
titlePanel("Conteúdo página 3"),
fluidRow(
column(
width = 3,
plotOutput("pg_3_grafico")
),
column(
width = 9,
tableOutput("pg_3_tabela")
)
)
),
bs4Dash::bs4TabItem(
tabName = "pagina_4",
titlePanel("Conteúdo página 4")
),
bs4Dash::bs4TabItem(
tabName = "pagina_5",
titlePanel("Conteúdo página 5")
)
)
)
)


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

output$pg_2_grafico <- renderPlot({
plot(x = 1:10, y = 1:10)
})

output$pg_3_grafico <- renderPlot({
plot(x = 1:10, y = 10:1)
})

output$pg_3_tabela <- renderTable(
mtcars
)

}

shinyApp(ui, server)

0 comments on commit 4d6eef9

Please sign in to comment.