Compare commits

..

No commits in common. "dae2b5a5d9b1265c716d2176618af95422166491" and "86f4602f1d345dc75d240e3e81b1e7759a66bbf9" have entirely different histories.

5 changed files with 125 additions and 140 deletions

View file

@ -25,7 +25,6 @@ interface Props {
} }
const BIN_COUNT = 12; const BIN_COUNT = 12;
const MIN_CHART_ANALOGS = 8;
const fmtK = (n: number) => `${Math.round(n / 1000)}k`; const fmtK = (n: number) => `${Math.round(n / 1000)}k`;
interface Bin { interface Bin {
@ -75,7 +74,7 @@ export function DistributionCard({ estimate }: Props) {
return out; return out;
}, [estimate.analogs, subject]); }, [estimate.analogs, subject]);
// Empty state: меньше 3 валидных аналогов — бины не строим вовсе. // Empty state: меньше 3 валидных аналогов — распределение не показываем.
if (bins.length === 0) return null; if (bins.length === 0) return null;
const n = estimate.analogs.filter((l) => l.price_per_m2 > 0).length; const n = estimate.analogs.filter((l) => l.price_per_m2 > 0).length;
@ -95,73 +94,63 @@ export function DistributionCard({ estimate }: Props) {
</div> </div>
</div> </div>
{n < MIN_CHART_ANALOGS ? ( {/* #835: декоративный чарт — aria-hidden (данные в тексте/легенде карточки). */}
<div className="card-body"> <div aria-hidden="true" style={{ width: "100%", height: 260, padding: "12px 8px 0" }}>
<p style={{ color: "var(--muted)", textAlign: "center", padding: "24px 0" }}> <ResponsiveContainer>
Мало аналогов для графика нужно не менее {MIN_CHART_ANALOGS}. <BarChart data={bins} margin={{ top: 8, right: 16, left: 8, bottom: 8 }}>
</p> <CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
</div> <XAxis
) : ( dataKey="mid"
<> type="number"
{/* #835: декоративный чарт — aria-hidden (данные в тексте/легенде карточки). */} domain={["dataMin", "dataMax"]}
<div aria-hidden="true" style={{ width: "100%", height: 260, padding: "12px 8px 0" }}> tickFormatter={fmtK}
<ResponsiveContainer> tick={{ fontSize: 11 }}
<BarChart data={bins} margin={{ top: 8, right: 16, left: 8, bottom: 8 }}> />
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" /> <YAxis allowDecimals={false} tick={{ fontSize: 11 }} />
<XAxis <Tooltip
dataKey="mid" cursor={{ fill: "var(--surface-3)" }}
type="number" formatter={(value: number) => [`${value} лот.`, "В диапазоне"]}
domain={["dataMin", "dataMax"]} labelFormatter={(mid: number) => {
tickFormatter={fmtK} const b = bins.find((x) => x.mid === mid);
tick={{ fontSize: 11 }} return b
? `${Math.round(b.start).toLocaleString("ru-RU")}${Math.round(
b.end,
).toLocaleString("ru-RU")} /м²`
: `${Math.round(mid).toLocaleString("ru-RU")} ₽/м²`;
}}
/>
<Bar dataKey="count" radius={[3, 3, 0, 0]}>
{bins.map((b, i) => (
<Cell
key={i}
fill={b.isSubject ? "var(--accent-2)" : "var(--accent)"}
fillOpacity={b.isSubject ? 1 : 0.55}
/> />
<YAxis allowDecimals={false} tick={{ fontSize: 11 }} /> ))}
<Tooltip </Bar>
cursor={{ fill: "var(--surface-3)" }} <ReferenceLine
formatter={(value: number) => [`${value} лот.`, "В диапазоне"]} x={subject}
labelFormatter={(mid: number) => { stroke="var(--accent-2)"
const b = bins.find((x) => x.mid === mid); strokeWidth={2}
return b strokeDasharray="4 2"
? `${Math.round(b.start).toLocaleString("ru-RU")}${Math.round( label={{
b.end, value: "ваша квартира",
).toLocaleString("ru-RU")} /м²` position: "top",
: `${Math.round(mid).toLocaleString("ru-RU")} ₽/м²`; fontSize: 11,
}} fill: "var(--accent-2)",
/> }}
<Bar dataKey="count" radius={[3, 3, 0, 0]}> />
{bins.map((b, i) => ( </BarChart>
<Cell </ResponsiveContainer>
key={i} </div>
fill={b.isSubject ? "var(--accent-2)" : "var(--accent)"}
fillOpacity={b.isSubject ? 1 : 0.55}
/>
))}
</Bar>
<ReferenceLine
x={subject}
stroke="var(--accent-2)"
strokeWidth={2}
strokeDasharray="4 2"
label={{
value: "ваша квартира",
position: "top",
fontSize: 11,
fill: "var(--accent-2)",
}}
/>
</BarChart>
</ResponsiveContainer>
</div>
<div className="table-foot"> <div className="table-foot">
<span> <span>
Ваша оценка:{" "} Ваша оценка:{" "}
<b style={{ color: "var(--fg)" }}>{subject.toLocaleString("ru-RU")} /м²</b> · <b style={{ color: "var(--fg)" }}>{subject.toLocaleString("ru-RU")} /м²</b> ·
оранжевый столбец ваш диапазон оранжевый столбец ваш диапазон
</span> </span>
</div> </div>
</>
)}
</article> </article>
); );
} }

