Skip to content

PlBarChart

Lengths, compared. A bar encodes how much as length, which is why its axis always starts at zero.

React
tsx
import { PlBarChart } from 'plass-ui';

<PlBarChart series={revenue} categories={regions} />;
dart
import 'package:plass_ui/plass_ui.dart';

PlBarChart(series: revenue, categories: regions);

Crop the scale and a bar twice as long stops meaning twice as much, and the reader has no way to know it happened. Reach for a line chart when what matters is the shape of a change rather than the size of each value.

Props

PropTypeDefaultDescription
series * readonly PlassChartSeries[]The data
categoriesreadonly PlassChartCategory[]What the category axis says
orientation'vertical' | 'horizontal''vertical'Which way the bars run. horizontal is the right answer whenever the category names are words: it has a whole column for them
stackedboolean | 'full'falsePuts the series on top of each other instead of beside each other. 'full' makes every bar the same length, so the chart is about share rather than size
roundedbooleantrueCuts the corners off the data end of each bar. The baseline end stays square: a rounded foot makes the axis look scalloped
barSizenumberthe size ladder — 24 at mdHow thick a bar may get. Below the cap the bars fill their share of the band; above it the leftover stays as air
valueLabels'none' | 'last' | 'extremes' | 'all''none'Which values are written on the bars. all is defensible here in a way it is not on a line chart: eight bars with their numbers on them is a chart and a table at once
xAxisPlassChartAxisThe category axis
yAxisPlassChartAxisThe value axis
legendPlassChartLegendThe legend
tooltipPlassChartTooltipThe tooltip
heightnumber | stringHow tall the plot is
formatIntl.NumberFormatOptionsHow a value is written
labelstring'Chart'What the whole drawing is called
emptyReactNodeWhat is drawn when there is nothing to draw
sizeshared'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Type scale, plot height and the bar thickness cap
densityshared'default' | 'compact''default'How much of a category's slot the bars in it may take. Never the height
PropTypeDefaultDescription
series * List<PlassChartSeries>The data
categoriesList<PlassChartCategory>?What the category axis says
orientationPlassOrientationPlassOrientation.verticalWhich way the bars run. horizontal is the right answer whenever the category names are words: it has a whole column for them
stackingPlBarStackingPlBarStacking.groupedHow the series sit relative to each other. Three named states rather than React's boolean | 'full'
roundedbooltrueCuts the corners off the data end of each bar. The baseline end stays square: a rounded foot makes the axis look scalloped
barSizedouble?the size ladder — 24 at mdHow thick a bar may get. Below the cap the bars fill their share of the band; above it the leftover stays as air
valueLabelsPlassChartValueLabelsPlassChartValueLabels.noneWhich values are written on the bars. all is defensible here in a way it is not on a line chart: eight bars with their numbers on them is a chart and a table at once
xAxisPlChartAxisPlChartAxis()The category axis
yAxisPlChartAxisPlChartAxis()The value axis
legendPlChartLegendPlChartLegend()The legend
tooltipPlChartTooltipPlChartTooltip()The tooltip
heightdouble?How tall the plot is
formatString Function(double)?How a value is written
semanticLabelString?'Chart'What the whole drawing is called
emptyWidget?What is drawn when there is nothing to draw
sizesharedPlassSizePlassSize.mdType scale, plot height and the bar thickness cap
densitysharedPlassDensityPlassDensity.standardHow much of a category's slot the bars in it may take. Never the height

The data is the same PlassChartSeries every chart takes. A null is a gap here too, and a bar is simply not drawn for one, which is the distinction that matters most on this chart, because a zero-length bar and a missing bar are the same picture and only one of them is honest.

What the shared axes mean across the library is in prop conventions.

Examples

orientation

horizontal is the right answer whenever the category names are words: it has a whole column for them, where a vertical chart has the width of one bar.

React

Everything swaps with it, which band each axis reserves, which way the grid runs, which way the crosshair goes and which end of a bar is rounded.

stacked

Grouped bars answer "which series is bigger here". Stacked bars answer "what is this total made of". They are different questions and the chart should be asked only one of them at a time.

React

'full' makes every bar the same length, so the chart is about share rather than size, exactly as it does on an area chart, and for the same reason it renormalises the data rather than the drawing.

The gap between two stacked segments is taken off the far end of each, so the stack still totals the right length and the seam is the sheet showing through rather than a line drawn on it. A border around a bar is ink that is not data.

Negative values

The two arms are accumulated separately, so a series that dips does not shorten the one above it, and a negative bar grows down from the baseline while the positives grow up.

React

The baseline is redrawn over the bars. Every bar starts there, and under them the line would be half-hidden by the first pixel of each one.

rounded

The corners come off the data end of each bar only. The baseline end stays square: that is where the value starts from, and a rounded foot makes the axis look scalloped.

barSize and density

barSize is a cap, not a width. The band a bar sits in is whatever the plot divided by the category count gives; below the cap the bars fill their share of it, and above it the leftover stays as air. density is the share of the band the bars may take at all.

Accessibility

Everything PlLineChart says applies here: the name and the per-series summary, the legend as real controls, and (on React) the hidden table that carries every number.

Released under the MIT License