From c741bd197247f7ffb8f578c8ec7ec40f6c2bc84a Mon Sep 17 00:00:00 2001 From: Antigravity Date: Fri, 29 May 2026 12:30:48 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20normalizeSlide=20transforme=20{label,val?= =?UTF-8?q?ue}=20=E2=86=92=20{name,value}=20pour=20recharts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le graphe était noir car recharts cherchait xKey='name' mais les données avaient {label,value}. Fix dans normalizeSlide case 'chart': - data.map({label,value} → {name,value}) - xKey: 'name', yKeys: ['value'] explicitement Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../components/lab/slides-renderer.tsx | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/memento-note/components/lab/slides-renderer.tsx b/memento-note/components/lab/slides-renderer.tsx index 540bbda..88da968 100644 --- a/memento-note/components/lab/slides-renderer.tsx +++ b/memento-note/components/lab/slides-renderer.tsx @@ -25,21 +25,10 @@ const GRID_STROKE = 'rgba(255,255,255,0.07)' // ── Chart ────────────────────────────────────────────────────────────────────── function SlideChart({ slide }: { slide: SlideSpec }) { - // Support both old format (slide.chart) and new flat format (slide.chartType + slide.data) - const chart = slide.chart ?? ( - slide.chartType || slide.data - ? { - type: slide.chartType ?? 'bar', - data: (slide.data as any[])?.map((d: any) => ({ name: d.label ?? d.name, value: d.value })) ?? [], - xKey: 'name', - yKeys: ['value'], - showLegend: true, - } - : undefined - ) + const chart = slide.chart if (!chart?.data?.length) return null - const colors = chart.colors ?? CHART_COLORS + const colors = (chart as any).colors ?? CHART_COLORS const xKey = chart.xKey ?? 'name' const yKeys = chart.yKeys ?? Object.keys(chart.data[0]).filter(k => k !== xKey) const legend = chart.showLegend !== false && yKeys.length > 1 @@ -580,7 +569,13 @@ function normalizeSlide(slide: any, index: number): SlideSpec { layout: 'chart', chart: { type: slide.chartType ?? 'bar', - data: slide.data ?? [] + // Normalize {label,value} → {name,value} so recharts xKey='name' works + data: (slide.data ?? []).map((d: any) => ({ + name: d.label ?? d.name ?? '', + value: typeof d.value === 'number' ? d.value : Number(d.value) || 0, + })), + xKey: 'name', + yKeys: ['value'], }, notes: slide.notes }