task done
This commit is contained in:
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