I solved the problem by using navigate method, I used iframe
instead of renderUI(includeHTML())
to speed up the page loading.
- Only English version shows the
radarchart
- Only English version can linked to the title and sub-tittle by clicked the top content section
## UI
require('shiny')
require('shinythemes')
require('shinydashboard')
require('dashboardthemes')
require('shinyWidgets')
require('shinyjs')
require('memoise')
### creating custom logo object
my_logo <- shinyDashboardLogoDIY(
boldText = 'ENG',
mainText = 'Lian Hu',
textSize = 16,
badgeText = 'RYO', #'®γσ',
badgeTextColor = 'white',
badgeTextSize = 2,
badgeBackColor = "#40E0D0",
badgeBorderRadius = 3)
alignCenter <- memoise(function(el) {
htmltools::tagAppendAttributes(el, style="width:500vw;height:100vh;background-color:#fff;display:flex;align-items:center;justify-content:center;")
})
ui <- shinyUI(
dashboardPage(
dashboardHeader(title = my_logo),
dashboardSidebar(
sidebarMenu(id = "tabs",
menuItem("Home", tabName = "menu",
icon = icon("home"), startExpanded = TRUE,
menuSubItem("Curriculum Vitae", tabName = "home"),
menuSubItem("English", tabName = "en"),
menuSubItem("Simplified Chinese", tabName = "cn"),
menuSubItem("Traditional Chinese", tabName = "tw"),
menuSubItem("Japanese", tabName = "jp")),
menuItem("Appendices", icon = icon("th"), tabName = "Appendices",
menuSubItem("Author", tabName = "author"))
)),
dashboardBody(
shinyDashboardThemes(theme = 'blue_gradient'),
tabItems(
tabItem(tabName = 'home', alignCenter(
prettyRadioButtons(
inputId = 'rb', label = '',
choices = c('ENGLISH' = 'en', 'Chinese (Simplified)' = 'cn',
'Chinese (Traditional)' = 'tw', 'Japanese' = 'jp'),
#choices = c('ENGLISH' = 'en', '简体中文' = 'cn',
# '繁体中文' = 'tw', '日本語' = 'jp'),
shape = 'curve', bigger = TRUE, animation = 'pulse',
selected = character(0), status = 'primary', thick = TRUE,
icon = icon('registered'))
)),
tabItem(tabName = 'en', h2('English'),
tags$iframe(src = 'https://englianhu.github.io/2018/10/ryo-en.html',
height = 800, width = '100%', frameborder = 0)),
tabItem(tabName = 'cn', h2('Chinese (Simplified)'),
tags$iframe(src = 'https://englianhu.github.io/2018/10/ryo-cn.html',
height = 800, width = '100%', frameborder = 0)),
tabItem(tabName = 'tw', h2('Chinese (Traditional)'),
tags$iframe(src = 'https://englianhu.github.io/2018/10/ryo-tw.html',
height = 800, width = '100%', frameborder = 0)),
tabItem(tabName = 'jp', h2('Japanese'),
tags$iframe(src = 'https://englianhu.github.io/2018/10/ryo-jp.html',
height = 800, width = '100%', frameborder = 0)),
tabItem(tabName = 'author', h2('Author'),
tags$iframe(src = 'https://beta.rstudioconnect.com/content/4351/ryo-eng.html',
height = 800, width = '100%', frameborder = 0))),
br(),
p('Powered by - Copyright® Intellectual Property Rights of ',
tags$a(href='http://www.scibrokes.com', target = '_blank',
tags$img(height = '20px', alt = 'scibrokes', #align='right',
src='www/scb_logo.jpg')),
HTML("<a href='http://www.scibrokes.com'>Scibrokes®</a>")))))
#shinyApp(server = server, ui = ui)
and
## Server
require('shiny')
require('shinythemes')
require('shinydashboard')
require('dashboardthemes')
require('shinyWidgets')
require('shinyjs')
server <- shinyServer(function(input, output, session) {
#observeEvent(input$rb, {
# newtab <- switch(input$tabs,
# "en" = "en",
# "cn" = "cn",
# "tw" = "tw",
# "jp" = "jp")
# updateTabItems(session, "tabs", newtab)
# })
#output$cv_page <- renderUI({
#
# page = switch(input$rb,
# en = 'ryo-en.html',
# cn = 'ryo-cn.html',
# tw = 'ryo-tw.html',
# jp = 'ryo-jp.html')
#
#HTML(markdown::markdownToHTML('ryo-en.md'))
#HTML(rmarkdown::render(knit('ryo-en.Rmd')))
# includeHTML(page)
#})
#observeEvent(input$rb, {
# newtab <- switch(input$tabs,
# "home" = "home",
# "en" = "en",
# "cn" = "cn",
# "tw" = "tw",
# "jp" = "jp",
# "author" = "author")
# updateTabItems(session, "tabs", newtab)
#})
observeEvent(input$rb == 'en', {
updateTabItems(session, "tabs", selected = "en")
})
observeEvent(input$rb == 'cn', {
updateTabItems(session, "tabs", selected = "cn")
})
observeEvent(input$rb == 'tw', {
updateTabItems(session, "tabs", selected = "tw")
})
observeEvent(input$rb == 'jp', {
updateTabItems(session, "tabs", selected = "jp")
})
#output$ryo_en <- renderUI({
# #HTML(markdown::markdownToHTML('ryo-en.md'))
# #HTML(rmarkdown::render(knit('ryo-en.Rmd')))
# includeHTML("ryo-en.html")
#})
#output$ryo_cn <- renderUI({
# #HTML(markdown::markdownToHTML('ryo-en.md'))
# #HTML(rmarkdown::render(knit('ryo-en.Rmd')))
# includeHTML("ryo-cn.html")
#})
#output$ryo_tw <- renderUI({
# #HTML(markdown::markdownToHTML('ryo-en.md'))
# #HTML(rmarkdown::render(knit('ryo-en.Rmd')))
# includeHTML("ryo-tw.html")
#})
#output$ryo_jp <- renderUI({
# #HTML(markdown::markdownToHTML('ryo-en.md'))
# #HTML(rmarkdown::render(knit('ryo-en.Rmd')))
# includeHTML("ryo-jp.html")
#})
})
shinyApp(server = server, ui = ui)
Reference