recharts-composed-chart
evilcharts/recharts-composed-chartFreeComponent
Composed chart component combining bar and line charts
Install it
npx shadcn@latest add https://evilcharts.com/r/recharts-composed-chart.jsonSource
1"use client";23import {4 Children,5 createContext,6 isValidElement,7 use,8 useCallback,9 useId,10 useMemo,11 useRef,12 useState,13 type ComponentProps,14 type FC,15 type ReactElement,16 type ReactNode,17} from "react";18import {19 Bar as RechartsBar,20 CartesianGrid,21 ComposedChart as RechartsComposedChart,22 Line as RechartsLine,23 XAxis as RechartsXAxis,24 YAxis as RechartsYAxis,25} from "recharts";26import {27 type ChartConfig,28 ChartContainer,29 getColorsCount,30 getLoadingData,31 LoadingIndicator,32} from "@/registry/ui/recharts-chart";33import {34 ChartTooltip,35 ChartTooltipContent,36 type TooltipRoundness,37 type TooltipVariant,38} from "@/registry/ui/recharts-tooltip";39import { ChartLegend, ChartLegendContent, type ChartLegendVariant } from "@/registry/ui/recharts-legend";40import { Brush, EvilBrush, useEvilBrush, type BrushProps, type EvilBrushRange } from "@/registry/ui/recharts-brush";41import { ChartDot, type DotVariant } from "@/registry/ui/recharts-dot";42import { motion, useReducedMotion } from "motion/react";4344// Constants45const STROKE_WIDTH = 2;46const DEFAULT_BAR_RADIUS = 4;47const LOADING_DATA_KEY = "loading";48const LOADING_ANIMATION_DURATION = 2000; // in milliseconds49const REVEAL_DURATION = 1; // line intro wipe length, in seconds50const REVEAL_EASE: [number, number, number, number] = [0, 0.7, 0.5, 1]; // intro easing51const BAR_GROW_DURATION = 0.5; // per-bar grow-in length, in seconds52const BAR_STAGGER = 0.05; // delay between consecutive bars, in seconds5354type CurveType = ComponentProps<typeof RechartsLine>["type"];55type LineDotProp = ComponentProps<typeof RechartsLine>["dot"];56type LineActiveDotProp = ComponentProps<typeof RechartsLine>["activeDot"];57type StrokeVariant = "solid" | "dashed" | "animated-dashed";58type BarVariant = "default" | "hatched" | "duotone" | "duotone-reverse" | "gradient" | "stripped";5960/**61 * Direction of the custom motion.dev intro. Recharts' own animation is62 * permanently disabled — lines wipe in along this direction, while bars grow up63 * from their baseline staggered in this same order.64 *65 * NOTE: the intro is a per-frame animation, heavier than a static chart.66 * `"none"` opts out — as does a device with the OS "reduce motion" preference.67 */68type ComposedAnimationType = "none" | "left-to-right" | "right-to-left" | "center-out" | "edges-in";69type RevealAnimationType = Exclude<ComposedAnimationType, "none">;7071// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from EvilCharts
All 271 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| echarts-area-chartecharts-area-chart | EvilCharts | Components | Free | 2 deps | |
| echarts-bar-chartecharts-bar-chart | EvilCharts | Components | Free | 2 deps | |
| echarts-brushecharts-brush | EvilCharts | Components | Free | 1 dep | |
| echarts-chartecharts-chart | EvilCharts | Components | Free | 1 dep | |
| echarts-composed-chartecharts-composed-chart | EvilCharts | Components | Free | 2 deps | |
| echarts-dotecharts-dot | EvilCharts | Components | Free | 1 dep | |
| echarts-legendecharts-legend | EvilCharts | Components | Free | no deps | |
| echarts-line-chartecharts-line-chart | EvilCharts | Components | Free | 2 deps |
