Public
Edited
Sep 22, 2023
Insert cell
Insert cell
LIB-2023-09-24-candidats-senat.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
data_senate2
Insert cell
LIB-2023-09-24-Senatoriales.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Select a data source…
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
chart2 = Plot.plot((() => {
const n = 20;
const color = {"M.":'grey', "Mme":'red'};
[0,1,2].forEach(function (e) {
data_senate2.filter(d=>d.Type_candidat == e).sort(function (a,b) { return b.Civ_num - a.Civ_num})
.forEach(function (d, i) {
d['id2'] = i
})
})
return {
height: 800,
axis: null,
grid:false,
marginLeft: 50,
marginBottom: 10,
marginTop: 10,
marks: [
Plot.dot(data_senate2.sort(function (a,b) { return b.Civ_num - a.Civ_num}),
{x: (d) =>(d.id2 % n)/25 + d.Type_candidat,
r:3,
fill:(d) => color[d.CivilitePsn],
y : (d) =>Math.floor(d.id2/n),
sort:'Civ_num'
}),
]
}
})())
Insert cell
chart3 = Plot.plot((() => {
const n = 20;
const color = {"M.":'grey', "Mme":'red'};
[0,1,2].forEach(function (e) {
data_senate2.filter(d=>d.Type_candidat == e).sort(function (a,b) { return b.Civ_num - a.Civ_num})
.forEach(function (d, i) {
d['id2'] = i
})
})
return {
height: 800,
axis: null,
grid:false,
marginLeft: 50,
marginBottom: 10,
marginTop: 10,
marks: [
Plot.dot(data_senate2,
Plot.dodgeY({x: (d) =>(d.id2 % n)/25 + d.Type_candidat,
r:3,
fill:(d) => color[d.CivilitePsn],
sort:'Civ_num'
}))
]
}
})())
Insert cell
chart_nuances = Plot.plot((() => {
const n = 20;
const color = {"M.":'grey', "Mme":'red'};
const this_data = data_senate_nuances.filter(d=>d.Type_candidat !=2);
[0,1,2,3,4,5,6,7,8].forEach(function (e) {
this_data.filter(d=>d.nuance_num == e).sort(function (a,b) { return a.Civ_num - b.Civ_num})
.forEach(function (d, i) {
d['id2'] = i
})
})
return {
height: 300,
axis: null,
grid:false,
marginLeft: 50,
marginBottom: 10,
marginTop: 10,
marginRight: 10,
marks: [
Plot.dot(this_data,
Plot.dodgeY({x: (d) =>(d.id2 % n)/25 + d.nuance_num,
r:5,
fill:(d) => color[d.CivilitePsn],
sort:'Civ_num'
}))
]
}
})())
Insert cell
chart_nuances2 = Plot.plot((() => {
const n = 5;
const color = {"M.":'grey', "Mme":'red'};
const this_data = data_senate_nuances.filter(d=>d.Type_candidat !=2);
[0,1,2,3,4,5,6,7,8].forEach(function (e) {
this_data.filter(d=>d.nuance_num == e).sort(function (a,b) { return a.Civ_num - b.Civ_num})
.forEach(function (d, i) {
d['id2'] = i
})
})
return {
height: 200,
axis: null,
grid:false,
marginLeft: 50,
marginBottom: 30,
marginTop: 10,
marginRight: 20,
marks: [
Plot.dot(this_data,
{x: (d) =>(d.id2 % n)/10 + d.nuance_num,
r:3,
fill:(d) => color[d.CivilitePsn],
y : (d) =>Math.floor(d.id2/n)
}),
Plot.text(partis_nuances, {x: (d) =>d[1], y:-5,text:(d) =>d[0], frameAnchor: "bottom-left", dx: -8,
fill:"black", fontSize:8}),
]
}
})())
Insert cell
Array.from(new Set(data_senate_nuances.map(d=> d.NUANCE)))
Insert cell
partis_nuances = [
["Divers",5],
["Centre",4],
["Droite",7],
["Gauche",1],
["Ecologiste",2],
["Extrême droite",8],
["Centre droit",6],
["Extrême gauche",0],
["Régionaliste",3]
]
Insert cell
new Set(data_senate_nuances.map(d => d.nuance_num))
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