Comparisons (synastry) of the own chart and persons
/osszevetesek compares any two of the user's charts (own and persons); the person card and the person's chart page have "Összevetés velem". The comparison page shows a double wheel (first person inside with houses, second outside, aspects between them), the aspects by character, and tabs: paid relationship analysis (synastry unit), the cross aspect grid, house overlays, composite and the full aspect list. Correcting a person within the hour now deletes the user's own comparisons with them instead of being refused; still refused after a paid analysis or when someone else's comparison uses the chart. The relationship analysis prompt is editable on /admin/promptok too, and can be tried on one of the admin's comparisons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { ANGLES, ASPECTS, POINTS, SIGNS, dms, orbText, pointName, signName } from "@/lib/astro";
|
||||
import type { Aspect, Chart, Position } from "@/lib/types";
|
||||
|
||||
function Pos({ p }: { p: Position }) {
|
||||
export function Pos({ p }: { p: Position }) {
|
||||
return (
|
||||
<>
|
||||
{dms(p.degree_in_sign_dms)} <span className="sym">{SIGNS[p.sign]?.glyph}</span> {signName(p.sign)}
|
||||
@@ -47,7 +47,7 @@ export function BigThree({ chart }: { chart: Chart }) {
|
||||
}
|
||||
|
||||
// Rows and columns of the aspect grid: the points drawn on the wheel, then the angles.
|
||||
const GRID_POINTS = [
|
||||
export const GRID_POINTS = [
|
||||
"sun",
|
||||
"moon",
|
||||
"mercury",
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ASPECTS, POINTS, SIGNS, dms, orbText, pointName, signName } from "@/lib
|
||||
import type { ChartResult, Position } from "@/lib/types";
|
||||
|
||||
// Radii of the rings (viewBox is SIZE × SIZE, centre C).
|
||||
const SIZE = 680;
|
||||
export const SIZE = 680;
|
||||
const C = SIZE / 2;
|
||||
const R_LABEL = 322; // ASC / MC labels
|
||||
const R_OUT = 300; // outer edge of the zodiac ring
|
||||
@@ -13,7 +13,7 @@ const R_HOUSE = 172; // outer edge of the house-number ring
|
||||
const R_INNER = 146; // aspect circle
|
||||
|
||||
// Points drawn on the wheel; the asteroids and the south node are only in the tables.
|
||||
const WHEEL_POINTS = [
|
||||
export const WHEEL_POINTS = [
|
||||
"sun",
|
||||
"moon",
|
||||
"mercury",
|
||||
@@ -30,10 +30,10 @@ const WHEEL_POINTS = [
|
||||
];
|
||||
// Aspects drawn on the wheel, between these points; the rest (minor aspects,
|
||||
// nodes, Lilith, Chiron) are only in the aspect table.
|
||||
const WHEEL_ASPECTS = ["opposition", "square", "trine", "sextile"];
|
||||
const ASPECT_POINTS = ["sun", "moon", "mercury", "venus", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto"];
|
||||
const SIGN_ORDER = Object.keys(SIGNS);
|
||||
const SIGN_ELEMENT = ["fire", "earth", "air", "water"];
|
||||
export const WHEEL_ASPECTS = ["opposition", "square", "trine", "sextile"];
|
||||
export const ASPECT_POINTS = ["sun", "moon", "mercury", "venus", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto"];
|
||||
export const SIGN_ORDER = Object.keys(SIGNS);
|
||||
export const SIGN_ELEMENT = ["fire", "earth", "air", "water"];
|
||||
const ANGLE_LABELS: [string, string][] = [
|
||||
["ascendant", "ASC"],
|
||||
["midheaven", "MC"],
|
||||
@@ -42,15 +42,15 @@ const ANGLE_LABELS: [string, string][] = [
|
||||
];
|
||||
|
||||
/** Screen point of an ecliptic longitude: the ascendant (or 0° Aries) is on the left. */
|
||||
function xy(lon: number, r: number, start: number): [number, number] {
|
||||
export function xy(lon: number, r: number, start: number): [number, number] {
|
||||
const a = ((180 + lon - start) * Math.PI) / 180;
|
||||
return [C + r * Math.cos(a), C - r * Math.sin(a)];
|
||||
}
|
||||
|
||||
const f = (n: number) => n.toFixed(2);
|
||||
export const f = (n: number) => n.toFixed(2);
|
||||
|
||||
/** Pushes glyphs apart so that neighbours are at least `min` degrees from each other. */
|
||||
function spread(lons: number[], min: number): number[] {
|
||||
export function spread(lons: number[], min: number): number[] {
|
||||
const n = lons.length;
|
||||
const order = lons.map((_, i) => i).sort((a, b) => lons[a] - lons[b]);
|
||||
const pos = order.map((i) => lons[i]);
|
||||
@@ -73,7 +73,7 @@ function spread(lons: number[], min: number): number[] {
|
||||
return out;
|
||||
}
|
||||
|
||||
function arcPath(r1: number, r2: number, from: number, to: number, start: number): string {
|
||||
export function arcPath(r1: number, r2: number, from: number, to: number, start: number): string {
|
||||
const [x1, y1] = xy(from, r2, start);
|
||||
const [x2, y2] = xy(to, r2, start);
|
||||
const [x3, y3] = xy(to, r1, start);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { api, errorText } from "@/lib/api";
|
||||
|
||||
/** Compares two charts (or opens their existing comparison). */
|
||||
export function CompareButton({
|
||||
chart1,
|
||||
chart2,
|
||||
label = "Összevetés velem",
|
||||
className = "btn btn-sm btn-ghost",
|
||||
}: {
|
||||
chart1: string;
|
||||
chart2: string;
|
||||
label?: string;
|
||||
className?: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
async function compare() {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const s = await api<{ id: string }>("/synastries", { body: { chart1_id: chart1, chart2_id: chart2 } });
|
||||
router.push(`/osszevetesek/${s.id}`);
|
||||
} catch (e) {
|
||||
setError(errorText(e));
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<button type="button" className={className} onClick={compare} disabled={busy}>
|
||||
{busy ? "Számolás…" : label}
|
||||
</button>
|
||||
{error && (
|
||||
<p className="msg msg-error" role="alert">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -14,30 +14,65 @@ const MAX_POLLS = 120; // 10 minutes
|
||||
|
||||
type Step = "offer" | "confirm" | "pay";
|
||||
|
||||
/** What is analysed: a natal chart, or a comparison of two charts. */
|
||||
export type AnalysisTarget = { kind: "natal"; chartId: string } | { kind: "synastry"; synastryId: string };
|
||||
|
||||
const TEXTS = {
|
||||
natal: {
|
||||
eyebrow: "Részletes elemzés",
|
||||
title: "Az egész képleted, fejezetekre bontva",
|
||||
about:
|
||||
"Kb. 1500 szó hat fejezetben: személyiség, érzelmek, gondolkodás, szerelem és kapcsolatok, hivatás, fejlődési út. " +
|
||||
"A végén erősségek, kihívások és útravaló. Csak a képleted pozíciói alapján készül.",
|
||||
loadingTitle: "Készül az elemzésed",
|
||||
loading:
|
||||
"Most íródik a hat fejezet a képleted alapján. Ez általában 1–3 perc; nyugodtan elhagyhatod az oldalt, az elemzés elkészül és itt vár.",
|
||||
item: "Részletes képletelemzés",
|
||||
unitName: "képletelemzés",
|
||||
},
|
||||
synastry: {
|
||||
eyebrow: "Kapcsolati elemzés",
|
||||
title: "Kettőtök képlete, fejezetekre bontva",
|
||||
about:
|
||||
"Kb. 1300 szó öt fejezetben: mi vonz egymáshoz, kommunikáció, érzelmi kötődés, súrlódások, hosszú távú lehetőségek " +
|
||||
"(a kompozit képlettel). A végén erősségek, kihívások és útravaló. Csak a két képlet pozíciói alapján készül.",
|
||||
loadingTitle: "Készül a kapcsolati elemzés",
|
||||
loading:
|
||||
"Most íródik az öt fejezet a két képlet alapján. Ez általában 1–3 perc; nyugodtan elhagyhatod az oldalt, az elemzés elkészül és itt vár.",
|
||||
item: "Részletes kapcsolati elemzés",
|
||||
unitName: "kapcsolati elemzés",
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The detailed analysis of a chart. A saved one is shown at once; otherwise
|
||||
* The detailed analysis of a chart or a comparison. A saved one is shown at once; otherwise
|
||||
* the offer: admins start it free, users with units confirm, others pay
|
||||
* (a stand-in payment for now). While the worker writes it, a loading wheel.
|
||||
*/
|
||||
export function DetailedAnalysis({
|
||||
chartId,
|
||||
target,
|
||||
initial,
|
||||
left,
|
||||
isAdmin,
|
||||
canPay,
|
||||
note,
|
||||
}: {
|
||||
chartId: string;
|
||||
target: AnalysisTarget;
|
||||
initial: Analysis | null;
|
||||
left: number;
|
||||
isAdmin: boolean;
|
||||
/** The stand-in payment is on (MOCK_PAYMENTS). */
|
||||
canPay: boolean;
|
||||
/** Shown above a finished analysis (e.g. who is the first and the second person). */
|
||||
note?: string;
|
||||
}) {
|
||||
const [analysis, setAnalysis] = useState<Analysis | null>(initial);
|
||||
const [step, setStep] = useState<Step>("offer");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const waiting = analysis?.status === "pending" || analysis?.status === "running";
|
||||
const t = TEXTS[target.kind];
|
||||
const path = target.kind === "natal" ? `/charts/${target.chartId}` : `/synastries/${target.synastryId}`;
|
||||
|
||||
useEffect(() => {
|
||||
if (!waiting || !analysis) return;
|
||||
@@ -66,8 +101,8 @@ export function DetailedAnalysis({
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
if (pay) await api("/payments/mock", { body: { unit: "natal" } });
|
||||
setAnalysis(await api<Analysis>(`/charts/${chartId}/analyses`, { method: "POST" }));
|
||||
if (pay) await api("/payments/mock", { body: { unit: target.kind } });
|
||||
setAnalysis(await api<Analysis>(`${path}/analyses`, { method: "POST" }));
|
||||
setStep("offer");
|
||||
} catch (e) {
|
||||
setError(errorText(e));
|
||||
@@ -78,21 +113,19 @@ export function DetailedAnalysis({
|
||||
|
||||
if (analysis?.status === "done" && analysis.content) {
|
||||
return (
|
||||
<section className="analysis-card" aria-label="Részletes elemzés">
|
||||
<span className="eyebrow">Részletes elemzés</span>
|
||||
<AnalysisView content={analysis.content} />
|
||||
<section className="analysis-card" aria-label={t.eyebrow}>
|
||||
<span className="eyebrow">{t.eyebrow}</span>
|
||||
{note && <p className="hint">{note}</p>}
|
||||
<AnalysisView content={analysis.content} kind={target.kind} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
if (waiting) {
|
||||
return (
|
||||
<section className="analysis-card" aria-label="Részletes elemzés" aria-busy="true">
|
||||
<span className="eyebrow">Részletes elemzés</span>
|
||||
<AnalysisLoading
|
||||
title="Készül az elemzésed"
|
||||
text="Most íródik a hat fejezet a képleted alapján. Ez általában 1–3 perc; nyugodtan elhagyhatod az oldalt, az elemzés elkészül és itt vár."
|
||||
/>
|
||||
<section className="analysis-card" aria-label={t.eyebrow} aria-busy="true">
|
||||
<span className="eyebrow">{t.eyebrow}</span>
|
||||
<AnalysisLoading title={t.loadingTitle} text={t.loading} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -100,13 +133,10 @@ export function DetailedAnalysis({
|
||||
return (
|
||||
<section className="analysis-card analysis-offer" aria-labelledby="detailed-title">
|
||||
<div className="offer-head">
|
||||
<span className="eyebrow">Részletes elemzés</span>
|
||||
<h2 id="detailed-title">Az egész képleted, fejezetekre bontva</h2>
|
||||
<span className="eyebrow">{t.eyebrow}</span>
|
||||
<h2 id="detailed-title">{t.title}</h2>
|
||||
</div>
|
||||
<p className="muted">
|
||||
Kb. 1500 szó hat fejezetben: személyiség, érzelmek, gondolkodás, szerelem és kapcsolatok, hivatás, fejlődési út.
|
||||
A végén erősségek, kihívások és útravaló. Csak a képleted pozíciói alapján készül.
|
||||
</p>
|
||||
<p className="muted">{t.about}</p>
|
||||
{analysis?.status === "failed" && (
|
||||
<p className="msg msg-error" role="alert">
|
||||
Az előző kérés nem sikerült{isAdmin ? "" : ", az elemzést visszaadtuk a keretedbe"}. Próbáld újra.
|
||||
@@ -121,7 +151,7 @@ export function DetailedAnalysis({
|
||||
{isAdmin ? (
|
||||
<div className="form-actions">
|
||||
<button type="button" className="btn btn-primary" onClick={() => start(false)} disabled={busy}>
|
||||
{busy ? "Indítás…" : "Részletes elemzés készítése"}
|
||||
{busy ? "Indítás…" : `${t.item} készítése`}
|
||||
</button>
|
||||
<span className="hint">Adminként ingyenes.</span>
|
||||
</div>
|
||||
@@ -134,21 +164,25 @@ export function DetailedAnalysis({
|
||||
<button type="button" className="btn btn-ghost" onClick={() => setStep("offer")} disabled={busy}>
|
||||
Mégse
|
||||
</button>
|
||||
<span className="hint">Ez felhasznál 1-et a {left} képletelemzésedből.</span>
|
||||
<span className="hint">
|
||||
Ez felhasznál 1-et a {left} {t.unitName}edből.
|
||||
</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="form-actions">
|
||||
<button type="button" className="btn btn-primary" onClick={() => setStep("confirm")}>
|
||||
Részletes elemzés kérése
|
||||
</button>
|
||||
<span className="hint">Még {left} képletelemzésed van.</span>
|
||||
<span className="hint">
|
||||
Még {left} {t.unitName}ed van.
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
) : canPay ? (
|
||||
step === "pay" ? (
|
||||
<div className="pay-box">
|
||||
<div className="pay-line">
|
||||
<span>Részletes képletelemzés</span>
|
||||
<span>{t.item}</span>
|
||||
<strong>1 db</strong>
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
@@ -166,16 +200,20 @@ export function DetailedAnalysis({
|
||||
<button type="button" className="btn btn-primary" onClick={() => setStep("pay")}>
|
||||
Részletes elemzés kérése
|
||||
</button>
|
||||
<Link href="/pelda" className="btn btn-ghost">
|
||||
Példa megtekintése
|
||||
</Link>
|
||||
{target.kind === "natal" && (
|
||||
<Link href="/pelda" className="btn btn-ghost">
|
||||
Példa megtekintése
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
) : (
|
||||
<div className="form-actions">
|
||||
<Link href="/pelda" className="btn">
|
||||
Példa megtekintése
|
||||
</Link>
|
||||
{target.kind === "natal" && (
|
||||
<Link href="/pelda" className="btn">
|
||||
Példa megtekintése
|
||||
</Link>
|
||||
)}
|
||||
<span className="hint">A részletes elemzés fizetős; a csomagok hamarosan elérhetők.</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -6,8 +6,21 @@ import { useState } from "react";
|
||||
|
||||
import { api, errorText } from "@/lib/api";
|
||||
|
||||
/** Correct (while allowed) or delete a person. */
|
||||
export function PersonActions({ id, name, editable }: { id: string; name: string; editable: boolean }) {
|
||||
import { CompareButton } from "./CompareButton";
|
||||
|
||||
/** Compare with the own chart, correct (while allowed) or delete a person. */
|
||||
export function PersonActions({
|
||||
id,
|
||||
name,
|
||||
editable,
|
||||
ownId,
|
||||
}: {
|
||||
id: string;
|
||||
name: string;
|
||||
editable: boolean;
|
||||
/** The user's own chart, for "compare with me". */
|
||||
ownId?: string | null;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [confirm, setConfirm] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
@@ -39,6 +52,7 @@ export function PersonActions({ id, name, editable }: { id: string; name: string
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{ownId && <CompareButton chart1={ownId} chart2={id} />}
|
||||
{editable && (
|
||||
<Link href={`/kepletek/${id}/javitas`} className="btn btn-sm btn-ghost">
|
||||
Adatok javítása
|
||||
|
||||
@@ -17,6 +17,7 @@ export function SiteHeader({ me }: { me: Me }) {
|
||||
const links = [
|
||||
{ href: "/keplet", label: "Képletem" },
|
||||
{ href: "/szemelyek", label: "Személyek" },
|
||||
{ href: "/osszevetesek", label: "Összevetések" },
|
||||
{ href: "/profil", label: "Profil" },
|
||||
];
|
||||
if (me.user.roles.includes("admin")) links.push({ href: "/admin", label: "Admin" });
|
||||
|
||||
@@ -0,0 +1,314 @@
|
||||
import { ASPECTS, POINTS, SIGNS, dms, orbText, pointName, signName } from "@/lib/astro";
|
||||
import type { HouseOverlay, InterAspect, Synastry, SynastryResult } from "@/lib/types";
|
||||
|
||||
import { GRID_POINTS, Pos } from "./ChartTables";
|
||||
|
||||
const NATURES: { key: keyof SynastryResult["summary"]["by_nature"]; label: string; hint: string }[] = [
|
||||
{ key: "harmonious", label: "Harmonikus", hint: "trigon, szextil: ami könnyen megy köztetek" },
|
||||
{ key: "challenging", label: "Feszültebb", hint: "kvadrát, szembenállás: súrlódás, de mozgatóerő is" },
|
||||
{ key: "neutral", label: "Együttállás", hint: "összeolvadás: erős, a bolygóktól függő hatás" },
|
||||
];
|
||||
|
||||
/** The inter-chart aspects by character, as a bar and counts. */
|
||||
export function NatureBar({ summary }: { summary: SynastryResult["summary"] }) {
|
||||
const total = summary.aspect_count || 1;
|
||||
return (
|
||||
<div className="nature">
|
||||
<div className="nature-bar" aria-hidden="true">
|
||||
{NATURES.map((n) => (
|
||||
<span
|
||||
key={n.key}
|
||||
className={`nature-seg nature-${n.key}`}
|
||||
style={{ flexGrow: summary.by_nature[n.key] / total }}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<dl className="nature-list">
|
||||
{NATURES.map((n) => (
|
||||
<div key={n.key}>
|
||||
<dt>
|
||||
<span className={`nature-dot nature-${n.key}`} aria-hidden="true" /> {n.label}
|
||||
</dt>
|
||||
<dd>
|
||||
<strong>{summary.by_nature[n.key]}</strong> <span className="hint">{n.hint}</span>
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const GRID_ANGLES: [string, string][] = [
|
||||
["ascendant", "AC"],
|
||||
["midheaven", "MC"],
|
||||
];
|
||||
|
||||
function gridPoints(s: Synastry["chart1"]): [string, string][] {
|
||||
const present = new Set(s.chart.points.map((p) => p.id));
|
||||
const rows: [string, string][] = GRID_POINTS.filter((id) => present.has(id)).map((id) => [id, POINTS[id]?.glyph ?? id]);
|
||||
if (s.highlights.time_known) {
|
||||
for (const [key, label] of GRID_ANGLES) if (s.chart.angles?.[key]) rows.push([key, label]);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/** The aspects between the two charts: the first person in the rows, the second in the columns. */
|
||||
export function CrossGrid({ synastry, name1, name2 }: { synastry: Synastry; name1: string; name2: string }) {
|
||||
const rows = gridPoints(synastry.chart1);
|
||||
const cols = gridPoints(synastry.chart2);
|
||||
const byPair = new Map<string, InterAspect>();
|
||||
for (const a of synastry.synastry.aspects) byPair.set(`${a.person1}|${a.person2}`, a);
|
||||
const label = ([id, text]: [string, string], who: string) => (
|
||||
<span className={text.length > 2 ? "sym" : "grid-angle"} aria-label={`${who}: ${pointName(id)}`} role="img">
|
||||
{text}
|
||||
</span>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="aspect-grid-wrap">
|
||||
<table className="aspect-grid cross-grid" aria-label={`Fényszögek: sorokban ${name1}, oszlopokban ${name2}`}>
|
||||
<thead>
|
||||
<tr>
|
||||
<td className="corner cross-corner">
|
||||
<span className="cross-col">{name2} →</span>
|
||||
<span className="cross-row">↓ {name1}</span>
|
||||
</td>
|
||||
{cols.map((c) => (
|
||||
<th key={c[0]} scope="col" title={`${name2}: ${pointName(c[0])}`} className="p2-head">
|
||||
{label(c, name2)}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((row) => {
|
||||
const [id] = row;
|
||||
return (
|
||||
<tr key={id}>
|
||||
<th scope="row" title={`${name1}: ${pointName(id)}`}>
|
||||
{label(row, name1)}
|
||||
</th>
|
||||
{cols.map(([other]) => {
|
||||
const a = byPair.get(`${id}|${other}`);
|
||||
const info = a ? ASPECTS[a.aspect] : undefined;
|
||||
const text = a
|
||||
? `${name1} ${pointName(id)} ${info?.hu ?? a.aspect} ${name2} ${pointName(other)}, orbis ${orbText(a.orb)}`
|
||||
: undefined;
|
||||
return (
|
||||
<td key={other} title={text}>
|
||||
{a && (
|
||||
<span className={`sym asp asp-${a.aspect}`} aria-label={text} role="img">
|
||||
{info?.glyph ?? "?"}
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function OverlayTable({ title, overlays, missing }: { title: string; overlays: HouseOverlay[] | null; missing: string }) {
|
||||
return (
|
||||
<div className="table-wrap">
|
||||
<h3 style={{ marginBottom: 8 }}>{title}</h3>
|
||||
{overlays ? (
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Pont</th>
|
||||
<th scope="col">Jegy</th>
|
||||
<th scope="col">Ház</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{overlays.map((o) => (
|
||||
<tr key={o.point}>
|
||||
<td>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{POINTS[o.point]?.glyph}
|
||||
</span>{" "}
|
||||
{pointName(o.point)}
|
||||
</td>
|
||||
<td>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{SIGNS[o.sign]?.glyph}
|
||||
</span>{" "}
|
||||
{signName(o.sign)}
|
||||
</td>
|
||||
<td className="num">{o.house}.</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
) : (
|
||||
<p className="muted">{missing}</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Each person's points in the other's houses (needs the other's birth time). */
|
||||
export function HouseOverlays({ synastry, name1, name2 }: { synastry: Synastry; name1: string; name2: string }) {
|
||||
const o = synastry.synastry.house_overlays;
|
||||
return (
|
||||
<div className="field" style={{ gap: 16 }}>
|
||||
<p className="hint">
|
||||
Melyik életterületét érinti a másik: az egyik fél bolygói a másik házaiban. Ehhez a ház „gazdájának” pontos
|
||||
születési ideje kell.
|
||||
</p>
|
||||
<div className="grid-2" style={{ alignItems: "start" }}>
|
||||
<OverlayTable
|
||||
title={`${name2} bolygói ${name1} házaiban`}
|
||||
overlays={o.person2_in_person1}
|
||||
missing={`${name1} születési ideje ismeretlen, ezért a házai nem számolhatók.`}
|
||||
/>
|
||||
<OverlayTable
|
||||
title={`${name1} bolygói ${name2} házaiban`}
|
||||
overlays={o.person1_in_person2}
|
||||
missing={`${name2} születési ideje ismeretlen, ezért a házai nem számolhatók.`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** The composite chart (midpoints of the two charts). */
|
||||
export function CompositeTables({ synastry }: { synastry: Synastry }) {
|
||||
const c = synastry.synastry.composite;
|
||||
const hasHouses = Boolean(c.houses);
|
||||
const angles = (
|
||||
[
|
||||
["ascendant", "ASC"],
|
||||
["midheaven", "MC"],
|
||||
] as const
|
||||
).filter(([key]) => c.angles?.[key]);
|
||||
const aspects = [...c.aspects].filter((a) => a.orb <= 3).sort((a, b) => a.orb - b.orb);
|
||||
return (
|
||||
<div className="field" style={{ gap: 16 }}>
|
||||
<p className="hint">
|
||||
A kompozit képlet a két képlet felezőpontjaiból áll: a kapcsolatot mint önálló harmadik „személyt” írja le.
|
||||
{!c.angles && " Tengelyek és házak nélkül, mert legalább az egyik születési idő ismeretlen."}
|
||||
</p>
|
||||
<div className="grid-2" style={{ alignItems: "start" }}>
|
||||
<div className="table-wrap">
|
||||
<h3 style={{ marginBottom: 8 }}>Pontok</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Pont</th>
|
||||
<th scope="col">Pozíció</th>
|
||||
{hasHouses && <th scope="col">Ház</th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{c.points.map((p) => (
|
||||
<tr key={p.id}>
|
||||
<td>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{POINTS[p.id]?.glyph}
|
||||
</span>{" "}
|
||||
{pointName(p.id)}
|
||||
</td>
|
||||
<td className="num">
|
||||
<Pos p={p} />
|
||||
</td>
|
||||
{hasHouses && <td className="num">{p.house ? `${p.house}.` : "–"}</td>}
|
||||
</tr>
|
||||
))}
|
||||
{angles.map(([key, label]) => (
|
||||
<tr key={key}>
|
||||
<td>{label}</td>
|
||||
<td className="num">
|
||||
{dms(c.angles![key].degree_in_sign_dms)} <span className="sym">{SIGNS[c.angles![key].sign]?.glyph}</span>{" "}
|
||||
{signName(c.angles![key].sign)}
|
||||
</td>
|
||||
{hasHouses && <td />}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="table-wrap">
|
||||
<h3 style={{ marginBottom: 8 }}>Szoros fényszögek</h3>
|
||||
{aspects.length === 0 ? (
|
||||
<p className="muted">Nincs 3°-nál szorosabb fényszög.</p>
|
||||
) : (
|
||||
<table>
|
||||
<tbody>
|
||||
{aspects.map((a) => (
|
||||
<tr key={`${a.point1}-${a.point2}-${a.aspect}`}>
|
||||
<td>
|
||||
{pointName(a.point1)} <AspectTag aspect={a.aspect} /> {pointName(a.point2)}
|
||||
</td>
|
||||
<td className="num">{orbText(a.orb)}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function AspectTag({ aspect }: { aspect: string }) {
|
||||
const info = ASPECTS[aspect];
|
||||
return (
|
||||
<span className={`aspect-tag aspect-${info?.kind ?? "neutral"}`}>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{info?.glyph}
|
||||
</span>{" "}
|
||||
{info?.hu ?? aspect}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/** Every aspect between the two charts, closest first. */
|
||||
export function InterAspectList({ synastry, name1, name2 }: { synastry: Synastry; name1: string; name2: string }) {
|
||||
const aspects = [...synastry.synastry.aspects].sort((a, b) => a.orb - b.orb);
|
||||
if (aspects.length === 0) return <p className="muted">Nincs fényszög a két képlet között.</p>;
|
||||
return (
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{name1}</th>
|
||||
<th scope="col">Fényszög</th>
|
||||
<th scope="col">{name2}</th>
|
||||
<th scope="col">Orbisz</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{aspects.map((a) => (
|
||||
<tr key={`${a.person1}-${a.person2}-${a.aspect}`}>
|
||||
<td>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{POINTS[a.person1]?.glyph}
|
||||
</span>{" "}
|
||||
{pointName(a.person1)}
|
||||
</td>
|
||||
<td>
|
||||
<AspectTag aspect={a.aspect} />
|
||||
</td>
|
||||
<td>
|
||||
<span className="sym p2-text" aria-hidden="true">
|
||||
{POINTS[a.person2]?.glyph}
|
||||
</span>{" "}
|
||||
{pointName(a.person2)}
|
||||
</td>
|
||||
<td className="num">{orbText(a.orb)}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
import { ASPECTS, POINTS, SIGNS, dms, orbText, pointName, signName } from "@/lib/astro";
|
||||
import type { ChartPoint, ChartResult, InterAspect, Position } from "@/lib/types";
|
||||
|
||||
import {
|
||||
ASPECT_POINTS,
|
||||
SIGN_ELEMENT,
|
||||
SIGN_ORDER,
|
||||
SIZE,
|
||||
WHEEL_ASPECTS,
|
||||
WHEEL_POINTS,
|
||||
arcPath,
|
||||
f,
|
||||
spread,
|
||||
xy,
|
||||
} from "./ChartWheel";
|
||||
|
||||
const C = SIZE / 2;
|
||||
const R_LABEL = 322; // ASC / MC labels of the first person
|
||||
const R_OUT = 300; // outer edge of the zodiac ring
|
||||
const R_ZOD = 262; // inner edge of the zodiac ring
|
||||
const R2_GLYPH = 238; // second person: glyphs
|
||||
const R2_DEG = 214;
|
||||
const R_MID = 198; // border of the two rings
|
||||
const R1_GLYPH = 176; // first person: glyphs
|
||||
const R1_DEG = 154;
|
||||
const R_HOUSE = 138; // house-number ring of the first person
|
||||
const R_INNER = 114; // aspect circle
|
||||
|
||||
const ANGLE_LABELS: [string, string][] = [
|
||||
["ascendant", "ASC"],
|
||||
["midheaven", "MC"],
|
||||
["descendant", "DSC"],
|
||||
["imum_coeli", "IC"],
|
||||
];
|
||||
|
||||
function angleOf(chart: ChartResult, key: string): Position | null {
|
||||
const a = chart.angles?.[key];
|
||||
return typeof a === "object" && a !== null ? a : null;
|
||||
}
|
||||
|
||||
/** One person's planets on a ring: tick on the outer edge, glyph, degree. */
|
||||
function Ring({
|
||||
points,
|
||||
placed,
|
||||
edge,
|
||||
glyphR,
|
||||
degR,
|
||||
start,
|
||||
who,
|
||||
timeKnown,
|
||||
className,
|
||||
}: {
|
||||
points: ChartPoint[];
|
||||
placed: number[];
|
||||
edge: number;
|
||||
glyphR: number;
|
||||
degR: number;
|
||||
start: number;
|
||||
who: string;
|
||||
timeKnown: boolean;
|
||||
className: string;
|
||||
}) {
|
||||
return (
|
||||
<g className={className}>
|
||||
{points.map((p, i) => {
|
||||
const [t1x, t1y] = xy(p.longitude, edge, start);
|
||||
const [t2x, t2y] = xy(p.longitude, edge - 8, start);
|
||||
const [lx, ly] = xy(placed[i], glyphR + 13, start);
|
||||
const [gx, gy] = xy(placed[i], glyphR, start);
|
||||
const [dx, dy] = xy(placed[i], degR, start);
|
||||
const deg = Number.parseInt(p.degree_in_sign_dms, 10);
|
||||
return (
|
||||
<g key={p.id} className="w-point">
|
||||
<title>
|
||||
{who}: {pointName(p.id)} {dms(p.degree_in_sign_dms)} {signName(p.sign)}
|
||||
{p.retrograde ? ", retrográd" : ""}
|
||||
{timeKnown && p.house ? `, ${p.house}. ház` : ""}
|
||||
</title>
|
||||
<line x1={f(t1x)} y1={f(t1y)} x2={f(t2x)} y2={f(t2y)} className="w-point-tick" />
|
||||
<line x1={f(t2x)} y1={f(t2y)} x2={f(lx)} y2={f(ly)} className="w-leader" />
|
||||
<text x={f(gx)} y={f(gy)} className="w-point-glyph" dominantBaseline="central" textAnchor="middle">
|
||||
{POINTS[p.id]?.glyph ?? p.id}
|
||||
</text>
|
||||
<text x={f(dx)} y={f(dy)} className="w-point-deg" dominantBaseline="central" textAnchor="middle">
|
||||
{deg}°{p.retrograde ? "℞" : ""}
|
||||
</text>
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Two charts on one wheel: the first person's planets and houses inside, the
|
||||
* second person's planets in the outer ring, the aspects between them in the middle.
|
||||
*/
|
||||
export function SynastryWheel({
|
||||
chart1,
|
||||
chart2,
|
||||
time1,
|
||||
time2,
|
||||
aspects,
|
||||
name1,
|
||||
name2,
|
||||
}: {
|
||||
chart1: ChartResult;
|
||||
chart2: ChartResult;
|
||||
time1: boolean;
|
||||
time2: boolean;
|
||||
aspects: InterAspect[];
|
||||
name1: string;
|
||||
name2: string;
|
||||
}) {
|
||||
const asc = time1 ? angleOf(chart1, "ascendant") : null;
|
||||
const start = asc?.longitude ?? 0;
|
||||
const cusps = time1 ? (chart1.houses?.cusps ?? []) : [];
|
||||
|
||||
const pick = (chart: ChartResult) =>
|
||||
WHEEL_POINTS.map((id) => chart.points.find((p) => p.id === id)).filter((p) => p !== undefined);
|
||||
const points1 = pick(chart1);
|
||||
const points2 = pick(chart2);
|
||||
// The inner ring is shorter, so its glyphs need a wider angle.
|
||||
const placed1 = spread(
|
||||
points1.map((p) => p.longitude),
|
||||
12,
|
||||
);
|
||||
const placed2 = spread(
|
||||
points2.map((p) => p.longitude),
|
||||
8,
|
||||
);
|
||||
|
||||
const endsOf = (points: ChartPoint[], placed: number[], chart: ChartResult, timeKnown: boolean) => {
|
||||
const ends = new Map<string, number>();
|
||||
points.forEach((p, i) => {
|
||||
if (ASPECT_POINTS.includes(p.id)) ends.set(p.id, placed[i]);
|
||||
});
|
||||
if (timeKnown) {
|
||||
for (const key of ["ascendant", "midheaven"]) {
|
||||
const a = angleOf(chart, key);
|
||||
if (a) ends.set(key, a.longitude);
|
||||
}
|
||||
}
|
||||
return ends;
|
||||
};
|
||||
const ends1 = endsOf(points1, placed1, chart1, time1);
|
||||
const ends2 = endsOf(points2, placed2, chart2, time2);
|
||||
const lines = aspects
|
||||
.filter((a) => WHEEL_ASPECTS.includes(a.aspect) && ends1.has(a.person1) && ends2.has(a.person2))
|
||||
.map((a) => ({ ...a, strength: a.max_orb > 0 ? 1 - Math.min(a.orb / a.max_orb, 1) : 0.5 }))
|
||||
.sort((x, y) => x.strength - y.strength);
|
||||
|
||||
return (
|
||||
<svg className="chart-wheel" viewBox={`0 0 ${SIZE} ${SIZE}`} role="img" aria-labelledby="biwheel-title biwheel-desc">
|
||||
<title id="biwheel-title">
|
||||
{name1} és {name2} képlete egy körön
|
||||
</title>
|
||||
<desc id="biwheel-desc">
|
||||
Belül {name1} bolygói{time1 ? " és házai" : ""}, kívül {name2} bolygói; középen a kettejük közti főfényszögek.
|
||||
</desc>
|
||||
|
||||
{/* Zodiac ring */}
|
||||
<circle cx={C} cy={C} r={R_OUT} className="w-ring" />
|
||||
{SIGN_ORDER.map((sign, i) => {
|
||||
const [gx, gy] = xy(i * 30 + 15, (R_OUT + R_ZOD) / 2, start);
|
||||
return (
|
||||
<g key={sign}>
|
||||
<path d={arcPath(R_ZOD, R_OUT, i * 30, i * 30 + 30, start)} className={`w-sign w-${SIGN_ELEMENT[i % 4]}`} />
|
||||
<text x={f(gx)} y={f(gy)} className="w-sign-glyph" dominantBaseline="central" textAnchor="middle">
|
||||
<title>{SIGNS[sign].hu}</title>
|
||||
{SIGNS[sign].glyph}
|
||||
</text>
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
{Array.from({ length: 72 }, (_, k) => {
|
||||
const d = k * 5;
|
||||
const [x1, y1] = xy(d, R_ZOD, start);
|
||||
const [x2, y2] = xy(d, R_ZOD + (d % 10 === 0 ? 8 : 5), start);
|
||||
return <line key={d} x1={f(x1)} y1={f(y1)} x2={f(x2)} y2={f(y2)} className="w-tick" />;
|
||||
})}
|
||||
<circle cx={C} cy={C} r={R_ZOD} className="w-ring" />
|
||||
<circle cx={C} cy={C} r={R_MID} className="w-ring w-faint w-p2-band" />
|
||||
|
||||
{/* The first person's houses */}
|
||||
{cusps.length === 12 && (
|
||||
<g>
|
||||
<circle cx={C} cy={C} r={R_HOUSE} className="w-ring w-faint" />
|
||||
{cusps.map((c, i) => {
|
||||
const isAngle = i % 3 === 0;
|
||||
const [x1, y1] = xy(c.longitude, R_INNER, start);
|
||||
const [x2, y2] = xy(c.longitude, isAngle ? R_OUT : R_MID, start);
|
||||
const next = cusps[(i + 1) % 12].longitude;
|
||||
const mid = c.longitude + ((next - c.longitude + 360) % 360) / 2;
|
||||
const [nx, ny] = xy(mid, (R_HOUSE + R_INNER) / 2, start);
|
||||
return (
|
||||
<g key={c.house}>
|
||||
<line x1={f(x1)} y1={f(y1)} x2={f(x2)} y2={f(y2)} className={isAngle ? "w-axis" : "w-cusp"} />
|
||||
<text x={f(nx)} y={f(ny)} className="w-house-num" dominantBaseline="central" textAnchor="middle">
|
||||
{c.house}
|
||||
</text>
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
{ANGLE_LABELS.map(([key, label]) => {
|
||||
const a = angleOf(chart1, key);
|
||||
if (!a) return null;
|
||||
const [x, y] = xy(a.longitude, R_LABEL, start);
|
||||
return (
|
||||
<text key={key} x={f(x)} y={f(y)} className="w-axis-label" dominantBaseline="central" textAnchor="middle">
|
||||
<title>
|
||||
{name1}: {pointName(key)} {dms(a.degree_in_sign_dms)} {signName(a.sign)}
|
||||
</title>
|
||||
{label}
|
||||
</text>
|
||||
);
|
||||
})}
|
||||
</g>
|
||||
)}
|
||||
|
||||
{/* Aspects between the two */}
|
||||
<circle cx={C} cy={C} r={R_INNER} className="w-ring w-inner" />
|
||||
{lines.map((a) => {
|
||||
const [x1, y1] = xy(ends1.get(a.person1)!, R_INNER, start);
|
||||
const [x2, y2] = xy(ends2.get(a.person2)!, R_INNER, start);
|
||||
const s = a.strength;
|
||||
return (
|
||||
<line
|
||||
key={`${a.person1}-${a.person2}-${a.aspect}`}
|
||||
x1={f(x1)}
|
||||
y1={f(y1)}
|
||||
x2={f(x2)}
|
||||
y2={f(y2)}
|
||||
className={`w-aspect w-asp-${a.aspect}`}
|
||||
strokeOpacity={(0.2 + 0.8 * s * s).toFixed(2)}
|
||||
strokeWidth={(0.6 + 1.9 * s).toFixed(2)}
|
||||
>
|
||||
<title>
|
||||
{name1} {pointName(a.person1)} {ASPECTS[a.aspect]?.hu ?? a.aspect} {name2} {pointName(a.person2)} (orbis{" "}
|
||||
{orbText(a.orb)})
|
||||
</title>
|
||||
</line>
|
||||
);
|
||||
})}
|
||||
{[...ends1].map(([id, lon]) => {
|
||||
const [x, y] = xy(lon, R_INNER, start);
|
||||
return <circle key={`e1-${id}`} cx={f(x)} cy={f(y)} r={2.2} className="w-end" />;
|
||||
})}
|
||||
{[...ends2].map(([id, lon]) => {
|
||||
const [x, y] = xy(lon, R_INNER, start);
|
||||
return <circle key={`e2-${id}`} cx={f(x)} cy={f(y)} r={2.2} className="w-end w-end-p2" />;
|
||||
})}
|
||||
|
||||
<Ring
|
||||
points={points1}
|
||||
placed={placed1}
|
||||
edge={R_MID}
|
||||
glyphR={R1_GLYPH}
|
||||
degR={R1_DEG}
|
||||
start={start}
|
||||
who={name1}
|
||||
timeKnown={time1}
|
||||
className="w-p1"
|
||||
/>
|
||||
<Ring
|
||||
points={points2}
|
||||
placed={placed2}
|
||||
edge={R_ZOD}
|
||||
glyphR={R2_GLYPH}
|
||||
degR={R2_DEG}
|
||||
start={start}
|
||||
who={name2}
|
||||
timeKnown={false}
|
||||
className="w-p2"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/** Key to the two rings and the aspect lines. */
|
||||
export function SynastryLegend({ name1, name2, time1 }: { name1: string; name2: string; time1: boolean }) {
|
||||
return (
|
||||
<div className="hint wheel-legend">
|
||||
<p className="wheel-legend-items">
|
||||
<span className="legend-item">
|
||||
<span className="legend-dot legend-p1" aria-hidden="true" /> belül: {name1}
|
||||
{time1 ? " (bolygók és házak)" : ""}
|
||||
</span>
|
||||
<span className="legend-item">
|
||||
<span className="legend-dot legend-p2" aria-hidden="true" /> kívül: {name2}
|
||||
</span>
|
||||
</p>
|
||||
<p className="wheel-legend-items">
|
||||
{[
|
||||
["trine", "trigon"],
|
||||
["sextile", "szextil"],
|
||||
["square", "kvadrát"],
|
||||
["opposition", "szembenállás"],
|
||||
].map(([aspect, label]) => (
|
||||
<span key={aspect} className="legend-item">
|
||||
<span className={`legend-line legend-${aspect}`} aria-hidden="true" /> {label}
|
||||
</span>
|
||||
))}
|
||||
</p>
|
||||
<p>A vonalak a két fél bolygói közti főfényszögek; vastagabb vonal: szorosabb fényszög. Az összes a táblázatokban.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user