Open zac-garland opened 4 years ago
Thanks for the report and sorry for the delay.
With a simpler example this is working ok with both highcharter and plotly.
---
title: "Untitled"
output: revealjs::revealjs_presentation
---
```{r setup, include=FALSE}
library(highcharter)
library(plotly)
x <- c(rnorm(10000), rnorm(1000, 4, 0.5))
hchart(x, name = "data")
mtcars %>%
plot_ly(x = ~mpg,
y = ~cyl)
This means that it could be caused by specific component with those JS library that will / could conflict with reveal.js library.
We'll look into it.
In fact, more information:
It seems like a conflict between plotly and highcharter
---
title: "Untitled"
output: revealjs::revealjs_presentation
---
```{r setup, include=FALSE}
library(highcharter)
library(plotly)
library(tidyverse)
library(htmltools)
x <- c(rnorm(10000), rnorm(1000, 4, 0.5))
hchart(x, name = "data")
mtcars %>%
plot_ly(x = ~mpg,
y = ~cyl)
mtcars %>%
as_tibble() %>%
split(.$carb) %>%
map(~{
.x %>%
plot_ly(x = ~mpg,
y = ~hp)
}) %>%
map(div,style="width:100%;display:inline-block") %>%
div()
* Adding one slide with several highcharter = Plotly no more working !
````markdown
---
title: "Untitled"
output: revealjs::revealjs_presentation
---
```{r setup, include=FALSE}
library(highcharter)
library(plotly)
library(tidyverse)
library(htmltools)
x <- c(rnorm(10000), rnorm(1000, 4, 0.5))
hchart(x, name = "data")
n <- 5
set.seed(123)
colors <- c("#d35400", "#2980b9", "#2ecc71", "#f1c40f", "#2c3e50", "#7f8c8d")
colors2 <- c("#000004", "#3B0F70", "#8C2981", "#DE4968", "#FE9F6D", "#FCFDBF")
df <- data.frame(x = seq_len(n) - 1) %>%
mutate(
y = 10 + x + 10 * sin(x),
y = round(y, 1),
z = (x*y) - median(x*y),
e = 10 * abs(rnorm(length(x))) + 2,
e = round(e, 1),
low = y - e,
high = y + e,
value = y,
name = sample(fruit[str_length(fruit) <= 5], size = n),
color = rep(colors, length.out = n),
segmentColor = rep(colors2, length.out = n)
)
create_hc <- function(t) {
dont_rm_high_and_low <- c("arearange", "areasplinerange",
"columnrange", "errorbar")
is_polar <- str_detect(t, "polar")
t <- str_replace(t, "polar", "")
if(!t %in% dont_rm_high_and_low) df <- df %>% select(-e, -low, -high)
highchart() %>%
hc_title(text = paste(ifelse(is_polar, "polar ", ""), t),
style = list(fontSize = "15px")) %>%
hc_chart(type = t,
polar = is_polar) %>%
hc_xAxis(categories = df$name) %>%
hc_add_series(df, name = "Fruit Consumption", showInLegend = FALSE)
}
c("line", "spline", "area", "areaspline",
"column", "bar", "waterfall" , "funnel", "pyramid",
"pie" , "treemap", "scatter", "bubble",
"arearange", "areasplinerange", "columnrange", "errorbar",
"polygon", "polarline", "polarcolumn", "polarcolumnrange",
"coloredarea", "coloredline") %>%
map(create_hc) %>%
div()
mtcars %>%
plot_ly(x = ~mpg,
y = ~cyl)
mtcars %>%
as_tibble() %>%
split(.$carb) %>%
map(~{
.x %>%
plot_ly(x = ~mpg,
y = ~hp)
}) %>%
map(div,style="width:100%;display:inline-block") %>%
div()
Interesting ! but maybe not directly related to reveal.js 🤔
HTMLwidget compatibility is always difficult due to potential JS lib conflict
hi all,
last week, all of my revealjs presentations were working great. but at some point (around Friday evening), all of my JS dependent charts (i.e. plotly & highcharter) stopped showing up in the rendered HTML doc.
I reproduced the issue with both single plots (one plot per chunk) and multiple plots (split dataframe, or chart type and mapped to a div). I tested this on both work and personal laptops and the issue remains.
Could someone kindly look into this? Happy to help anyway I can. I appreciate your help in advance.
Rmarkdown reprex
Rendered HTML
My version info: