Photonix

Pie Chart

Proportional data distribution using PieChart.

Preview

Usage
import { ChartContainer, PieChart, Pie, Cell, ChartTooltip, ChartLegend, ChartLegendContent } from '@photonix/ultimate';

const config = {
  mobile: { label: 'Mobile', color: 'var(--chart-1)' },
  desktop: { label: 'Desktop', color: 'var(--chart-2)' },
  // ...
};

const data = [
  { name: 'Mobile', value: 400 },
  { name: 'Desktop', value: 300 },
  // ...
];

<ChartContainer config={config}>
  <PieChart>
    <Pie data={data} dataKey="value">
        {data.map((entry, index) => {
             // Logic to find corresponding color from config
             // In a real app, data entries usually have a 'key' or 'id' matching the config key.
             const configKey = Object.keys(config).find(k => config[k].label === entry.name);
             return (
                <Cell 
                    key={index} 
                    fill={config[configKey]?.color}
                />
             );
        })}
    </Pie>
    <ChartTooltip />
    <ChartLegend />
  </PieChart>
</ChartContainer>

Component API

PieChart

Prop
Type
Default
Description
children
ReactElement
-
Chart components (Pie, Tooltip, Legend, etc).

Pie

Prop
Type
Default
Description
data
any[]
-
The source data array.
dataKey
string
-
The key of data to be displayed.
cx
string | number
50%
The x-coordinate of center.
cy
string | number
50%
The y-coordinate of center.
innerRadius
number
0
The inner radius of pie.
outerRadius
number
80%
The outer radius of pie.

On this page

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