Public
Edited
Jul 2, 2024
3 forks
Insert cell
Insert cell
ua = FileAttachment("ukraine2@1.json").json()
Insert cell
regions = topojson.feature(ua, ua.objects.regions)
Insert cell
Insert cell
Insert cell
otgLonLan
Insert cell
data2.filter((d) => d.ADMIN4.includes("дачн"))
Insert cell
Insert cell
vis2 = Plot.plot({
style: { fontSize: 14 },
inset: 10,
width: width > 600 ? 650 : 350,
height: width > 600 ? 550 : 350,
grid: true,
color: {
// scheme: "RdYlBu",
domain: [0, 200],
range: ["red", "blue"]
// type: "threshold"
// legend: true
},
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 })
// Plot.linearRegressionY(data2, {
// x: "per_inc",
// y: "per_spend",
// opacity: 0.5
// })
]
})
Insert cell
d3.rollup(
data,
(v) => v.length,
(d) => d.INCO3
)
Insert cell
// 11020000 Податок на прибуток підприємств
// 14040000 Акцизний податок з реалізації суб’єктами …дарювання роздрібної торгівлі підакцизних товарів.
// 13030000 Рентна плата за користування надрами загальнодержавного значення
// 41020000 Дотації з державного бюджету місцевим бюджетам
// 11010000 Податок та збір на доходи фізичних осіб

data = {
return (await FileAttachment("data@2.tsv").tsv())
.filter(
(d) => d.INCO3 == "11010000 Податок та збір на доходи фізичних осіб"
)
.map((d) => {
return {
...d,
v21: +d["2021_EXECUTED"],
v22: +d["2022_EXECUTED"],
diff: +d["2022_EXECUTED"] - +d["2021_EXECUTED"],
diff_per2: +d["2022_EXECUTED"] / +d["2021_EXECUTED"],
diff_per:
((+d["2022_EXECUTED"] - +d["2021_EXECUTED"]) / +d["2021_EXECUTED"]) *
100,
type:
d.ADMIN4.includes("міської") || d.ADMIN4.includes("Київ")
? "Міські"
: d.ADMIN4.includes("сільської")
? "сілські"
: d.ADMIN4.includes("селищної")
? "селищні"
: "інші",
otg: d.ADMIN4.replace(/.+Бюджет\s/, "").replace(/(цьк.+)|(ськ.+)/, "")
};
})
.sort((a, b) => b.diff - a.diff)
.filter((d) => d.type != "інші");
// .filter((d) => d.diff_per > -100);
}

Insert cell
data.sort((b, a) => a.diff_per - b.diff_per)
Insert cell
// data.filter((d) => d.ADMIN4.includes("Дніпро"))
Insert cell
diff = new Map(data.map((d) => [d.otg, d.diff_per]))
Insert cell
otgLonLan = {
return (
(await FileAttachment("otg_LotLan.geojson").json()).features
.map((d) => {
return {
...d,
diff: diff.get(d.properties.hromada.replace(/(цьк.+)|(ськ.+)/, ""))
};
})
// .filter((d) => d.diff < 1000 && d.diff > -50)
.sort((a, b) => b.diff - a.diff)
);
}
Insert cell
data2 = {
return (await FileAttachment("opendudget@5.csv").csv()).map((d) => {
return {
...d,
per_inc: +d.per_inc,
per_spend: +d.per_spend,
per_inc22: +d.per_inc22,
per_spend22: +d.per_spend22,
gromada: d.ADMIN4.replace(/.+жет\s/, "")
};
});
// .filter((d) => d.diff < 1000 && d.diff > -50)
}
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