Remove crosstalk from listings and sales tabs
All checks were successful
Deploy stAndrews / deploy (push) Successful in 6s
All checks were successful
Deploy stAndrews / deploy (push) Successful in 6s
This commit is contained in:
31
app.R
31
app.R
@@ -6,7 +6,6 @@ library(sf)
|
|||||||
library(dplyr)
|
library(dplyr)
|
||||||
library(leafpop)
|
library(leafpop)
|
||||||
library(DT)
|
library(DT)
|
||||||
library(crosstalk)
|
|
||||||
|
|
||||||
# load data ----
|
# load data ----
|
||||||
owners <- readRDS("./data/owners.rds")
|
owners <- readRDS("./data/owners.rds")
|
||||||
@@ -16,14 +15,12 @@ listings <- readRDS("./data/listings.rds") |>
|
|||||||
price_fmt = scales::dollar(price),
|
price_fmt = scales::dollar(price),
|
||||||
ppsf_fmt = scales::dollar(price_per_sqft)
|
ppsf_fmt = scales::dollar(price_per_sqft)
|
||||||
)
|
)
|
||||||
shared_listings <- SharedData$new(listings, key = ~address)
|
|
||||||
sales <- readRDS("./data/sales.rds") |>
|
sales <- readRDS("./data/sales.rds") |>
|
||||||
arrange(desc(listed_date)) |>
|
arrange(desc(listed_date)) |>
|
||||||
mutate(
|
mutate(
|
||||||
price_fmt = scales::dollar(price),
|
price_fmt = scales::dollar(price),
|
||||||
ppsf_fmt = scales::dollar(price_per_sqft)
|
ppsf_fmt = scales::dollar(price_per_sqft)
|
||||||
)
|
)
|
||||||
shared_sales <- SharedData$new(sales, key = ~address)
|
|
||||||
last_sale_date <- format(attr(owners, "last_sale_date"), "%Y-%m-%d")
|
last_sale_date <- format(attr(owners, "last_sale_date"), "%Y-%m-%d")
|
||||||
sbdvn <- sf::st_read("./data/plats/plats.shp")
|
sbdvn <- sf::st_read("./data/plats/plats.shp")
|
||||||
beaches <- readRDS("./data/beaches.rds")
|
beaches <- readRDS("./data/beaches.rds")
|
||||||
@@ -491,7 +488,7 @@ server <- function(input, output) {
|
|||||||
|
|
||||||
# listings map ----
|
# listings map ----
|
||||||
output$listings_map <- renderLeaflet({
|
output$listings_map <- renderLeaflet({
|
||||||
leaflet(shared_listings) |>
|
leaflet(listings) |>
|
||||||
addProviderTiles("CartoDB.Voyager") |>
|
addProviderTiles("CartoDB.Voyager") |>
|
||||||
addPolygons(
|
addPolygons(
|
||||||
data = sbdvn,
|
data = sbdvn,
|
||||||
@@ -515,26 +512,22 @@ server <- function(input, output) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
# listings table ----
|
# listings table ----
|
||||||
output$listings_table <- renderDT(server = FALSE, {
|
output$listings_table <- renderDT({
|
||||||
datatable(
|
datatable(
|
||||||
shared_listings,
|
listings |> select(listed_date, address, sqft, price_fmt, ppsf_fmt),
|
||||||
colnames = c("Listed", "Address", "Sq Ft", "Price (raw)", "$/Sq Ft (raw)",
|
colnames = c("Listed", "Address", "Sq Ft", "Price", "$/Sq Ft"),
|
||||||
"Lat", "Lng", "Price", "$/Sq Ft"),
|
|
||||||
rownames = FALSE,
|
rownames = FALSE,
|
||||||
options = list(
|
options = list(
|
||||||
pageLength = 25,
|
pageLength = 25,
|
||||||
searching = FALSE,
|
searching = FALSE,
|
||||||
dom = 't',
|
dom = 't'
|
||||||
columnDefs = list(
|
|
||||||
list(visible = FALSE, targets = c(3, 4, 5, 6))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
# sales map ----
|
# sales map ----
|
||||||
output$sales_map <- renderLeaflet({
|
output$sales_map <- renderLeaflet({
|
||||||
leaflet(shared_sales) |>
|
leaflet(sales) |>
|
||||||
addProviderTiles("CartoDB.Voyager") |>
|
addProviderTiles("CartoDB.Voyager") |>
|
||||||
addPolygons(
|
addPolygons(
|
||||||
data = sbdvn,
|
data = sbdvn,
|
||||||
@@ -559,19 +552,15 @@ server <- function(input, output) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
# sales table ----
|
# sales table ----
|
||||||
output$sales_table <- renderDT(server = FALSE, {
|
output$sales_table <- renderDT({
|
||||||
datatable(
|
datatable(
|
||||||
shared_sales,
|
sales |> select(listed_date, address, sqft, price_fmt, ppsf_fmt),
|
||||||
colnames = c("Date", "Address", "Sq Ft", "Price (raw)", "$/Sq Ft (raw)",
|
colnames = c("Date", "Address", "Sq Ft", "Price", "$/Sq Ft"),
|
||||||
"Lat", "Lng", "Price", "$/Sq Ft"),
|
|
||||||
rownames = FALSE,
|
rownames = FALSE,
|
||||||
options = list(
|
options = list(
|
||||||
pageLength = 10,
|
pageLength = 10,
|
||||||
searching = FALSE,
|
searching = FALSE,
|
||||||
dom = 't',
|
dom = 't'
|
||||||
columnDefs = list(
|
|
||||||
list(visible = FALSE, targets = c(3, 4, 5, 6))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user