Published unlisted
Edited
Mar 16, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
GroupByAuthors_plot = Plot.plot({
height: 800,
width: 1000,
marginBottom: 50,
marginTop: 50,
marginRight: 50,
marginLeft: 50,
color: {
//https://observablehq.com/@d3/color-schemes
scheme: "Warm",//"Cividis",
quantiles: 50
},
x: {
tickFormat: (d) => `${d}`,
tickRotate: 45
},
y: {
grid: true,
label: "Number of Sonnets",
labelAnchor: "center"
},
marks: [
Plot.rectY(
dataOupoco,
Plot.stackY(
{ order: "sum", reverse: true },
Plot.binX(
{ y: "count", title: (v) => `${v[0].auteur}: ${v.length} [ ${v[0].date} ]` },
{ rx: 10, x: "dateFiltre", fill: "auteur" }
)
)
),

Plot.ruleY([0, 1])
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//viewof choiceGenre = Inputs.checkbox(["oui", "non","nsp"], {label: "Sonnets féminins..."})
//viewof choiceGenre1 = Inputs.checkbox(new Map([["femmes", "oui"], ["hommes", "non"], ["nsp", "nsp"]]), {label: "N'afficher que les..."})
viewof choiceGenre = checkbox({
//title: "Genre",
description: "Vous pouvez ne visualiser que les hommes ou les femmes.",
options: [
{ value: "oui", label: "femmes" },
{ value: "non", label: "hommes" },
{ value: "nsp", label: "(nsp)" }
],
value: ["oui", "non", "nsp"],
submit: true
})
Insert cell
Insert cell
Authors_plot = Plot.plot({
height: 800,
width: 1000,
marginBottom: 150,
marginTop: 30,
marginRight: 50,
marginLeft: 50,
color: {
scheme: "Warm",
reverse: true
},
x: {
tickRotate: 45,
label: null,
domain: auteurs_50etPlus.sort((a, b) => d3.descending(a.Count, b.Count)).map(
(d) => d.auteurs
)
},
y: {
grid: true,
nice: true,
label: "Nombre de sonnets"
},

marks: [
Plot.barY(
auteurs_50etPlus,

{
y: "Count",
x: "auteurs",
fill: "auteurs",
order: (a, b) => d3.descending(a.Count, b.Count),
title: (d) => `${d.auteurs}: ${d.Count} sonnets dans la base`
}
),

Plot.ruleY([0])
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {swatches as Swatches} from "@d3/color-legend"
Insert cell
dataOupoco = FileAttachment("sonnets-oupoco.csv").csv()
Insert cell
Inputs.table(dataOupoco, { format: { Year: (d) => `${d}` } })
Insert cell
dataOupoco.columns
Insert cell
Insert cell
import {checkbox} from "@jashkenas/inputs"
Insert cell
Insert cell
auteurs = aq.from(dataOupoco)
.groupby(["auteur"])
.objects({grouped: "entries"});
Insert cell
Insert cell
map_auteurs = {
var list_a = [];
for (let i = 0; i < auteurs.length; ++i) {
// nom auteur = auteurs[i][0]
// nb de sonnets par auteurs[i][1].length
let myList_a = []
myList_a.push(auteurs[i][0]);
myList_a.push(auteurs[i][1].length);
list_a[i] = myList_a;
}
return list_a;
}
Insert cell
listAuteurs = dataOupoco.map((d) => d.auteur)
Insert cell
zoom = {
if (minOcc > 150 ){
var myZoom = 1;
}
else if (minOcc > 100 ){
var myZoom = 2;
}
else if (minOcc > 50 ){
var myZoom = 3 ;
}
else if (minOcc > 20 ){
var myZoom = 4 ;
}
else{
var myZoom = 8;
}
return myZoom;
}
Insert cell
dataAuteurs = d3
.rollups(
listAuteurs,
(group) => group.length*zoom,
(w) => w
)
.sort(([, a], [, b]) => d3.descending(a, b))
.slice(0, 250)
.map(([text, value]) => ({ text, value}))
.filter(function(map) {
return map.value < minOcc*zoom })
Insert cell
verif = {
for (let i = 0; i < dataAuteurs.length; ++i) {
if (dataAuteurs[i]['text'] == "Jacques Villebrune"){
return dataAuteurs[i];
}
}
}
Insert cell
myVar = {let ind = 2;
return ind;
}
Insert cell
auteurs_50etPlus = map_auteurs.map(([auteurs, Count]) => ({
auteurs,
Count
})).filter((d) => d.Count > 50)
Insert cell
Insert cell
selected_auteur = dataOupoco.filter((d) => d.auteur === auteur)
Insert cell
auteursPerDate = aq.from(dataOupoco)
.groupby(["auteur","dateFiltre"])
.objects({grouped: "entries"});
Insert cell
auteursPerDate[5];
Insert cell
Insert cell
choiceGenre
Insert cell
select_genre = dataOupoco.filter((d) => d.femme === choiceGenre[0] | d.femme === choiceGenre[1] | d.femme === choiceGenre[2])
Insert cell
listAuteursPerGenre = select_genre.map((d) => d.auteur)
Insert cell
dataAuteursPerGenre = d3
.rollups(
listAuteursPerGenre,
(group) => group.length*zoom,
(w) => w
)
.sort(([, a], [, b]) => d3.descending(a, b))
.slice(0, 250)
.map(([text, value]) => ({ text, value}))
.filter(function(map) {
return map.value < minOcc*zoom })
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