import { Bar, BarChart, CartesianGrid, Legend, Line, LineChart, ResponsiveContainer, Scatter, ScatterChart, Tooltip, XAxis, YAxis, } from "recharts"; import type { ChatResult } from "./types"; const seriesColors = ["#36589f", "#6379ad", "#8e9bc0", "#203968"]; function formatValue(value: unknown) { if (typeof value === "number") { return new Intl.NumberFormat("en-IN", { maximumFractionDigits: 2 }).format(value); } return String(value ?? ""); } export function AnalysisChart({ result }: { result: ChatResult }) { if ( result.visualization === "none" || !result.rows.length || !result.x_key || !result.y_keys.length ) { return null; } const common = ( <> {result.y_keys.length > 1 ? ( ) : null} ); return (
{result.title ?
{result.title}
: null}
{result.visualization === "bar" ? ( {common} {result.y_keys.map((key, index) => ( ))} ) : result.visualization === "scatter" ? ( ) : ( {common} {result.y_keys.map((key, index) => ( ))} )}
); }