legacy site deprication
This commit is contained in:
36
old/current_site/src/pages/graph/table.js
Normal file
36
old/current_site/src/pages/graph/table.js
Normal file
@@ -0,0 +1,36 @@
|
||||
// создание таблицы
|
||||
const showTable = (idTable, data) => {
|
||||
const table = d3.select("#" + idTable);
|
||||
|
||||
// создание строк таблицы (столько, сколько элементов в массиве)
|
||||
const rows = table
|
||||
.selectAll("tr")
|
||||
.data(data)
|
||||
.enter()
|
||||
.append('tr')
|
||||
.style("display", "");
|
||||
|
||||
// создание ячеек каждой строки на основе каждого элемента массива
|
||||
const cells = rows
|
||||
.selectAll("td")
|
||||
.data(d => Object.values(d))
|
||||
.enter()
|
||||
.append("td")
|
||||
.text(d => d);
|
||||
|
||||
// создание шапки таблицы
|
||||
const head = table
|
||||
.insert("tr", "tr")
|
||||
.selectAll("th")
|
||||
.data(d => Object.keys(data[0]))
|
||||
.enter()
|
||||
.append("th")
|
||||
.text(d => d);
|
||||
}
|
||||
|
||||
const clearTable = (idTable) => {
|
||||
const table = document.getElementById(idTable);
|
||||
while (table.children.length > 0) {
|
||||
table.removeChild(table.children[0]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user