Skip to content

Instantly share code, notes, and snippets.

@Tutuchan
Created September 14, 2016 19:34
Show Gist options
  • Save Tutuchan/28f6ac4b38a60ffd93b3e80133d863dc to your computer and use it in GitHub Desktop.
Save Tutuchan/28f6ac4b38a60ffd93b3e80133d863dc to your computer and use it in GitHub Desktop.
---
title: "loop over widgets"
author: "Tutuchan"
date: "14 septembre 2016"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(chartjs)
library(knitr)
```
```{r}
plot_list <- lapply(1:2, function(i) {
chartjs(height = "200px") %>%
cjsBar(labels = LETTERS[1:10]) %>%
cjsSeries(data = c(abs(c(rnorm(8))), NA, 0.5), label = "Series 1") %>%
cjsSeries(data = abs(c(rnorm(10))), label = "Series 2") %>%
cjsSeries(data = abs(c(rnorm(10))), label = "Series 3") %>%
cjsTitle(title = paste("Chart", i)) %>%
cjsLegend()
})
```
```{r}
htmltools::tagList(plot_list)
```
@NikosAlexandris
Copy link

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment