intentionsChart = (candidat) => {
let current = data.filter(s => s.candidat == candidat)
let h = current.length * 30
let plot = Plot.plot({
height: h,
marginRight: 250,
x: {
domain: [0, 50],
grid: true,
label: "intentions de vote",
labelAnchor: 'center'
},
y: {
type: 'band',
axis: 'right',
padding: 0.25,
domain: current.map(s => `${s.sondage} : ${s.hypothese}`)
},
marks:[
Plot.ruleX([moyennes.find(c=> c.candidat == candidat).inf, moyennes.find(c=> c.candidat == candidat).sup], {stroke: 'red', strokeOpacity: 0.2 }),
Plot.barX(current, { x1: 'erreur_inf', x2: 'erreur_sup', y: s => `${s.sondage} : ${s.hypothese}`, fill: '#ccc'}),
Plot.tickX(current, { x: 'intentions', y: s => `${s.sondage} : ${s.hypothese}` }),
Plot.ruleX([moyennes.find(c=> c.candidat == candidat).moyenne], {stroke: 'red', strokeOpacity: 0.5 })
]
})
return plot
}