Skip to content

Bar Charts

BarChart is the modern v2 bar surface for object-row data. It supports vertical and horizontal bars, grouped bars, stacked bars, 100% stacked bars, negative values, horizontal scrolling, automatic axis padding, theme presets, value labels, tap selection, tooltips, and a simple bottom legend.

Use this API for new apps. The v2 package also exports a StackedBarChart compatibility facade for legacy stacked-bar data during migration.

All examples on this page are part of the public free v2 API.

Basic Bars

import { BarChart } from "react-native-chart-kit/v2";

const data = [
  { month: "Jan", signups: 180 },
  { month: "Feb", signups: 520 },
  { month: "Mar", signups: 260 },
  { month: "Apr", signups: 740 },
  { month: "May", signups: 390 },
  { month: "Jun", signups: 860 }
];

export function SignupsChart() {
  return (
    <BarChart
      data={data}
      xKey="month"
      yKey="signups"
      width={360}
      height={240}
    />
  );
}

Grouped Bars

Use series for multiple bars per x value. The chart shows a bottom legend by default when there is more than one series.

const data = [
  { month: "Jan", organic: 28, paid: 62 },
  { month: "Feb", organic: 74, paid: 34 },
  { month: "Mar", organic: 39, paid: 88 },
  { month: "Apr", organic: 96, paid: 41 },
  { month: "May", organic: 54, paid: 103 },
  { month: "Jun", organic: 118, paid: 58 }
];

<BarChart
  data={data}
  xKey="month"
  series={[
    { yKey: "organic", label: "Organic" },
    { yKey: "paid", label: "Paid" }
  ]}
  preset="analytics"
  showValuesOnTopOfBars
  width={360}
  height={260}
/>;

Useful grouped-bar props:

  • barWidthRatio: controls how much of each x band is filled by bars.
  • barGapRatio: controls spacing between bars inside a group.
  • barRadius: controls corner radius.
  • legend={false}: hides the default legend.

Negative Values

Negative values render below the zero baseline. Keep yDomain on its default include-zero behavior unless you intentionally want a cropped baseline.

const profit = [
  { month: "Jan", profit: 38 },
  { month: "Feb", profit: -28 },
  { month: "Mar", profit: 64 },
  { month: "Apr", profit: -42 },
  { month: "May", profit: 81 },
  { month: "Jun", profit: -18 }
];

<BarChart
  data={profit}
  xKey="month"
  yKey="profit"
  preset="fintech"
  showValuesOnTopOfBars
  formatYLabel={(value) => (value < 0 ? `-$${Math.abs(value)}k` : `$${value}k`)}
  width={360}
  height={250}
/>;

Horizontal Bars

Set orientation="horizontal" when category labels are easier to scan down the left axis.

const supportVolume = [
  { channel: "Chat", tickets: 95 },
  { channel: "Email", tickets: 37 },
  { channel: "Phone", tickets: 68 },
  { channel: "Social", tickets: 24 },
  { channel: "Community", tickets: 113 }
];

<BarChart
  data={supportVolume}
  xKey="channel"
  yKey="tickets"
  orientation="horizontal"
  showValuesOnTopOfBars
  width={360}
  height={260}
/>;

Horizontal bars support grouped, stacked, 100% stacked, and negative values through the same mode, series, and yDomain props as vertical bars.

Stacked Bars

Set mode="stacked" to stack series by row. Positive and negative stacks are tracked separately from the zero baseline.

const data = [
  { month: "Jan", newCustomers: 180, expansion: 60 },
  { month: "Feb", newCustomers: 520, expansion: 210 },
  { month: "Mar", newCustomers: 260, expansion: 120 },
  { month: "Apr", newCustomers: 740, expansion: 330 },
  { month: "May", newCustomers: 390, expansion: 170 },
  { month: "Jun", newCustomers: 860, expansion: 410 }
];

<BarChart
  data={data}
  xKey="month"
  mode="stacked"
  series={[
    { yKey: "newCustomers", label: "New" },
    { yKey: "expansion", label: "Expansion" }
  ]}
  width={360}
  height={260}
/>;

100% Stacked Bars

Set mode="stacked100" for percentage composition. The original values are preserved in the bar model while rendered heights are normalized to row totals.

const platformShare = [
  { month: "Jan", ios: 62, android: 25, web: 13 },
  { month: "Feb", ios: 38, android: 47, web: 15 },
  { month: "Mar", ios: 55, android: 21, web: 24 },
  { month: "Apr", ios: 29, android: 58, web: 13 },
  { month: "May", ios: 68, android: 19, web: 13 },
  { month: "Jun", ios: 44, android: 31, web: 25 }
];

<BarChart
  data={platformShare}
  xKey="month"
  mode="stacked100"
  series={[
    { yKey: "ios", label: "iOS" },
    { yKey: "android", label: "Android" },
    { yKey: "web", label: "Web" }
  ]}
  formatYLabel={(value) => `${value}%`}
  width={360}
  height={250}
