task done

This commit is contained in:
=
2026-03-13 17:01:25 +10:00
parent 58b398228f
commit c7f1192b41
3 changed files with 54 additions and 0 deletions

40
labs/lab2/task/main.js Normal file
View File

@@ -0,0 +1,40 @@
const books = [
{
title: 'Мастер и Маргарита',
author: 'Булгаков М.А.'
},
{
title: 'Белая гвардия',
author: 'Булгаков М.А.'
},
{
title: 'Война и мир',
author: 'Толстой Л.Н.'
},
{
title: 'Анна Каренина',
author: 'Толстой Л.Н.'
},
{
title: 'Игрок',
author: 'Достоевский Ф.М.'
}
];
const booksByAuthor = d3.group(books, d => d["author"])
document.addEventListener("DOMContentLoaded", function () {
temp = d3.selectAll("p")
.data(booksByAuthor)
.enter()
.append("p")
.text(d => d[0])
.append("select")
.selectAll("option")
.data(d => [{ title: "выбрать все" }, ...d[1]])
.enter()
.append("option")
.text(d => d["title"])
})