Closed shrektan closed 8 years ago
I guess it's something related to the handling of R object to JSON.
Note, if I remove the last Chinese character 类
, the code works fine, i.e.:
library(magrittr)
r <- data.frame(a = 1:3, b = c("a", "b", "c"))
highcharter::highchart() %>%
highcharter::hc_chart(type = "column") %>%
highcharter::hc_xAxis(categories = r$b) %>%
highcharter::hc_add_series(data = r$a, name = "权益")
I guess it's not an error related to your package, because I find that the DT
can't work as well.
DT::datatable(data.frame(name = "权益类"))
So, feel free to close this issue if you end up with the same conclusion. Thanks!
@jbkunst Sorry, after I reboot my PC, the issue is gone... Sometimes, the best solution in Windows is rebooting... So, I'll close this issue.
:satisfied: Sometimes? Always!
Regards
i got the same problem on centos.
Hi @funnng,
If you have the same message/error:
Error in gsub("</", "\\u003c/", payload, fixed = TRUE) :
That line belogs to the htmlwidgets
package (see line here)
So I'm not sure how I can help you. Have you tried removing special characters?
@funnng covert the UTF8 character to native might help
i tried the code below and it show nothing, and i check the console log in chrome and found this error.
highchart() %>% hc_add_series_treemap(treemap(data.frame(city=c('广州','广州','佛山','佛山'), zone=c('天河','海珠','顺达','禅城'), pay = c(563,235)), index = c('city','zone'), vSize='pay', vColor='pay', type='comp', palette = rev(viridis(9)), draw = F))
@jbkunst @shrektan i think it is not the same issue, the error i met is not like Error in gsub("</", "\\u003c/", payload, fixed = TRUE) :
> devtools::session_info()
Session info -------------------------------------------------------------------------------------------------------
setting value
version R version 3.2.3 (2015-12-10)
system x86_64, linux-gnu
ui RStudio (0.99.892)
language (EN)
collate en_US.UTF-8
tz <NA>
date 2016-05-23
Hi @funnng
The issue is because internally the hc_add_series_treemap
function is using a helper function str_to_id
which try to remove spectial character to put the name of the value as id
in the data series (check str_to_id("广州")
).
By now, you can use a modify hc_add_series_treemap2
(see code below) until I check if there no problem if I remove some replacement in the str_to_id
function.
library(dplyr)
library(purrr)
hc_add_series_treemap2 <- function(hc, tm, ...) {
df <- tm$tm %>%
tbl_df() %>%
select_("-x0", "-y0", "-w", "-h", "-stdErr", "-vColorValue") %>%
rename_("value" = "vSize", "valuecolor" = "vColor") %>%
purrr::map_if(is.factor, as.character) %>%
data.frame(stringsAsFactors = FALSE) %>%
tbl_df()
ndepth <- which(names(df) == "value") - 1
ds <- map_df(seq(ndepth), function(lvl){ # lvl <- sample(seq(ndepth), size = 1)
df2 <- df %>%
filter_(sprintf("level == %s", lvl)) %>%
rename_("name" = names(df)[lvl]) %>%
mutate_("id" = "name")
if (lvl > 1) {
df2 <- df2 %>%
mutate_("parent" = names(df)[lvl - 1],
"parent" = "parent")
} else {
df2 <- df2 %>%
mutate_("parent" = NA)
}
df2
})
ds <- list.parse3(ds)
ds <- map(ds, function(x){
if (is.na(x$parent))
x$parent <- NULL
x
})
hc %>% hc_add_series(data = ds, type = "treemap", ...)
}
Hi, first of all, thanks for this great package. It's very powerful.
However, I encounter an issue related to the encoding in windows. I'm not familiar with
htmlwidgets
and not be able to figure out what the problem is. So, I come here to file this issue and hopefully can get the help from you, thanks.Here's the minimal reproducible example
The Error msg
devtools::session_info()
sessionInfo()