mages / googleVis

Interface between R and the Google Chart Tools
https://mages.github.io/googleVis/
360 stars 155 forks source link

Error: "Tried to unbox a vector of length 3" when I use gvisTreeMap in Shiny #82

Closed APonce73 closed 5 years ago

APonce73 commented 5 years ago

I tried to run gvisTreeMap in Shiny. When I used outside of shiny is not problem... work well! But when I tried to use it with shiny with "renderGvis" I have the next message:

screen shot 2019-02-07 at 11 50 15

Here the server.R ####### library(tidyverse) library(shiny) library(googleVis) library(RColorBrewer)

mx.states1 <- read.table("~/Dropbox/Shiny1/Tabla.txt", header = T)

Define server logic for slider examples

shinyServer(function(input, output, session) {

output$Treeplot1 <- renderGvis({

#Feynmann1 <- mx.states1
Feynmann1 <- mx.states1 %>%
  select(Estado, parent, Valor) %>%
  mutate(Valor1 = Valor)

Treeplot11 <- gvisTreeMap(Feynmann1,  
                     options = list(width = 1000, height = 800,
                                    fontSize = 18,
                                    minColor = '#F7FBFF',
                                    midColor = '#FD8D3C',
                                    maxColor = '#800026',
                                    headerHeight = 20,
                                    fontColor = c('black','black','white'),
                                    showScale = TRUE))
return(Treeplot11)   

})

#######

Here de ui.R

library(tidyverse) library(shiny) library(knitr) library(plotly) library(googleVis)

shinyUI(navbarPage( title = "",

tabPanel('Local leanguage', 
       shinyUI(fluidPage(
         #Application title
         titlePanel("Maize in different Leanguage"),
             width = 1)),       
           fluidRow(
             column(9,
                    htmlOutput("Treeplot1", width = "1000", height = "600"))
           ))

))

The file that I used is this one:

Tabla.txt

I hope that you can give me a tip!!!

Here my sessioninfo()

screen shot 2019-02-07 at 11 58 38

Alex

mages commented 5 years ago

The way you specify the textStyle option is not correct. The following works for me:

Treeplot11 <- gvisTreeMap(
  Feynmann1, idvar = "Estado", parentvar ="parent",
  sizevar = "Valor", colorvar = "Valor1",
  options = list(width = 1000, height = 800,
                 textStyle = "{fontSize:18, fontColor:['black', 'black', 'white']}",
                 minColor = '#F7FBFF',
                 midColor = '#FD8D3C',
                 maxColor = '#800026',
                 headerHeight = 20,
                 showScale = TRUE))
APonce73 commented 5 years ago

Many many many thanks!!! Now works perfectly!!! Gracias (Thanks a lot!!!!!)

mages commented 5 years ago

You are welcome.