« back

Instructions

Click on the boxes to see breakdown by language (when available). Click "Wikimedia" at the top to get back to the overall view.

About

This treemap of WMF projects was generated using data from Page Counts endpoint by my coworkers Max and Jan, R, and Kent Russell's R htmlwidget for d3.js treemaps.

R Code

# Required R packages:
library(jsonlite) # install.packages("jsonlite", repos = "https://cran.rstudio.com/")
library(curl) # install.packages("curl", repos = "https://cran.rstudio.com/")
library(tidyverse) # First:    install.packages("tidyverse", repos = "https://cran.rstudio.com/")
# Then dev version of ggplot2: devtools::install_github("hadley/ggplot2")
# install.packages("devtools", repos = "https://cran.rstudio.com/")
library(polloi) # devtools::install_github("wikimedia/wikimedia-discovery-polloi", dependencies = "Imports")

# Download JSON of page counts over HTTPS via curl and process into a neat data frame:
page_counts <- curl("https://tools.wmflabs.org/pagecounts/pagecounts.json") %>%
  { suppressWarnings(stream_in(., simplifyVector = FALSE))[[1]] } %>%
  lapply(function(x) {
    data.frame(total_pages = x$pages, content_pages = x$contentPages)
  }) %>%
  bind_rows(.id = "site") %>%
  arrange(desc(content_pages))

# Break the site into language-project pairs:
polloi::update_prefixes()
lang_proj <- suppressMessages(polloi:::parse_wikiid(page_counts$site))
lang_proj[is.na(lang_proj$language) & is.na(lang_proj$project), ] <- "Other"
page_counts <- cbind(page_counts, lang_proj) %>%
  select(c(site, language, project, content_pages, total_pages)) %>%
  as_tibble

# Visualize:
library(treemap) # install.packages("treemap", repos = "https://cran.rstudio.com/")
library(d3treeR) # devtools::install_github("timelyportfolio/d3treeR")
page_counts$language[is.na(page_counts$language)] <- "None"
d3tree2(
  treemap(
    page_counts,
    index = c("project", "language", "site"),
    vSize = "content_pages",
    vColor = "total_pages",
    type = "dens",
    title = "The Wikimedia Universe",
    palette = "Blues",
    fontfamily.title = "sans",
    fontfamily.labels = "sans",
    fontfamily.legend = "sans"
  ), rootname = "Wikimedia"
)