Use the this tag for questions regarding the htmlwidgets for R JavaScript visualization library. For questions regarding generic HTML widgets, use the html and widget tags.
Questions tagged [htmlwidgets]
422 questions
32
votes
1 answer
Embedding an R htmlwidget into existing webpage
I am trying to embed an R htmlwidget into an existing webpage -- a webpage that already has bootstrap and styling applied. For example, consider the following webpage (note where the widget should be placed):
…

JasonAizkalns
- 20,243
- 8
- 57
- 116
18
votes
2 answers
savewidget from htmlwidget in R , cannot save html file in another folder
I have a map leaflet that I want to save in an html file in a specific folder.
I am using Windows 7.
I tried the following :
library(htmlwidgets)
saveWidget(map_leaflet, file="ressources/test.html")
library(htmlwidgets)
saveWidget(map_leaflet,…

tuttifolies
- 1,417
- 2
- 14
- 20
18
votes
1 answer
Interactive `ggplotly` graph is not plotted from inside `for` loop in `Rmd` file in R
I tried to plot series of interactive ggplotly graphs from inside for loop in R markdown (.Rmd) file. Contents of my .Rmd file:
---
title: "Untitled"
output: html_document
---
```{r}
library(ggplot2) # for plots
library(plotly) # for interactive…

GegznaV
- 4,938
- 4
- 23
- 43
15
votes
2 answers
How to include plotly in R Studio Presentations (Rpres)
How to include a plotly plot in a Rpres file?
If you do it like in a normal Rmd file
Basic Plot
========================================================
```{r, echo=FALSE}
library(plotly)
plot_ly(economics, x = date, y = unemploy / pop)
```
The…

jakob-r
- 6,824
- 3
- 29
- 47
14
votes
2 answers
Highlight all connected paths from start to end in Sankey graph using R
I want to highlight the whole path when i click on the node to know the whole story of specific node and here's an example- http://bl.ocks.org/git-ashish/8959771 .
Please check this link and you will find the function that highlight the path in…

Omar Abd El-Naser
- 684
- 7
- 20
14
votes
1 answer
Put line break in node labels in networkD3 sankey diagram
++++++++++++++++
Update:
I think the answer to my question is that you can't put line breaks in. A colleague pointed out to me the node labels are SVG blocks, which don't support line breaks.
++++++++++++++++
How do I put a line break into the node…

edsherman
- 141
- 4
13
votes
2 answers
Save/Load rpivottable configuration
I use rpivottable on several (rmarkdown) web pages.
I have seen an example here of saving/restoring table configuration to/from cookie.
Since I am not good in javascript, I would like to ask if it is possible to programmatically add two buttons in…

gd047
- 29,749
- 18
- 107
- 146
13
votes
1 answer
Modify networkD3 sankey plot with user-defined colors
I have a sankey plot created in networkD3 package. I would like to modify the colors and transparency of both nodes and links.
My data networkD3_data is appended at the end.
Question 1: How to modify node colors with user-defined palette?
I am not…

Djork
- 3,319
- 1
- 16
- 27
13
votes
4 answers
R networkD3 package: node coloring in simpleNetwork()
The networkD3 package (see here and here) allows a user to create simple interactive networks:
# Load package
library(networkD3)
# Create fake data
src <- c("A", "A", "A", "A",
"B", "B", "C", "C", "D")
target <- c("B", "C", "D", "J",
…

warship
- 2,924
- 6
- 39
- 65
11
votes
1 answer
How to resize HTML widget using saveWidget in htmlwidgets R?
I use saveWidget function in htmlwidgets to save HTML widgets in R. I got the saved HTML files with width 960 and height 500.
I am pretty sure that I can resize the widget within knitrOptions parameters but I can not find out the list of the…

rasyidstat
- 585
- 2
- 6
- 17
10
votes
1 answer
Argument "selfcontained" deprecated in htmlwidgets::saveWidget()
I keep getting [WARNING] Deprecated: --self-contained. use --embed-resources --standalone when saving a plotly plot as a self-contained html widget, using htmlwidgets::saveWidget(..., selfcontained = TRUE).
I can't figure out how to use…

bt3
- 156
- 1
- 10
10
votes
2 answers
Change size of hover text in Plotly
I am building a Plotly plot based on a ggplot in R. I would like to increase the size of the text in the hover boxes. Suppose I have a scatterplot like this:
library(plotly)
library(ggplot2)
d <- data.frame(a = sample(1:50, 30, T),
…

nhoeft
- 535
- 6
- 17
10
votes
2 answers
How to capture html output as png in R
I use interactive output created by networkD3 package in R. I know how to save the output as html page, but I also need to save the 'static' version of the diagram as .png file.
The code looks like this:
# Load package
library(networkD3)
# Create…

Lenka Vraná
- 1,686
- 2
- 19
- 29
9
votes
2 answers
Is it possible to include custom css in htmlwidgets for R and/or LeafletR?
I'd like to make some style changes to my leaflet map.
Is it possible to include
style elements OR
a custom path to a css file
either via htmlwidgets for R or LeafletR?
Best

kabr
- 1,249
- 1
- 12
- 22
9
votes
1 answer
Sankey diagram in R
Attempting to make a fairly generic Sankey diagram with the help of R's networkD3 package. Just for reference--here's the example from the package's manual
library(networkD3)
library(jsonlite)
library(magrittr)
energy <-…

tomw
- 3,114
- 4
- 29
- 51