@@ -82,6 +82,10 @@ function DataDetail({ indicator, onBack }) {
|
||||
const rows = (i.points || [])
|
||||
// 图表 X 轴统一用 period 字段
|
||||
const chartRows = rows.map((r) => ({ ...r, period: periodOf(r) }))
|
||||
// 表格按时间反序: 最新在前
|
||||
const tableRows = [...rows].reverse()
|
||||
const [showAll, setShowAll] = useState(false)
|
||||
const visibleRows = showAll ? tableRows : tableRows.slice(0, 10)
|
||||
const lp = lastPoint({ rows })
|
||||
const { trend } = calcTrend(rows)
|
||||
const title = i.title || i.name
|
||||
@@ -106,17 +110,22 @@ function DataDetail({ indicator, onBack }) {
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
<div style={{ maxHeight: 240, overflow: 'auto' }}>
|
||||
<div className={'data-table-wrap' + (showAll ? ' scroll' : '')}>
|
||||
<table className="data-table">
|
||||
<thead>
|
||||
<tr><th>月份</th><th style={{ textAlign: 'right' }}>数值</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((r) => (
|
||||
{visibleRows.map((r) => (
|
||||
<tr key={periodOf(r)}><td>{periodOf(r)}</td><td style={{ textAlign: 'right' }}>{r.value}</td></tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
{tableRows.length > 10 && !showAll && (
|
||||
<div className="table-more" onClick={() => setShowAll(true)}>
|
||||
展开全部(共 {tableRows.length} 行)
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@@ -170,6 +170,9 @@ input, textarea, select { font: inherit; }
|
||||
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
.data-table th, .data-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--color-border); }
|
||||
.data-table th { background: #f8f8f8; font-weight: 600; }
|
||||
.data-table-wrap { position: relative; }
|
||||
.data-table-wrap.scroll { max-height: 300px; overflow: auto; }
|
||||
.table-more { text-align: center; padding: 10px 0 2px; font-size: 13px; color: var(--color-primary); cursor: pointer; }
|
||||
|
||||
/* 页面标题 */
|
||||
.page-title { font-size: 20px; font-weight: 700; padding: 14px 16px 4px; }
|
||||
|
||||
Reference in New Issue
Block a user