Skip to content
  • System
  • Light
  • Dark
  • High contrast

Getting started

Terminal window
pnpm add @eekodigital/raster

react and react-dom 19 are peer dependencies. If you use GeoChart, also install its optional peer:

Terminal window
pnpm add topojson-client

Raster ships one stylesheet. Import it once at your app root, before your own styles:

import "@eekodigital/raster/styles.css";

No chart imports CSS itself, so the package’s sideEffects lists only the stylesheet: bundlers can drop any chart you don’t use, but keep the stylesheet import. If the stylesheet is missing, charts still render: marks get their colours from attributes, and the visually hidden summary and title keep an inline visually-hidden style (the data table stays hidden until its button is pressed). Animations, focus rings and the default grid and axis styling do need it.

Import from the main entry, or from a chart’s own entry if you’d rather be explicit about what you pull in. Both tree-shake the same way.

Import Exports
@eekodigital/raster Every chart except GeoChart, plus ChartTooltip, useChartTooltip, ChartFrame, ChartDataTable and describeChart
@eekodigital/raster/line-chart LineChart
@eekodigital/raster/bar-chart BarChart
@eekodigital/raster/donut-chart DonutChart
@eekodigital/raster/scatter-chart ScatterChart
@eekodigital/raster/sparkline Sparkline
@eekodigital/raster/gauge Gauge
@eekodigital/raster/linear-gauge LinearGauge
@eekodigital/raster/radar-chart RadarChart
@eekodigital/raster/chart-tooltip ChartTooltip, useChartTooltip
@eekodigital/raster/geo GeoChart (needs topojson-client)
@eekodigital/raster/time timeAxis, for dates on LineChart
@eekodigital/raster/export exportSVG, exportPNG: exporting charts
@eekodigital/raster/frame ChartFrame, ChartDataTable, describeChart: wrapping other charts
@eekodigital/raster/labels describeChart, DEFAULT_LABELS, without "use client"
@eekodigital/raster/theme rasterVars, the theming contract
@eekodigital/raster/styles.css The stylesheet

Server rendering and React Server Components

Section titled “Server rendering and React Server Components”

Every chart renders on the server: the figure, summary, data table and named marks are in the HTML before any JavaScript runs.

With React Server Components (the Next.js App Router), the entries that export components start with "use client", so you can import a chart straight into a Server Component page. "use client" doesn’t stop server rendering. The chart is still rendered to HTML on the server; it only marks where the browser takes over (hydration) for keyboard, tooltips and selection.

A few props can’t be passed from a Server Component, because they hold functions, which can’t cross from server to client:

  • xAxis={timeAxis(…)}, formatValue, formatX, formatXTick, onSelect and other callbacks
  • labels with function overrides (summary, mark, …)

Put a chart that needs them in a small client component of your own (a file starting with "use client"), and pass it plain data from the server. timeAxis (/time), exportSVG (/export), describeChart (/labels) and rasterVars (/theme) aren’t marked, so server code can call them. Import describeChart from /labels in a Server Component: the main entry and /frame are marked. TypeScript won’t catch a function prop passed from a Server Component; the framework reports it when the page renders.

In development, Vite discovers each raster entry the first time a page imports it, and reloads the page to optimise it. To skip those reloads, list the entries you use:

vite.config.ts
import { defineConfig } from "vite";
export default defineConfig({
optimizeDeps: {
include: ["@eekodigital/raster", "@eekodigital/raster/time", "@eekodigital/raster/export"],
},
});

Charts inherit font-family and color from where you render them, so they pick up your typography with no configuration. Spacing is internal. To match your colours, map your tokens onto raster’s contract; see Theming charts.