vis2 = Plot.plot({
subtitle:
"Як змінилися доходи компаній із США, що залишилися працювати в Росії",
style: { fontSize: 14, fontWeight: 400 },
marginTop: 20,
marginLeft: 130,
marginRight: 60,
y: { grid: true, label: null, tickSize: 0 },
x: { label: "млн дол", labelArrow: null, tickFormat: (d) => "$" + d },
width: width > 650 ? 650 : 350,
marks: [
Plot.link(data2, {
y: "Company name",
x1: (d) => d.rev21,
x2: (d) => d.rev23,
markerStart: "dot",
markerEnd: "arrow",
sort: { y: "-x2" },
stroke: (d) => (+d.rev23 - d.rev21 > 0 ? "#F2AC59" : "#81C081"),
strokeWidth: 2.5
}),
Plot.text(
data2.filter((d) => d.rev21 > 2500 && d["Company name"] !== "Mars"),
{
bend: true,
dx: 30,
dy: 0,
fontSize: 11,
fontWeight: 300,
y: "Company name",
x: (d) => +d.rev21,
text: (d) => "$" + Math.round(d.rev21 / 1) + " млн"
}
),
Plot.text(
[
`За час війни компанія Mars збільшила дохід в Росії з 2,2 до 2,9 млрд дол США`
],
{
frameAnchor: "top-left",
textAnchor: "start",
bend: true,
dx: width > 650 ? 185 : 70,
dy: 55,
lineWidth: width > 650 ? 18 : 10
}
),
Plot.text(
data2.filter((d) => d.rev23 > 2000 && d["Company name"] !== "Mars"),
{
bend: true,
dx: -30,
dy: 0,
fontSize: 11,
fontWeight: 300,
y: "Company name",
x: (d) => +d.rev23,
text: (d) => "$" + Math.round(d.rev23 / 1) + " млн"
}
),
Plot.text([`2023`], {
frameAnchor: "top-left",
textAnchor: "end",
bend: true,
dx: 190,
dy: 40,
lineWidth: 12,
fontWeight: 700,
opacity: width > 650 ? 1 : 0
}),
Plot.text([`2021`], {
frameAnchor: "top-left",
textAnchor: "end",
bend: true,
dx: 140,
dy: 40,
lineWidth: 12,
fontWeight: 700,
opacity: width > 650 ? 1 : 0
}),
Plot.text([`2021·→2023`], {
frameAnchor: "top-left",
textAnchor: "end",
bend: true,
dx: 140,
dy: -15,
lineWidth: 12,
fontWeight: 700,
opacity: width > 650 ? 0 : 1
})
]
})