Public
Edited
Jan 27, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
badge_labels = get_labels(["Q17437796", "Q17437798"], lang).then((d) =>
d.objects()
)
Insert cell
property_labels = get_labels(
["P19", "P20", "P27", "P119", "P551", "P937"],
lang
).then((d) => d.objects())
Insert cell
labels_map = new Map(
badge_labels.map(({ label, qid }) => [label + " (" + qid + ")", qid])
)
Insert cell
property_labels_map = new Map(
property_labels.map(({ label, qid }) => [label + " (" + qid + ")", qid])
)
Insert cell
import { get_labels } from "@pac02/what-kind-of-articles-have-you-created"
Insert cell
Insert cell
query = `SELECT ?name ?url ?value ?valueLabel ?coord
WHERE {
?url schema:isPartOf <https://${wikipedia}/>;
wikibase:badge wd:${badge};
schema:about ?item;
schema:name ?name.
?item wdt:${property} ?value.
?value wdt:P625 ?coord;
rdfs:label ?valueLabel.
FILTER(LANG(?valueLabel) = "${lang}" )
}`
Insert cell
data = fetch(
`https://query.wikidata.org/sparql?query=${encodeURIComponent(query)}`,
{ headers: { accept: "application/sparql-results+json" } }
).then((response) => response.json())
Insert cell
array = data.results.bindings.map((d) => ({
url: d.url.value,
name: d.name.value,
value: d.value.value,
valueLabel: d.valueLabel.value,
coord: d.coord.value
}))
Insert cell
df = aq.from(array)
Insert cell
df.view()
Insert cell
df2 = df
.groupby(["value", "valueLabel", "coord"])
.count()
.orderby(aq.desc("count"))
Insert cell
df2.orderby(aq.desc("count")).view()
Insert cell
geoarray = geo.coords2geo(df2.objects(), { coords: "coord", reverse: true })
Insert cell
df.dedupe("url").numRows()
Insert cell
Insert cell
geo = require("geotoolbox@2")
Insert cell
viz = require("geoviz@0.4.4")
Insert cell
d3 = require("d3@7", "d3-geo-projection@4")
Insert cell
Insert cell
Insert cell
import { wikipedias } from "@pac02/user-level-gender-statistics-for-wikipedia"
Insert cell
Insert cell
get_default = () => {
const params = new URL(document.URL).searchParams;
const defaults = {
badge: "Q17437796",
wikipedia: "fr.wikipedia.org",
lang: "en",
property: "P19"
};
if (params.has("badge")) {
defaults.badge = params.get("badge");
}
if (params.has("wikipedia")) {
defaults.wikipedia = params.get("wikipedia");
}
if (params.has("wikipedia")) {
defaults.wikipedia = params.get("wikipedia");
}
if (params.has("lang")) {
defaults.lang = params.get("lang");
}
return defaults;
}
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