This example has been adapted from Vega-Lite.

Brush on the right-hand side to zoom in on the bar chart on the left.

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(jsonlite)
library(virgo)

selection <- select_interval(encodings = "y")

cars <- fromJSON("https://vega.github.io/vega-editor/app/data/cars.json") %>% 
  count(Name) %>% 
  mutate(Name = reorder(Name, -n))

minimap <- cars %>% 
  vega(width = 50, height = 200) %>% 
  mark_bar(
    enc(
      x = n, 
      y = Name, 
    ),
    selection = I(selection),
  ) %>% 
  scale_y(name = NULL, breaks = NULL) %>% 
  scale_x(name = NULL, breaks = NULL)

bar <- cars %>% 
    vega(height = 800) %>% 
    mark_bar(
    enc(
      x = n, 
      y = Name, 
    ),
    selection = selection,
  ) %>% 
  scale_x(name = "Count", domain = c(0,6), orient = "top") %>% 
  scale_y(name = NULL)

hconcat(bar, minimap)