Background
Customize the background of your charts with various styles and patterns
Usage
<EvilLineChart
xDataKey="month"
data={data}
chartConfig={chartConfig}
backgroundVariant="dots"
/>Variants
Dots
backgroundVariant='dots'
Grid
backgroundVariant='grid'
Cross Hatch
backgroundVariant='cross-hatch'
Diagonal Lines
backgroundVariant='diagonal-lines'
Plus
backgroundVariant='plus'
Falling Triangles
backgroundVariant='falling-triangles'
4-Pointed Star
backgroundVariant='4-pointed-star'
Tiny Checkers
backgroundVariant='tiny-checkers'
Overlapping Circles
backgroundVariant='overlapping-circles'
Wiggle Lines
backgroundVariant='wiggle-lines'
Bubbles
backgroundVariant='bubbles'
Custom Variant
You can add your own background style by defining an SVG <pattern> and registering it as a new variant.
- Add the new name to the
BackgroundVariantunion insrc/registry/ui/background.tsx. - Create a pattern component that returns a
<pattern>with your SVG shapes. - Register the pattern component in
PATTERN_MAP.
Example custom pattern:
export type BackgroundVariant =
| "dots"
| "grid"
| "cross-hatch"
| "custom-pattern";
// ...other variants
const CustomPattern = ({ id }: { id: string }) => (
<pattern
id={id}
x="0"
y="0"
width="24"
height="24"
patternUnits="userSpaceOnUse"
>
<path
className="text-border dark:text-border"
d="M12 2l2.2 4.6L19 9l-4.8 2.4L12 16l-2.2-4.6L5 9l4.8-2.4L12 2z"
fill="currentColor"
fillOpacity="0.35"
/>
</pattern>
);
const PATTERN_MAP: Record<BackgroundVariant, React.FC<{ id: string }>> = {
dots: DotsPattern,
grid: GridPattern,
"cross-hatch": CrossHatchPattern,
"custom-pattern": CustomPattern,
// ...other variants
};
Then use your new variant in any chart:
<EvilLineChart
xDataKey="month"
data={data}
chartConfig={chartConfig}
backgroundVariant="custom-pattern"
/>Note
Tip: You can use a custom logo as a pattern. In your pattern component, swap the SVG shape for an
<image> element that points to your logo, then control size and transparency. For example:
<image href="/logo.svg" width="24" height="24" opacity="0.2" />.