htmlwidgets

Open hyperlink on click on an ggplot/plotly chart

核能气质少年 提交于 2019-12-11 03:24:47
问题 This is a follow up question on the answer provided for Add onclick open hyperlink event to an html widget created in R. Consider the following example: library(ggplot2) library(plotly) library(htmlwidgets) library(htmltools) myData <- data.frame( x=c(1,2,3), y=c(3,2,1), label=c("Google", "Bing", "R"), category=c("search", "search", "other"), urls=c("http://google.de", "http://bing.com", "http://r-project.org") ) f <- function(p) { ply <- ggplotly(p) javascript <- HTML(paste(" var myPlot =

Adding Color and Hover Options to VisNetwork Igraph

纵饮孤独 提交于 2019-12-11 01:49:37
问题 I have been having trouble with this. I can only get one or the other but not both options in one graph. Below is the code and I received a lot of help from @lukeA to get me to this point. I have the following graph in which I can get the cluster colors into the visNetwork Igraph : library(igraph) library(visNetwork) B = matrix( c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 3, 0, 3, 0, 1, 10, 13, 5, 0, 3, 19, 0, 1, 0, 1, 7, 3, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 32, 0, 0, 3, 2, 1, 0, 0, 0,

R networkD3: click action to show information from node data frame

。_饼干妹妹 提交于 2019-12-10 23:42:13
问题 I have this code: library(networkD3) # Load data data(MisLinks) data(MisNodes) new.nodes <- MisNodes new.nodes$var1 <- runif(nrow(MisNodes),1,2) new.nodes$var2 <- runif(nrow(MisNodes),1,2) # Some script to show the node index in the new.nodes data frame script <- 'alert("row: " + (d.index + 1));' # Plot forceNetwork(Links = MisLinks, Nodes = new.nodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.8, clickAction = script) I figured out to

openweathermap weather tile in Leaflet in R

南楼画角 提交于 2019-12-10 11:42:33
问题 I am trying to add custom weather tiles on a leaflet map in a Shiny application using leaflet-openweathermap javascript library available here. I am not conversant with javascript and the map doesn't render the weather layers. I first downloaded leaflet-openweathermap.js and placed it in www/js folder in my app's path. I then registered the plugin: openWeatherPlugin <- htmlDependency( "Leaflet.OpenWeather", "1.6.0", src = normalizePath(path = getwd()), script = "www/js/leaflet.openweathermap

Generate formattable widgets in a loop in an R markdown document

╄→尐↘猪︶ㄣ 提交于 2019-12-10 10:53:30
问题 I want to put HTML widgets like formattable (from formattable package) in an HTML page generated through RMarkdown. I need the widgets to be generated from within a for loop. How can i do that? With or without print() , both don't work. This is an example code (partly taken from formattable homepage): --- title: "formattable example loop" output: html_document --- ```{r} library(formattable) df <- data.frame( id = 1:10, name = c("Bob", "Ashley", "James", "David", "Jenny", "Hans", "Leo", "John

Change the color of the legend text in forceNetwork for networkD3

别等时光非礼了梦想. 提交于 2019-12-08 21:21:25
Using forceNetwork from the networkD3 R package, how can I change the color of the text in the legend to white? My Code: library(networkD3) forceNetwork(Links = subLinkList, Nodes = subNodes, Source = "root", Target = "children", Value = "linkValue", NodeID = "nodeName", Nodesize = "nodeSize", Group = "nodeGroup", colourScale = JS(colorScale), charge = -500, opacity = 1, opacityNoHover = 1, fontSize = 25, fontFamily = "Calibri", linkDistance = JS('function(){d3.select("body").style("background-color", "#144370");return 200;}'), linkWidth = 3, linkColour = "white", legend = TRUE, bounded = TRUE

Save .png by webshot in R

和自甴很熟 提交于 2019-12-08 07:57:22
问题 I'm using webshot to save a png file from HTML : p <- plot_ly(plotly::wind, r = ~r, t = ~t) %>% add_area(color = ~nms)%>% layout(radialaxis = list(ticksuffix = "%"), orientation = 270) saveWidget(as.widget(p), "temp.html") webshot("temp.html",file = "temp.png",cliprect = "viewport") This is giving me a plot like this. It returns a small image in the upper left corner. What should I do to have a full-size image in a center? 来源: https://stackoverflow.com/questions/48289771/save-png-by-webshot

Shiny App-showModal does not pop up with renderSankeyNetwork

青春壹個敷衍的年華 提交于 2019-12-08 07:50:50
问题 I am developing a Shiny application which has two components Sankey Diagram and one action button which pop up "SaveMsg" dialog box on click of button . I am seeing unexpected behavior where, If I user actionbutton and Sankeyvisualization in one dashboard, on click of action button, dashboard screen greyed out. however If I comment Sankey code and keep only Action button on UI, Action button works as expected by showing pop up message of "save successfull". If I comment action button code and

R combining data tables DT package and sparkline package box plot with target value

北慕城南 提交于 2019-12-08 04:41:14
问题 I'm using sparkline plots in a DT table as outlayed here: https://leonawicz.github.io/HtmlWidgetExamples/ex_dt_sparkline.html Boiled down dummy example as follows library(data.table) library(DT) library(sparkline) hist.A<-rnorm(100) hist.B<-rnorm(100) hist.C<-rnorm(100) current.A<-rnorm(1) current.B<-rnorm(1) current.C<-rnorm(1) #whisker should show full range of data boxval.A<-paste(quantile(hist.A,probs=c(0,0.25,0.5,0.75,1)),collapse = ",") boxval.B<-paste(quantile(hist.B,probs=c(0,0.25,0.5

How to arrange html widget plots in a grid for export as pdf?

此生再无相见时 提交于 2019-12-07 11:58:28
问题 I would like to combine the richness of html widgets (mainly plotly and networkD3), with the possibility of arranging them as plots in a grid in R, to export them as pdf graphic for a publication. However, if I create some html widget objects in R and try to arrange them with gridExtra::grid.arrange() (see minimal example below) I get the following error: Error in gList(list(x = list(links = list(source = c(0, 0), target = c(1, : only 'grobs' allowed in "gList" I searched for “converting html