3 pages (market, PRINZIP drilldown, developers leaderboard) on top of existing v_developer_full_metrics + domrf_realization views. ECharts on the frontend, FastAPI router /api/v1/analytics on the backend.
41 lines
997 B
TypeScript
41 lines
997 B
TypeScript
"use client";
|
|
|
|
import { useMemo } from "react";
|
|
|
|
import { useYandexListings } from "@/lib/analytics-api";
|
|
|
|
import { ChartShell } from "./ChartShell";
|
|
|
|
const CLASS_LABELS: Record<string, string> = {
|
|
ECONOM: "Эконом",
|
|
COMFORT: "Комфорт",
|
|
COMFORT_PLUS: "Комфорт+",
|
|
BUSINESS: "Бизнес",
|
|
ELITE: "Элит",
|
|
};
|
|
|
|
export function YandexClassPie() {
|
|
const { data, isLoading } = useYandexListings();
|
|
|
|
const option = useMemo(() => {
|
|
const rows = data?.by_class ?? [];
|
|
return {
|
|
tooltip: { trigger: "item" },
|
|
legend: { bottom: 0 },
|
|
series: [
|
|
{
|
|
type: "pie",
|
|
radius: ["45%", "70%"],
|
|
avoidLabelOverlap: false,
|
|
label: { formatter: "{b}: {c}" },
|
|
data: rows.map((r) => ({
|
|
name: CLASS_LABELS[r.obj_class] ?? r.obj_class,
|
|
value: r.count,
|
|
})),
|
|
},
|
|
],
|
|
};
|
|
}, [data]);
|
|
|
|
return <ChartShell option={option} loading={isLoading} height={300} />;
|
|
}
|