Published
Edited
Oct 25, 2018
Insert cell
Insert cell
url = "https://api.code.gov/repos?api_key=90LWafgJ8bcxpCNHxkhA3jcxbG8TQKlQates3tJ9&size=10000"
Insert cell
repos = fetch(url).then(response => response.json()).then(data => data.repos)
Insert cell
php_repos = repos.filter(repo => {
try {
// check if PHP in the name
if (repo.name.toLowerCase().includes("php")) {
return true;
}

// check if PHP in languages metadata property
let languages = repo.languages;
if (languages && Array.isArray(languages)) {
languages = languages.map(language => language.toLowerCase());
if (languages.includes("php")) {
return true;
}
}

// couldn't find PHP in name or languages, so return false
return false;
} catch (error) {
console.log(error);
return false;
}
})
Insert cell
Insert cell
counts = _.countBy(php_repos, "agency.acronym")
Insert cell
data = _.toPairs(counts)
.sort((a,b) => a[1] - b[1])
.map(pair => {
let [name, value] = pair;
return { name, value };
})
Insert cell
Insert cell
import { chart } with { data, height } from "@mbostock/d3-bar-chart@172"
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more