In my mod_page_charts
I have two charts as an output TypeA_Chart
TypeB_Chart
,
In my mod_page_ui
have added a filter for charts, where i am attempting to filter charts where the output in tabPanel
for plotlyOutput
should show the chart based on chart type selected.
How do i render UI so that the chart changes based on pickerInput
selectio ?
mod_page_ui <- function(id) {
ns <- NS(id)
tabItem(
tabName = "chart_page",
fluidPage(
fluidRow(
column(12, ),
fluidRow(column(12, tabsetPanel(
tabPanel("Value Chart " , fluidRow(
column(
2,
align = "center",
h3("Filter Chart"),
pickerInput(
inputId = ns("selectType"),
label = "Select Type to View",
choices = c("TypeA", "TypeB"),
selected = c("TypeA", "TypeB"),
),
uiOutput(ns("attributePicker"))
),
column(12, tabsetPanel(tabPanel(
"chart Panel ",
plotlyOutput(ns("TypeA_Chart"),
plotlyOutput(ns("TypeB_Chart")))
))))))))}
mod_page_charts <- function(input, output, session) {
ns <- session$ns
options(scipen = 100, digits = 4)
output$attributePicker <- renderUI({
if (input$selectType == "TypeA") {
pickerInput(
inputId = ns("selectedTypeA"),
label = "Select Category to View",
choices = c("Daily", "Weekly"),
selected = c("Daily", "Weekly"),
multiple = TRUE,
options = list(size = 5)
)
} else if (input$selectType == "TypeB") {
pickerInput(
inputId = ns("selectedTypeB"),
label = "Select Category to View",
choices = c("Daily", "Weekly"),
selected = c("Daily", "Weekly"),
multiple = TRUE,
options = list(size = 5)
)}})
output$TypeA_Chart <- renderPlotly({
plt <- generate_plot_typeA(
data = datatypeA,
attributeID = input$selectType,
x = `Dates`,
y = `Values`,
title = "Type-A Chart"
)
})
output$TypeB_Chart <- renderPlotly({
plt <- generate_plot_typeB(
data = datatypeB,
attributeID = input$selectType,
x = `Dates`,
y = `Values`,
title = "Type-B Chart"
)})