## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = FALSE ) ## ----dynamic_raster----------------------------------------------------------- # library(rMosaic) # # # Generate mock spatial data # set.seed(42) # n <- 5000 # df <- data.frame( # x = runif(n, 0, 100), # y = runif(n, 0, 100), # cell_type = sample(c("TypeA", "TypeB"), n, TRUE, c(0.6, 0.4)) # ) # # # Define Mosaic spec (YAML as R list) # spec <- list( # meta = list( # title = "Dynamic Density Raster", # description = "Zoom in/out – bins stay 2 units wide so resolution sharpens." # ), # # data = list(spatial = list()), # df will be registered in DuckDB # # params = list(pixel = 2), # pixel-size parameter # # plot = list( # list( # raster mark layer # mark = "raster", # data = list(from = "spatial"), # all points # x = "x", # y = "y", # fill = "density", # count per bin # pixelSize = "$pixel" # ), # list(select = "panZoom", x = "$xs", y = "$ys") # ), # # width = 700, # height = 600, # colorScale = "sqrt", # colorScheme = "viridis" # ) # # # Launch the application # runMosaicApp( # spec = spec, # data = list(spatial = df), # title = "Dynamic Raster Demo", # backend = "wasm" # ) ## ----custom_pixel------------------------------------------------------------- # spec_with_slider <- spec # spec_with_slider$vconcat <- list( # spec_with_slider$plot, # list(vspace = 10), # list( # input = "slider", # label = "Pixel Size", # min = 1, # max = 10, # step = 1, # as = "$pixel" # ) # ) # spec_with_slider$plot <- NULL # moved into vconcat above # # runMosaicApp( # spec = spec_with_slider, # data = list(spatial = df), # title = "Dynamic Raster with Pixel Size Control", # backend = "wasm" # )