Public
Edited
Jan 9, 2024
Insert cell
Insert cell
Insert cell
wordsAuteur = myData.map((d) => d.myAuteur)
Insert cell
wordsAuteur.filter((w) => /\W/.test(w))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof minOcc = Inputs.range([5, 400], { label: "inférieur à ", step:1, value: 400})
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 = []
//if (auteurs[i][0] !== "[Autre]") {
//if (auteurs[i][0] !== "None"){
//if (auteurs[i][0] !== "None" && auteurs[i][0] !== "[Autre]"){
myList_a.push(auteurs[i][0]);
myList_a.push(auteurs[i][1].length);
list_a[i] = myList_a;
//}
}
return list_a;
}
Insert cell
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 d'exemple"
},

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} exemples dans la base`
}
),

Plot.ruleY([0])
]
})
Insert cell
Choisir un auteur pour lister les exemples de cet auteur dans la base :
Insert cell
typeof(liste_Auteurs)
Insert cell
viewof auteurSelect = Inputs.select(
liste_Auteurs,
{
sort: true,
unique: true,
label: "choisir un auteur",
value: "Zola Émile"//"Amélie Gex"
}
)
Insert cell
selected_auteur = myData.filter((d) => d.auteur === auteurSelect)
Insert cell
Inputs.table(selected_auteur, {
format: {
Year: (d) => `${d}`
}
})
Insert cell
Plot.plot({
height: 800,
width: 1000,
marginBottom: 50,
// marginTop: 50,
marginRight: 50,
marginLeft: 50,
color: {
range: d3.schemeDark2
.concat(d3.schemeAccent)
.concat(d3.schemeAccent)
.concat(d3.schemeAccent)
.concat(d3.schemeAccent)
},
x: {
tickFormat: (d) => `${d}`,
tickRotate: 45
//tickValues(domain().filter((date,i)=>i%60==0));
// tickValues(xScale.domain().filter(function(d,i){
// return !(i%10)
//}));
},
y: {
grid: true,
label: "Nombre d'exemples",
labelAnchor: "center"
},
marks: [
Plot.rectY(
myData,
Plot.binX(
{ y: "count", title: "first" },
{
//rx: 15,
rx: 1,
x: "date",
fill: "id",
title: (d) => `${d.auteur}`
}
)
),
Plot.ruleY([0, 1])
]
})
Insert cell
Insert cell
myData = FileAttachment("jsonToCsv@1.csv").csv()
Insert cell
Inputs.table(myData, { format: { Year: (d) => `${d}` } })
Insert cell
listAuteursPerGenre = auteurs.map((d) => d.myAuteur)
Insert cell
myData.columns
Insert cell
Insert cell
auteurs = aq.from(myData)
.filter(d => d.myAuteur != "" && d.myAuteur != "None" && d.myAuteur != "[Autre]")
.groupby(["myAuteur"])
.objects({grouped: "entries"});
Insert cell
Le nombre d'auteurs dans la base est de ${ auteurs.length }.
Insert cell
auteurs[6][0]
Insert cell
listAuteurs = {
let lstAuteurs = ""
for(let i=0; i<auteurs.length; i++){
lstAuteurs += auteurs[i][0] + ","
//lstAuteurs.push(auteurs[i][0])
}
return lstAuteurs;
}
Insert cell
liste_Auteurs = {
let liste_Auteurs = []
for(let i=0; i<auteurs.length; i++){
liste_Auteurs.push(auteurs[i][0])
}
return liste_Auteurs;
}
Insert cell
myVar = {let ind = 2;
return ind;
}
Insert cell
import {swatches as Swatches} from "@d3/color-legend"
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

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