Scatter Chart
gaia/scatter-chartFreeComponent
A scatter chart for exploring correlation between two numeric variables.
Install it
npx shadcn@latest add https://ui.heygaia.io/r/scatter-chart.jsonSource
1"use client";23import type * as React from "react";4import {5 ScatterChart as RechartsScatterChart,6 Scatter,7 XAxis,8 YAxis,9} from "recharts";10import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card";11import {12 type ChartConfig,13 ChartContainer,14 ChartTooltip,15 ChartTooltipContent,16} from "@/components/ui/chart";1718const CHART_COLORS = ["#00bbff", "#34d399", "#60a5fa", "#f472b6", "#fb923c"];1920function ChartCard({21 title,22 description,23 footer,24 children,25 dataPoints = 0,26}: {27 title?: string;28 description?: string;29 footer?: string;30 children: React.ReactNode;31 dataPoints?: number;32}) {33 const width =34 dataPoints > 0 ? Math.min(768, Math.max(300, dataPoints * 80)) : undefined;35 return (36 <Card37 className="max-w-3xl"38 style={width ? { width } : { width: "100%" }}39 >40 {(title || description) && (41 <CardHeader className="pb-0">42 {title && (43 <p className="text-sm font-semibold text-card-foreground">44 {title}45 </p>46 )}47 {description && (48 <p className="text-xs text-muted-foreground">{description}</p>49 )}50 </CardHeader>51 )}52 <CardContent>{children}</CardContent>53 {footer && (54 <CardFooter>55 <p className="text-xs text-muted-foreground">{footer}</p>56 </CardFooter>57 )}58 </Card>59 );60}6162export type ScatterChartProps = {63 data: Array<Record<string, string | number>>;64 xKey: string;65 yKey: string;66 title?: string;67 description?: string;68 footer?: string;69 labelKey?: string;70};7172export function ScatterChart(props: ScatterChartProps) {73 const chartConfig: ChartConfig = {74 scatter: { label: "Data", color: CHART_COLORS[0] },75 };76 return (77 <ChartCard78 title={props.title}79 description={props.description}80 footer={props.footer}81 dataPoints={props.data.length}82 >83 <ChartContainer config={chartConfig} className="h-50 w-full">84 <RechartsScatterChart>85 <XAxis86 dataKey={props.xKey}87 axisLine={false}88 tickLine={false}89 tick={{ fill: "#71717a", fontSize: 11 }}90 />91 <YAxis92 dataKey={props.yKey}93 axisLine={false}94 tickLine={false}95 tick={{ fill: "#71717a", fontSize: 11 }}96 />97 <ChartTooltip content={<ChartTooltipContent />} />98 <Scatter data={props.data} fill="var(--color-scatter)" />99 </RechartsScatterChart>100 </ChartContainer>101 </ChartCard>102 );103}
What it pulls in
npm packages
Other registry items
Files it writes
More from gaia
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Area Chartarea-chart | gaia | Components | Free | 1 dep | |
| Author Tooltipauthor-tooltip | gaia | Components | Free | no deps | |
| Bar Chartbar-chart | gaia | Components | Free | 1 dep | |
| Composercomposer | gaia | Components | Free | no deps | |
| Email Compose Cardemail-compose-card | gaia | Components | Free | no deps | |
| Gauge Chartgauge-chart | gaia | Components | Free | 1 dep | |
| GitHub Stars Buttongithub-stars-button | gaia | Components | Free | 1 dep | |
| Holo Cardholo-card | gaia | Components | Free | 1 dep · 2 files |
