Отобразить интерактивную древовидную карту с высокой диаграммой в flexdashboard - PullRequest
0 голосов
/ 09 января 2019

Я использую flexdashboard для создания интерактивной древовидной карты. Но сюжет не отображается правильно.

Мой код и вывод следующие:

---
title: "flexdashboard: Shiny Embedding"
output: 
  flexdashboard::flex_dashboard:
    social: menu
    source_code: embed 
runtime: shiny
---

```{r global, include=FALSE}


library(tidyverse)
library(highcharter)
library(treemap)

## generate a sample dataset
sample<-tbl_df(data.frame(c("City1","City2","City3","City1","City2","City3",
"City2","City3"),
c("A","B","C","D","D","A","A","B"),
c(12,14,15,12,12,14,8,10)))
colnames(sample)<-c("City","Country","Amount")
variable<-"City"
trmap<-function(variable)
{
 d<- cbind(sample[,variable],sample[,"Amount"])

    tm <- treemap(d, index = variable,
                             vSize = "Amount")
 highchart() %>%
  hc_title(text = paste("Treemap de", variable ),
          style = list(fontSize = "15px")) %>% 
hc_add_series_treemap(tm)


}
```

Column {.sidebar}
-------------------------------------------
```{r}
selectInput(inputId="variable",label="group by",choices=c("City","Country"))
```

Column
------------------------------------------
### Plot

```{r}
renderPlot(trmap(input$variable))
```

Результатом этого кода является следующая панель инструментов: enter image description here

Но изначально сюжет динамический, потому что он показывает цифры суммы, когда я помещаю курсор в поле каждого города.

enter image description here

Как правильно отобразить график, чтобы получить динамический график, отображающий числа ??

...