Bar chart
import { BarChart } from '@arshad-shah/swift-chart';
const chart = new BarChart('#chart', { theme: 'midnight' });chart.setData(monthlySales, { x: 'month', y: ['revenue', 'cost'] });import { Bar } from '@arshad-shah/swift-chart/react';
<Bar data={monthlySales} mapping={{ x: 'month', y: ['revenue', 'cost'] }} theme="midnight" height={320}/>Common options
Section titled “Common options”Single-series with negatives
Section titled “Single-series with negatives”Per-datum colours
Section titled “Per-datum colours”Colour individual bars by value with a colorFn, or bind to a row field with colorField + colorMap. See the per-datum colours guide for the full resolution chain.
// Either bind via the row data...chart.setData(regionPnL, { x: 'region', y: 'pnl', colorField: 'sign', colorMap: { pos: '#22c55e', neg: '#ef4444' },});
// ...or compute at draw time:new BarChart('#chart', { colorFn: (v) => v < 0 ? '#ef4444' : '#22c55e',}).setData(regionPnL, { x: 'region', y: 'pnl' });