Bar

Bar charts compare values across categories, with one column or row per item and its length showing the amount.

LLMs

Basic

Put a BarChart inside ChartContainer and give each Bar a radius to round the top corners of the columns.

Stacked

Give two bars the same stackId to pile them into one column, with background drawing the empty track behind each.

Tiny

A BarChart with no axes, grid or tooltip, sized as a sparkline under a weekly sales figure.

Bar background

Set background on one Bar to draw a track behind each of its columns, so the remaining space reads at a glance.

Two value axes

Give each YAxis a yAxisId and point each Bar at one, so orders and revenue each get their own scale.

Positive and negative

Bars grow up or down from a ReferenceLine at zero, and a custom tick colors each axis value by its sign.

Stacked by sign

Set stackOffset="sign" so positive values stack above zero and negative values stack below it, in one column.

Minimum bar height

Set minPointSize so very small values still draw a visible bar, with a custom LabelList badge above each column.

Ranged bars

Pass a [low, high] pair as the value and each Bar spans from one to the other, like a day's lowest and highest temperature.

Ranged stack

Wrap ranged bars in BarStack to place each phase at its own start and end, with radius rounding the whole stack.

Axis labels

Put a Label inside XAxis or pass label to YAxis to name each axis, and add a LabelList to tag every bar.

Label lists

Add a LabelList to each Bar: one writes page names inside the columns at an angle, the other prints values on top.

Label background

Pass a content component to LabelList that draws a rounded pill behind each value, so it stays readable over the bar.

Threshold line

A ReferenceLine marks the budget across a stacked chart, and a LabelList with valueAccessor prints each week's total.

Legend highlight

Handle onMouseEnter and onClick on ChartLegend to fade the other series, and click a name to keep it highlighted.

Brush

Add a Brush under the chart and drag its handles to zoom into a range of days, with the legend placed on top.

Two category axes

A second XAxis with its own xAxisId and a custom tick groups the months into quarters under the main axis.

Population pyramid

A horizontal BarChart with stackOffset="sign" puts male shares left of the axis and female shares right of it.

Custom shape

Pass a shape component to draw each bar as a curved peak, colored by its position, with a matching LabelList on top.

Outlined bars

A shape component draws each bar as an outline in its own color, with a thicker stroke on one and an SVG pattern on another.

Click to select

A shape component holds its own state and toggles the bar between faded and solid each time you click it.

Waterfall

Ranged bars that start where the previous one ended show how gains and costs add up to profit, colored by a shape.

Candlestick

A ranged Bar draws each candle's body and an ErrorBar its wick, colored up or down, with a custom tooltip of prices.

Box plot

A ranged Bar with a custom shape draws quartiles and the median, ErrorBar adds whiskers and a Scatter the outliers.

Animated bar width

One shape used as activeBar too keeps every bar mounted, so a CSS transition widens the bar under the pointer.

Streaming window

Slide a window over the data and compare animationMatchBy strategies, or swap in a swipe with animationInterpolateFn.

Animate on scroll

An AnimationControllerProvider drives the bars' entry animation from the page's scroll position instead of a timer.