Animated Bar Chart
remocn/animated-bar-chartFreeComponent
Bars spring up from the baseline in a staggered cascade.
Install it
npx shadcn@latest add https://www.remocn.dev/r/animated-bar-chart.jsonSource
1"use client";23import { spring, useCurrentFrame, useVideoConfig } from "remotion";45export interface AnimatedBarChartProps {6 data?: number[];7 labels?: string[];8 width?: number;9 height?: number;10 barColor?: string;11 gap?: number;12 staggerFrames?: number;13 speed?: number;14 className?: string;15}1617export function AnimatedBarChart({18 data = [35, 60, 45, 80, 55, 70, 90, 65],19 labels,20 width = 1000,21 height = 500,22 barColor = "#0ea5e9",23 gap = 16,24 staggerFrames = 6,25 speed = 1,26 className,27}: AnimatedBarChartProps) {28 const frame = useCurrentFrame() * speed;29 const { fps } = useVideoConfig();3031 const padding = 60;32 const labelSpace = labels ? 40 : 0;33 const innerWidth = width - padding * 2;34 const innerHeight = height - padding * 2 - labelSpace;35 const max = Math.max(...data);36 const barWidth = (innerWidth - gap * (data.length - 1)) / data.length;37 const baseY = padding + innerHeight;3839 return (40 <div41 className={className}42 style={{43 position: "absolute",44 inset: 0,45 display: "flex",46 alignItems: "center",47 justifyContent: "center",48 fontFamily:49 "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",50 }}51 >52 <svg width={width} height={height} viewBox={`0 0 ${width} ${height}`}>53 {/* Baseline */}54 <line55 x1={padding}56 x2={padding + innerWidth}57 y1={baseY}58 y2={baseY}59 stroke="#27272a"60 strokeWidth={2}61 />6263 {data.map((value, index) => {64 const targetHeight = (value / max) * innerHeight;65 const x = padding + index * (barWidth + gap);66 const y = baseY - targetHeight;6768 const scaleY = spring({69 frame: frame - index * staggerFrames,70 fps,71 config: { damping: 12, stiffness: 100, mass: 0.8 },72 from: 0,73 to: 1,74 });7576 return (77 <g key={index}>78 <rect79 x={x}80 y={y}81 width={barWidth}82 height={targetHeight}83 rx={6}84 fill={barColor}85 style={{86 transform: `scaleY(${scaleY})`,87 transformOrigin: `${x + barWidth / 2}px ${baseY}px`,88 transformBox: "fill-box",89 filter: `drop-shadow(0 4px 16px ${barColor}55)`,90 }}91 />92// … truncated
What it pulls in
npm packages
Files it writes
More from remocn
All 282 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| UI Accordionaccordion | remocn | Components | Free | 1 dep · 2 files | |
| UI AI Prompt Flowai-prompt-flow | remocn | Components | Free | 1 dep | |
| UI Alert Dialogalert-dialog | remocn | Components | Free | 1 dep · 2 files | |
| Animated Line Chartanimated-line-chart | remocn | Components | Free | 1 dep | |
| ASCII Dissolveascii-dissolve | remocn | Components | Free | 2 deps | |
| ASCII Renderascii-render | remocn | Components | Free | 1 dep | |
| Backdropbackdrop | remocn | Components | Free | 1 dep | |
| UI Blur Inblur-in | remocn | Components | Free | 1 dep · 2 files |
