Cell
Cell sets the fill, stroke, and class for a single data entry in a Bar, Pie, RadialBar, or Scatter chart. Use a <For> loop to apply cells to each data point.
import { PieChart, Pie, Cell, For } from "solid-recharts";
<PieChart width={400} height={300}>
<Pie data={data} dataKey="value">
<For each={data}>{(_, i) => <Cell fill={COLORS[i() % COLORS.length]} />}</For>
</Pie>
</PieChart>;
Loading source...
Props
| Prop | Type | Default | Description |
|---|---|---|---|
fill | string | — | Fill color (CSS color value) |
stroke | string | — | Stroke color |
class | string | — | CSS class for the element |
Notes
- No
keyprop: Unlike React, Solid does not require akeyon<For>items. - Iterate with
<For>: Use<For each={data}>{(item, i) => <Cell ... />}</For>to create one cell per data point. The index accessori()is read as a function. - Order matters: Cells are assigned to data entries in the order they render. The first
<Cell>applies todata[0], the second todata[1], etc. - Supported parents:
Pie,Bar,Scatter,RadialBar. Not forLine,Area, orRadar. - SVG-only:
fillandstrokeare CSS colors; CSS classes apply SVG presentation attributes.