fix(report): 矩阵方向改回「博主做行、日期做列」
用户要的是日期在上、昵称在左。上一版转置反了:日期做行、博主做列。 只改渲染方向,数据接口不变(它返回的是长表,两个方向都能拼)。
This commit is contained in:
@@ -250,25 +250,27 @@
|
|||||||
const table = document.createElement('table');
|
const table = document.createElement('table');
|
||||||
const thead = document.createElement('thead');
|
const thead = document.createElement('thead');
|
||||||
const headRow = document.createElement('tr');
|
const headRow = document.createElement('tr');
|
||||||
|
// 左上角那一格钉住两个方向 —— 横着滚日期、竖着滚博主都要能看到它。
|
||||||
const corner = document.createElement('th');
|
const corner = document.createElement('th');
|
||||||
corner.textContent = '日期';
|
corner.textContent = '博主 \\ 日期';
|
||||||
headRow.appendChild(corner);
|
headRow.appendChild(corner);
|
||||||
for (const creator of data.creators) {
|
for (const day of data.dates) {
|
||||||
const th = document.createElement('th');
|
const th = document.createElement('th');
|
||||||
th.textContent = creator.name;
|
th.textContent = day;
|
||||||
headRow.appendChild(th);
|
headRow.appendChild(th);
|
||||||
}
|
}
|
||||||
thead.appendChild(headRow);
|
thead.appendChild(headRow);
|
||||||
table.appendChild(thead);
|
table.appendChild(thead);
|
||||||
|
|
||||||
const tbody = document.createElement('tbody');
|
const tbody = document.createElement('tbody');
|
||||||
for (const day of data.dates) {
|
for (const creator of data.creators) {
|
||||||
const tr = document.createElement('tr');
|
const tr = document.createElement('tr');
|
||||||
const th = document.createElement('th');
|
const th = document.createElement('th');
|
||||||
th.textContent = day;
|
th.textContent = creator.name;
|
||||||
|
th.title = creator.name;
|
||||||
tr.appendChild(th);
|
tr.appendChild(th);
|
||||||
|
for (const day of data.dates) {
|
||||||
const rowCells = data.cells[day] || {};
|
const rowCells = data.cells[day] || {};
|
||||||
for (const creator of data.creators) {
|
|
||||||
tr.appendChild(cellNode(rowCells[creator.hash]));
|
tr.appendChild(cellNode(rowCells[creator.hash]));
|
||||||
}
|
}
|
||||||
tbody.appendChild(tr);
|
tbody.appendChild(tr);
|
||||||
|
|||||||
Reference in New Issue
Block a user