library(highcharter)
## Highcharts (www.highcharts.com) is a Highsoft software product which is
## not free for commercial and Governmental use
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(purrr)
##
## Attaching package: 'purrr'
## The following objects are masked from 'package:dplyr':
##
## contains, order_by
set.seed(123)
n <- 10
df <- data_frame(
lat = runif(n, -180, 180),
lon = runif(n, -180, 180),
z = round(runif(n)*10) + 1,
color = colorize(lat)
)
sequences <- map2(1:n, df$z, function(x, y){ ifelse(x == 1:n, y, 0) })
df <- mutate(df, sequence = sequences)
df
## # A tibble: 10 × 5
## lat lon z color sequence
## <dbl> <dbl> <dbl> <chr> <list>
## 1 -76.47209 164.46000 10 #3C2060 <dbl [10]>
## 2 103.78985 -16.79970 8 #6AAD69 <dbl [10]>
## 3 -32.76831 63.92543 7 #34406C <dbl [10]>
## 4 137.88627 26.14802 11 #9BC052 <dbl [10]>
## 5 158.56822 -142.94711 8 #FDE725 <dbl [10]>
## 6 -163.59966 143.93699 8 #440154 <dbl [10]>
## 7 10.11798 -91.40842 6 #248085 <dbl [10]>
## 8 141.27086 -164.85857 7 #CCD33B <dbl [10]>
## 9 18.51661 -61.94854 4 #399980 <dbl [10]>
## 10 -15.61870 163.62131 2 #2C6079 <dbl [10]>
hcmap() %>%
hc_add_series(data = df, type = "mapbubble",
minSize = 0, maxSize = 15) %>%
hc_motion(enabled = TRUE, series = 1, labels = 1:n,
loop = TRUE, autoPlay = TRUE,
updateInterval = 1000, magnet = list(step = 1))