R: saving multiple html widgets together
If format doesn't matter too much, you can merge the widgets using tagList and save them directly:
htmltools::save_html(tagList(widget_1, widget_2, widget_3, widget_4), file = "C://Users//Me//Desktop//widgets.html")
(It goes without saying that you will need to edit the filepath!)
If you want to control the layout of the widgets, you can wrap each in a div, and then style those:
doc <- htmltools::tagList(
div(widget_1, style = "float:left;width:50%;"),
div(widget_2,style = "float:left;width:50%;"),
div(widget_3, style = "float:left;width:50%;"),
div(widget_4, style = "float:left;width:50%;")
)
htmltools::save_html(html = doc, file = "C://Users//Me//Desktop//widgets.html")
How to export two HTML widgets in the same HTML page in R?
Use R Markdown to create html pages with multiple exhibits/widgets:
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(timevis)
library(DT)
data <- data.frame(
id = 1:4,
content = c("Item one", "Item two",
"Ranged item", "Item four"),
start = c("2016-01-10", "2016-01-11",
"2016-01-20", "2016-02-14 15:00:00"),
end = c(NA, NA, "2016-02-04", NA)
)
acs <- read.csv(url("http://stat511.cwick.co.nz/homeworks/acs_or.csv"))
acs_temp <- DT::datatable(acs, options = list(pageLength = 10))
```
## R Markdown
```{r timeviz}
timevis(data)
acs_temp
```
R : combine and save rgl widgets as a single html file
Your widgets
object is a list of 3 widgets with class c("shiny.tag.list","list")
, not a widget. You can save it using the htmltools::save_html
function. So instead of
htmlwidgets::saveWidget(widgets, "y.html")
you want
htmltools::save_html(widgets, "y.html")
How to resize HTML widget using saveWidget in htmlwidgets R?
I had this problem today.
Unfortunately, I didn't find a good solution to this.
I had to change the attribute width of the widget:
wid <- ggiraph(ggobj=pl,
zoom_max=1000,
tooltip_opacity=0.7,
tooltip_extra_css="width:300px;background-color:black;color:white;font-family:Sans,Arial",
width_svg=80,
height_svg=7,
width=1)
wid$x$width <- "6000px"
temp_output <- tempfile(tmpdir=getwd(), fileext=".html")
saveWidget(widget=wid, file=basename(temp_output), selfcontained=TRUE,
knitrOptions=list())
R: Adjusting Titles in HTML files
library(htmltools)
library(plotly)
#create widget_1
widget_1 = plot_ly(iris, x = ~Sepal.Length, type = "histogram", nbinsx = 20)
#create_widget_2
widget_2 = plot_ly(iris, x = ~Sepal.Width, type = "histogram", nbinsx = 20)
#create_widget_3
widget_3 = plot_ly(iris, x = ~Petal.Length, type = "histogram", nbinsx = 20)
#create widget_4
widget_4 = plot_ly(iris, x = ~Petal.Width, type = "histogram", nbinsx = 20)
doc <- tagList(
tags$h3(style = "text-align: center;", "Main title"),
div(
style = "display: flex; justify-content: space-between;",
div(
style = "display: flex; flex-direction: column; align-items: center; width: 45%",
widget_1,
tags$p("title 1")
),
div(
style = "display: flex; flex-direction: column; align-items: center; width: 45%",
widget_2,
tags$p("title 2")
)
),
div(style = "height: 50px;"),
div(
style = "display: flex; justify-content: space-between;",
div(
style = "display: flex; flex-direction: column; align-items: center; width: 45%",
widget_3,
tags$p("title 3")
),
div(
style = "display: flex; flex-direction: column; align-items: center; width: 45%",
widget_4,
tags$p("title 4")
)
)
)
browsable(doc)
Related Topics
Can HTML5 Communicate with Peripherals Like Scanners and Credit Card Readers
Make Input Type="Password" Use Number Pad on Mobile Devices
How to Center Cards in Bootstrap 4
How to Hide Autofill Safari Icon in Input Field
Scrolling to an Anchor Using Transition/CSS3
CSS: Unexpected Vertical Position of "Inline-Block" Elements
Why Does Chrome 80 Cause This Grid-Template-Rows: Auto Problem
Offline iOS Web App: Loads My Manifest, But Doesn't Work Offline
Mailto Links Do Nothing in Chrome But Work in Firefox
Force an Image to Fit and Keep Aspect Ratio
Django: How to Send HTML Emails with Embedded Images
HTML Embed Autoplay="False", But Still Plays Automatically
Are Nested HTML Comments Possible