/>;

Legacy StackedBarChart Facade

Existing StackedBarChart data can render through the modern stacked-bar engine without changing the old data shape.

import { StackedBarChart } from "react-native-chart-kit/v2";

<StackedBarChart
  data={{
    labels: ["Free", "Starter", "Team"],
    legend: ["Active", "Trial", "Paused"],
    data: [
      [44, 18, 8],
      [38, 24, 11],
      [52, 28, 14]
    ],
    barColors: ["#2563eb", "#0891b2", "#7c3aed"]
  }}
  width={360}
  height={250}
  chartConfig={{
    backgroundGradientFrom: "#ffffff",
    backgroundGradientTo: "#ffffff",
    decimalPlaces: 0
  }}
  segments={4}
  yAxisSuffix="k"
/>;

The facade maps labels, legend, data, barColors, hideLegend, percentile, segments, barPercentage, chartConfig.barPercentage, chartConfig.barRadius, decimalPlaces, formatYLabel, withVerticalLabels, withHorizontalLabels, withInnerLines, yAxisLabel, and yAxisSuffix.

Tap Selection And Tooltips

Bar selection is opt-in. Use interaction="tap" for the simplest behavior, or pass an object when you need callbacks or outside-press dismissal.

const data = [
  { month: "Jan", organic: 28, paid: 62 },
  { month: "Feb", organic: 74, paid: 34 },
  { month: "Mar", organic: 39, paid: 88 },
  { month: "Apr", organic: 96, paid: 41 },
  { month: "May", organic: 54, paid: 103 },
  { month: "Jun", organic: 118, paid: 58 }
];

<BarChart
  data={data}
  xKey="month"
  series={[
    { yKey: "organic", label: "Organic" },
    { yKey: "paid", label: "Paid" }
  ]}
  interaction={{
    mode: "tap",
    deselectOnOutsidePress: true,
    onSelect: (event) => {
      setSelectedChannel(event.seriesLabel);
    }
  }}
  tooltip={{
    anchor: "pointer",
    placement: "above",
    width: 132
  }}
  defaultSelectedBar={{ dataIndex: 3, seriesKey: "paid" }}
  width={360}
  height={260}
/>;

The public select event includes dataIndex, seriesKey, seriesLabel, value, formattedValue, x, xLabel, color, position, and the original raw row.

Tooltip positioning uses anchor: "bar" and placement: "auto" by default. Use anchor: "pointer" with placement: "above" when the tooltip should follow the tap position and stay above the finger. Styling follows the chart theme tooltip tokens by default and can be overridden per chart with backgroundColor, borderColor, textColor, labelColor, padding, borderRadius, fontFamily, fontSize, labelFontSize, and shadow props.

Scrollable Bars

Use scrollable, visiblePoints, and initialIndex for long categorical bar charts. For bars, visiblePoints maps to visible bar bands.

const weeklySpend = [
  { week: "W1", spend: 18 },
  { week: "W2", spend: 52 },
  { week: "W3", spend: 26 },
  { week: "W4", spend: 74 },
  { week: "W5", spend: 31 },
  { week: "W6", spend: 88 },
  { week: "W7", spend: 43 },
  { week: "W8", spend: 96 },
  { week: "W9", spend: 39 },
  { week: "W10", spend: 108 },
  { week: "W11", spend: 57 },
  { week: "W12", spend: 121 },
  { week: "W13", spend: 44 },
  { week: "W14", spend: 132 },
  { week: "W15", spend: 63 },
  { week: "W16", spend: 118 },
  { week: "W17", spend: 71 },
  { week: "W18", spend: 146 }
];

<BarChart
  data={weeklySpend}
  xKey="week"
  yKey="spend"
  scrollable
  visiblePoints={8}
  initialIndex="end"
  formatYLabel={(value) => `$${value}k`}
  width={360}
  height={250}
/>;

The y-axis labels stay pinned while the bars and x-axis labels scroll horizontally.

Custom Bar Rendering

Use renderBar when bars need product-specific styling while keeping the built-in layout, selection, hit testing, labels, sticky axes, and tooltips.

import { Rect } from "react-native-svg";

const weeklySpend = [
  { week: "W1", spend: 18 },
  { week: "W2", spend: 52 },
  { week: "W3", spend: 26 },
  { week: "W4", spend: 74 },
  { week: "W5", spend: 31 },
  { week: "W6", spend: 88 },
  { week: "W7", spend: 43 },
  { week: "W8", spend: 96 }
];

<BarChart
  data={weeklySpend}
  xKey="week"
  yKey="spend"
  width={360}
  height={250}
  renderBar={({ bar, fill, radius }) => (
    <Rect
      x={bar.x}
      y={bar.y}
      width={bar.width}
      height={bar.height}
      rx={radius}
      fill={fill}
    />
  )}
/>;

Labels and Themes

