import { Charts3D } from "@/components/3d/charts";
export default function Example() {
return (
<div style={{ height: 420 }}>
<Charts3D
variant="heatmap"
theme="light"
/>
</div>
);
}
Deps: three, @react-three/fiber, @react-three/drei
Installation
Install the runtime dependencies, then copy the component module (and the shared 3D core when the component uses WebGL).
npm install three @react-three/fiber @react-three/drei
# Copy the component module
cp -r src/components/3d/charts <your-project>/src/components/3d/charts
# Copy the shared 3D core
cp -r src/components/3d/core <your-project>/src/components/3d/coreDependencies: three, @react-three/fiber, @react-three/drei
Usage
Every category module exposes one typed component. Pick an implementation with variant and pass props grouped by concern.
import { Charts3D } from "@/components/3d/charts";
export default function Example() {
return (
<div style={{ height: 420 }}>
<Charts3D
variant="heatmap"
theme="light"
/>
</div>
);
}
React implementation
With every prop set explicitly. The complete, copyable source of src/components/3d/charts/index.tsx is available in the playground’s Source tab.
import { Charts3D } from "@/components/3d/charts";
export default function Example() {
return (
<div style={{ height: 420 }}>
<Charts3D
variant="heatmap"
theme="amoled"
dataset="revenue"
axes
labels
legend
transparent={false}
quality="medium"
/>
</div>
);
}
Next.js implementation
WebGL needs the browser. Load the scene through next/dynamic with ssr disabled and a sized placeholder to avoid layout shift.
// app/3d-heatmap/page.tsx (Next.js App Router)
"use client";
import dynamic from "next/dynamic";
// WebGL must never run on the server — load the scene client-side only.
const Charts3D = dynamic(
() => import("@/components/3d/charts").then((m) => m.Charts3D),
{ ssr: false, loading: () => <div aria-busy="true" style={{ height: 420 }} /> },
);
export default function Page() {
return (
<main>
<div style={{ height: 420 }}>
<Charts3D
variant="heatmap"
theme="light"
/>
</div>
</main>
);
}
TypeScript interfaces
export type Theme = "light" | "amoled";
export interface 3DHeatmapProps {
/** Which 3D Data Visualization implementation to render */
variant: "heatmap";
theme: Theme;
/* Content */
dataset?: "revenue" | "traffic" | "engagement"; // default "revenue"
/* Visual */
axes?: boolean; // default true
labels?: boolean; // default true
legend?: boolean; // default true
/* Rendering */
transparent?: boolean; // default false
quality?: "low" | "medium" | "high"; // default "medium"
}
Props reference
| Prop | Type | Default | Group | Description |
|---|---|---|---|---|
| variant | "heatmap" | — | Core | Selects the implementation. |
| theme | "light" | "amoled" | — | Core | Themes surfaces, materials and lighting. |
| dataset | "revenue" | "traffic" | "engagement" | "revenue" | Content | Dataset |
| axes | boolean | true | Visual | Show axes |
| labels | boolean | true | Visual | Show labels |
| legend | boolean | true | Visual | Show legend / filters |
| transparent | boolean | false | Rendering | Transparent background |
| quality | "low" | "medium" | "high" | "medium" | Rendering | Quality preset |
Customization
Colour props accept any hex string. Content props accept plain strings. Every value shown in the playground maps 1:1 to a prop, so you can design visually and copy the generated code. Use Share to send a pre-configured link or Export to download the configuration JSON.
import { Charts3D } from "@/components/3d/charts";
export default function Example() {
return (
<div style={{ height: 420 }}>
<Charts3D
variant="heatmap"
theme="light"
/>
</div>
);
}
Animation settings
This component exposes no dedicated animation controls.
All motion is suspended when prefers-reduced-motion is on.
Theme support
Pass theme="light" or theme="amoled". Lighting rigs, environment reflections, blending modes and canvas backgrounds change with it — AMOLED uses true #000000 with controlled emissive accents; Light uses soft studio lighting with contact shadows. Use the theme switch in the playground toolbar to preview both.
Responsive behavior
The component fills its parent, so size it with the container. Use the playground’s desktop / tablet / mobile selector to test. Canvas resolution adapts through the adaptive DPR range of the active quality preset.
Accessibility notes
- — Every chart ships an sr-only data table with the exact values.
- — Legend chips are toggle buttons (aria-pressed) that filter series.
- — The tooltip region is aria-live=polite.
Performance notes
- — Bars animate by damping a scale — no geometry rebuilds when filtering.
- — Heatmaps, spheres and candles use instanced meshes with per-instance picking.
- — Labels use drei <Html>; keep tick counts modest.
Presets: LOW (DPR 1, no AA, ~35% density) · MEDIUM (DPR ≤1.5, ~70%) · HIGH (DPR ≤2, full density).