# Generated by DropToApp library(shiny) library(bslib) ui <- page_navbar( title = "Iris explorer", nav_panel( "Overview", layout_columns( value_box(title = "Flowers measured", value = "150", theme = "primary"), value_box(title = "Species", value = "3", theme = "info"), value_box( title = "Measurements per flower", value = "4", theme = "secondary" ) ), accordion( accordion_panel( "About the data", p( "Edgar Anderson measured the sepals and petals of 50 flowers from each of three iris species: setosa, versicolor and virginica." ) ), accordion_panel( "How to use this app", p( "Open Explore to compare two measurements in an interactive chart, or Data to search and sort all 150 flowers." ) ) ) ), nav_panel( "Explore", layout_columns( col_widths = c(3, 9), card( selectInput( "x", "X axis", choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"), selected = "Sepal.Length" ), selectInput( "y", "Y axis", choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"), selected = "Petal.Length" ), tooltip( checkboxInput("by_species", "Colour by species", value = TRUE), "Give each species its own colour in the chart" ) ), card( full_screen = TRUE, card_header("Interactive chart"), plotly::plotlyOutput("chart") ) ) ), nav_panel("Data", DT::DTOutput("table")) ) server <- function(input, output, session) { # Inputs: input$x, input$y, input$by_species output$chart <- plotly::renderPlotly({ x <- iris[[input$x]] y <- iris[[input$y]] p <- if (input$by_species) { plotly::plot_ly(x = x, y = y, color = iris$Species, type = "scatter", mode = "markers") } else { plotly::plot_ly(x = x, y = y, type = "scatter", mode = "markers") } plotly::layout(p, xaxis = list(title = input$x), yaxis = list(title = input$y)) }) output$table <- DT::renderDT({ iris }) } shinyApp(ui, server)