> Native Solid 2 fork of [solid-recharts](https://github.com/yumemi-thomas/solid-recharts) (MIT, © Thomas Guehenneux), derived from [Recharts](https://github.com/recharts/recharts) (MIT, © recharts). Adapted documentation; neither project endorses this fork.

# Getting started

Install the native Charts package and render your first chart.

## 1. Install the package

Charts is published on npm as 0.1.0-rc.4 (release candidate, dist-tag `next`): [@wsagency/radix2solid-charts@0.1.0-rc.4](https://www.npmjs.com/package/@wsagency/radix2solid-charts/v/0.1.0-rc.4). The npm `latest` tag still points to rc.2, so pin the exact version:

```bash
npm install -E @wsagency/radix2solid-charts@0.1.0-rc.4
```

```bash
pnpm add -E @wsagency/radix2solid-charts@0.1.0-rc.4
```

Charts requires `solid-js` and `@solidjs/web` `2.0.0-rc.15` with the matching `@solidjs/signals`, `@solidjs/compiler` and `@solidjs/babel-plugin` `2.0.0-rc.15`, compiled by `@solidjs/vite-plugin` `3.0.0-next.50`. It has no dependency on Themes; install [Themes](/themes/docs/overview/getting-started) as well if you want the token colors used below. The [runnable Charts sandbox](/sandboxes/charts-css-modules.tar.gz) is a complete application with exact npm package versions, the RC15 workspace overrides and release-age exceptions for these Solid versions.

The earlier published rc.2 lacks the next-suite Legend, XAxis and Sankey APIs. To try those APIs with the full pinned setup, download and extract the runnable sandbox above, run `pnpm install`, then `pnpm dev`. To set up your own application, use the [Solid RC15 workspace overrides](/themes/docs/overview/getting-started); Charts itself needs no Primitives override.

## 2. Render a chart

Wrap a chart in `ResponsiveContainer` to fill its parent, or give the chart a fixed `width` and `height`. Series colors can be any CSS color, including Themes tokens such as `var(--accent-9)`.

```tsx
() => {

	const data = [

		{ month: "Jan", visitors: 4000, signups: 2400 },

		{ month: "Feb", visitors: 3000, signups: 1398 },

		{ month: "Mar", visitors: 2000, signups: 3800 },

		{ month: "Apr", visitors: 2780, signups: 3908 },

	];

	return <ResponsiveContainer width="100%" height={280} initialDimension={{ width: 560, height: 280 }}>

		<BarChart data={data} title="Visitors and signups">

			<CartesianGrid strokeDasharray="3 3" stroke="var(--gray-a6)" vertical={false} />

			<XAxis dataKey="month" />

			<YAxis />

			<Tooltip />

			<Legend />

			<Bar dataKey="visitors" fill="var(--accent-9)" />

			<Bar dataKey="signups" fill="var(--teal-9)" />

		</BarChart>

	</ResponsiveContainer>;

}
```

## The composable model

| Piece                      | Role                                                       |
| -------------------------- | ---------------------------------------------------------- |
| `LineChart`, `BarChart`, … | Chart container: owns layout, scales and interaction state |
| `Line`, `Bar`, `Area`, …   | A graphical series bound to a `dataKey`                    |
| `XAxis`, `YAxis`           | Axes, categorical or numerical, several per chart          |
| `CartesianGrid`            | Background grid lines                                      |
| `Tooltip`, `Legend`        | Hover information and the series legend                    |

Components register themselves with the chart context. In the browser you can add, remove or reorder them and the chart redraws. Server rendering is different: with automatic domains or axis sizes, the server HTML does not match the client. For server-rendered Cartesian charts, follow the complete bounded recipe in [Server geometry needs explicit axes](../guides/responsive-and-ssr#server-geometry-needs-explicit-axes).

## Accessibility

Pass `title` and `desc` to name and describe the chart's SVG. `accessibilityLayer` (on by default for cartesian and polar charts) makes the chart focusable and lets arrow keys move the active tooltip between data points. Charts are images of data: when the numbers matter, also provide them as text or a table.

## Next steps

- [Responsive charts and SSR](../guides/responsive-and-ssr)
- [Migrating from Recharts](../guides/migrating-from-recharts)
- [Download the runnable sandbox](/sandboxes/charts-css-modules.tar.gz)
