SwiftUI.js
Components

Chart

Chart presents numeric series as either bar or line marks.

Chart presents numeric series as either bar or line marks.

Examples

Bar Mark

Preview unavailable for this example in the static docs build.

Show code
<Chart caption="Quarterly revenue" data={monthlyRevenue} label="Revenue" mark="bar" showValues></Chart>

Line Mark

Preview unavailable for this example in the static docs build.

Show code
<Chart caption="Quarterly revenue" data={monthlyRevenue} label="Revenue" mark="line" showValues></Chart>

Empty State

Preview unavailable for this example in the static docs build.

Show code
<Chart data={[]} emptyState="No revenue data yet" label="Revenue"></Chart>

Selection

Preview unavailable for this example in the static docs build.

Show code
<Chart caption="Quarterly revenue" data={monthlyRevenue} defaultSelectedDatumId="feb" label="Revenue" mark="bar" showValues valueFormatter={(value) => `$${value}k`}></Chart>

Line Selection

Preview unavailable for this example in the static docs build.

Show code
<Chart caption="Quarterly revenue" data={monthlyRevenue} defaultSelectedDatumId="feb" label="Revenue" mark="line" showValues valueFormatter={(value) => `$${value}k`}></Chart>

API

PropTypeRequiredDescription
dataIChartDatum[]YesNo description yet.
labelstringYesNo description yet.
captionstringNoNo description yet.
mark'bar' | 'line'NoNo description yet.
showValuesbooleanNoNo description yet.
emptyStatestringNoNo description yet.
heightnumberNoNo description yet.
selectedDatumIdstringNoNo description yet.
defaultSelectedDatumIdstringNoNo description yet.
onSelectionChange(datum: IChartDatum) => voidNoNo description yet.
valueFormatter(value: number, datum: IChartDatum) => stringNoNo description yet.

Inherits additional props from IBaseComponent.

Overview

Chart presents numeric series as either bar or line marks.

SwiftUI Correspondence: Adapts Swift Charts into a lightweight React component with a simplified single-series API.

Notes

  • Use mark="bar" for category comparisons
  • Use mark="line" for trend visualization
  • Use showValues when exact values should stay visible beside the graphic
  • Use selectedDatumId or defaultSelectedDatumId when the surrounding UI needs a highlighted datum
  • Use valueFormatter to keep visible values and accessibility labels aligned
  • Marks support keyboard selection with arrow keys, Home, and End

On this page