次日预测振幅支持点击查看计算明细
This commit is contained in:
@@ -46,7 +46,7 @@
|
|||||||
<td class="na">—</td>
|
<td class="na">—</td>
|
||||||
<td class="na">—</td>
|
<td class="na">—</td>
|
||||||
<td class="na">—</td>
|
<td class="na">—</td>
|
||||||
<td><span style="color:var(--accent);font-weight:700;">{{ next_amp }}</span></td>
|
<td><span class="amp-cell" style="color:var(--accent);font-weight:700;" data-next="1">{{ next_amp }}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for row in rows %}
|
{% for row in rows %}
|
||||||
@@ -84,18 +84,30 @@ document.querySelectorAll('.amp-cell').forEach(function(cell) {
|
|||||||
cell.addEventListener('click', function() {
|
cell.addEventListener('click', function() {
|
||||||
var row = cell.parentElement.parentElement;
|
var row = cell.parentElement.parentElement;
|
||||||
var tbl = document.getElementById('bars-table');
|
var tbl = document.getElementById('bars-table');
|
||||||
// Only rows with data-index (skip header + next-day row)
|
|
||||||
var dataRows = tbl.querySelectorAll('tr[data-index]');
|
var dataRows = tbl.querySelectorAll('tr[data-index]');
|
||||||
|
|
||||||
|
// Next-day row: use latest 5 data rows
|
||||||
|
if (cell.dataset.next) {
|
||||||
|
if (dataRows.length < 5) return;
|
||||||
|
showDrawer(cell, '{{ contract }}', dataRows, 0, 5);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var idx = parseInt(row.dataset.index);
|
var idx = parseInt(row.dataset.index);
|
||||||
// Need 5 older rows (higher index, since newest first)
|
// Need 5 older rows (higher index, since newest first)
|
||||||
if (idx + 5 >= dataRows.length) return;
|
if (idx + 5 >= dataRows.length) return;
|
||||||
|
showDrawer(cell, '{{ contract }}', dataRows, idx + 1, idx + 5);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
document.getElementById('drawer-title').textContent = '{{ contract }}';
|
function showDrawer(cell, product, dataRows, fromIdx, toIdx) {
|
||||||
document.getElementById('drawer-date').textContent = '目标: ' + row.dataset.date + ' ' + row.dataset.weekday + ' 振幅 ' + cell.textContent.trim();
|
document.getElementById('drawer-title').textContent = product;
|
||||||
|
var label = cell.dataset.next ? '次日预测' : '目标';
|
||||||
|
document.getElementById('drawer-date').textContent = label + ' 振幅 ' + cell.textContent.trim();
|
||||||
|
|
||||||
var html = '<tr><td>日期</td><td>最高−最低</td></tr>';
|
var html = '<tr><td>日期</td><td>最高−最低</td></tr>';
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
for (var j = idx + 1; j <= idx + 5; j++) {
|
for (var j = fromIdx; j <= toIdx; j++) {
|
||||||
var r = dataRows[j];
|
var r = dataRows[j];
|
||||||
html += '<tr><td>' + r.dataset.date + ' ' + r.dataset.weekday + '</td><td>' + r.dataset.diff + '</td></tr>';
|
html += '<tr><td>' + r.dataset.date + ' ' + r.dataset.weekday + '</td><td>' + r.dataset.diff + '</td></tr>';
|
||||||
sum += parseInt(r.dataset.diff);
|
sum += parseInt(r.dataset.diff);
|
||||||
@@ -106,10 +118,10 @@ document.querySelectorAll('.amp-cell').forEach(function(cell) {
|
|||||||
document.getElementById('overlay').classList.add('show');
|
document.getElementById('overlay').classList.add('show');
|
||||||
document.getElementById('drawer').classList.add('show');
|
document.getElementById('drawer').classList.add('show');
|
||||||
|
|
||||||
|
var row = cell.parentElement.parentElement;
|
||||||
if (activeRow) activeRow.classList.remove('active');
|
if (activeRow) activeRow.classList.remove('active');
|
||||||
row.classList.add('active');
|
row.classList.add('active');
|
||||||
activeRow = row;
|
activeRow = row;
|
||||||
});
|
}
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user