Public
Edited
Sep 26, 2023
Fork of Untitled
Insert cell
Insert cell
{var number = 5;
var value = 12.3467;
var active = true;
var text = "Crystal clear";
return number;}
Insert cell
Insert cell
Insert cell
function f_f(num) {
var child = {
kind: "boy",
age: num,
rost: 123.7
};
return child;
}
Insert cell
f_f(3)
Insert cell
competitions = FileAttachment("competition.xlsx").xlsx()
Insert cell
date_competishions = competitions.sheet(0,{headers : true})
Insert cell
date_competishions.columns
Insert cell
date_competishions
Insert cell
function f_god(date) {
const num = []
for (let i in date) {
var m = date[i]["Год рождения"];
if (!(num.includes(m)) && m != undefined ){
num.push(m)
}
}
return num;
}

Insert cell
select_g = f_god(date_competishions)
Insert cell
date_competishions.filter( x => x["Год рождения"] == 1996)
Insert cell
fb_2 = new Set(date_competishions.map(function (x) {return x['Год рождения']}))
Insert cell
fb = new Set(date_competishions.map((x) => x["Год рождения"]))
Insert cell
viewof select_god = Inputs.select(select_g, {label: "укажите год"})
Insert cell
Inputs.table(date_competishions.filter( x => x["Год рождения"] == select_god), {
columns: ["Фамилия", "Год рождения", "Бег 1000 метров, мин. и сек."]} )
Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
viewof select1 = Inputs.select(["A", "B"], {label: "укажите ..."})
Insert cell
Insert cell
Insert cell
{var numbers = [ 5, 10, '15', 20.8, 25 ];
var names = [ '2', '3'];
var s = '';
for (var i = 0; i < names.length; i++) {
s += ' '+names[i];
}
return s;}
Insert cell
//массив объектов

var childs = [

{
kind: "boy",
age: 12,
rost: 123.7
},
{
kind: "boy",
age: 10,
rost: 110.2
}
];

Insert cell
childs = [
{
kind: "boy",
age: 12,
rost: 123.7
},
{
kind: "boy",
age: 10,
rost: 110.2
}
]
Insert cell
Insert cell
childsJS = [
{
"kind": "boy",
"age": 12,
"rost": 123.7},
{
"kind": "boy",
"age": 10,
"rost": 110.2}
]
Insert cell
Insert cell
Insert cell
sad_rf = FileAttachment("sad_RF.xlsx").xlsx()
Insert cell
{//выведем текст сообщения с использование javascript
let a = "После открытия привязки файла, представим его данные в виде списка объектов\n где каждый объект - это словарь-> ключ: значение\n" + "воспользуемся методом sheet (API JavaScript для Excel), которому передадим номер листа";
return a;}
Insert cell
data_sad = sad_rf.sheet(0, {headers: true})
Insert cell
Insert cell
data_sad.slice(0,3)
Insert cell
Insert cell
data_sad.columns
Insert cell
{ const s = "можно отфильтровать данные (условие на значения)";
return s;}
Insert cell
a = data_sad.filter( (d)=> d["хорошее"] > 40 && d["очень хорошее"]>10)
Insert cell
Insert cell
{let s = "";
data_sad.forEach((item, index) => {s+=`\n ${item["регион"]} показатель \"очень плохое\" у ${item["очень плохое"]} опрошенных`});
return s.length;}
Insert cell
data_sad1= data_sad.map((d) => d['регион'] = d['регион'].toUpperCase())
Insert cell
b = data_sad.map((item) => item['всего хорошее'] = item['хорошее'] + item['очень хорошее'])
Insert cell
data_sad
Insert cell
Insert cell
viewof table = Inputs.table(data_sad)
Insert cell
data_sad
SELECT * FROM data_sad
Insert cell
Insert cell
data_sad
SELECT *
FROM data_sad
ORDER BY регион DESC
LIMIT 10
Insert cell
Insert cell
Select a data source…
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Plot.plot({
marks: [
Plot.barY(data_sad, {x: "регион", y: "очень плохое", sort: {x: "y", reverse: true}}),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Plot.plot({
width:1000,
marks: [
Plot.barX(data_sad, {y: "регион", x: "хорошее", fill:"#aabfab", 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
competition = FileAttachment("competition.xlsx").xlsx()
Insert cell
data102 = competition.sheet(0, { headers: true })
Insert cell
Plot.plot({
marks: [
Plot.circle(data102.filter(d=> d["Год рождения"]==select), {x: "Бег 30 метров, сек.", y: "Прыжок в длину с места, см ", fill: "Пол"})
],
color: { legend: true },
marginLeft: 100
})
Insert cell
viewof select = Inputs.select(stateNames, {label: "год рождения"})
Insert cell
Plot.plot({
grid: true,
facet: {
data: data102,
y: "Год рождения"
},
marks: [
Plot.circle(data102, {x: "Бег 30 метров, сек.", y: "Прыжок в длину с места, см ", r:"Год рождения",fill: "Пол"})
],color: { legend: true },
marginLeft: 100
})
Insert cell
viewof rows = Inputs.table(data102, {typed: true})
Insert cell
stateNames = new Set(data102.map(d => d['Год рождения']))
Insert cell
Insert cell
Plot.plot({ marks: [ Plot.barY(data102, Plot.groupX({y: "count"}, {x: "Год рождения", fill:"#a19fab", sort: {x: "y",reverse: true, limit: 10}})), Plot.ruleX([0, 235]) ] })
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.rectY(data102, Plot.binX({y: "count"}, {x: "Год рождения", fill: "Пол"})),
Plot.ruleY([0])
],
color: {
legend: true
},
x: {
domain: [1996, 2000]
}
})
Insert cell
Plot.plot({
grid: true,
facet: {
data: data102,
y: "Пол"
},
marks: [
Plot.rectY(data102, Plot.binX({y: "count"}, {x: "Год рождения", fill: "Пол"})),
Plot.ruleY([0, 50, 75, 100, 125, 145, 165]),
Plot.textY([75, 100, 125, 145, 165], {fill:"#a61F1a"})
],
color: {
legend: true
},
x: {
domain: [1996, 2000]
}
})
Insert cell
Plot.plot({
height: 400,
marks: [
Plot.dot(data102, Plot.dodgeY({x: "Прыжок в длину с места, см ",fill: "Пол" }))
],
color: {
legend: true
},
})
Insert cell
childs
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
viewof range = Inputs.range([0, 100], {label: "Amount", step: 1})
Insert cell
childs
SELECT * FROM "childs"
WHERE "age" <= ${range}
Insert cell
workbook = FileAttachment("f.xlsx").xlsx()
Insert cell
workbook.sheetNames
Insert cell
data = workbook.sheet(0, {
headers: true,
range: "B2:D40"
})
Insert cell
Plot.plot({
marks: [
Plot.ruleY([0, 100]),
Plot.lineY(data, {x: "date", y: "pr"})
]
})
Insert cell
Plot.plot({
marks: [
Plot.dot(data, {x: "date", y: "summa", fill:"pr"})
],
})
Insert cell
viewof table_ = Inputs.table(data)
Insert cell
data
select * from data
Insert cell
b2 = data.filter((x)=>x["summa"] > 200)
Insert cell
viewof table_f = Inputs.table(cars)
Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

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