r - Increase size of rCharts on Shiny Dashboard -
i doing shiny dashboard using shinydashboard package. see in image attached, chart done using rcharts , highcharts library not using space of box. know if knows how user space of box. see attached code used:
## app.r ## library(shinydashboard) library(rcharts) ui <- dashboardpage( dashboardheader(title = "basic dashboard"), dashboardsidebar(), dashboardbody( fluidrow( tags$head(tags$style('.col-sm-6 {padding-left: 0px; padding-right: 0px ;}')), box(status = "primary", width = 3, showoutput("plotatmosphere", "highcharts")) ) ) ) server <- function(input, output) { output$plotatmosphere = renderchart({ <- rhighcharts:::chart$new() d <- data.frame(label = c("negative", "positive"), value = c(30, 70)) a$title(text = "") # <- hplot(value ~ label, data = d, type = 'pie') a$data(x = c("negative","positive"), y = c(30, 70), type = "pie", name = "amount") a$plotoptions(pie = list(innersize = "90%", startangle = -90, endangle = 90, center = list("50%", "100%"),datalabels = list(enabled = f))) a$exporting(enabled = f) a$chart(height = 150) return(a) }) } shinyapp(ui, server) 
this annoyingly complicated, have pass additional parameter server() fuction:
server <- function(input, output, session) and use 1 of session variables clientdata dynamically resize plots:
output$hexchart<-renderchart2({ h1 <- highcharts$new() h1$chart(type = "spline") h1$series(data = c(1, 3, 2, 4, 5, 4, 6, 2, 3, 5, na), dashstyle = "longdash") h1$series(data = c(na, 4, 1, 3, 4, 2, 9, 1, 2, 3, 4), dashstyle = "shortdot") h1$legend(symbolwidth = 80) h1$set(width = session$clientdata$output_plot1_width) #dynamically resize session variable return(h1) }) where plot1 dummy plot inserted in ui:
box(width = 12, height = 450, solidheader = false, status = "primary", plotoutput("plot1", height = "1px"), showoutput("hexchart","highcharts") )
Comments
Post a Comment