Components
Chart Axis
Themed X and Y axis primitives for Recharts charts.
Installation
$ npx veil-ui@latest add chart-axisUsage
import { Bar, BarChart } from "recharts";
import { ChartContainer } from "@/components/ui/chart";
import { ChartXAxis, ChartYAxis } from "@/components/ui/chart-axis";
<ChartContainer config={config}>
<BarChart data={data}>
<ChartXAxis dataKey="day" />
<ChartYAxis />
<Bar dataKey="orders" fill="#6366f1" />
</BarChart>
</ChartContainer>;Examples
Basic
Formatted
API reference
The package exports chart-axis along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.
Accessibility
- Charts render inside a container with an explicit height so they stay responsive without layout shift.
- Color is never the only encoding; pair charts with labels, summaries or a data table for critical information.
- Tooltips and legends are rendered as HTML, so their text is available to assistive technology.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add chart-axis --framework vue or switch the framework in components.json.
<script setup lang="ts">
withDefaults(
defineProps<{
labels: Array<string | number>;
width?: number;
height?: number;
padding?: number;
}>(),
{ width: 560, height: 240, padding: 24 },
);
</script>
<template>
<g data-slot="chart-x-axis" class="fill-muted-foreground">
<text
v-for="(label, index) in labels"
:key="String(label)"
:x="index * (width / Math.max(labels.length, 1)) + width / Math.max(labels.length, 1) / 2"
:y="height - 4"
text-anchor="middle"
font-size="12"
>
{{ label }}
</text>
</g>
</template>