0

Leaflet と d3scatter プロットをリンクする多変量データを使用しています。1つの変数に対してうまく機能します。2 番目の addCircleMarkers と addLayersControl によって Leaflet に 2 番目の変数を含めようとすると、sharedData リンクが壊れ、フィルタリングが機能せず、ブラッシングが機能しません。前もって感謝します。MWE が添付されています。

library("crosstalk")
library("d3scatter")
library("leaflet")

Long <- c(117.4,117.5,117.6)
Lat<- c(-33.7,-33.8,-33.9)
var1 <- c(21,22,23)
var2 <- c(31,32,33)
species <- c(8,9,10)

df1<- data.frame(Long, Lat, var1, var2, species)
sdf1 <- SharedData$new(df1)

col_1 <- c( "yellow" ,"black" ,"orange")
col_2 <- c("red" ,"green" ,"blue")


l <- leaflet(sdf1)%>% 
  setView(117.5, -33.8, 10) %>% 
  addCircleMarkers(radius = 1, color = col_1, group = "1") %>%
#  addCircleMarkers(radius = 1, color =  col_2, group = "2") %>%
# PROBLEM  -  adding the second "addCircleMarkers" enables the overlayGroups but 
#             it breaks the link between the plots and breaks the filter
  addLayersControl(overlayGroups=c("1","2"))


m <- list(l, filter_checkbox("unique_id_for_species", "Animal Species", sdf1, ~species))
n <- list(d3scatter(sdf1, ~var2, ~var1, color = ~species, x_lim = c(30,40), y_lim = c(20,25), width="70%",  height=200),
          d3scatter(sdf1, ~var1, ~var2, color = ~species, y_lim = c(30,40), x_lim = c(20,25), width="70%",  height=200))

bscols(m, n)
4

0 に答える 0