Price Chart
solanaui/price-chartFreeComponent
An area chart for displaying token price history over time using Recharts.
Live preview
live · rendered by the registry
Rendered by solanaui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solanaui.dev/r/price-chart.jsonSource
1"use client";23import React from "react";4import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts";5import {6 type ChartConfig,7 ChartContainer,8 ChartTooltip,9 ChartTooltipContent,10} from "@/components/ui/chart";11import { cn } from "@/lib/utils";1213interface PriceChartProps {14 title?: string;15 description?: string;16 series: {17 time: string;18 value: number;19 }[];20 className?: string;21}2223const POSITIVE_COLOR = "hsl(160 84% 39%)";24const NEGATIVE_COLOR = "hsl(0 84% 67%)";2526const chartConfig = {27 value: {28 label: "Value",29 },30} satisfies ChartConfig;3132const PriceChart = ({33 title,34 description,35 series,36 className,37}: PriceChartProps) => {38 const gradientId = React.useId();3940 if (!series.length) return null;4142 const firstValue = series[0].value;43 const lastValue = series[series.length - 1].value;44 const isPositive = lastValue >= firstValue;45 const chartColor = isPositive ? POSITIVE_COLOR : NEGATIVE_COLOR;4647 const minValue = Math.min(...series.map((s) => s.value));48 const maxValue = Math.max(...series.map((s) => s.value));49 const padding = (maxValue - minValue) * 0.1;5051 return (52 <div53 className={cn(54 "flex min-h-0 flex-1 flex-col gap-4 rounded-lg border bg-card p-4",55 className,56 )}57 >58 {(title || description) && (59 <div className="flex flex-col gap-0.5">60 {title && (61 <h3 className="text-base font-semibold tracking-tight">{title}</h3>62 )}63 {description && (64 <p className="text-sm text-muted-foreground">{description}</p>65 )}66 </div>67 )}68 <ChartContainer config={chartConfig} className="min-h-0 flex-1 w-full">69 <AreaChart accessibilityLayer data={series}>70 <defs>71 <linearGradient id={gradientId} x1="0" y1="0" x2="0" y2="1">72 <stop offset="0%" stopColor={chartColor} stopOpacity={0.2} />73 <stop offset="100%" stopColor={chartColor} stopOpacity={0} />74 </linearGradient>75 </defs>76 <CartesianGrid77 vertical={false}78 strokeDasharray="3 3"79 stroke="var(--border)"80 />81 <XAxis82 dataKey="time"83 tickLine={false}84 axisLine={false}85 tickMargin={8}86 tickFormatter={(value: string) => {87 const date = new Date(value);88 return date.toLocaleDateString("en-US", {89 month: "short",90// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from solanaui
All 31 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Action Boxaction-box | solanaui | Components | Free | no deps | |
| Activity Feedactivity-feed | solanaui | Components | Free | 1 dep | |
| Address Displayaddress-display | solanaui | Components | Free | 1 dep | |
| Auth Cardauth-card | solanaui | Components | Free | no deps | |
| Health Barhealth-bar | solanaui | Components | Free | no deps | |
| Leverage Sliderleverage-slider | solanaui | Components | Free | no deps | |
| NFT Cardnft-card | solanaui | Components | Free | no deps | |
| Order Bookorder-book | solanaui | Components | Free | no deps |
