Ranked bars
ProParts compared on one scale, largest first, with the rest in one row last; and a funnel's steps with each one's share of the step before. Not an M3 component (@windmorph/react-pro).
import { RankedBars, FunnelBars } from '@windmorph/react-pro/charts';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Purpose
RankedBars answers which part is bigger: orders by city, pages by visits, the questions asked most. Each row is a name, a bar and an amount, largest first, with the rest in one quieter row last. FunnelBars answers where people drop out: the steps of a checkout or a sign-up in the order people take them, each after the first with its share of the step before.
Use them where a donut would go: bars on one scale compare more exactly than slices. For parts that make up one whole, use a Segmented bar; for change over time, a Bar chart or a Line chart. M3 has no charts, so they follow M3's colour roles, type scale and springs instead of a spec.
Ranked bars
rowsare{ key, label, value }. Withsort="descending", the default, the largest comes first;sort="none"keeps your order, for rows that have one of their own, such as age bands.- A row marked
rest("Everywhere else") goes last whatever its size, in the quiet colour and dotted, so the remainder never ranks among the parts. The other bars take the charts' first colour slot, built from the theme's primary. - Every bar is drawn against the largest amount shown, the rest row's included. A value below nought counts as nought on the scale and prints as it is; one that isn't a number ranks below every number and prints
labels.noValue("No value"), never "NaN". A row that counts as nought, or has no value, draws no bar; any other keeps at least a pixel, however small.
Funnel bars
stepsare{ key, label, value }, in the order people take them. A funnel is never ranked: its order is the point.- Each step after the first says its share of the step before,
labels.ofPrevious("65% of the step before"), written byformatShare: by default a whole percentage, never "0%" above nought ("0.3%") nor "100%" short of the whole ("99.9%"). A step says none when the step before has nothing above nought, or when its own value isn't a number. - The bars are on one scale, against the largest step, and a step of nought or no value draws no bar.
- A funnel is an ordered list (
ol), since its steps' order is the meaning; ranked bars are a plain list.
Behaviour
- Names, bars and amounts are three columns of one grid, so every bar is on the same scale whatever its row's words. The names' column takes up to 14rem (the
name-widthtoken); a long name wraps and is never cut. - Under 18rem of its own width, through a container query, a name takes a line with its amount at the end and its bar runs the whole width under it, so the server's HTML is right at any width.
formatValuewrites the amounts (the page's locale by default).- The bars grow from nothing one after another when the list first comes into view, and a change moves every bar at once, on the spatial spring. A list on screen as the page loads shows its bars at once, from the server's HTML. Under reduced motion the list shows its final picture at once, wherever it is on the page.
- In a
ChartFrame, the frame's title names the list, unless it has anaria-labeloraria-labelledbyof its own. They give the frame no table, since every figure is already printed, so the frame shows no table switch unless you pass it atable.
When not to use
For parts that make up one whole, use a Segmented bar; for change over time, a Bar chart or Line chart.
See also
- Segmented bar: One whole in a few parts, as a bar that prints its figures or a thin bar above a list of the parts; parts with an order can take the theme's ramp, lightest to darkest (the reverse in dark mode). Not an M3 component (@windmorph/react-pro).
- Bar chart: Columns over places: one series, or several stacked into a total, read by pointer, finger and keyboard. Not an M3 component (@windmorph/react-pro).
- Chart frame: The card a chart sits in: its title names the chart, a switch shows the same numbers as a table, and it has empty, loading, pending and error states. Not an M3 component (@windmorph/react-pro).