具有d3treeR的交互式树形图无法在闪亮

时间:2016-12-09 11:08:48

标签: r shiny treemap htmlwidgets

我是Shiny的新手,我正在尝试使用 d3TreeR HTML Widget 来显示交互式树形图

我使用了以下代码,它在R中完美运行:

library(readxl)
budget_map <- read_excel(path = 'Trader Dashboard Data Prep Sample.xlsx',sheet='v2',col_names = TRUE)
library(treemap)
budget_treemap <- treemap(budget_map,index=c("Sales Agency","Agency","Advertiser"),vSize="Booked Revenue Net",vColor="Sales Agency",palette = "Set1",type="categorical",title="Australia Budget Map",fontsize.title=22)
library(d3treeR)
d3tree2(budget_treemap)

我正在尝试使用Shiny进行渲染,并使用以下代码:

library(shiny)
library(readxl)
library(treemap)
library(htmlwidgets)
library(data.tree)
library(d3treeR)
budget_map <- read_excel(path = 'C:/Users/rahul/Desktop/30k foot view/Trader Dashboard Data Prep Sample.xlsx',sheet='v2',col_names = TRUE)
budget_treemap <- treemap(budget_map,index=c("Sales Agency","Agency","Advertiser"),vSize="Booked Revenue Net",vColor="Sales Agency",palette = "Set1",type="categorical")

ui <- fluidPage(
  d3tree2Output("au_budget_map")
)


server <- function(input,output){
    output$au_budget_map <- renderD3tree2({budget_treemap})
}

shinyApp(ui = ui, server = server)

附加样本数据以使其可重现:https://drive.google.com/open?id=0B2LJXtBTsuhhcnZJeXI3T0kwYW8 我知道我可能会遗漏一些非常明显的东西 - 但我无法发现它!任何帮助都会非常棒!谢谢!

1 个答案:

答案 0 :(得分:2)

renderD3tree2接受d3tree2的结果作为输入:

output$au_budget_map <- renderD3tree2({d3tree2(budget_treemap)})