"use client"; import { useApp } from "@/contexts/AppContext"; import { useEffect, useRef } from "react"; import * as echarts from "echarts"; export default function AssetDistribution() { const { t } = useApp(); const chartRef = useRef(null); const legends = [ { nameKey: "transparency.fixedIncome", color: "bg-[#1447e6]" }, { nameKey: "transparency.alternativeAssets", color: "bg-[#10b981]" }, { nameKey: "transparency.alternativeCredit", color: "bg-[#ff6900]" }, ]; useEffect(() => { if (!chartRef.current) return; const chart = echarts.init(chartRef.current, null, { renderer: "svg", }); const option = { series: [ { type: "pie", radius: ["45%", "70%"], center: ["50%", "50%"], avoidLabelOverlap: true, itemStyle: { borderRadius: 0, borderColor: "transparent", borderWidth: 0, }, label: { show: true, position: "outside", alignTo: "none", formatter: (params: any) => { return `{name|${params.name}}\n{line|}\n{value|${params.data.displayValue}}`; }, rich: { name: { fontSize: 14, fontWeight: "bold", color: "#0f172b", lineHeight: 20, }, line: { height: 1, width: 100, backgroundColor: "transparent", }, value: { fontSize: 12, fontWeight: "500", lineHeight: 18, }, }, }, labelLine: { show: true, length: 20, length2: 60, lineStyle: { width: 1, }, }, emphasis: { disabled: true, }, data: [ { value: 52.7, name: t("transparency.usTreasuryBills"), displayValue: "$140M (30.1%)", itemStyle: { color: "#1447e6", }, label: { rich: { value: { color: "#1447e6", }, }, }, labelLine: { lineStyle: { color: "#1447e6", }, }, }, { value: 30.1, name: t("transparency.realEstate"), displayValue: "$140M (30.1%)", itemStyle: { color: "#10b981", }, label: { rich: { value: { color: "#10b981", }, }, }, labelLine: { lineStyle: { color: "#10b981", }, }, }, { value: 17.2, name: t("transparency.privateCredit"), displayValue: "$80M (17.2%)", itemStyle: { color: "#ff6900", }, label: { rich: { value: { color: "#ff6900", }, }, }, labelLine: { lineStyle: { color: "#ff6900", }, }, }, ], animationType: "expansion", animationEasing: "cubicOut", animationDuration: 1000, }, ], }; chart.setOption(option); const handleResize = () => { chart.resize(); }; window.addEventListener("resize", handleResize); return () => { window.removeEventListener("resize", handleResize); chart.dispose(); }; }, [t]); return (
{/* Header */}

{t("transparency.assetDistribution")}

{t("transparency.distributionSubtitle")}

{/* Pie Chart Section */}
{/* ECharts Pie Chart */}
{/* Center 100 */}
100
{/* Legends */}
{legends.map((legend, index) => (
{t(legend.nameKey)}
))}
); }