Set relative link / anchor in R Shiny

I would like to create a drillable graphic that links to other places in my Shiny App.

library(tidyverse)
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
dashboardHeader(title="My Fitness Dashboard",titleWidth =400),
####sidebar#####
dashboardSidebar(width = 240,
                 sidebarMenu(startExpanded = TRUE,
                             br(),
                             br(),
                             br(),
                             menuItem(text = 'Overview', 
                                      tabName = "fitDash"),
                             menuItem(text = 'Floors', 
                                      tabName = "floors")
                 )), #close dashboardSidebar
dashboardBody(
    tabItems(
        tabItem(tabName = 'fitDash',
                uiOutput("dashboard"), 
        ), #close tabItem

        tabItem(tabName = 'floorsUp',
                fluidRow(
                    column(width = 10,
                           box(width = 12, 
                               textOutput('floorsClimbed') #plot comments
                           ) #close box
                    )  #close column
                ) #close fluidRow
        ) #close tabItem
    ) #close tabItems
) #close dashboardBody
) #close dashboardPage


###### Server logic required to draw plots####
server <- function(input, output, session) {

output$dashboard <- renderUI({

    tags$map(name="fitMap",
             tags$area(shape ="rect", coords="130,250,240,150", alt="floors", href="https://www.w3schools.com"), 
             #tags$area(shape ="rect", coords="130,250,240,150", alt="floors", href="/floorsClimbed"), 
             tags$img(src = 'fitbit1.jpg', alt = 'System Indicators', usemap = '#fitMap') 
            ) #close tags$map
})

output$floorsClimbed <- renderText({ 
    "I walked up 12 floors today!"
})

} #close server function

# Run the application 
shinyApp(ui = ui, server = server)

The following line works perfectly to link to an external site:

tags$area(shape ="rect", coords="130,250,240,150", alt="floors", href="https://www.w3schools.com")

However, I would actually like to internally link to the "floorsUp" tab with something like:

tags$area(shape ="rect", coords="130,250,240,150", alt="floors", href="/floorsUp")

image

This was solved in Stack Overflow by Tonio Liebrand

Stack Post

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.