View file

@ -25,7 +25,6 @@ interface Props {
estimate: AggregatedEstimate; estimate: AggregatedEstimate;
} }
const MIN_CHART_ANALOGS = 8;
const fmtM = (n: number) => `${(n / 1_000_000).toFixed(1)}`; const fmtM = (n: number) => `${(n / 1_000_000).toFixed(1)}`;
interface Point { interface Point {
@ -73,74 +72,64 @@ export function ExposureCard({ estimate }: Props) {
</div> </div>
</div> </div>
{points.length < MIN_CHART_ANALOGS ? ( {/* #835: чарт декоративный (данные в заголовке/легенде/тексте карточки);
<div className="card-body"> aria-hidden убирает recharts symbol'ы role="img" без accessible-name. */}
<p style={{ color: "var(--muted)", textAlign: "center", padding: "24px 0" }}> <div aria-hidden="true" style={{ width: "100%", height: 280, padding: "12px 8px 0" }}>
Недостаточно данных для графика нужно не менее {MIN_CHART_ANALOGS} аналогов со сроком. <ResponsiveContainer>
</p> <ScatterChart margin={{ top: 8, right: 20, left: 8, bottom: 16 }}>
</div> <CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
) : ( <XAxis
<> type="number"
{/* #835: чарт декоративный (данные в заголовке/легенде/тексте карточки); dataKey="price"
aria-hidden убирает recharts symbol'ы role="img" без accessible-name. */} name="Цена"
<div aria-hidden="true" style={{ width: "100%", height: 280, padding: "12px 8px 0" }}> tickFormatter={fmtM}
<ResponsiveContainer> tick={{ fontSize: 11 }}
<ScatterChart margin={{ top: 8, right: 20, left: 8, bottom: 16 }}> domain={["auto", "auto"]}
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" /> label={{ value: "млн ₽", position: "insideBottomRight", offset: -8, fontSize: 11 }}
<XAxis />
type="number" <YAxis
dataKey="price" type="number"
name="Цена" dataKey="days"
tickFormatter={fmtM} name="Срок"
tick={{ fontSize: 11 }} tick={{ fontSize: 11 }}
domain={["auto", "auto"]} label={{ value: "дней", angle: -90, position: "insideLeft", fontSize: 11 }}
label={{ value: "млн ₽", position: "insideBottomRight", offset: -8, fontSize: 11 }} />
/> <ZAxis range={[60, 60]} />
<YAxis <Tooltip
type="number" cursor={{ strokeDasharray: "3 3" }}
dataKey="days" formatter={(value: number, name: string) =>
name="Срок" name === "Цена"
tick={{ fontSize: 11 }} ? [`${value.toLocaleString("ru-RU")}`, name]
label={{ value: "дней", angle: -90, position: "insideLeft", fontSize: 11 }} : [`${value} дн.`, name]
/> }
<ZAxis range={[60, 60]} /> />
<Tooltip <Scatter
cursor={{ strokeDasharray: "3 3" }} data={points}
formatter={(value: number, name: string) => fill="var(--accent)"
name === "Цена" fillOpacity={0.6}
? [`${value.toLocaleString("ru-RU")}`, name] />
: [`${value} дн.`, name] <ReferenceLine
} x={subjectPrice}
/> stroke="var(--accent-2)"
<Scatter strokeWidth={2}
data={points} strokeDasharray="4 2"
fill="var(--accent)" label={{
fillOpacity={0.6} value: "ваша цена",
/> position: "top",
<ReferenceLine fontSize: 11,
x={subjectPrice} fill: "var(--accent-2)",
stroke="var(--accent-2)" }}
strokeWidth={2} />
strokeDasharray="4 2" </ScatterChart>
label={{ </ResponsiveContainer>
value: "ваша цена", </div>
position: "top",
fontSize: 11,
fill: "var(--accent-2)",
}}
/>
</ScatterChart>
</ResponsiveContainer>
</div>
<div className="table-foot"> <div className="table-foot">
<span> <span>
Каждая точка аналог в продаже · вертикаль ваша оценка{" "} Каждая точка аналог в продаже · вертикаль ваша оценка{" "}
<b style={{ color: "var(--fg)" }}>{fmtM(subjectPrice)} млн </b> <b style={{ color: "var(--fg)" }}>{fmtM(subjectPrice)} млн </b>
</span> </span>
</div> </div>
</>
)}
</article> </article>
); );
} }

