terra vidhal

Stats Chart Tabs

Dashboards 2

About

A polished analytics panel with an animated headline metric, a keyboard-friendly and controlled or uncontrolled period tab switcher, and a self-drawing area, line or bar chart. Each period can plot several series, such as revenue by channel, with individual accents, dashed lines and area fills; a previous period is drawn as a dashed comparison. Goal and average references, labelled event annotations, multi-series hover and keyboard tooltips, peak insight, axis labels and per-period summary figures are all optional. Visitors can switch the chart treatment, the plot measures its own width so curves and dots stay undistorted, and it ships as a card, glass surface or borderless panel with loading, empty and pre-focused tooltip states.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Stats Chart Tabs to your project and fits it to your theme.

Code

How Stats Chart Tabs is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

/**
 * PrequelUI Animate — MIT — https://prequeluianimate.terravidhal.me
 */

import { StatsChartTabs, type StatsPeriod } from "@/components/ui/stats-chart-tabs";

const PERIODS: StatsPeriod[] = [
  {
    id: "week",
    label: "Week",
    value: 48_280,
    delta: 8.2,
    labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
    points: [6_100, 6_900, 6_300, 7_600, 7_200, 8_100, 6_080],
    series: [
      {
        id: "organic",
        label: "Organic",
        tone: "violet",
        points: [2_500, 2_800, 2_600, 3_100, 2_900, 3_300, 2_500],
      },
      {
        id: "paid",
        label: "Paid",
        tone: "sky",
        points: [2_100, 2_400, 2_200, 2_700, 2_600, 2_900, 2_100],
      },
      {
        id: "referral",
        label: "Referral",
        tone: "emerald",
        points: [1_500, 1_700, 1_500, 1_800, 1_700, 1_900, 1_480],
      },
    ],
    markers: [{ index: 5, label: "Weekend", tone: "primary" }],
  },
  {
    id: "month",
    label: "Month",
    value: 186_900,
    delta: 12.4,
    labels: ["1", "4", "7", "10", "13", "16", "19", "22", "25", "28"],
    points: [
      16_400, 17_800, 16_900, 19_600, 18_400, 20_100, 19_200, 21_500, 18_900,
      18_100,
    ],
    series: [
      {
        id: "organic",
        label: "Organic",
        tone: "violet",
        points: [
          6_800, 7_200, 6_900, 7_900, 7_400, 8_100, 7_700, 8_700, 7_600, 7_300,
        ],
      },
      {
        id: "paid",
        label: "Paid",
        tone: "sky",
        points: [
          5_600, 6_100, 5_800, 7_000, 6_400, 7_100, 6_700, 7_600, 6_700, 6_300,
        ],
      },
      {
        id: "referral",
        label: "Referral",
        tone: "emerald",
        points: [
          4_000, 4_500, 4_200, 4_700, 4_600, 4_900, 4_800, 5_200, 4_600, 4_500,
        ],
      },
    ],
    markers: [
      { index: 3, label: "Payday", tone: "emerald" },
      { index: 7, label: "Promo", tone: "amber" },
    ],
  },
  {
    id: "year",
    label: "Year",
    value: 742_310,
    delta: -3.1,
    labels: [
      "Jan",
      "Feb",
      "Mar",
      "Apr",
      "May",
      "Jun",
      "Jul",
      "Aug",
      "Sep",
      "Oct",
      "Nov",
      "Dec",
    ],
    points: [
      52_100, 58_300, 61_900, 64_600, 59_400, 66_800, 63_500, 68_200, 61_700,
      70_400, 55_300, 60_110,
    ],
    series: [
      {
        id: "organic",
        label: "Organic",
        tone: "violet",
        points: [
          20_840, 23_320, 24_760, 25_840, 23_760, 26_720, 25_400, 27_280,
          24_680, 28_160, 22_120, 24_044,
        ],
      },
      {
        id: "paid",
        label: "Paid",
        tone: "sky",
        points: [
          18_235, 20_405, 21_665, 22_610, 20_790, 23_380, 22_225, 23_870,
          21_595, 24_640, 19_355, 21_039,
        ],
      },
      {
        id: "referral",
        label: "Referral",
        tone: "emerald",
        points: [
          13_025, 14_575, 15_475, 16_150, 14_850, 16_700, 15_875, 17_050,
          15_425, 17_600, 13_825, 15_027,
        ],
      },
    ],
    markers: [{ index: 9, label: "Launch", tone: "rose" }],
  },
];

export default function StatsChartTabsDemo() {
  return (
    <main className="flex min-h-screen w-full items-center justify-center bg-background px-6 py-16">
      <StatsChartTabs
        title="Revenue"
        periods={PERIODS}
        defaultPeriod="month"
        defaultActiveIndex={7}
        prefix="$"
        accent="violet"
        currentLabel="Total"
        chart="area"
        chartHeight={320}
        variant="plain"
        showChartSwitcher
        showInsight={false}
      />
    </main>
  );
}

Dependencies

More by terra vidhal

View all
  • Gravity Stars Background

    Gravity Stars Background

    16
  • Audio Waveform

    Audio Waveform

    13
  • Topographic Lines

    Topographic Lines

    12
  • Notification Center

    Notification Center

    11
  • Booking Calendar

    Booking Calendar

    11
  • Spotlight Card

    Spotlight Card

    11
  • Command Palette

    Command Palette

    9
  • Kpi Counter

    Kpi Counter

    9

More in Dashboards

View all
  • Creator Dashboard

    Creator Dashboard

    160
  • serf dashboard

    serf dashboard

    108
  • Dashboard with Collapsible Sidebar

    Dashboard with Collapsible Sidebar

    2.7K
  • Glass Dashboard

    Glass Dashboard

    1.3K
  • Glass Smart Home Dashboard

    Glass Smart Home Dashboard

    53
  • Adjustable Glass Dashboard

    Adjustable Glass Dashboard

    1.2K
  • App Dashboard Layout

    App Dashboard Layout

    591
  • Admin Dashboard Cards

    Admin Dashboard Cards

    18