Public
Edited
Sep 26, 2023
Insert cell
Insert cell
demografia = FileAttachment("demografia.xlsx").xlsx()
Insert cell
data_sad = demografia.sheet(0, {headers: true})
Insert cell
data_sad.columns
Insert cell
Insert cell
{let s = "";
data_sad.forEach((item, index) => {s+=`\n ${item["CountryNameRu"]} демография за 2013 год ${item["2013"]}`});
return s;}
Insert cell
viewof table = Inputs.table(data_sad)
Insert cell
Plot.plot({
marks: [
Plot.barY(data_sad, {x: "CountryCode", y: "2013", sort: {x: "y", reverse: false}}),
Plot.ruleY([0])
]
})
Insert cell
Plot.plot({
marks: [
Plot.barY(data_sad.filter( (d)=> d["2013"] > 90000000), {x: "CountryCode", y: "2013", sort: {x: "y", reverse: false}}),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
{const arr=[];
arr.push(data_sad[0]["2015"]);
arr.push(data_sad[0]["2014"]);
arr.push(data_sad[0]["2013"]);
arr.push(data_sad[0]["2012"]);
arr.push(data_sad[0]["2011"]);
arr.push(data_sad[0]["2010"]);
arr.push(data_sad[0]["2009"]);
arr.push(data_sad[0]["2008"]);
arr.push(data_sad[0]["2007"]);
arr.push(data_sad[0]["2006"]);
arr.push(data_sad[0]["2005"]);
arr.push(data_sad[0]["2004"]);
const year=["2015", "2014", "2013", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004"];
return Plot.plot({
marks: [
Plot.barY(data_sad, {x: year, y: arr, sort: {x: "y", reverse: false}}),
Plot.ruleY([0])
]
})
}
Insert cell
Plot.plot({
width:1000,
marks: [
Plot.barX(data_sad.filter( (d)=> d["CountryNameRu"] != "World"), {y: "CountryNameRu", x: "2015", fill:"#027500", sort: {y: "x", reverse: false}}),
Plot.ruleX([0, 10, 20, 30, 40, 50, 60], {fill:"#aaaaaa"})],
color: { legend: true },
marginLeft: 200,
})
Insert cell
Insert cell
data_sad[51]
Insert cell
Insert cell
data_sad[67]
Insert cell
Insert cell
function arr() {
const arr_demog = [
{ Year: "2004", demog: data_sad[51]["2004"], Country: "Гонконг, Китай"},
{ Year: "2005", demog: data_sad[51]["2005"], Country: "Гонконг, Китай"},
{ Year: "2006", demog: data_sad[51]["2006"], Country: "Гонконг, Китай"},
{ Year: "2007", demog: data_sad[51]["2007"], Country: "Гонконг, Китай"},
{ Year: "2008", demog: data_sad[51]["2008"], Country: "Гонконг, Китай"},
{ Year: "2009", demog: data_sad[51]["2009"], Country: "Гонконг, Китай"},
{ Year: "2010", demog: data_sad[51]["2010"], Country: "Гонконг, Китай"},
{ Year: "2011", demog: data_sad[51]["2011"], Country: "Гонконг, Китай"},
{ Year: "2012", demog: data_sad[51]["2012"], Country: "Гонконг, Китай"},
{ Year: "2013", demog: data_sad[51]["2013"], Country: "Гонконг, Китай"},
{ Year: "2014", demog: data_sad[51]["2014"], Country: "Гонконг, Китай"},
{ Year: "2015", demog: data_sad[51]["2015"], Country: "Гонконг, Китай"},
{ Year: "2004", demog: data_sad[67]["2004"], Country: "Израиль "},
{ Year: "2005", demog: data_sad[67]["2005"], Country: "Израиль "},
{ Year: "2006", demog: data_sad[67]["2006"], Country: "Израиль "},
{ Year: "2007", demog: data_sad[67]["2007"], Country: "Израиль "},
{ Year: "2008", demog: data_sad[67]["2008"], Country: "Израиль "},
{ Year: "2009", demog: data_sad[67]["2009"], Country: "Израиль "},
{ Year: "2010", demog: data_sad[67]["2010"], Country: "Израиль "},
{ Year: "2011", demog: data_sad[67]["2011"], Country: "Израиль "},
{ Year: "2012", demog: data_sad[67]["2012"], Country: "Израиль "},
{ Year: "2013", demog: data_sad[67]["2013"], Country: "Израиль "},
{ Year: "2014", demog: data_sad[67]["2014"], Country: "Израиль "},
{ Year: "2015", demog: data_sad[67]["2015"], Country: "Израиль "}
];
return arr_demog
}
Insert cell
arr_demog=arr();
Insert cell
Plot.plot({
style: "overflow: visible;",
marks: [
Plot.barX(arr_demog, {
x: "demog",
y: "Year",
fill: "Country",
sort: {y: "x", reverse: true}
}),
],
});
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