jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
718 stars 147 forks source link

FlexDashBoard with Highcharter not displaying maps properly #744

Closed jameshenry1995 closed 2 years ago

jameshenry1995 commented 2 years ago

Following the trailing garbage error when loading hcmaps, following the addition of a colon to every map, a suggested fix was to pull the development version.

With this version, flexdashboard does not render charts properly anymore. The first one in the dashboard appears, then all subsequent plots do not.

There's also an issue with the hw_grid() function, which, also following the update, only displays a single plot instead of two.

jbkunst commented 2 years ago

Hi @jameshenry1995

Can you send a reproducible example to work with? Are you using the latest versions of the packages?

jameshenry1995 commented 2 years ago

Hey @jbkunst , After many hours of tinkering I've finally managed to reproduce my problem using random data I generated, which perfectly reflects my own data.

Here's my code for the flexdashboard, with all the packages I use in my main dashboard:

`--- title: "Untitled" output: flexdashboard::flex_dashboard: orientation: columns vertical_layout: fill

library(flexdashboard)
library(tidyverse)
library(DBI)
library(rgeolocate)
library(highcharter)
library(stringr)
library(jsonlite)
library(httr)
library(lubridate)
library(reshape2)
library(scales)

Column {data-width=650}

Chart A

table <- as_tibble(data.frame(id = c(1:200),
           value = sample(c(500:1000), 200, replace = T),
           variable = sample(c("v1","v2","v3","v4","v5","v6"), 200, replace = T)))

table %>%
  hchart("scatter",hcaes(x = id, y = value, group = variable))

Chart A

cars <- cars %>%
  mutate(char = ifelse(speed < 10, "below","above"))

cars %>%
  hchart("scatter",hcaes(x = speed, y = dist, group = char))

Chart A


cars %>%
  hchart("scatter",hcaes(x = speed, y = dist, group = char))

`

If you run this you should see that the first plot renders perfectly, and the others just don't appear. Conversely, if you replace my plot with a copy paste of the cars plot, it will render. Here's an image of both cases:

image

image

I cannot for the life of me understand what causes the issue. All I changed between the two examples is one plot, but they all work the same way.

Here's the code again without the brackets to make sure you can copy paste:


title: "Untitled" output: flexdashboard::flex_dashboard: orientation: columns vertical_layout: fill

library(flexdashboard)
library(tidyverse)
library(DBI)
library(rgeolocate)
library(highcharter)
library(stringr)
library(jsonlite)
library(httr)
library(lubridate)
library(reshape2)
library(scales)

Column {data-width=650}

Chart A

table <- as_tibble(data.frame(id = c(1:200),
           value = sample(c(500:1000), 200, replace = T),
           variable = sample(c("v1","v2","v3","v4","v5","v6"), 200, replace = T)))

table %>%
  hchart("scatter",hcaes(x = id, y = value, group = variable))

Chart A

cars <- cars %>%
  mutate(char = ifelse(speed < 10, "below","above"))

cars %>%
  hchart("scatter",hcaes(x = speed, y = dist, group = char))

Chart A


cars %>%
  hchart("scatter",hcaes(x = speed, y = dist, group = char))
jbkunst commented 2 years ago

Hi @jameshenry1995

Test again with the development version. I removed the accesibility module and it worked.