osuus_plot = Plot.plot({
marginLeft: 100,
marginRight: 100,
marginBottom: 40,
color: { legend: false },
style: {
fontSize: "14px",
},
title: `${selectedMetric.label} kunnittain ja valmistumisvuosittain`,
x: {
label: selectedMetric.label,
domain: [0, d3.max(filteredData, d => d.Arvo)],
tickFormat: d3.format("d"),
labelAnchor: "center"
},
y: {label:null},
fy: {label:""},
marks: [
Plot.barX(filteredData, {
fy: "Kaupunki",
y: "Periodi",
x: "Arvo",
fill: "Periodi",
tip: null,
text: d => d.Arvo.toString()
}),
Plot.text(filteredData, {
fy: "Kaupunki",
y: "Periodi",
x: d => d.Arvo/2,
fill: "black",
text: d => d.Arvo.toFixed(1)
}),
Plot.ruleX([0])
]
})