Skip to content

Chart

Themed wrappers around SwiftChart — line, area, bar, pie, donut, scatter, and radar — that follow Cynosure tokens out of the box.

  • stable
  • since v0.1.0
  • 8.0 kB
  • data-display
  • chart
  • visualization

Charts render to Canvas; provide a descriptive aria-label and pair quantitative charts with a hidden data table for screen-reader users.

Preview
Open
tsx

Each chart accepts a data array and a mapping object that declares which fields to read for the axes / series.

import { LineChart } from '@arshad-shah/cynosure-react/chart';
const data = [
{ month: 'Jan', revenue: 1200 },
{ month: 'Feb', revenue: 1600 },
];
<LineChart
data={data}
mapping={{ x: 'month', y: ['revenue'], seriesNames: ['Revenue'] }}
smooth
dots
/>

BarChart renders vertical bars. Pass an array to mapping.y for grouped bars.

Preview
Open
tsx

AreaChart is equivalent to a line chart with a gradient fill — pass smooth for a softened curve.

Preview
Open
tsx

DonutChart and PieChart consume labelField / valueField instead of x / y.

Preview
Open
tsx

Each chart wraps in a sized container. Use aspectRatio for fluid responsive charts (default "16 / 9"), or pass an explicit height for fixed dashboards. minHeight (default 220) keeps the chart usable inside flex containers.

PropTypeDefaultDescription
aspectRatio
string|number
"16 / 9"
Aspect ratio for the wrapper. Accepts any CSS `aspect-ratio` value (e.g. `"16 / 9"`, `"4/3"`) or a number (`1.78`). Ignored when `height` is set.
minHeight
string|number
220
Minimum height applied to the wrapper — keeps the canvas from collapsing inside flex/grid parents that don't define an intrinsic height.
  • Charts paint to a <canvas> — provide a descriptive aria-label (or a visible heading) so the chart’s purpose is announced.
  • Pair quantitative charts with a hidden data table (or <details> block) so screen-reader users can access the raw values.
  • The default palette adapts to the active color scheme via the registered cynosure-light / cynosure-dark SwiftChart themes.
  • Tooltips fire on pointer move and on focus where supported.
  • Color alone never conveys meaning — series names are surfaced via the legend and tooltips.
  • Use aspectRatio="16 / 9" for hero charts; set height for fixed-size dashboards.
  • Pass a custom theme to override the default light/dark theme registration.
  • Combine smooth + dots for a clean, readable trendline.
  • Use the named chart you need — LineChart, BarChart, AreaChart, PieChart, DonutChart, RadarChart, ScatterChart, WaterfallChart, TreemapChart, or Sparkline.