Useful label and theme props:

  • labelStrategy: auto, show, or hide.
  • formatXLabel: formats x-axis labels.
  • formatYLabel: formats y-axis and value labels.
  • showHorizontalGridLines: enabled by default.
  • showXAxisLabels / showYAxisLabels: hide axis label groups without removing grid geometry.
  • yTickCount: controls y-axis tick density.
  • preset: uses the same cartesian presets as LineChart.
  • theme: overrides chart colors, plot background, text, typography, and series colors.

Current Limitations

This is still an early modern BarChart slice. Full legacy BarChart prop mapping belongs to the root compatibility facade rather than the modern object-row API.

Props

BarChart

PropTypeDescription
dataTData[]Object-row source data for the chart.
xKeykeyof TDataRow key used for category, date, or numeric x values.
yKeykeyof TDataSingle row key used for bar values when series or yKeys is not provided.
yKeysArray<keyof TData>Multiple row keys rendered as grouped or stacked series with default styling.
seriesBarChartSeries<TData>[]Full per-series configuration, including y key, label, key, and color.
widthnumberOuter chart width in pixels.
heightnumberOuter chart height in pixels.
themeChartKitThemeMode or CartesianChartThemeTheme mode or inline theme tokens for this chart.
presetCartesianChartPresetValueBuilt-in or registered preset name used to seed chart colors and typography.
scrollablebooleanEnables a horizontal scroll viewport for long bar sets.
visiblePointsnumberNumber of x values visible in the viewport when scrollable is enabled.
initialIndexChartViewportInitialIndexInitial scroll position, such as "start" or "end".
orientationBarChartOrientationRenders vertical or horizontal bars.
modeBarChartModeChooses grouped, stacked, or 100% stacked layout.
yDomainNumericDomainInputOverrides or constrains the computed value-axis domain.
barRadiusnumberCorner radius applied to rendered bars.
barWidthRationumberPortion of each category slot occupied by bars.
barGapRationumberRelative gap between grouped bars.
showValuesOnTopOfBarsbooleanShows formatted value labels at bar ends.
showHorizontalGridLinesbooleanShows or hides horizontal grid lines.
showXAxisLabelsbooleanShows or hides x-axis labels.
showYAxisLabelsbooleanShows or hides y-axis labels.
yTickCountnumberNumber of ticks used for value-axis labels and grid lines.
legendbooleanShows or hides the bottom legend.
interactionBarChartInteraction<TData>Tap selection mode and callbacks.
selectedBarBarChartSelectedBarControlled selected bar by data index and series key.
defaultSelectedBarBarChartSelectedBarInitial uncontrolled selected bar.
selectionAnimationboolean or BarChartSelectionAnimationConfigEnables and configures selected-bar animation.
tooltipboolean or BarChartTooltipConfigShows and configures selected-bar tooltip content and placement.
renderBar(props) => ReactNodeCustom renderer for each bar while preserving layout and hit testing.
rendererBarChartRendererRenderer implementation used for SVG-compatible primitives.
labelStrategyBarChartLabelStrategyControls x-axis label visibility.
formatXLabel(value, index) => stringFormats x-axis labels and selected x labels.
formatYLabel(value) => stringFormats y-axis labels, value labels, and tooltip values.
idstringStable chart id used for coordinated selection scope.
accessibilityLabelstringOverrides the generated accessible chart summary.
testIDstringTest identifier applied to the chart surface.

StackedBarChart

StackedBarChart is the v2 compatibility facade for legacy stacked-bar data.

PropTypeDescription
dataStackedBarChartLegacyDataLegacy stacked-bar data with labels, legend, data, and barColors.
widthnumberOuter chart width in pixels.
heightnumberOuter chart height in pixels.
chartConfigStackedBarChartLegacyConfigLegacy color, label, decimal, bar, and grid configuration.
hideLegendbooleanHides the generated legend when true.
styleStyleProp<ViewStyle>Style applied to the compatibility wrapper.
barPercentagenumberOverrides the bar width ratio from chartConfig.
decimalPlacesnumberControls formatted value precision.
withVerticalLabelsbooleanShows or hides x-axis labels.
withHorizontalLabelsbooleanShows or hides y-axis labels.
withInnerLinesbooleanShows or hides inner grid lines.
segmentsnumberControls y-axis tick density.
percentilebooleanRenders the stack as 100% stacked values.
fromZerobooleanForces the value domain to include zero.
yAxisLabelstringPrefix added to formatted y-axis values.
yAxisSuffixstringSuffix added to formatted y-axis values.
verticalLabelsHeightPercentagenumberLegacy compatibility prop accepted by the facade.
formatYLabel(yLabel) => stringFormats y-axis labels after decimal formatting.
themeChartKitThemeMode or CartesianChartThemeTheme mode or inline theme tokens for this chart.
presetCartesianChartPresetValueBuilt-in or registered preset name used to seed chart colors and typography.
accessibilityLabelstringOverrides the generated accessible chart summary.
testIDstringTest identifier applied to the chart surface.