robservable Gallery

Julien Barnier, Kenton Russell


The goal of this vignette is to show some examples of (hopefully) useful, interesting or fun notebooks usable with robservable.

Draggable Pie/Donut Chart

Yes, I know, pie charts are mostly bad. But the following notebook allows the creation of interactive pie or ‘donut’ charts, with slices optionally ‘draggable’ to rearrange their order.

Here is a small example. To display the chart we have to include both the chart and draw cells, and we hide draw as it is only useful to render the plot. We pass our data as a data frame with name and value columns.

df <- data.frame(
  name = rownames(USPersonalExpenditure), 
  value = USPersonalExpenditure[,"1960"]
  include = c("chart", "draw"),
  hide = "draw",
  input = list(data = df),
  width = 700

Bar chart race

The following notebook generates animated “bar chart race” charts.

To use it from robservable you have to place your data in a data frame with the following columns :

Optionally, if you want the displayed date value to be different than the one used in your dataset (for example if you iterate over monthly data but prefer to only display the year), you can add a corresponding date_label column.


## Load Covid-19 data from Johns Hopkins Github repository
d <- read_csv("")

## Reformat data
d <- d %>%
  select(-`Province/State`, -Lat, -Long) %>%
  rename(id = `Country/Region`) %>%
  group_by(id) %>%
  summarise(across(everything(), sum)) %>%
  pivot_longer(-id, names_to = "date") %>%
  mutate(date = as.character(lubridate::mdy(date)))

## Filter out data
d <- d %>%
  group_by(date) %>%
  filter(value > 0 & (n() - row_number(value)) <= 12) %>%

We can then generate the chart with the following robservable call. Note that we have to include several cells : the chart itself, the draw cell which updates it, the date play/pause control, and the CSS styles.

## Generate chart
  include = c("viewof date", "chart", "draw", "styles"),
  hide = "draw",
  input = list(
    data = d,
    title = "COVID-19 deaths",
    subtitle = "Cumulative number of COVID-19 deaths by country",
    source = "Source : Johns Hopkins University"
  width = 700,
  height = 710

Voronoi Map

The following notebook allows to create a Voronoi diagram on a map background.

Here we load data about the location of engineering schools in France in 2020 (Source : Onisep).

d <- read_csv("")

And we display it as a Voronoi diagram by calling robservable the following way. Note that we have to include both chart and draw cells for the map to be rendered (but we hide draw as it doesn’t display anything by itself).

map_url <- ""

 include = c("chart", "draw"),
 hide = "draw",
 input = list(
  contour = map_url,
  contour_width = 1,
  data = d,
  longitude_var = "longitude (X)",
  latitude_var = "latitude (Y)",
  point_radius = 1.5,
  zoom = TRUE
  width = 600,
  height = 600

You can zoom and pan the map.

Bivariate Choropleth

The following notebook makes bivariate choropleth maps with zoom and tooltips.

We first load some data from the Github project, only keep California counties, and select two of the available variables.


d <- USA_county_data
d <- d[d$State == "California",]
d <- d[, c("name_16", "Graduate.Degree", "Less.Than.High.School")]
names(d) <- c("name_16", "Graduate", "<High.School")

Then we can call robservable to load the notebook, render only chart and draw (both are needed for the map to show), hide draw and update a bunch of cells values via the input named list. You can refer to the notebook for an explanation of the different values.

  include = c("chart", "draw"),
  hide = "draw",
  input = list(
    data = d,
    data_id = "name_16",
    data_name = "name_16",
    data_var1 = "Graduate",
    data_var2 = "<High.School",
    map = "",
    map_object = "geometry",
    map_id_property = "name",
    legend_position = "bottomleft"
  width = 800,
  height = 500