Photonix

Bar Chart

Categorical data comparison using BarChart.

Preview

Usage
import { ChartContainer, BarChart, Bar, ChartTooltip, CartesianGrid, XAxis, YAxis, ChartLegend, ChartLegendContent } from '@photonix/ultimate';

const config = {
  sales: { label: 'Sales', color: 'var(--chart-1)' },
  profit: { label: 'Profit', color: 'var(--chart-2)' }
};

<ChartContainer config={config}>
  <BarChart data={data}>
    <CartesianGrid vertical={false} stroke="var(--border-neutral-tertiary)" strokeDasharray="4 4" />
    <XAxis
        dataKey="month"
        axisLine={false}
        tickLine={false}
        tick={{ fill: 'var(--text-neutral-secondary)', fontSize: 12 }}
        dy={10}
    />
    <YAxis
        axisLine={false}
        tickLine={false}
        tick={{ fill: 'var(--text-neutral-secondary)', fontSize: 12 }}
    />
    <ChartTooltip />
    <ChartLegend content={<ChartLegendContent />} />
    <Bar dataKey="sales" fill="var(--color-sales)" radius={[4, 4, 0, 0]} />
    <Bar dataKey="profit" fill="var(--color-profit)" radius={[4, 4, 0, 0]} />
  </BarChart>
</ChartContainer>

Component API

BarChart

Prop
Type
Default
Description
data
any[]
-
The source data array.
children
ReactElement
-
Chart components (Bar, XAxis, Tooltip, Legend, etc).

Bar

Prop
Type
Default
Description
dataKey
string
-
The key of data to be displayed.
fill
string
-
The color of the bar.
radius
number | array
0
The radius of the bar.

On this page

Preview
Usage
Component API
Photonix UI - React Components, Templates & Figma Design System