task done
This commit is contained in:
2
labs/lab2/task/d3.v7.min.js
vendored
Normal file
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
12
labs/lab2/task/index.html
Normal 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
40
labs/lab2/task/main.js
Normal 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"])
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user