Change the height attributes of a graph created with rCharts to use with rshiny

I use rCharts to implement interactive graphics in rshiny. I am using the morris library Here is a minimal example of my problem:

## ui.R require(rCharts) shinyUI(pageWithSidebar( headerPanel("rCharts: Interactive Charts from R using morris.js"), sidebarPanel( ), mainPanel( showOutput("myChart", "morris") ) )) require(rCharts) shinyServer(function(input, output) { output$myChart <- renderChart({ data(economics, package = 'ggplot2') econ <- transform(economics, date = as.character(date)) m1 <- mPlot(x = 'date', y = c('psavert', 'uempmed'), type = 'Line', data = econ) m1$set(pointSize = 0, lineWidth = 1) m1$addParams(dom = 'myChart') m1$params$width = 200 m1$params$height = 200 return(m1) }) }) 

The height and width components work fine if the m1 object is not sent brilliant, but they seem to be ignored after renderChart processing. I applied the interim fix using the stylesheet:

 .shiny-html-output.morris{ height: 200px; width: 200px; } 

Is there any option that I am missing? For example, in plotOutput in the shiny package, you can specify plotOutput("plot2", height = "260px") for example.

+4
source share
1 answer

This is currently the functionality that will be added to rCharts in the future. As a temporary fix, I added an entry to the stylesheet to implement two morris plots in my application. Add the www / directory to the application directory and create the styles.css file. Add

  tags$head( tags$link(rel = 'stylesheet', type = 'text/css', href = 'styles.css') ), 

to ui.R and put

 .shiny-html-output.morris{ height: 200px; width: 200px; } 

in styles.css

+5
source

Source: https://habr.com/ru/post/1491070/


All Articles