Public
Edited
Feb 4, 2024
Mapping of a writer's work
Mapping of a director's work
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
Insert cell
Insert cell
query = `SELECT DISTINCT ?item ?itemLabel ?place ?placeLabel ?coord WHERE {
?item wdt:P57 wd:${qid};
OPTIONAL{
?item
wdt:P840 ?place.
?place wdt:P625 ?coord.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "${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) => ({
item: d.item.value,
itemLabel: d.itemLabel.value,
place: d.place?.value,
placeLabel: d.placeLabel?.value,
coord: d.coord?.value
}))
Insert cell
df = aq
.from(array)
.derive({ item2: (d) => `<a href="${d.item}"> ${d.itemLabel}` })
Insert cell
df.derive({ link: (d) => `[${d.itemLabel}](${d.item})` }).view()
Insert cell
function tohtml(d) {
return (x) => htl.html`${d} `;
}
Insert cell
geoarray = geo.coords2geo(
array.filter((d) => d.place !== undefined),
{
coords: "coord",
reverse: true
}
)
Insert cell
array.filter((d) => d.place !== undefined)
Insert cell
geobuffer = geo.buffer(geoarray, { dist: 400, merge: true })
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
import { SearchForm } from "@floatingpurr/input-autocomplete"
Insert cell
Insert cell
import { wikipedias } from "@pac02/user-level-gender-statistics-for-wikipedia"
Insert cell
import { get_label } from "@pac02/user-level-gender-statistics-for-wikipedia"
Insert cell
Insert cell
get_default = () => {
const params = new URL(document.URL).searchParams;
const defaults = {
qid: "Q239823",
wikipedia: "fr.wikipedia.org",
article: "",
lang: "en"
};
if (params.has("qid")) {
defaults.qid = params.get("qid");
}
if (params.has("lang")) {
defaults.lang = params.get("lang");
}
return defaults;
}
Insert cell
Insert cell
qid = {
if (article === "") {
return get_default().qid;
} else {
return fetch(
`https://${wikipedia}/w/api.php?action=query&prop=pageprops&titles=${encodeURI(
article
)} &format=json&origin=*`
)
.then((d) => d.json())
.then((d) => Object.values(d.query.pages)[0].pageprops.wikibase_item);
}
}
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