Skip to content
InsightCharts

Search

Search guides and components

Diverging bar chart

Draws bars either side of a centre line: positive against negative values, or stacked agree / disagree responses around a neutral midpoint.

Use when
Values that can be above or below zero (net change, balance, deviation from average); survey scales where the split between the two sides matters; two opposed groups back to back.
Avoid when
Values that are all positive (use bar chart); parts that do not have a natural two-sided order (use a stacked bar chart); change between two dates (use arrow chart or dumbbell chart).

Preview

Austin's population grew 21.3% between 2010 and 2020

Population change, 2010 to 2020

Illustrative figures.

Composition

Used in

No molecule or template lists diverging bar chart in its composes. It still fits any slot that takes a component.

Installation

$ pnpm dlx shadcn@latest add @insightcharts/diverging-bar-chart

The CLI copies the source into your project and needs the @insightcharts registry in components.json; see installation. With the package, import it by name:

import { DivergingBarChart } from "insightcharts";

Examples

Likert scale around a neutral midpoint

73% of staff agree their manager gives useful feedback

Share of employees responding to each statement

Illustrative figures.

Two opposed groups, long format

Women aged 75 and over make up 4.6% of the population

Share of total population by age group and sex

Illustrative figures.

Vertical over time, good and bad

Payroll employment fell by 71,000 in August 2024

Monthly change in payroll employment, thousands

Illustrative figures.

Stress: 14 long statements, one highlighted, normalised

42% of respondents support capping rents by law

Share of respondents, normalised to 100% per statement

Synthetic data for layout testing.

Props

PropTypeDefaultDescription
xrequiredstringCategory field.
yrequiredstring | string[]One signed value field, or several fields ordered from most negative to most positive.
seriesstringField that splits rows into ordered series (long data).
neutralstring | falseSeries centred on the midline. Default: the middle one of an odd number of series.
percentbooleanfalseNormalise each row to 100% (stacked series).
colors"polarity" | "sentiment""polarity"Single series: diverging poles, or the positive / negative colours when one side is good and the other bad.
sort"none" | "asc" | "desc"Row order. Default: descending by value or by the positive side; data order for dates.
orientation"auto" | "horizontal" | "vertical""auto"Horizontal, except vertical for a single series over dates.
labelsbooleanValues at bar ends (single) or inside segments (stacked). Default: on when there is room.
namesRecord<string, string>Display names for series keys.
Common chart props 29

Every chart built with defineChart accepts these on top of its own props.

PropTypeDescription
dataDataInputRows, CSV text, a URL, { url, path }, an async function, or an Arrow-style table. Omit inside <InsightData>.
transformTransform | Transform[]A pipeline of transforms applied before drawing.
titlestringThe title. One plain statement of what the data shows, with the number and the period ("Monthly churn fell from 4.2% to 2.1% in 2024"), or a plain label ("Monthly churn, 2024"). One clause, no figures of speech.
subtitlestringMeasure, unit, population, period.
sourcestringData source, shown as "Source: ...".
notestringMethod notes or caveats.
heightnumber | stringCSS height of the plot. Default 360.
aspectnumberWidth / height. Overrides height.
highlightstring | string[]The entity (or entities) the title is about. Every other series is drawn in grey.
annotationsAnnotation[]Reference lines, shaded bands and callouts, in data coordinates.
formatFormatSpecHow to print values: "compact", "percent", "currency:USD", "{value} kg", Intl options, or a function.
legendbooleanShow the legend. Default: shown when there are two or more series.
selectboolean | stringMake marks clickable to filter. Inside <InsightData> the selection filters every other chart. Pass a field name, or true to use the chart's category field.
onSelect(values: string[], field: string) => voidCalled with the selected values whenever the selection changes.
optionEChartsOption | ((option: EChartsOption, ctx: BuildContext) => EChartsOption)Deep-merged over the generated ECharts option, or a function that receives and returns it. Use it for ECharts settings no prop covers.
themeThemeInputA theme, or a partial set of tokens merged over the surrounding theme, for this chart only.
modeModeInput"auto" (default) follows the page, "system" follows the OS, or force "light" / "dark".
rendererRendererInput"auto" (default) uses SVG for light charts and canvas for heavy ones.
animatebooleanSet false to disable animation. Reduced-motion preferences are always respected.
lazybooleanMount the chart only when it scrolls near the viewport. Default true.
groupstringLink tooltips with other charts sharing this group id.
exportableboolean | ExportFormat[]Show an export menu: true or a list of formats from png, jpeg, svg, pdf, csv, json.
tablebooleanShow a collapsible "View data" table under the chart.
altstringAccessible description: the chart type and measures, then the main pattern and the notable values.
idstringStable id for this chart's selection in the shared store.
onEventsRecord<string, ChartEventHandler>ECharts event handlers, e.g. { click: (params, chart) => {} }. Prefix a name with zr: to bind to the canvas itself.
onReady(chart: EChartsInstance) => voidCalled with the ECharts instance once it is created.
classNamestringClass name for the outer <figure>.
styleCSSPropertiesInline style for the outer <figure>.