BarChart
Compares values across categories or dates. Rows that share an x value are summed, so raw rows work without grouping them first.
Playground
Paid social: 5 bars. Highest North America at $47.7K; lowest Middle East & Africa at $4.6K. Organic search: 5 bars. Highest North America at $51.6K; lowest Middle East & Africa at $5.5K. Email: 5 bars. Highest North America at $37.8K; lowest Middle East & Africa at $5.6K. Direct: 5 bars. Highest North America at $22.9K; lowest Middle East & Africa at $3.3K.
| Region | Paid social | Organic search | Direct | |
|---|---|---|---|---|
| North America | $47.7K | $51.6K | $37.8K | $22.9K |
| Europe | $33.4K | $31.6K | $25.5K | $13.6K |
| Asia Pacific | $20.7K | $20.7K | $16.2K | $11.1K |
| Latin America | $10.8K | $10.4K | $6.2K | $4.5K |
| Middle East & Africa | $4.6K | $5.5K | $5.6K | $3.3K |
<BarChart
data={orders}
x="region"
y="amount"
group="channel"
select
format="currency-compact"
/>Installation
BarChart is exported from @quartile/react, alongside every other chart and component.
git clone https://github.com/zinnoberHaus/quartileNot on npm yet: build the package from the clone as described in Installation. The preview API may change before publication.
Usage
Pass rows and name the fields. Types, formats and axis labels come from the data's schema; see Data model.
import { BarChart } from '@quartile/react';
// orders: { region: 'Europe', channel: 'Email', amount: 128.5 }, …
type Order = { region: string; channel: string; amount: number };
export function RevenueByRegion({ orders }: { orders: Order[] }) {
return <BarChart data={orders} x="region" y="amount" group="channel" sort="desc" select />;
}select, clicking a bar (or Enter on the focused bar) toggles its x value in the nearest <Selection>, and onSelect receives the new predicate. See Linked selections.Props
stack).group, matching the other charts.x (or null).Frame and state props shared with the charts (11) · ChartBaseProps, ChartStateProps
table renders the same data as a table, with the same formats, at the chart's size. Large lazy tables expose a data-view control rather than mounting every hidden row.Accessibility
select, Enter or Space toggles the focused bar. Escape clears the cursor.view="table" shows it at the chart's size.