@sqlrooms/recharts
Recharts integration for SQLRooms with a theme-aware chart container and tooltip/legend helpers.
This package re-exports the full recharts API and adds SQLRooms-friendly wrappers:
ChartContainerChartTooltip,ChartTooltipContentChartLegend,ChartLegendContentChartConfigtyping for series labels/colors
Installation
bash
npm install @sqlrooms/rechartsBasic usage
tsx
import {
Bar,
BarChart,
CartesianGrid,
ChartContainer,
ChartTooltip,
ChartTooltipContent,
XAxis,
YAxis,
} from '@sqlrooms/recharts';
const defaultRows = [
{month: 'Jan', revenue: 1200},
{month: 'Feb', revenue: 1800},
{month: 'Mar', revenue: 1600},
];
export function RevenueChart({
rows = defaultRows,
}: {
rows?: Array<{month: string; revenue: number}>;
}) {
return (
<ChartContainer
className="min-h-[16rem] w-full"
config={{
revenue: {
label: 'Revenue',
color: 'hsl(var(--chart-1))',
},
}}
>
<BarChart data={rows} accessibilityLayer={true}>
<CartesianGrid vertical={false} />
<XAxis dataKey="month" />
<YAxis />
<ChartTooltip content={<ChartTooltipContent />} />
<Bar dataKey="revenue" fill="var(--color-revenue)" radius={6} />
</BarChart>
</ChartContainer>
);
}Using with SQLRooms query results
tsx
import {useSql} from '@sqlrooms/duckdb';
import {RevenueChart} from './RevenueChart';
function RevenueChartFromSql() {
const {data} = useSql<{month: string; revenue: number}>({
query: `
SELECT month, SUM(revenue) AS revenue
FROM sales
GROUP BY month
ORDER BY month
`,
});
const rows = data?.toArray() ?? [];
return <RevenueChart rows={rows} />;
}Notes
@sqlrooms/rechartsis UI-only; it does not require a specific SQLRooms slice.- Best used with
@sqlrooms/duckdbquery hooks and@sqlrooms/uitheming.
Namespaces
Classes
- Area
- Bar
- Brush
- CartesianAxis
- ErrorBar
- Line
- ReferenceArea
- ReferenceDot
- ReferenceLine
- Scatter
- XAxis
- YAxis
- ZAxis
- Sankey
- Treemap
- DefaultLegendContent
- Legend
- Tooltip
- Funnel
- Pie
- PolarAngleAxis
- PolarRadiusAxis
- Radar
- RadialBar
Interfaces
Type Aliases
- ChartConfig
- AreaProps
- BarProps
- BrushProps
- CartesianAxisProps
- CartesianGridProps
- ErrorBarProps
- LineProps
- ReferenceAreaProps
- ReferenceDotProps
- ReferenceLineProps
- ScatterProps
- XAxisProps
- YAxisProps
- CellProps
- CustomizedProps
- DefaultLegendContentProps
- LabelProps
- LabelListProps
- LegendProps
- TextProps
- TooltipProps
- LayerProps
- SurfaceProps
- FunnelProps
- PieLabel
- PieProps
- PolarAngleAxisProps
- PolarGridProps
- PolarRadiusAxisProps
- RadarProps
- RadialBarProps
- CrossProps
- CurveProps
- DotProps
- PolygonProps
- RectangleProps
- SectorProps
- SymbolsProps
- TrapezoidProps
- LegendType
Variables
- ChartContainer
- ChartTooltip
- ChartTooltipContent
- ChartLegend
- ChartLegendContent
- AreaChart
- BarChart
- ComposedChart
- FunnelChart
- LineChart
- PieChart
- RadarChart
- RadialBarChart
- ScatterChart
- SunburstChart
- Cell
- DefaultTooltipContent
- ResponsiveContainer
- Text
- Layer
- PolarGrid
- Cross
- Curve
- Dot
- Polygon
- Rectangle
- Sector
- Symbols
- Trapezoid
- Global
