Skip to main content

Bar chart

Grey bars with one highlighted, direct value labels, vertical or ranked horizontal.

Guidance​

Bar charts compare categories. Bars are grey with square tops; one bar can be highlighted in the key colour (highlight), the only colour on the chart. Values are printed directly at the bar ends in 13px mono; when bars are too narrow for every label, only the highlighted and largest bars are labelled and a range-frame axis appears instead. Estimated or stale bars are hatched, never recoloured.

orientation="horizontal" is the ranked-list form (failed runs per pipeline, queries per agent), with the category names in a column and sort="desc" to rank them. Stacked bars take stack (at most three names) and values per bar: the first two segments are greys and the third is the key colour, labelled directly beside the last bar instead of in a legend.

Keyboard: Tab to the chart, then the arrow keys move between bars and show the tooltip; Home and End jump to the ends; Escape hides the tooltip.

Properties​

PropertyAttributeTypeDefaultDescription
datadataBarDatum[][]The bars, in order.
orientationorientation'vertical' | 'horizontal''vertical'vertical (default) or horizontal, the ranked-list form.
highlighthighlightstring''Label of the one bar drawn in the key colour.
stackstackstring[][]Names of stacked segments, at most three: two greys, then the key colour.
unitunitstring''Unit after each value, after a non-breaking space.
sortsort'none' | 'desc' | 'asc''none'none keeps the given order; desc or asc ranks the bars.
categoryLabelcategory-labelstring''Heading for the categories in the tooltip and table.
valueLabelvalue-labelstring''Heading for the values in the tooltip and table.
labellabelstring''What is measured, in sentence case, e.g. "Queries per hour". Starts the summary sentence and names the table.
summarysummarystring''Replaces the generated summary sentence read by screen readers.
heightheightnumber240Plot height in px.
defaultWidthdefault-widthnumber640Width used before the first measurement and on the server, in px.
loadingloadingbooleanfalseShows the topographic loading field (after 200ms, for at least 400ms).
errorerrorstring''An error sentence. When set, the chart draws its empty frame with this sentence.
emptyTextempty-textstring''Sentence shown when there is no data.
tonetone'primary' | 'info''primary'Key series colour: primary (burnt sienna, default) or info (slate). The only colour on the chart.
activeIndexnumberIndex of the focused or hovered data point, or -1.

CSS parts​

PartDescription
frameThe focusable plot region.
plotThe SVG drawing.
messageThe empty or error sentence.

CSS custom properties​

PropertyDescription
--mm-chart-keyColour of the highlighted bar or key segment.
--mm-chart-groundThe ground behind the chart, used for label halos. Defaults to --mm-paper.

Examples​

Every state of mm-bar-chart in Storybook, with keyboard and screen reader tests.