2016-06-12 116 views
1

我试图按比例缩小plotOutput闪亮R.闪亮R标下来plotOutput

我有这样的情节: enter image description here

从这个代码:

#In ui: 
fluidRow(
     column(width = 12, 
      h4("Diagrama Persistencia"), 
      plotOutput("Diagrama") 
     ) 
    ) 

#In server 
output$Diagrama <- renderPlot({ 
     F_PlotDiag(Diag = isolate(values$data), tipoPlot = input$radioPlot, tamEjeNom = input$sliderTamEjeNom) 
     }, height = input$sliderHeight, width = input$sliderWidth) 

的通知高度和宽度参数。这是有效的,因为所有的都在一个observeEvent上下文中。

正如你所看到的,孔图不适合在屏幕上。与降低高度和宽度的问题是,它看起来像这样:

enter image description here

但实际上,如果我点击右键,保存第一个图像,它看起来不像第二图像细腻: enter image description here

有没有办法通过缩小浏览器来显示整个图表?这样我就可以看到它,就好像我下载了图像一样。

我真的不知道很多关于CSS,所以我真的不能提供任何逻辑的尝试,但是这是我试过了我的HTML:

enter image description here

tags$style(type="text/css", ".shiny-bound-output { transform: 'scale(.5)' }") 
    tags$style(type="text/css", ".shiny-plot-output { transform: 'scale(.5)' }") 
    tags$style(type="text/css", "#Diagrama { height: 20px }") 

由于没有成功。

回答

2

由于您没有提供可重复的示例,请参阅此示例是否可以帮助您。基于https://stackoverflow.com/a/8839678/4190526

关键是下面的行,其中发现下div图像与ID distPlot(即积名ui.R),并限定具有max-height但其他汽车的CSS。

tags$style(HTML("div#distPlot img {width: auto; height: auto; max-width: auto; max-height: 400px;}")), 

的完整代码

library(shiny) 

ui <- shinyUI(fluidPage(

    tags$style(HTML("div#distPlot img {width: auto; height: auto; max-width: auto; max-height: 400px;}")), 
    titlePanel("Old Faithful Geyser Data"), 
    sidebarLayout(
     sidebarPanel(
     sliderInput("bins", 
        "Number of bins:", 
        min = 1, 
        max = 50, 
        value = 30) 
    ), 
     mainPanel(
     plotOutput("distPlot") 
    ) 
    ) 
)) 

server <- shinyServer(function(input, output) { 

    output$distPlot <- renderPlot({ 
     x <- faithful[, 2] 
     bins <- seq(min(x), max(x), length.out = input$bins + 1) 

     hist(x, breaks = bins, col = 'darkgray', border = 'white') 
    }, width=600, height=1200) 
}) 

shinyApp(ui = ui, server = server) 
+0

最好的,谢谢。 –