Taking the example in this How to programmatically generate tabset-panel in quarto?, I have established rendering charts in dynamically rendered tabsets.
I am hoping to replace the ggplots with interactive echarts, which work independently of the quarto document.
See below code:
---
title: "Panel tabs"
format:
html:
embed-resources: true
---
`{r echo=F, warning=F, message=F}
library(tidyverse)
library(echarts4r)
data <- iris
species <- list()
for(i in unique(data$Species)){
species[[paste(i)]] <- data %>%
filter(Species == i) %>%
e_charts(Sepal.Length) %>%
e_line(Sepal.Width)
# species[[paste(i)]] <- data %>%
# filter(Species == i) %>%
# ggplot(aes(x = Sepal.Length, y = Sepal.Width)) +
# geom_point() +
# theme_bw(base_size = 18)
#
#
#
# species[[paste(i)]] <- data %>%
# filter(Species == i) %>%
# plotly::plot_ly(x = ~ Sepal.Length, y = ~ Sepal.Width)
}
`
# Iris Plots
::: {.panel-tabset}
`{r}
#| results: asis
#| fig-width: 14
#| fig-height: 6
iwalk(species, ~ {
cat('## ', .y, 'nn')
print(.x)
cat('nn')
})
`
:::
I’ve commented out the ggplot2 code which works. When I try to render echarts4r, the code either doesn’t render at all or returns the html composition of the echart. I suspect this is related the cat() functionality, but cannot find a solution (or whether there is one). Any thoughts would be much appreciated!