我在下面有Shinddasboard,在其中我使用jscode
和GetScreenHeight
设置地块的高度。我想知道是否可以同时对宽度进行相同操作。我使用了jsode2
,但似乎无法正常工作。
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(highcharter)
jscode <-
'$(document).on("shiny:connected", function(e) {
var jsHeight = 0.65 * document.body.clientWidth;
Shiny.onInputChange("GetScreenHeight", jsHeight);
});
'
jscode2 <-
'$(document).on("shiny:connected", function(e) {
var jsWidth = 0.20 * document.body.clientWidth;
Shiny.onInputChange("GetScreenWidth", jsWidth);
});
'
shinyApp(
ui = dashboardPagePlus(
header = dashboardHeaderPlus(
),
sidebar = dashboardSidebar(),
body = dashboardBody(
tags$script(jscode),
boxPlus(
title = "Closable Box with dropdown",
closable = TRUE,
width = NULL,
status = "warning",
solidHeader = FALSE,
collapsible = TRUE,
highchartOutput("pl",height = "100%",width = "100%")
)
)
),
server = function(input, output) {
output$pl <- renderHighchart({
data(diamonds, mpg, package = "ggplot2")
hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class))%>%
hc_size(height =input$GetScreenHeight,width = input$GetScreenWidth )
})
}
)