【问题标题】:Unable to appropriately assign a size to NVD3 chart无法为 NVD3 图表适当分配大小
【发布时间】:2015-06-03 06:43:34
【问题描述】:

我正在尝试使用 NVD3 图表,虽然它在闪亮的仪表板中正确呈现,但包含图表的 div 溢出闪亮的仪表板box() 容器(不适合紧贴盒子)。显式设置图表的高度和宽度会改变图表的大小,但不会改变包含的 div,它会继续溢出 box 容器;我似乎无法控制 div 的大小?代码如下:

app.R

library(shiny)
library(shinydashboard)
library(rCharts)
library(curl)

consent <- read.csv(curl("https://raw.githubusercontent.com/kilimba/data/master/consent.csv"))

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(
      box(showOutput("distPlot2"),width = 6)
      )
    )
)

server <- function(input, output) { 

  output$distPlot2 <- renderChart2({
    p2 <- nPlot(HIVConsentRate ~ Year, 
                group = 'HIVRefused', 
                data = consent, 
                type = 'stackedAreaChart',
                height = 250,
                width = 450)

    return(p2)
  })
}

shinyApp(ui, server)

任何帮助表示赞赏, 图马尼

【问题讨论】:

    标签: nvd3.js rcharts shiny


    【解决方案1】:

    我测试了您的代码并将库参数 nvd3 添加到 UI 部分,如下所示:box(showOutput("distPlot2",'nvd3'),width = 6) 以加载 javascript 库。我能够在 ui 端调整框的宽度和/或在服务器端调整图表的宽度。

    【讨论】:

      【解决方案2】:

      对不起,伙计们,仍然不确定是怎么回事,但是经过尝试和测试的“将其关闭并重新打开”在这里对我有用。请注意,我还忘记在 showOutput() 中添加 lib 变量(至少在此处粘贴的这段代码中,尽管我已经私下将 lib 变量设置为“nvd3”进行了测试,但就大小调整而言,它仍然被证明是有问题的. 但是它现在可以工作了:)

      【讨论】:

        猜你喜欢
        • 2012-03-05
        • 1970-01-01
        • 1970-01-01
        • 2012-12-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-06
        • 2021-12-02
        相关资源
        最近更新 更多