Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utkast fane Indikator UI #498

Open
larstun opened this issue Jan 3, 2025 · 0 comments
Open

Utkast fane Indikator UI #498

larstun opened this issue Jan 3, 2025 · 0 comments
Labels
discussion Discussion needed before proceeding indicator

Comments

@larstun
Copy link

larstun commented Jan 3, 2025

Har testet shinyUIeditor - https://rstudio.github.io/shinyuieditor/live-demo/ for å se på mulighet til å forbedre UI i imongr. Kan dette brukes?

Image

App script
The following code defines the currently being edited app. Copy and paste it to an app.R file to use.

app.R
library(shiny)
library(ggplot2)
library(bslib)
library(gridlayout)


ui <- page_navbar(
  title = "Data | SKDE",
  selected = "Indikator",
  collapsible = TRUE,
  theme = bslib::bs_theme(),
  nav_panel(
    title = "Indikator",
    grid_container(
      layout = c(
        "indikator     indikator      ",
        "register      Indikatortittel",
        "velgindikator kortbeskrivelse",
        "innstillinger Langbeskrivelse"
      ),
      row_sizes = c(
        "0.23fr",
        "0.54fr",
        "0.69fr",
        "2.84fr"
      ),
      col_sizes = c(
        "330px",
        "1fr"
      ),
      gap_size = "10px",
      grid_card(
        area = "register",
        full_screen = TRUE,
        card_header(h1(strong("Register"))),
        card_body(
          selectInput(
            inputId = "mySelectInput",
            label = "Velg register",
            choices = list("Hjerneslag" = "a", "Hjerteinfarkt" = "b")
          )
        )
      ),
      grid_card_text(
        content = "Indikator",
        alignment = "center",
        area = "indikator"
      ),
      grid_card(
        area = "Indikatortittel",
        card_body(
          textInput(
            inputId = "myTextInput",
            label = "Indikatortittel (Maks 100 tegn)",
            value = "",
            placeholder = "Skriv inn tittel på indikator",
            width = "80%"
          )
        )
      ),
      grid_card(
        area = "velgindikator",
        full_screen = TRUE,
        card_header("Indikator"),
        card_body(
          selectInput(
            inputId = "mySelectInput",
            label = "Velg indikator",
            choices = list("hjerneslag_beh_enhet" = "a", "choice b" = "b")
          ),
          actionButton(
            inputId = "myButton",
            label = "Lag helt ny indikator",
            width = "70%"
          )
        )
      ),
      grid_card(
        area = "kortbeskrivelse",
        card_body(
          textInput(
            inputId = "myTextInput",
            label = "Kort indikatorbeskrivelse (Maks 500 tegn)",
            value = "",
            placeholder = "Skriv inn kort indikatorbeskrivelse",
            width = "100%"
          )
        )
      ),
      grid_card(
        area = "innstillinger",
        full_screen = TRUE,
        card_header(
          "Innstillinger
          "
        ),
        card_body(
          gap = "10px",
          actionButton(
            inputId = "myButton",
            label = "Publiser endringer",
            width = "62%"
          ),
          selectInput(
            inputId = "mySelectInput",
            label = "Velg tilhørende dekningsgradsindikator",
            choices = list("hjerneslag_dg" = "a", "choice b" = "b")
          ),
          strong("Måloppnåelse"),
          checkboxInput(
            inputId = "myCheckboxInput",
            label = "Høy verdi er god måloppnåelse?",
            value = TRUE
          ),
          sliderInput(
            inputId = "inputId",
            label = "Høy mål oppnåelse er større eller lik",
            min = 0,
            max = 100,
            value = 50,
            width = "100%",
            step = 10
          ),
          sliderInput(
            inputId = "inputId",
            label = "Middels måloppnåelse er større eller lik?",
            min = 0,
            max = 100,
            value = 50,
            width = "100%",
            step = 10
          ),
          numericInput(
            inputId = "myNumericInput",
            label = "Minste antall observasjoner?",
            value = 5,
            min = 5,
            max = 10,
            width = "65%"
          ),
          radioButtons(
            inputId = "myRadioButtons",
            label = "Indikatortype",
            choices = list(
              "Andel" = "a",
              "Something" = "b",
              "Something else" = "value3"
            ),
            width = "100%"
          ),
          radioButtons(
            inputId = "myRadioButtons",
            label = "Indikatorformat",
            choices = list("Prosent" = "a", "Something" = "b"),
            width = "100%"
          ),
          numericInput(
            inputId = "myNumericInput",
            label = "Antall desimaler (0,000)",
            value = 0,
            min = 0,
            max = 3
          )
        )
      ),
      grid_card(
        area = "Langbeskrivelse",
        card_body(
          gap = "15px",
          textInput(
            inputId = "myTextInput",
            label = "Lang indikatorbeskrivelse (maks 1000 tegn)",
            value = "",
            placeholder = "Skriv inn lang indikatorbeskrivelse",
            width = "100%"
          ),
          actionButton(
            inputId = "myButton",
            label = "Publiser tekstendringer",
            width = "24%"
          )
        )
      )
    )
  ),
  nav_panel(
    title = "Distributions",
    grid_container(
      row_sizes = c(
        "165px",
        "1fr"
      ),
      col_sizes = c(
        "1fr"
      ),
      gap_size = "10px",
      layout = c(
        "facetOption",
        "dists"
      ),
      grid_card_plot(area = "dists"),
      grid_card(
        area = "facetOption",
        card_header("Distribution Plot Options"),
        card_body(
          radioButtons(
            inputId = "distFacet",
            label = "Facet distribution by",
            choices = list("Diet Option" = "Diet", "Measure Time" = "Time")
          )
        )
      )
    )
  )
)


server <- function(input, output) {
   
  output$linePlots <- renderPlot({
    obs_to_include <- as.integer(ChickWeight$Chick) <= input$numChicks
    chicks <- ChickWeight[obs_to_include, ]
  
    ggplot(
      chicks,
      aes(
        x = Time,
        y = weight,
        group = Chick
      )
    ) +
      geom_line(alpha = 0.5) +
      ggtitle("Chick weights over time")
  })
  
  output$dists <- renderPlot({
    ggplot(
      ChickWeight,
      aes(x = weight)
    ) +
      facet_wrap(input$distFacet) +
      geom_density(fill = "#fa551b", color = "#ee6331") +
      ggtitle("Distribution of weights by diet")
  })
  
}

shinyApp(ui, server)

@larstun larstun added the discussion Discussion needed before proceeding label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion needed before proceeding indicator
Projects
None yet
Development

No branches or pull requests

2 participants