Public
Edited
Dec 11, 2023
Insert cell
Insert cell
data1 = FileAttachment("comp_new.xlsx").xlsx()
Insert cell
data2 = FileAttachment("arch_Novosib_2021_new.xlsx").xlsx()
Insert cell
data_1 = data1.sheet(0, {headers: true})
Insert cell
data_2 = data2.sheet(0, {headers: true})
Insert cell
data_1
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
data_2
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
viewof table1 = Inputs.table(data_1, {
columns: [
"Время отправки",
"Задача",
"Участник",
"Баллы",
"Время выполнения"
],
sort: "Время отправки", reverse:false, required: false})
Insert cell
Insert cell
Insert cell
viewof grid = Inputs.select(new Map([["Включить",true],["Выключить",false]]), {label: "Сетка месяца:"})
Insert cell
Plot.plot({
marginRight: 100,
marginLeft: 120,
grid: grid,
marks: [
Plot.barX(data_1.slice(0,100),{x: "Баллы", y: "Участник", fill:"#23af99"}),
Plot.ruleX([0])
]
})
Insert cell
viewof count1 = Inputs.range([800, 1700], {label: "Размер таблицы:", step: 1, width: 300, value: 1700})
Insert cell
Plot.plot({
width: count1,
grid: grid,
marginRight: 0,
marginLeft: 50,
marks: [
Plot.barY(data_1.slice(0,100),{x: "Участник", y: "Баллы", fill:"#23af99"})
]
})
Insert cell
data_temp1 = data_1.map(function (d) {
return {date_n: Date(d["Время отправки"]),
quest: Number(d["Задача"].substring(0,2)),
part: String(d["Участник"]) ,
points: Number(d["Баллы"]),
time: Number(d["Время выполнения"].substring(0,2)),
} } ).sort((a, b) => a["date_b"] > b["date_b"] ? 1 : -1)
Insert cell
Insert cell
Plot.rectY(data_temp1, {x1: "time" , x2:"date_n" , y1:"points" , y2:"quest" , fill:"part"}).plot
(
{color: { legend: true },
grid: true,
margin: 30,
width: 1600,
height: 550,

}
)
Insert cell
Insert cell
data_temp = data_2.map(function (d) {
return {date_b: new Date(d["Местное время в Новосибирске"].substring(6,10)+"-"+d["Местное время в Новосибирске"].substring(3,5)+"-"+d["Местное время в Новосибирске"].substring(0,2)+"T"+d["Местное время в Новосибирске"].substring(11,16)),
temper: Number(d["T"]),
press: Number(d["P"]) ,
Po: Number(d["P"]),
} } ).sort((a, b) => a["date_b"] > b["date_b"] ? 1 : -1)
Insert cell
function time_area(object) {
if (object["date_b"].getHours() > 10 && object["date_b"].getHours()<=20) return 1 //день
else return 2
}
Insert cell
Plot.plot({
width: 1200,
height: 300,
grid: true,
x: {label: "Местное время в Новосибирске"},
y: {label: "Температура"},
marks: [
Plot.areaY(data_temp, {x:"date_b", y:"temper", fill:"#88bbbb",z:(d=>time_area(d)), fillOpacity: 0.4, fill:"temper"}),
Plot.ruleY([0])
]
})
Insert cell
function time_zone(object) {
if (5<=object["date_b"].getHours() && object["date_b"].getHours() < 10) return "утро"
if (10<=object["date_b"].getHours() && object["date_b"].getHours() < 18) return "день"
if (18<=object["date_b"].getHours()&& object["date_b"].getHours() < 22) return "вечер"
return "ночь"
}
Insert cell
Plot.plot({
width: 1200,
height: 800,
grid: true,
x: {label: "Местное время в Новосибирске"},
facet: {
data: data_temp,
y: (d=>time_zone(d)),
margin: 50
},
y: {label: "Температура"},
marks: [
Plot.areaY(data_temp, {x:"date_b", y:"temper", fill:"#88bbbb",z:(d=>time_area(d)), fillOpacity: 0.4, fill:"temper"}),
Plot.ruleY([0])
]
})

Insert cell
Insert cell
Plot.plot({
caption:`Температурная карта для г.Новосибирск месяц:`,
marks: [
Plot.cell(data_temp, { x: d => d["date_b"].getDate(), y: d => d["date_b"].getHours(), fill: "temper"})
],
color: { legend: true },
})
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more