Access Matrix
Montre les permissions detenues par chaque sujet, sous forme de tableau ou d'une entree de liste par sujet. Installez Access Matrix depuis le registre VLLNT UI avec la CLI shadcn.
Affiche un graphique a barres pour la visualisation de donnees. Installez Bar Chart depuis le registre VLLNT UI avec la CLI shadcn.
import * as React from "react";
import { cn } from "../../../lib/utils";
type Datum = {
label?: string;
value: number;
};
export type BarChartProps = {
color?: string;
data: Datum[];
gap?: number;
gradientId?: string;
height?: number;
width?: number;
} & React.HTMLAttributes<HTMLDivElement>;
const DEFAULT_WIDTH = 320;
const DEFAULT_HEIGHT = 140;
const DEFAULT_GAP = 12;
export const BarChart = ({
className,
color = "currentColor",
data,
gap = DEFAULT_GAP,
gradientId = "bar-chart-gradient",
height = DEFAULT_HEIGHT,
ref: reference,
width = DEFAULT_WIDTH,
...props
}: BarChartProps & { ref?: React.Ref<HTMLDivElement> }) => {
if (data.length === 0) {
return null;
}
const values = data.map((point) => point.value);
const maxValue = Math.max(...values, 0);
const normalizedMax = maxValue || 1;
const totalGap = gap * Math.max(data.length - 1, 0);
const barWidth = Math.max((width - totalGap) / data.length, 6);
return (
<div
className={cn(
"rounded-lg border border-border bg-background/40 p-3",
className,
)}
ref={reference}
{...props}
>
<svg
aria-label="Bar chart"
className="h-full w-full"
height={height}
role="img"
viewBox={`0 0 ${width} ${height}`}
width={width}
>
<defs>
<linearGradient id={gradientId} x1="0" x2="0" y1="0" y2="1">
<stop offset="0%" stopColor={color} stopOpacity="0.9" />
<stop offset="100%" stopColor={color} stopOpacity="0.4" />
</linearGradient>
</defs>
{data.map((point, index) => {
const barHeight = (point.value / normalizedMax) * (height - 12);
const x = index * (barWidth + gap);
const y = height - barHeight;
return (
<rect
fill={`url(#${gradientId})`}
height={barHeight}
key={`${point.label ?? "bar"}-${index.toString()}`}
rx={4}
width={barWidth}
x={x}
y={y}
>
<title>
{point.label ? `${point.label}: ` : ""}
{point.value.toLocaleString()}
</title>
</rect>
);
})}
</svg>
</div>
);
};
BarChart.displayName = "BarChart";
Affiche un graphique a barres pour la visualisation de donnees. Fait partie de la famille data dans VLLNT UI, il est publie comme entree de registre lisible par machine — copiez la source directement dans votre application avec la CLI shadcn et possedez-la, sans dependance d'execution a une bibliotheque de composants.
| Plateforme | Dependances | Capacites |
|---|---|---|
| Web | @vllnt/ui@^0.3.0 | Rendu navigateur, evenements DOM et semantique ARIA |
| Natif | — | Indisponible |
Ajoutez Bar Chart a votre projet avec la CLI shadcn. La source arrive dans votre code, prete a etre adaptee :
pnpm dlx shadcn@latest add https://ui.vllnt.com/r/bar-chart.jsonExplorez chaque variante et etat dans le Storybook interactif :