fix(chart): divisional tables show that chart's own rows, not D1 (T3, BUG-1076)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017eEAG8HD3mm8gsKXgk8uU8
This commit is contained in:
Jesse_Chen
2026-09-28 15:21:30 +08:00
co-authored by Claude Opus 5.5
parent af27709de4
commit ab6ee94e95
9 changed files with 503 additions and 25 deletions
@@ -6,6 +6,9 @@ import type {
ChartViewAscendantRow,
ChartViewOk,
ChartViewPlanetRow,
ChartViewVarga,
ChartViewVargaAscendantRow,
ChartViewVargaRow,
} from "@/lib/chart-view-contract";
import { CHART_VIEW_COPY, VARGA_CHIP_ORDER } from "@/lib/chart-view-labels";
import {
@@ -19,6 +22,7 @@ import {
import { formatDegreeMinutes } from "./chart-format";
import { ChartParamTable } from "./chart-param-table";
import { chartLayerFailureCopy } from "@/lib/chart-view-failure";
import { VARGA_DIGNITY_LABEL } from "@/lib/chart-view-varga";
import { ChartPageSkeleton } from "./chart-page-skeleton";
/** The same coloured symbol the chart draws, so a row and a house read as one body. */
@@ -86,6 +90,99 @@ function AscendantRow({ row }: { row: ChartViewAscendantRow }) {
);
}
/**
* The natal eight-column table. Everything the chart stopped drawing lands
* here: the chart carries symbols, this table carries the numbers behind them.
*/
function NatalTable({ view, caption }: { view: ChartViewOk; caption: string }) {
return (
<div className="chart-page-planet-table-wrap">
<table className="chart-page-planet-table">
<caption>{caption}</caption>
<thead>
<tr>
<th scope="col">行星</th>
<th scope="col">黄道经度</th>
<th scope="col">速度</th>
<th scope="col">宫位</th>
<th scope="col">星宿</th>
<th scope="col">宿主</th>
<th scope="col">pada</th>
<th scope="col">状态</th>
</tr>
</thead>
<tbody>
{view.vedic.ascendant && <AscendantRow row={view.vedic.ascendant} />}
{view.vedic.planets.map((planet) => (
<PlanetRow key={planet.name} row={planet} />
))}
</tbody>
</table>
</div>
);
}
function VargaRow({ row }: { row: ChartViewVargaRow }) {
const key = planetGlyphKey(row.name);
return (
<tr>
<th scope="row">
<PlanetCell name={row.name} label={row.label} abbr={key ? PLANET_ABBR[key] : "—"} />
{row.retrograde ? <span className="chart-page-planet-abbr"> 逆</span> : null}
</th>
<td className="chart-page-planet-num">{row.signLabel} {formatDegreeMinutes(row.degreeInSign)}</td>
<td className="chart-page-planet-mid">{row.house}宫</td>
<td>{row.natalSignLabel}</td>
<td className="chart-page-planet-mid">{row.dignity ? VARGA_DIGNITY_LABEL[row.dignity] : "—"}</td>
<td className="chart-page-planet-mid">{row.vargottama ? "同位" : "—"}</td>
</tr>
);
}
function VargaAscendantRow({ row }: { row: ChartViewVargaAscendantRow }) {
return (
<tr>
<th scope="row">
<PlanetCell name={null} label="上升" abbr="As" />
</th>
<td className="chart-page-planet-num">{row.signLabel} {formatDegreeMinutes(row.degreeInSign)}</td>
<td className="chart-page-planet-mid">1宫</td>
<td>{row.natalSignLabel}</td>
<td className="chart-page-planet-mid">—</td>
<td className="chart-page-planet-mid">{row.vargottama ? "同位" : "—"}</td>
</tr>
);
}
/**
* A divisional chart's own table (BUG-1076). Six columns, not the natal eight:
* nakshatra, its lord and pada are properties of the D1 longitude and would be
* wrong data here, so they are not shown at all.
*/
export function VargaTable({ varga }: { varga: ChartViewVarga }) {
return (
<div className="chart-page-planet-table-wrap">
<table className="chart-page-planet-table">
<caption>{varga.id} · {varga.meaning}</caption>
<thead>
<tr>
<th scope="col">行星</th>
<th scope="col">分盘星座</th>
<th scope="col">宫位</th>
<th scope="col">本命星座</th>
<th scope="col">庙旺</th>
<th scope="col">同位</th>
</tr>
</thead>
<tbody>
{varga.ascendant ? <VargaAscendantRow row={varga.ascendant} /> : null}
{(varga.rows ?? []).map((row) => <VargaRow key={row.name} row={row} />)}
</tbody>
</table>
</div>
);
}
export function ChartVedicTab({
view,
vargaId,
@@ -138,31 +235,11 @@ export function ChartVedicTab({
chart can and cannot be read for. */}
<p className="chart-page-boundary">{view.vedic.boundary}</p>
</div>
{/* Everything the chart stopped drawing lands here: the chart carries
symbols, this table carries the numbers behind them. */}
<div className="chart-page-planet-table-wrap">
<table className="chart-page-planet-table">
<caption>{varga.id} · {varga.meaning}</caption>
<thead>
<tr>
<th scope="col">行星</th>
<th scope="col">黄道经度</th>
<th scope="col">速度</th>
<th scope="col">宫位</th>
<th scope="col">星宿</th>
<th scope="col">宿主</th>
<th scope="col">pada</th>
<th scope="col">状态</th>
</tr>
</thead>
<tbody>
{view.vedic.ascendant && <AscendantRow row={view.vedic.ascendant} />}
{view.vedic.planets.map((planet) => (
<PlanetRow key={planet.name} row={planet} />
))}
</tbody>
</table>
</div>
{varga.id === "D1" || !varga.rows ? (
<NatalTable view={view} caption={`${varga.id} · ${varga.meaning}`} />
) : (
<VargaTable varga={varga} />
)}
</div>
)}
</div>