vis2 = Plot.plot({
style: { fontSize: 14 },
inset: 10,
width: width > 600 ? 650 : 350,
height: width > 600 ? 550 : 350,
grid: true,
color: {
domain: [0, 200],
range: ["red", "blue"]
},
marginBottom: 60,
marginLeft: 60,
x: { domain: [0, 350], nice: true },
y: { domain: [0, 350], nice: true },
marks: [
Plot.axisX({
tickFormat: (d) => d + "%",
label: "Доходи в 2022 році\nвідносно 2021 року",
fontWeight: 700,
labelOffset: 50
}),
Plot.axisY({
tickFormat: (d) => d + "%",
label: "Витрати в 2022 році\nвідносно 2021 року",
fontWeight: 700,
ticks: 4
}),
Plot.dot(data2, {
filter: (d) => d.gromada.includes("терит"),
x: "per_inc22",
y: "per_spend22",
fill: "per_inc22",
tip: true,
r: 4,
title: (d) =>
`Бюджет ${d.gromada}\n\nДоходи в 2022 році: ${Math.round(
d.per_inc22
)}%\nВитрати в 2022 році: ${Math.round(d.per_spend22)}%`,
stroke: "white",
strokeWidth: 0.5
}),
Plot.dot(data2, {
filter: (d) => d.gromada.includes("Мачух"),
x: "per_inc22",
y: "per_spend22",
fill: "per_inc22",
tip: true,
r: 14,
title: (d) =>
`Бюджет ${d.gromada}\n\nДоходи в 2022 році: ${Math.round(
d.per_inc22
)}%\nВитрати в 2022 році: ${Math.round(d.per_spend22)}%`,
stroke: "white",
strokeWidth: 0.5
}),
Plot.text(["Яворівська\nгромада"], {
frameAnchor: "middle",
dx: width > 600 ? 220 : 110,
dy: width > 600 ? -65 : -45,
stroke: "white",
strokeWidth: 4,
fill: "currentColor",
fontSize: 12
}),
Plot.ruleX([100], { strokeDasharray: 4, strokeOpacity: 0.4 }),
Plot.ruleY([100], { strokeDasharray: 4, strokeOpacity: 0.4 })
]
})