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

2
labs/lab2/task/d3.v7.min.js vendored Normal file

File diff suppressed because one or more lines are too long

12
labs/lab2/task/index.html Normal file
View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="ru<head>
<meta charset=" utf-8">
<title> Практика 2</title>
<script src="d3.v7.min.js"> </script>
<script src="main.js"></script>
</head>
<body>
</body>
</html>

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"])
})