View file

@ -46,10 +46,10 @@ export function PriceHistoryChart({ points }: Props) {
<article className="card" style={{ marginTop: 12, padding: 16 }}> <article className="card" style={{ marginTop: 12, padding: 16 }}>
<header style={{ marginBottom: 8 }}> <header style={{ marginBottom: 8 }}>
<h4 style={{ margin: 0, fontSize: 14, fontWeight: 600 }}> <h4 style={{ margin: 0, fontSize: 14, fontWeight: 600 }}>
История цен в этом доме Динамика цен в доме
</h4> </h4>
<small style={{ color: "var(--muted, #6b7280)" }}> <small style={{ color: "var(--muted, #6b7280)" }}>
Медиана /м² по годам · только этот дом · Avito + Яндекс ({totalLots} лотов) Медиана /м² по году · Avito + Яндекс (по {totalLots} лотам)
</small> </small>
</header> </header>
{/* #835: декоративный чарт — aria-hidden (данные в тексте/легенде карточки). */} {/* #835: декоративный чарт — aria-hidden (данные в тексте/легенде карточки). */}

View file

@ -58,8 +58,8 @@ export function PriceTrendCard({ estimate }: Props) {
<article className="card"> <article className="card">
<div className="card-head"> <div className="card-head">
<div> <div>
<div className="section-kicker">Аналитика · Тренд рынка</div> <div className="section-kicker">Аналитика · Тренд</div>
<h2>Динамика /м² по рынку района</h2> <h2>Динамика /м²</h2>
</div> </div>
<div className="card-meta"> <div className="card-meta">
<div> <div>
@ -101,7 +101,7 @@ export function PriceTrendCard({ estimate }: Props) {
<div className="table-foot"> <div className="table-foot">
<span> <span>
Медиана /м² по аналогам рынка · {fmtMonth(data[0].month)} {" "} Медиана /м² по месяцам · {fmtMonth(data[0].month)} {" "}
{fmtMonth(data[data.length - 1].month)} {fmtMonth(data[data.length - 1].month)}
</span> </span>
</div> </div>

View file

@ -198,6 +198,13 @@ export function SourcesProgress({ estimate, isPending }: Props) {
</div> </div>
<div className="card-foot"> <div className="card-foot">
<span className="mono" style={{ fontSize: 11, letterSpacing: "0.06em" }}>
CACHE-KEY ·{" "}
</span>
<span className="mono" style={{ fontSize: 11 }}>
{estimate?.estimate_id?.slice(0, 18) ?? "—"}
</span>{" "}
·{" "}
<span>при недоступности источника частичный результат не блокируется</span> <span>при недоступности источника частичный результат не блокируется</span>
</div> </div>
</article> </article>