Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

3.1 KB
Raw Blame
---
title: Animated Line Chart
description: A line chart whose path draws on from left to right
component: animated-line-chart
vibe: data
length: 90
useWhen:
  - "Showing growth or trend over time — revenue curve, DAU climb, error-rate drop."
  - "A SaaS demo needs a \"hockey stick\" moment where the line visibly inflects upward."
  - "You want a single continuous reveal motion rather than per-bar stagger."
avoidWhen:
  - "The data is categorical (not time-ordered) — use `animated-bar-chart` to compare discrete values side by side."
  - "You have only 2–3 data points; a near-straight line adds little; use a number counter or a headline stat instead."
askedAs:
  - "line graph drawing"
  - "growth curve drawing itself"
  - "I want a trend line that draws from left to right"
  - "show growth over time with a path tracing across the chart"
  - "investor-style moment where the upward line proves traction"
  - "data scene showing a metric climbing across months"
---

<ComponentPreview name="animated-line-chart" />

<InstallBlock name="animated-line-chart" />

## Usage

```tsx
// src/Root.tsx
import { Composition } from "remotion";
import { AnimatedLineChart } from "@/components/remocn/animated-line-chart";

const AnimatedLineChartScene = () => (
  <AnimatedLineChart
    data={[12, 19, 8, 15, 22, 18, 28, 25, 32]}
    strokeColor="#22c55e"
  />
);

export const RemotionRoot = () => (
  <Composition
    id="AnimatedLineChart"
    component={AnimatedLineChartScene}
    durationInFrames={90}
    fps={30}
    width={1280}
    height={720}
  />
);
```

### With Backdrop

Renders transparent — supply the background via `Backdrop`:

```tsx
import { Backdrop } from "@/components/remocn/backdrop";
import { AnimatedLineChart } from "@/components/remocn/animated-line-chart";

<Backdrop fill={{ type: "color", value: "#0a0a0a" }}>
  <AnimatedLineChart data={[12, 19, 8, 15, 22, 18, 28, 25, 32]} strokeColor="#22c55e" />
</Backdrop>
```

<PropsTable title="Props"
  rows={[
    {
      name: "data",
      type: "number[]",
      default: "[12, 19, 8, 15, 22, 18, 28, 25, 32]",
      description: "Y-values of the chart. Auto-scaled to the available height.",
    },
    {
      name: "width",
      type: "number",
      default: "1000",
      description: "SVG viewBox width",
    },
    {
      name: "height",
      type: "number",
      default: "500",
      description: "SVG viewBox height",
    },
    {
      name: "strokeColor",
      type: "string",
      default: "\"#22c55e\"",
      description: "Color of the line stroke",
    },
    {
      name: "strokeWidth",
      type: "number",
      default: "4",
      description: "Line stroke width in pixels",
    },
    {
      name: "gridColor",
      type: "string",
      default: "\"#27272a\"",
      description: "Grid and axis line color",
    },
    {
      name: "showDot",
      type: "boolean",
      default: "true",
      description: "Render a dot at the leading edge of the line as it draws",
    },
    {
      name: "className",
      type: "string",
      description: "Optional className passed to the outer container",
    },
  ]}
/>