New Upstream Snapshot - r-cran-threejs

Ready changes

Summary

Merged new upstream version: 0.3.3+git20220819.1.f9aadce+dfsg (was: 0.3.3+dfsg).

Resulting package

Built on 2022-10-21T11:36 (took 14m17s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots r-cran-threejs

Diff

diff --git a/DESCRIPTION b/DESCRIPTION
index 6ded89f..25b4d2d 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -3,8 +3,8 @@ Type: Package
 Title: Interactive 3D Scatter Plots, Networks and Globes
 Description: Create interactive 3D scatter plots, network plots, and
     globes using the 'three.js' visualization library (<https://threejs.org>).
-Version: 0.3.3
-Date: 2020-01-19
+Version: 0.3.4
+Date: 2021-08-30
 Authors@R: c(
     person("B. W.", "Lewis", role=c("aut","cre","cph"), email="blewis@illposed.net"),
     person(given="Three.js authors", role="cph", comment="three.js library"),
@@ -14,7 +14,7 @@ Authors@R: c(
     person("Andreas", "Briese", role=("ctb"), email="ab@edutoolbox.de"),
     person("B.", "Thieurmel", role=("ctb"), email="bthieurmel@gmail.com")
     )
-URL: https://bwlewis.github.io/rthreejs
+URL: https://bwlewis.github.io/rthreejs/
 BugReports: https://github.com/bwlewis/rthreejs/issues
 License: MIT + file LICENSE
 Depends: R (>= 3.0.0), igraph (>= 1.0.0)
@@ -22,9 +22,9 @@ Imports: htmlwidgets (>= 0.3.2), base64enc, crosstalk, methods, stats
 Suggests: maps
 Enhances: knitr, shiny
 Encoding: UTF-8
-RoxygenNote: 7.0.2
+RoxygenNote: 7.1.1
 NeedsCompilation: no
-Packaged: 2020-01-21 15:03:57 UTC; blewis
+Packaged: 2022-10-21 11:28:54 UTC; root
 Author: B. W. Lewis [aut, cre, cph],
   Three.js authors [cph] (three.js library),
   jQuery Foundation [cph] (jQuery library),
@@ -33,5 +33,3 @@ Author: B. W. Lewis [aut, cre, cph],
   Andreas Briese [ctb],
   B. Thieurmel [ctb]
 Maintainer: B. W. Lewis <blewis@illposed.net>
-Repository: CRAN
-Date/Publication: 2020-01-21 15:50:03 UTC
diff --git a/LICENSE b/LICENSE
index 0db6d9e..e8248f6 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,8 +1,63 @@
-YEAR: 2020
+The threejs R package:
+
+LICENSE: MIT
+YEAR: 2021
 COPYRIGHT HOLDER: Bryan W. Lewis
 
-YEAR: 2020
-COPYRIGHT HOLDER: The three.js authors
 
-YEAR: 2020
+The threejs package includes other open source software components. The
+following is a list of these components, their copyrights and licenses.
+
+FILE(S): inst/htmlwidgets/lib/threejs-*/*
+LICENSE: MIT
+YEAR: 2010-2021
+COPYRIGHT HOLDER: The three.js authors, see https://github.com/mrdoob/three.js/
+
+FILES(S): data/LeMis.RData
+LICENSE: GPL-3
+YEAR: 2021
+COPYRIGHT HOLDER: Mike Bostock, see https://bl.ocks.org/mbostock/4062045
+
+FILE(S): inst/images/world.jpg
+LICENSE: Unlimited
+YEAR: 2021
+SOURCE: NASA (Copyright N/A)
+
+FILE(S): inst/images/moon.jpg
+LICENSE: Unlimited
+YEAR: 2021
+SOURCE: NASA (Copyright N/A)
+
+FILE(S): data/ego.RData
+LICENSE: BSD_2_clause
+YEAR: 2007-20012
+COPYRIGHT HOLDER: Jure Leskovec, see https://snap.stanford.edu/data/ego-Facebook.html
+
+FILE(S): inst/htmlwidgets/lib/jquery/jquery.min.js
+LICENSE: jQuery
+YEAR: 2021
 COPYRIGHT HOLDER: JS Foundataion, see https://js.foundation
+
+jQuery license and license for included components from jQuery UI
+----------------------------------------------------------------------
+
+Copyright JS Foundation and other contributors, https://js.foundation/
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/MD5 b/MD5
deleted file mode 100644
index 334f185..0000000
--- a/MD5
+++ /dev/null
@@ -1,55 +0,0 @@
-ffd2ad564f7f6e3b39fba3065bb1f191 *DESCRIPTION
-b4a3c262dc0850deac687a32926df298 *LICENSE
-cbdc96e427820cbf849ac023aec43144 *NAMESPACE
-aabdd587021e2651067d5f6d4e26f0ad *R/data-definitions.R
-2708cf710ee23757fa666435bf19babc *R/globe.R
-ea8f98cee1aee4288d3c8595aaf62a9b *R/graph.R
-a67b74b6ddb93e1873e4cdb35a0909ed *R/scatterplot.R
-eb67eb1125c66ae48a40773169bf72f0 *R/threejs.R
-c3071533d659a11d51cf025b7953dcab *R/utilities.R
-d4330e129937f1105ce48424d0117385 *README.md
-15066af4ebda663340bdf26099646bea *data/LeMis.RData
-848df314cedd9e8ac0f17b19279956fc *data/ego.RData
-8e5e87f0e94273fd39da242c85e92a38 *data/flights.RData
-aa652e5492862920d1e5d5f3a867432a *demo/00Index
-d9d9ca4c0e58a579073c7f1fd35f65e7 *demo/click_animation.R
-0d0784f902bbaea0dbeca020d5305f41 *demo/click_animation2.R
-22d2327dff483a65c1ab938d2497d852 *demo/crosstalk.R
-fbd003d3c9061a966bf39b44a4842764 *inst/examples/globe/server.R
-fc021e944acd156f96bfdf7757514206 *inst/examples/globe/ui.R
-995bba99b441801f5b45bfd5702c59f1 *inst/examples/graph/server.R
-1d3d39b62a9d59ce120e99fca38ac7a3 *inst/examples/graph/ui.R
-a5e274183bd0674770b74388f730c96a *inst/examples/scatterplot/server.R
-0d9ce37a789d8f0cac06f1729527619f *inst/examples/scatterplot/ui.R
-1959139cfe26d0db813de2f429c40be8 *inst/htmlwidgets/globe.js
-95bee895d6c4c014b0220d3b181af0e5 *inst/htmlwidgets/globe.yaml
-4f252523d4af0b478c810c2547a63e19 *inst/htmlwidgets/lib/jquery/jquery.min.js
-90caa1488a37a14eebc22fc37396077a *inst/htmlwidgets/lib/threejs-111/CanvasRenderer.js
-4d6dd2e03e067d5e949f2316f24fafe7 *inst/htmlwidgets/lib/threejs-111/Detector.js
-0552b0aca46b57eaec735f14481957d6 *inst/htmlwidgets/lib/threejs-111/Projector.js
-d407a71bcc14f06baeaa3b92aa0896c0 *inst/htmlwidgets/lib/threejs-111/StateOrbitControls.js
-05422e3cc842a9160cd06f94bfc1a81e *inst/htmlwidgets/lib/threejs-111/TrackballControls.js
-daf1a794272fc7d9234980320460cb71 *inst/htmlwidgets/lib/threejs-111/three.min.js
-23e7213c0366e6495d4e907ca1a71d96 *inst/htmlwidgets/scatterplotThree.js
-39849dbc756e0a29e51a7990b2a0f130 *inst/htmlwidgets/scatterplotThree.yaml
-79b9e9384834cbb8f90dd8833cbeeb26 *inst/images/circle.png
-708d01dffedb283c365c8c67aa36c04f *inst/images/disc.png
-e03d6618d840119bbf1b6fdbac1f23a1 *inst/images/moon.jpg
-41dc495690510741c61bbeda8107c947 *inst/images/plus.png
-8e3ccdd0a25ef777c31a54410e2a654c *inst/images/world.jpg
-6627e5683e300fe96f43228a6156bfff *man/LeMis.Rd
-0723ea57aa77ef9e86c6d320ec706445 *man/ego.Rd
-a29d9fc8812b5d937cb1c34c167afa4b *man/flights.Rd
-08d3a69e1701ef8d33990938e136931d *man/gcol.Rd
-397b958b17e5b5802e24f312a7a832c5 *man/globejs.Rd
-cc0cc22381324d648948dd546f83a0a1 *man/graphjs.Rd
-c4ab794228ffdaeea22e66a2d6994ea9 *man/light_ambient.Rd
-e2ff55f8ce2eedb9f97ef93c0b626256 *man/light_directional.Rd
-6efbb8ad87cde286c3826089259e8092 *man/lines3d.Rd
-872418d12ff7231577655f488a7a6a9d *man/points3d.Rd
-1918e5df18f8b2d1bd02c8ec1dc48c6d *man/scatterplot3js.Rd
-74b9b0266cbc7222ffee57a8cc03fe7e *man/texture.Rd
-42f9fbff0bb6dfb0b19d5a4e917b9d49 *man/threejs-package.Rd
-ffc6d21f384ba55b1ba3cc357fccadda *man/threejs-shiny.Rd
-e3fa7ae55e9d24803cd038f36e145a71 *man/vertices-scatterplotThree-method.Rd
-4c14459a35d8fab0a92a82c867317f26 *tests/threejs.R
diff --git a/NAMESPACE b/NAMESPACE
index 3fa591f..3159379 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,5 +1,6 @@
 # Generated by roxygen2: do not edit by hand
 
+export(flights)
 export(globeOutput)
 export(globejs)
 export(graphjs)
diff --git a/R/data-definitions.R b/R/data-definitions.R
index 0cf78f4..6134519 100644
--- a/R/data-definitions.R
+++ b/R/data-definitions.R
@@ -6,9 +6,9 @@
 #' @name LeMis
 #' @keywords datasets
 #' @source
-#' Mike Bostock's D3.js force-directed graph example  \url{http://bl.ocks.org/mbostock/4062045}.
+#' Mike Bostock's D3.js force-directed graph example  \url{https://bl.ocks.org/mbostock/4062045}.
 #' Data based on character coappearence in Victor Hugo's Les Miserables, compiled by Donald Knuth
-#' (\url{http://www-cs-faculty.stanford.edu/~uno/sgb.html}).
+#' (\url{https://www-cs-faculty.stanford.edu/~uno/sgb.html}).
 #' @usage data(LeMis)
 #' @format An igraph package graph object.
 #'
@@ -17,16 +17,25 @@ NULL
 
 #' Global flight example data from Callum Prentice.
 #'
-#' Global flight example data from Callum Prentice.
+#' Global flight example data from Callum Prentice. Data are dynamically downloaded from GitHub.
 #'
 #' @docType data
 #' @name flights
 #' @keywords datasets
 #' @source See Callum Prentice
 #' \url{https://raw.githubusercontent.com/callumprentice/callumprentice.github.io/master/apps/flight_stream/js/flights_one.js}
-#' @usage data(flights)
-#' @format A data frame with 34,296 observations of 4 variables, origin_lat, origin_long, dest_lat, and dest_long.
-NULL
+#' @usage flights()
+#' @format A data frame with 34,296 observations of 4 variables: origin_lat, origin_long, dest_lat, and dest_long.
+#' @export
+flights <- function()
+{
+  u <- "https://raw.githubusercontent.com/callumprentice/callumprentice.github.io/master/apps/flight_stream/js/flights_one.js"
+  x <- data.frame(matrix(as.numeric(
+   strsplit(gsub("\\]", "", gsub("\\[", "", gsub(".*=", "", gsub("\\n", "",
+   readChar(u, 2e6))))),  ",")[[1]]), ncol=4, byrow=TRUE))
+  names(x) <- c("origin_lat", "origin_long", "dest_lat", "dest_long")
+  x
+}
 
 
 #' Facebook social circles
@@ -37,7 +46,7 @@ NULL
 #' @name ego
 #' @keywords datasets
 #' @source Stanford SNAP network repository
-#' \url{http://snap.stanford.edu/data/facebook_combined.txt.gz}
+#' \url{https://snap.stanford.edu/data/facebook_combined.txt.gz}
 #' @references
 #' J. McAuley and J. Leskovec. Learning to Discover Social Circles in Ego Networks. NIPS, 2012.
 #' @usage data(ego)
diff --git a/R/globe.R b/R/globe.R
index a841337..19fa572 100644
--- a/R/globe.R
+++ b/R/globe.R
@@ -55,6 +55,7 @@
 #'        The canvas renderer works across a greater variety of
 #'        viewers and browsers. The default setting of 'auto' automatically chooses
 #'        WebGL rendering if it's available.}
+#'   \item{"program"}{ User-supplied JavaScript run on plot initialization}
 #' }
 #' Specify colors with standard color names or hex color representations.
 #' The default values (well-suited to many earth-like map images) are
@@ -65,35 +66,37 @@
 #' globe corresponding to the center of the flat map image.
 #'
 #' @references
-#' The three.js project \url{http://threejs.org}.
+#' The three.js project \url{https://threejs.org}.
 #' (The corresponding three.js javascript file is in
 #' \code{ system.file("htmlwidgets/globejs",package="threejs")}.)
 #'
 #' An excellent overview of available map coordinate reference systems (PDF):
-#' \url{https://www.nceas.ucsb.edu/~frazier/RSpatialGuides/OverviewCoordinateReferenceSystems.pdf}
+#' \url{https://www.nceas.ucsb.edu/sites/default/files/2020-04/OverviewCoordinateReferenceSystems.pdf}.
 #'
 #' @examples
+#' \dontrun{
 #' # Plot flights to frequent destinations from Callum Prentice's
-#' # global flight data set,
+#' # global flight data,
 #' # http://callumprentice.github.io/apps/flight_stream/index.html
-#' data(flights)
+#' f <- flights()
 #' # Approximate locations as factors
-#' dest   <- factor(sprintf("%.2f:%.2f",flights[,3], flights[,4]))
+#' dest   <- factor(sprintf("%.2f:%.2f", f[,3], f[,4]))
 #' # A table of destination frequencies
 #' freq <- sort(table(dest), decreasing=TRUE)
 #' # The most frequent destinations in these data, possibly hub airports?
 #' frequent_destinations <- names(freq)[1:10]
 #' # Subset the flight data by destination frequency
 #' idx <- dest %in% frequent_destinations
-#' frequent_flights <- flights[idx, ]
+#' frequent_flights <- f[idx, ]
 #' # Lat/long and counts of frequent flights
-#' ll <- unique(frequent_flights[,3:4])
+#' ll <- unique(frequent_flights[, 3:4])
 #' # Plot frequent destinations as bars, and the flights to and from
 #' # them as arcs. Adjust arc width and color by frequency.
 #' globejs(lat=ll[, 1], long=ll[, 2], arcs=frequent_flights,
 #'         bodycolor="#aaaaff", arcsHeight=0.3, arcsLwd=2,
 #'         arcsColor="#ffff00", arcsOpacity=0.15,
 #'         atmosphere=TRUE, color="#00aaff", pointsize=0.5)
+#' }
 #'
 #' \dontrun{
 #' # Plot populous world cities from the maps package.
diff --git a/R/graph.R b/R/graph.R
index 53c5249..17f8da6 100644
--- a/R/graph.R
+++ b/R/graph.R
@@ -108,6 +108,11 @@
 #' crosstalk-SharedData data.frame-like object with the same number of rows as graph vertices
 #' (see the examples).
 #'
+#' @section User-defined JavaScript:
+#' Use the optional \code{program} argument (see \code{\link{scatterplot3js}}) to
+#' supply JavaScript code as a character string value.
+#' The code will be run during plot initialization. See the examples.
+#'
 #' @note
 #' Edge transparency values specified as part of \code{edge.color} are ignored, however
 #' you can set an overall transparency for edges with \code{edge.alpha}.
@@ -119,26 +124,49 @@
 #' @seealso \code{\link{igraph.plotting}}, \code{\link{scatterplot3js}}
 #'
 #' @references
-#' The three.js project \url{http://threejs.org}.
+#' The three.js project \url{https://threejs.org}.
 #'
 #' @examples
 #' set.seed(1)
 #' g <- sample_islands(3, 10, 5/10, 1)
-#' i <- cluster_louvain(g)
-#' (graphjs(g, vertex.color=c("orange", "green", "blue")[i$membership], vertex.shape="sphere"))
+#' i <- membership(cluster_louvain(g))
+#' (graphjs(g, vertex.color=c("orange", "green", "blue")[i],
+#'          vertex.shape="sphere"))
 #'
 #' # similar example with user-defined directional lighting
-#' l1 = light_directional(color = "red", position = c(0, -0.8, 0.5))
-#' l2 = light_directional(color = "yellow", position = c(0, 0.8, -0.5))
-#' l3 = light_ambient(color = "#555555")
-#' (graphjs(g, vertex.color="gray", vertex.shape="sphere", lights=list(l1, l2, l3)))
+#' l1 <- light_directional(color="red", position=c(0, -0.8, 0.5))
+#' l2 <- light_directional(color="yellow", position=c(0, 0.8, -0.5))
+#' l3 <- light_ambient(color="#555555")
+#' (graphjs(g, vertex.color="gray", vertex.shape="sphere",
+#'          lights=list(l1, l2, l3)))
 #'
 #' # Les Miserables Character Co-appearance Data
 #' data("LeMis")
 #' (graphjs(LeMis))
 #'
+#' # Use HTML and CSS directly in each vertex label to customize
+#' # and align the legend:
+#' (graphjs(LeMis,
+#'          vertex.label=sprintf("<h2 style='text-align:left;'>%s</h2>",
+#'            V(LeMis)$label)))
+#'
+#' # The plot legend 'div' element is of CSS class 'infobox'. Use JavaScript
+#' # to customize labels to hover near the mouse pointer:
+#' program <- "document.addEventListener('mousemove', function(e) {
+#'   e.preventDefault();
+#'   let x = document.getElementsByClassName('infobox')[0];
+#'   x.style['background'] = '#00c9c2';
+#'   x.style['border-radius'] = '5px';
+#'   x.style['color'] = '#222';
+#'   x.style['font-family'] = 'sans-serif';
+#'   x.style['position'] = 'absolute';
+#'   x.style['top'] = e.pageY + 'px';
+#'   x.style['left'] = e.pageX + 'px';
+#' })"
+#' (graphjs(LeMis, program = program))
+#'
 #' # ...plot Character names
-#' (graphjs(LeMis, vertex.shape=V(LeMis)$label))
+#' (graphjs(LeMis, vertex.shape=V(LeMis)$label, vertex.size=0.3))
 #'
 #' # SNAP Facebook ego network dataset
 #' data("ego")
diff --git a/R/scatterplot.R b/R/scatterplot.R
index b7cdcd6..7169997 100644
--- a/R/scatterplot.R
+++ b/R/scatterplot.R
@@ -86,6 +86,7 @@
 #'   \item{"main"}{ Plot title text}
 #'   \item{"top"}{ Top location in pixels from top of the plot title text}
 #'   \item{"left"}{ Left location in pixels from center of the plot title text}
+#'   \item{"program"}{ User-supplied JavaScript run on plot initialization}
 #' }
 #' The default CSS font string is "48px Arial". Note that the format of this
 #' font string differs from, for instance, the usual `par(font.axis)`.
@@ -141,7 +142,8 @@
 #' in \code{x, y, z}.
 #'
 #' @references
-#' The three.js project: \url{http://threejs.org}. The HTML Widgets project: \url{http://htmlwidgets.org}.
+#' The three.js project: \url{https://threejs.org}. The HTML Widgets project:
+#" \url{https://www.htmlwidgets.org}.
 #'
 #' @examples
 #' # Example 1 from the scatterplot3d package (cf.)
@@ -369,7 +371,7 @@ scatterplot3js <- function(
       i <- (abs(x) < 0.01 & x != 0)
       if (any(i))
       {
-        ans[i] <- sprintf("%.2e", x)
+        ans[i] <- sprintf("%.2e", x[i])
       }
       ans
     }
diff --git a/R/threejs.R b/R/threejs.R
index 9b18b7c..d3bd23a 100644
--- a/R/threejs.R
+++ b/R/threejs.R
@@ -4,7 +4,7 @@
 #'
 #' @name threejs-package
 #' @references
-#' \url{http://threejs.org}
+#' \url{https://threejs.org}
 #' @aliases threejs
 #' @examples
 #' \dontrun{
diff --git a/R/utilities.R b/R/utilities.R
index 0d08195..896cb36 100644
--- a/R/utilities.R
+++ b/R/utilities.R
@@ -24,7 +24,7 @@
 #' encoded and inserted into three.js without using files as dataURIs.
 #'
 #' @references
-#' The threejs project \url{http://threejs.org}.
+#' The threejs project \url{https://threejs.org}.
 #' \url{https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally}.
 #'
 #' @examples
diff --git a/README.md b/README.md
index 09cd0ef..55d34e2 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,11 @@ See https://bwlewis.github.io/rthreejs for R examples.
 This project is based on the htmlwidgets package. See http://htmlwidgets.org
 for details and links to many other visualization widgets for R.
 
+# Changes in version 0.3.4 (August, 2021)
+
+Added a JavaScript 'program' function argument to run extra user-supplied
+JavaScript initialization code, see the graphjs help for examples.
+
 # New in version 0.3.0 (June, 2017)
 
 The new 0.3.0 package version introduces major changes. The `scatterplot3js()`
@@ -93,6 +98,7 @@ devtools::install_github("bwlewis/rthreejs")
 
 See `?scatterplot3d` for more examples and detailed help.
 ```r
+library(threejs)
 z <- seq(-10, 10, 0.1)
 x <- cos(z)
 y <- sin(z)
diff --git a/data/flights.RData b/data/flights.RData
deleted file mode 100644
index 8ca1b84..0000000
Binary files a/data/flights.RData and /dev/null differ
diff --git a/debian/changelog b/debian/changelog
index 0ea8866..dd14cee 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+r-cran-threejs (0.3.3+git20220819.1.f9aadce+dfsg-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Fri, 21 Oct 2022 11:29:47 -0000
+
 r-cran-threejs (0.3.3+dfsg-2) unstable; urgency=medium
 
   * Team upload.
diff --git a/inst/htmlwidgets/globe.js b/inst/htmlwidgets/globe.js
index 9e2907c..932b074 100644
--- a/inst/htmlwidgets/globe.js
+++ b/inst/htmlwidgets/globe.js
@@ -302,6 +302,8 @@ HTMLWidgets.widget(
       }
     };
 
+    if(!(x.program == undefined)) eval(x.program);
+
     function render() {
       stuff.renderer.clear();
       stuff.camera.lookAt(stuff.scene.position);
diff --git a/inst/htmlwidgets/scatterplotThree.js b/inst/htmlwidgets/scatterplotThree.js
index 5d52846..7178afc 100644
--- a/inst/htmlwidgets/scatterplotThree.js
+++ b/inst/htmlwidgets/scatterplotThree.js
@@ -120,6 +120,7 @@ Widget.scatter = function(w, h)
 
     // Info box for mouse-over labels and generic text
     var info = document.createElement("div");
+    info.className = "infobox";
     info.style.textAlign = "center";
     info.style.zIndex = 100;
     info.style.fontFamily = "Sans";
@@ -962,6 +963,7 @@ Widget.scatter = function(w, h)
     if(x.vertices.length > 1 && _this.fps > 0) _this.frame = 0; // animate
     _this.idle = false;
     render();
+    if(!(x.program == undefined)) eval(x.program);
   }; // end of create_plot
 
 /** FIXME Help improving animation performance appreciated */
@@ -1195,10 +1197,6 @@ Widget.scatter = function(w, h)
     {
       _this.infobox.innerHTML = text;
       _this.infobox.style.color = _this.fgcss;
-      _this.infobox.style.top = "-" + _this.el.getBoundingClientRect().height + "px";
-      _this.infobox.style.left = "0px";
-      if(_this.options.top) _this.infobox.style.top = (_this.options.top - _this.el.getBoundingClientRect().height) + "px";
-      if(_this.options.left) _this.infobox.style.left = _this.options.left + "px";
     }
   }
 
diff --git a/man/LeMis.Rd b/man/LeMis.Rd
index 0993a67..6d6321b 100644
--- a/man/LeMis.Rd
+++ b/man/LeMis.Rd
@@ -4,11 +4,13 @@
 \name{LeMis}
 \alias{LeMis}
 \title{Les Miserables Character Coappearance Data}
-\format{An igraph package graph object.}
+\format{
+An igraph package graph object.
+}
 \source{
-Mike Bostock's D3.js force-directed graph example  \url{http://bl.ocks.org/mbostock/4062045}.
+Mike Bostock's D3.js force-directed graph example  \url{https://bl.ocks.org/mbostock/4062045}.
 Data based on character coappearence in Victor Hugo's Les Miserables, compiled by Donald Knuth
-(\url{http://www-cs-faculty.stanford.edu/~uno/sgb.html}).
+(\url{https://www-cs-faculty.stanford.edu/~uno/sgb.html}).
 }
 \usage{
 data(LeMis)
diff --git a/man/ego.Rd b/man/ego.Rd
index 139adaa..36365bb 100644
--- a/man/ego.Rd
+++ b/man/ego.Rd
@@ -4,12 +4,14 @@
 \name{ego}
 \alias{ego}
 \title{Facebook social circles}
-\format{An igraph package undirected graph object with 4039 vertices and 88234 edges. The
+\format{
+An igraph package undirected graph object with 4039 vertices and 88234 edges. The
 graph includes a force-directed layout with vertices colored by the \code{\link{cluster_fast_greedy}}
-algorithm from the igraph package.}
+algorithm from the igraph package.
+}
 \source{
 Stanford SNAP network repository
-\url{http://snap.stanford.edu/data/facebook_combined.txt.gz}
+\url{https://snap.stanford.edu/data/facebook_combined.txt.gz}
 }
 \usage{
 data(ego)
diff --git a/man/flights.Rd b/man/flights.Rd
index cdaf483..e166a5e 100644
--- a/man/flights.Rd
+++ b/man/flights.Rd
@@ -4,15 +4,17 @@
 \name{flights}
 \alias{flights}
 \title{Global flight example data from Callum Prentice.}
-\format{A data frame with 34,296 observations of 4 variables, origin_lat, origin_long, dest_lat, and dest_long.}
+\format{
+A data frame with 34,296 observations of 4 variables: origin_lat, origin_long, dest_lat, and dest_long.
+}
 \source{
 See Callum Prentice
 \url{https://raw.githubusercontent.com/callumprentice/callumprentice.github.io/master/apps/flight_stream/js/flights_one.js}
 }
 \usage{
-data(flights)
+flights()
 }
 \description{
-Global flight example data from Callum Prentice.
+Global flight example data from Callum Prentice. Data are dynamically downloaded from GitHub.
 }
 \keyword{datasets}
diff --git a/man/globejs.Rd b/man/globejs.Rd
index dd12c5d..beba192 100644
--- a/man/globejs.Rd
+++ b/man/globejs.Rd
@@ -96,6 +96,7 @@ solar system, and are also easily generated directly in R
        The canvas renderer works across a greater variety of
        viewers and browsers. The default setting of 'auto' automatically chooses
        WebGL rendering if it's available.}
+  \item{"program"}{ User-supplied JavaScript run on plot initialization}
 }
 Specify colors with standard color names or hex color representations.
 The default values (well-suited to many earth-like map images) are
@@ -107,27 +108,29 @@ globe corresponding to the center of the flat map image.
 }
 
 \examples{
+\dontrun{
 # Plot flights to frequent destinations from Callum Prentice's
-# global flight data set,
+# global flight data,
 # http://callumprentice.github.io/apps/flight_stream/index.html
-data(flights)
+f <- flights()
 # Approximate locations as factors
-dest   <- factor(sprintf("\%.2f:\%.2f",flights[,3], flights[,4]))
+dest   <- factor(sprintf("\%.2f:\%.2f", f[,3], f[,4]))
 # A table of destination frequencies
 freq <- sort(table(dest), decreasing=TRUE)
 # The most frequent destinations in these data, possibly hub airports?
 frequent_destinations <- names(freq)[1:10]
 # Subset the flight data by destination frequency
 idx <- dest \%in\% frequent_destinations
-frequent_flights <- flights[idx, ]
+frequent_flights <- f[idx, ]
 # Lat/long and counts of frequent flights
-ll <- unique(frequent_flights[,3:4])
+ll <- unique(frequent_flights[, 3:4])
 # Plot frequent destinations as bars, and the flights to and from
 # them as arcs. Adjust arc width and color by frequency.
 globejs(lat=ll[, 1], long=ll[, 2], arcs=frequent_flights,
         bodycolor="#aaaaff", arcsHeight=0.3, arcsLwd=2,
         arcsColor="#ffff00", arcsOpacity=0.15,
         atmosphere=TRUE, color="#00aaff", pointsize=0.5)
+}
 
 \dontrun{
 # Plot populous world cities from the maps package.
@@ -178,10 +181,10 @@ shiny::runApp(system.file("examples/globe",package="threejs"))
 # See http://bwlewis.github.io/rthreejs for additional examples.
 }
 \references{
-The three.js project \url{http://threejs.org}.
+The three.js project \url{https://threejs.org}.
 (The corresponding three.js javascript file is in
 \code{ system.file("htmlwidgets/globejs",package="threejs")}.)
 
 An excellent overview of available map coordinate reference systems (PDF):
-\url{https://www.nceas.ucsb.edu/~frazier/RSpatialGuides/OverviewCoordinateReferenceSystems.pdf}
+\url{https://www.nceas.ucsb.edu/sites/default/files/2020-04/OverviewCoordinateReferenceSystems.pdf}.
 }
diff --git a/man/graphjs.Rd b/man/graphjs.Rd
index c617ccc..d209b84 100644
--- a/man/graphjs.Rd
+++ b/man/graphjs.Rd
@@ -170,24 +170,54 @@ crosstalk-SharedData data.frame-like object with the same number of rows as grap
 (see the examples).
 }
 
+\section{User-defined JavaScript}{
+
+Use the optional \code{program} argument (see \code{\link{scatterplot3js}}) to
+supply JavaScript code as a character string value.
+The code will be run during plot initialization. See the examples.
+}
+
 \examples{
 set.seed(1)
 g <- sample_islands(3, 10, 5/10, 1)
-i <- cluster_louvain(g)
-(graphjs(g, vertex.color=c("orange", "green", "blue")[i$membership], vertex.shape="sphere"))
+i <- membership(cluster_louvain(g))
+(graphjs(g, vertex.color=c("orange", "green", "blue")[i],
+         vertex.shape="sphere"))
 
 # similar example with user-defined directional lighting
-l1 = light_directional(color = "red", position = c(0, -0.8, 0.5))
-l2 = light_directional(color = "yellow", position = c(0, 0.8, -0.5))
-l3 = light_ambient(color = "#555555")
-(graphjs(g, vertex.color="gray", vertex.shape="sphere", lights=list(l1, l2, l3)))
+l1 <- light_directional(color="red", position=c(0, -0.8, 0.5))
+l2 <- light_directional(color="yellow", position=c(0, 0.8, -0.5))
+l3 <- light_ambient(color="#555555")
+(graphjs(g, vertex.color="gray", vertex.shape="sphere",
+         lights=list(l1, l2, l3)))
 
 # Les Miserables Character Co-appearance Data
 data("LeMis")
 (graphjs(LeMis))
 
+# Use HTML and CSS directly in each vertex label to customize
+# and align the legend:
+(graphjs(LeMis,
+         vertex.label=sprintf("<h2 style='text-align:left;'>\%s</h2>",
+           V(LeMis)$label)))
+
+# The plot legend 'div' element is of CSS class 'infobox'. Use JavaScript
+# to customize labels to hover near the mouse pointer:
+program <- "document.addEventListener('mousemove', function(e) {
+  e.preventDefault();
+  let x = document.getElementsByClassName('infobox')[0];
+  x.style['background'] = '#00c9c2';
+  x.style['border-radius'] = '5px';
+  x.style['color'] = '#222';
+  x.style['font-family'] = 'sans-serif';
+  x.style['position'] = 'absolute';
+  x.style['top'] = e.pageY + 'px';
+  x.style['left'] = e.pageX + 'px';
+})"
+(graphjs(LeMis, program = program))
+
 # ...plot Character names
-(graphjs(LeMis, vertex.shape=V(LeMis)$label))
+(graphjs(LeMis, vertex.shape=V(LeMis)$label, vertex.size=0.3))
 
 # SNAP Facebook ego network dataset
 data("ego")
@@ -234,7 +264,7 @@ print(bscols(
 
 }
 \references{
-The three.js project \url{http://threejs.org}.
+The three.js project \url{https://threejs.org}.
 }
 \seealso{
 \code{\link{igraph.plotting}}, \code{\link{scatterplot3js}}
diff --git a/man/scatterplot3js.Rd b/man/scatterplot3js.Rd
index 500dbc9..36bd676 100644
--- a/man/scatterplot3js.Rd
+++ b/man/scatterplot3js.Rd
@@ -156,6 +156,7 @@ plot options are also supported:
   \item{"main"}{ Plot title text}
   \item{"top"}{ Top location in pixels from top of the plot title text}
   \item{"left"}{ Left location in pixels from center of the plot title text}
+  \item{"program"}{ User-supplied JavaScript run on plot initialization}
 }
 The default CSS font string is "48px Arial". Note that the format of this
 font string differs from, for instance, the usual `par(font.axis)`.
@@ -276,7 +277,7 @@ scatterplot3js(x, y, z, pch="@") \%>\%
 
 }
 \references{
-The three.js project: \url{http://threejs.org}. The HTML Widgets project: \url{http://htmlwidgets.org}.
+The three.js project: \url{https://threejs.org}. The HTML Widgets project:
 }
 \seealso{
 scatterplot3d, rgl, points3d, lines3d, light_ambient, light_directional
diff --git a/man/texture.Rd b/man/texture.Rd
index 1b736ee..935142e 100644
--- a/man/texture.Rd
+++ b/man/texture.Rd
@@ -43,6 +43,6 @@ t <- texture(img)
 
 }
 \references{
-The threejs project \url{http://threejs.org}.
+The threejs project \url{https://threejs.org}.
 \url{https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally}.
 }
diff --git a/man/threejs-package.Rd b/man/threejs-package.Rd
index d63370a..c7188a0 100644
--- a/man/threejs-package.Rd
+++ b/man/threejs-package.Rd
@@ -19,5 +19,5 @@ runApp(system.file("examples/scatterplot",package="threejs"))
 
 }
 \references{
-\url{http://threejs.org}
+\url{https://threejs.org}
 }
diff --git a/tests/threejs.R b/tests/threejs.R
index b165114..bd93694 100644
--- a/tests/threejs.R
+++ b/tests/threejs.R
@@ -6,18 +6,6 @@ y <- sin(z)
 scatterplot3js(x, y, z, color=rainbow(length(z)))
 scatterplot3js(x, y, z, color=rainbow(length(z)), axisLabels=c("a", "b", "c"))
 
-# globes
-data(flights, package="threejs")
-dest   <- factor(sprintf("%.2f:%.2f", flights[, 3], flights[, 4]))
-freq <- sort(table(dest), decreasing=TRUE)
-frequent_destinations <- names(freq)[1:10]
-idx <- dest %in% frequent_destinations
-frequent_flights <- flights[idx, ]
-ll <- unique(frequent_flights[, 3:4])
-globejs(lat=ll[, 1], long=ll[, 2], arcs=frequent_flights,
-        arcsHeight=0.3, arcsLwd=2, arcsColor="#ffff00", arcsOpacity=0.15,
-        atmosphere=TRUE, color="#00aaff", pointsize=0.5)
-
 # graphs
 data(LeMis, package="threejs")
 g <- graphjs(LeMis, main="Les Mis&eacute;rables")

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/lib/R/site-library/threejs/htmlwidgets/lib/threejs-111/three.min.js

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/lib/R/site-library/threejs/data/flights.RData

Control files: lines which differ (wdiff format)

  • Depends: r-base-core (>= 4.2.2.20221110-2), 4.2.1-3), r-api-4.0, r-cran-igraph (>= 1.0.0), r-cran-htmlwidgets (>= 0.3.2), r-cran-base64enc, r-cran-crosstalk

More details

Full run details