Skip to content

ExpressiveCSS

Browse documentation

Funnel chart

Steps people take in order, each drawn as a stage as wide as the people who reach it.

View as Markdown

A <figure class="funnel-chart"> draws each row of a <table> as a stage, from the top down, as wide as its value.

The first column labels each row and the second holds its value. The largest value fills the chart's width, and every other stage is as wide as its share of it, centered under the one before. Stages follow the table's order, so list the steps people take in the order they take them, such as a visit, a signup and a purchase. To compare values that are not steps, use a bar chart.

Signups this month
StepPeopleRevenue
Visited12,000$0
Signed up4,800$0
Started a trial2,100$0
Paid640$19,200
Renewed410$12,300
<figure class="funnel-chart">
  <figcaption>Signups this month</figcaption>
  <table>
    <thead>
      <tr><th>Step</th><th>People</th><th>Revenue</th></tr>
    </thead>
    <tbody>
      <tr><th>Visited</th><td>12,000</td><td>$0</td></tr>
      <tr><th>Signed up</th><td>4,800</td><td>$0</td></tr>
      <!-- One row per step, in order -->
    </tbody>
  </table>
</figure>

Values and gaps

Cells read as in a line chart. A cell's number is its data-value, or its text without currency signs, percent signs or grouping commas. The tooltip shows the cell's text as written, followed by the stage's value as a percentage of the first row's, such as "4,800 (40%)". Below 10% the percentage keeps a tenth.

A row whose value is not a number, or is zero or less, draws no stage but keeps its place and its label, and has no percentage. Only the second column draws stages. Further columns, such as revenue above, show in the tooltip with their header, so the chart has no legend.

Accessibility

The table is the chart's text alternative. Give it a header row and a header cell per row, and name the chart with a <figcaption>. The drawn stages and labels are hidden from assistive technology.

The plot is one Tab stop named by the caption. Keyboard focus shows the first row. The down and up arrows move to the next row and the one before, Home and End jump to the first and last rows, and Escape hides the tooltip. The keys are the same in a right-to-left page, where the labels move to the right. The pointer shows the row under it. The tooltip is a polite live region, so a screen reader hears the row, its value and its percentage as it moves. In forced colors the stages keep their color.

JavaScript

AutoInit() starts every .funnel-chart. To start one yourself, call FunnelChart.init. After changing its table, call update() to redraw it in place, or put data-watch on the figure and it redraws itself. Each stage grows or shrinks from its old width, or takes its new width at once with reduced motion. It has the line chart's options and methods.

const chart = Expressive.FunnelChart.init(document.querySelector('.funnel-chart'));
chart.show(2);   // highlight the third row; -1 hides the tooltip
chart.update();  // redraw from the table; focus and the highlighted row stay
chart.destroy(); // remove the drawing and show the table again

Tokens

Override these on the .funnel-chart.

Token Default
--md-comp-funnel-chart-row-height40px
--md-comp-funnel-chart-stage-height60% of each row's height
--md-comp-funnel-chart-shape4px, the stage's corner radius
--md-comp-funnel-chart-color-1primary, every stage's color

For a selective Sass build, include "funnel-chart" in $components.

No matching pages

  • Source color

    The seed every generated ramp derives from. Pick one and browse the docs — the whole theme follows. Error does not: it is a fixed hue.

    Default source: Mist Iris.

    ExpressiveCSS presets: Lagoon, Harbor, Breeze, Cobalt, Iris.

    Bold

    Soft

    Mist

    Glow