import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, DialogDescription } from "@/components/ui/dialog"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Code, Table as TableIcon, BarChart as ChartIcon, Download, LayoutDashboard, Loader2 } from "lucide-react"; import { ScrollArea } from "@/components/ui/scroll-area"; import { useDashboardStore } from "@/store/dashboardStore"; import { useVisualizationStore } from "@/store/visualizationStore"; import { VegaChart } from "./VegaChart"; export function VisualizationPanel() { const [view, setView] = useState<'table' | 'chart'>('chart'); const { addChart } = useDashboardStore(); const { currentData, currentSQL, currentChartSpec, currentChartInfo, isLoading, error } = useVisualizationStore(); const handleAddToDashboard = () => { if (!currentData || !currentSQL) return; const mark = currentChartSpec?.mark; const markType = typeof mark === "string" ? mark : mark?.type; const dashboardType = markType === "line" ? "line" : "bar"; addChart({ id: Date.now().toString(), title: currentChartSpec?.title || 'Generated Analysis', type: dashboardType, data: currentData, sql: currentSQL, }); alert("Added to Dashboard!"); }; if (isLoading) { return (
No data to visualize.
Ask the chat to generate some insights!
Data format is not supported for visualization.
No chart configuration available for this data.