Skip to content

Commit

Permalink
demo app: use d3scatter instead of leaflet
Browse files Browse the repository at this point in the history
  • Loading branch information
daattali committed Apr 14, 2023
1 parent 2b245b5 commit 1164818
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
9 changes: 0 additions & 9 deletions inst/example/earthquakes.csv

This file was deleted.

4 changes: 3 additions & 1 deletion inst/example/sampleData.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ dataWC <- data.frame(
templateWC("semi-finals", "Brazil", "Germany", 1, 7),
templateWC("semi-finals", "Netherlands", "Argentina", "0 (2)", "0 (4)"),
templateWC("final", "Germany", "Argentina", 1, 0)
)
),
goalsHome = c(0, 2, 1, 4, 1, 2, 1),
goalsAway = c(1, 1, 0, 3, 7, 4, 0)
)

# Data for groups example (this data also gets exported in the package)
Expand Down
9 changes: 4 additions & 5 deletions inst/example/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,13 @@ function(input, output, session) {
zoomOut("timelineInteractive", input$zoomBy, animation = input$animate)
})

eqs <- read.csv("earthquakes.csv")
eqs$content <- paste("<strong>Magnitude:", eqs$magnitude, "</strong><br/><em>", eqs$start, "</em>")
shared_df <- crosstalk::SharedData$new(eqs)
shared_df <- crosstalk::SharedData$new(dataWC)

output$timelineCrosstalk <- renderTimevis({
timevis(shared_df, options = list(multiselect = TRUE))
})
output$map <- leaflet::renderLeaflet({
leaflet::leaflet(shared_df) %>% leaflet::addTiles() %>% leaflet::addMarkers(lng = ~lng, lat = ~lat, label = ~start)
output$plot <- d3scatter::renderD3scatter({
d3scatter::d3scatter(shared_df, x = ~goalsHome, y = ~goalsAway,
x_label = "Home Goals", y_label = "Away Goals")
})
}
7 changes: 3 additions & 4 deletions inst/example/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ fluidPage(
tags$a("Crosstalk", href = "https://github.com/rstudio/crosstalk"),
)),
tags$p(
"The following timeline and map show major earthquakes from March 2001.", br(),
"The data is linked between the two - select any events in the timeline to see",
"them highlighted on the map, and vice versa."
"The data in the timeline and the plot below are linked - select any events in the timeline to see",
"them highlighted on the plot, and vice versa."
),
HTML("Use <i>ctrl</i> or <i>shift</i> to select multiple events"),
fluidRow(
Expand All @@ -187,7 +186,7 @@ fluidPage(
),
column(
6,
leaflet::leafletOutput("map", height = 300)
d3scatter::d3scatterOutput("plot")
)
),
br()
Expand Down

0 comments on commit 1164818

Please sign in to comment.