Rapid Rails UI Pro

—

Upgrade to unlock this component

Get Pro →

Chart

Compare values across categories with vertical or horizontal bars, grouped or stacked, one series or many. Server-rendered, with a hidden data table for screen readers. Charts and motion are Stimulus controllers plus server-rendered SVG and HTML. No chart library, no external JavaScript beyond @hotwired/stimulus.

Looking for ready-made examples and dashboard cards? See the Chart Gallery .

Key Features

  • Bars — :bar (vertical), :hbar (horizontal), :stacked (one 100% bar), :lollipop (ranked list), :funnel (steps), :calendar (day grid), :waffle (squares), :slope (two columns)
  • Multiple series — layout: :grouped or :stacked
  • Axes — nice ticks, grid, zero baseline, negative values, y_max:
  • Formats — number, percent, currency, :compact, or your own lambda
  • Per point — tooltip:, href:, highlight:, note:
  • Legend toggles — hide series and the chart rescales
  • Events — cancelable rui-chart:select
  • Annotations — reference lines and notes
  • Phones — responsive: :hbar
  • Accessible — labelled marks and a hidden data table
  • No dependencies — Stimulus plus server-rendered SVG; no chart library, no external JavaScript beyond @hotwired/stimulus
  • Pro tier — covered by the RRUI Pro license

Types

type: picks the shape. Unknown types fall back to :bar. height: sets the plot height in px.

Vertical bars: :bar

Collisions by year
Toronto, 2021 to 2023
0 5 10 15 20
2021 2022 2023
Collisions by year
Category collisions
2021 14 collisions
2022 17 collisions
2023 9 collisions
Vertical bars
<%= rui_chart(type: :bar, title: "Collisions by year", subtitle: "Toronto, 2021 to 2023",
      data: @collisions_by_year, unit: "collisions", height: 220) %>

Horizontal bars: :hbar

The track reserves room for the longest formatted value, so the longest bar's label stays inside the card.

Monthly plan revenue
Per plan, USD
  • Starter
  • Team
  • Studio
$0.00 $200.00 $400.00 $600.00 $800.00 $1,000.00
Monthly plan revenue
Category Value
Starter $120.00
Team $480.00
Studio $910.00
Horizontal bars
<%= rui_chart(type: :hbar, title: "Monthly plan revenue", subtitle: "Per plan, USD",
      data: @revenue_by_plan, value_format: :currency, show_values: true) %>

100% stacked: :stacked

One bar split into segments, with a legend. Single series. Pass legend: false to hide the legend.

Applications by status
Within 400 m, 76 total
  • Open 14
  • Approved 9
  • Closed 53
Applications by status
CategoryValueShare
Open1414 of 76 · 18%
Approved99 of 76 · 12%
Closed5353 of 76 · 70%
Stacked
<%= rui_chart(type: :stacked, title: "Applications by status", subtitle: "Within 400 m, 76 total",
      data: @review_queue) %>

Ranked list: :lollipop (0.79.0+)

A rule and a dot per row, the value printed after it. Same data: rows as :hbar, so switching is one word. See Lollipop for sorting and hidden rows.

Steps: :funnel (0.80.0+)

Centred bars per step, sized as a share of the first step. Same data: rows as :hbar. See Funnel for the two modes.

Day grid: :calendar (0.81.0+)

One column per week, one row per weekday, each day coloured by its count. Takes days:, a hash of date to count. See Calendar.

Squares: :waffle (0.82.0+)

A grid of squares with a legend, for a share or a small count. Same data: rows as :hbar. See Waffle.

Two columns: :slope (0.83.0+)

Two columns compared row by row, each row a small two-point slope. Takes columns: and rows:. See Slope.

Keywords that don't apply (0.84.1+). A type-specific keyword passed to a type that never reads it (squares: on :hbar, week_start: on :bar) is ignored, and in development and test the chart logs one [RapidRailsUI] chart: line naming the keyword and the types that use it. The schema lists the same mapping: each type-specific param carries types: at /api/schema/components/chart.

Data rows

data: is an array of hashes with :label and :value. Rows with a missing label or value are skipped. Missing values in a series count as 0.

Row shape
[
  { label: "Open", value: 14 },
  { label: "Approved", value: 9 }
]

Value Labels and Track

  • show_values: puts the value on each mark. On by default for :hbar, off for :bar. Stacked segments are not labelled. Labels use value_format:.
  • track: false removes the grey background behind horizontal bars. The bar fills the row height either way.

Horizontal bars with labels

Requests by type
  • Pothole
  • Streetlight
  • Graffiti
0 50 100 150 200 250
Requests by type
Category requests
Pothole 210 requests
Streetlight 75 requests
Graffiti 40 requests
Horizontal bars with labels
<%= rui_chart(type: :hbar, unit: "requests", data: @requests_by_type) %>

Horizontal bars without track

  • Pothole
  • Streetlight
  • Graffiti
0 500 1k 1.5k 2k 2.5k
Chart data
Category Value
Pothole 2.1k
Streetlight 750
Graffiti 400
No track, compact values
<%= rui_chart(type: :hbar, track: false, show_values: true, value_format: :compact, data: @requests_by_type) %>

Vertical bars with values

Collisions by year
0 5 10 15 20
2021 2022 2023
Collisions by year
Category collisions
2021 14 collisions
2022 17 collisions
2023 9 collisions
Vertical bars with values
<%= rui_chart(type: :bar, show_values: true, data: @collisions_by_year, unit: "collisions") %>

Series and Layouts

series: takes [{ name:, values: }], aligned to categories:. With more than one series a legend shows by default.

  • layout: :grouped (default) puts series side by side in each category.
  • layout: :stacked stacks the series in one column (or row) per category. Works with :bar and :hbar.

Grouped bars

Collisions by year
0 2 4 6 8 10
2021 2022 2023 2024 2025
Collisions by year
Category PedestrianCyclist
2021 6 collisions1 collisions
2022 8 collisions2 collisions
2023 7 collisions1 collisions
2024 9 collisions3 collisions
2025 8 collisions2 collisions
Grouped bars
<%= rui_chart(type: :bar, layout: :grouped, title: "Collisions by year",
      categories: %w[2021 2022 2023 2024 2025],
      series: [{ name: "Pedestrian", values: [6, 8, 7, 9, 8] },
               { name: "Cyclist", values: [1, 2, 1, 3, 2] }],
      unit: "collisions") %>

Stacked bars

Collisions by year
0 5 10 15
7 10 8 12 10
2021 2022 2023 2024 2025
Collisions by year
Category PedestrianCyclist
2021 6 collisions1 collisions
2022 8 collisions2 collisions
2023 7 collisions1 collisions
2024 9 collisions3 collisions
2025 8 collisions2 collisions
Stacked bars
<%= rui_chart(type: :bar, layout: :stacked, categories: %w[2021 2022 2023 2024 2025],
      series: [{ name: "Pedestrian", values: [6, 8, 7, 9, 8] },
               { name: "Cyclist", values: [1, 2, 1, 3, 2] }]) %>

Horizontal grouped bars

Trips by mode
  • Bus
  • Bike
  • Walk
0 100 200 300 400 500
Trips by mode
Category WeekdayWeekend
Bus 420 trips260 trips
Bike 310 trips290 trips
Walk 180 trips240 trips
Horizontal grouped bars
<%= rui_chart(type: :hbar, layout: :grouped, categories: %w[Bus Bike Walk],
      series: [{ name: "Weekday", values: [420, 310, 180] },
               { name: "Weekend", values: [260, 290, 240] }],
      unit: "trips") %>

Horizontal stacked bars

Trips by mode
  • Bus
  • Bike
  • Walk
0 200 400 600 800
Trips by mode
Category WeekdayWeekend
Bus 420 trips260 trips
Bike 310 trips290 trips
Walk 180 trips240 trips
Horizontal stacked bars
<%= rui_chart(type: :hbar, layout: :stacked, categories: %w[Bus Bike Walk],
      series: [{ name: "Weekday", values: [420, 310, 180] },
               { name: "Weekend", values: [260, 290, 240] }]) %>

Axes and Formats

  • Nice ticks at 1, 2 or 5 times a power of ten, with light grid lines and a zero baseline.
  • Negative values drop below the zero baseline.
  • value_format: :number (default, thousands separators), :percent, :currency, :compact (1.2k, 3.4M), or a lambda that receives the number.
  • y_max: forces the top of the axis.
  • unit: is added to labels and the hidden table. It is ignored when value_format: is set.
  • max_rows: shows that many categories. The rest are grouped as Other N, summed per series.

Negatives, compact values and a fixed top

Net cash flow
Thousands, USD
-2k 0 2k 4k 6k
Q1 Q2 Q3 Q4
Net cash flow
Category Value
Q1 1.2k
Q2 -850
Q3 4.3k
Q4 -600
Compact format with y_max
<%= rui_chart(type: :bar, data: @net_cash_flow, value_format: :compact, y_max: 5000) %>

Top categories with max_rows

Requests by type
  • Pothole
  • Graffiti
  • Streetlight
  • Other 2
0 50 100 150 200 250
Requests by type
Category requests
Pothole 210 requests
Graffiti 40 requests
Streetlight 75 requests
Other 2 34 requests
Top N categories
<%= rui_chart(type: :hbar, data: @requests, unit: "requests", max_rows: 3) %>

Per Point Options

On a single series, each row can carry its own options.

  • tooltip: replaces the default tooltip text.
  • href: makes the mark a link. Click or Enter first dispatches rui-chart:select. The link is followed only if the event is not prevented.
  • highlight: true dims the other marks.
  • note: is stored with the row, for your own use.
311 requests
  • Pothole
    210
  • Graffiti
  • Other
0 50 100 150 200 250
311 requests
Category requests
Pothole 210 requests
Graffiti 40 requests
Other 12 requests
Per point options
<%= rui_chart(type: :hbar, unit: "requests", data: [
      { label: "Pothole", value: 210, tooltip: "210 requests · median 9 days", href: "/311?type=pothole" },
      { label: "Graffiti", value: 40, highlight: true },
      { label: "Other", value: 12, note: "Includes bulky items" }
    ]) %>

The Pothole mark in this demo links to #data on this page. Your app would link to a real route.

Highlight with Multiple Series

highlight: takes a category label. The other categories dim across all series, and the highlighted category keeps its series colours.

0 2 4 6 8
2021 2022 2023
Chart data
Category PedestrianCyclist
2021 61
2022 82
2023 71
Highlight a category
<%= rui_chart(type: :bar, categories: %w[2021 2022 2023], highlight: "2022",
      series: [{ name: "Pedestrian", values: [6, 8, 7] },
               { name: "Cyclist", values: [1, 2, 1] }]) %>

Tooltip and Share

The tooltip shows a bold title (the category), then one line per series with a swatch and the value. Hover or focus a mark to see it. Escape hides it, and arrow keys move between visible marks.

show_share: true adds a share to each line. The base depends on the layout:

  • Stacked: the category's stack total, for example "31 of 76 · 41%".
  • Single series: the whole total.
  • Grouped: the category total. Share is off unless show_share: true is set.

Stacked share

0 2 4 6 8 10
7 10 8
2021 2022 2023
Chart data
Category PedestrianCyclist
2021 61
2022 82
2023 71
Stacked share
<%= rui_chart(type: :bar, layout: :stacked, show_share: true, categories: %w[2021 2022 2023],
      series: [{ name: "Pedestrian", values: [6, 8, 7] },
               { name: "Cyclist", values: [1, 2, 1] }]) %>

Grouped share

0 2 4 6 8
2021 2022 2023
Chart data
Category PedestrianCyclist
2021 61
2022 82
2023 71
Grouped share
<%= rui_chart(type: :bar, layout: :grouped, show_share: true, categories: %w[2021 2022 2023],
      series: [{ name: "Pedestrian", values: [6, 8, 7] },
               { name: "Cyclist", values: [1, 2, 1] }]) %>

Legend Toggles

Click a legend item to hide its series. The bars and the axis rescale. The last visible series cannot be hidden. Try it on the chart below.

0 5 10 15
2021 2022 2023 2024
Chart data
Category PedestrianCyclistDriver
2021 6112
2022 8210
2023 7111
2024 939
Legend toggles
<%= rui_chart(type: :bar, layout: :grouped, legend: true, categories: %w[2021 2022 2023 2024],
      series: [{ name: "Pedestrian", values: [6, 8, 7, 9] },
               { name: "Cyclist", values: [1, 2, 1, 3] },
               { name: "Driver", values: [12, 10, 11, 9] }]) %>

Events

Click or Enter on a mark dispatches rui-chart:select on the chart element. The event is cancelable. Use it to filter a table beside the chart. If you call preventDefault(), the mark's href is not followed.

Listen for rui-chart:select
element.addEventListener("rui-chart:select", (event) => {
  const { series, label, value, index } = event.detail
  // filter a table beside the chart; call event.preventDefault() to stop a link from being followed
})

References and Annotations

references: draws dashed, labelled reference lines. annotations: lists notes under the chart, attached to a category with at:.

Collisions by year
0 20 40 60
City target
2021 2022 2023 2024
  • 2024: New bike lane
Collisions by year
Category Value
2021 31
2022 44
2023 38
2024 52
References and annotations
<%= rui_chart(type: :bar, data: @collisions_by_year,
      references: [{ value: 40, label: "City target" }],
      annotations: [{ at: "2024", text: "New bike lane" }]) %>

Phones

responsive: :hbar shows a vertical bar chart with more than 6 categories as horizontal bars below 480 px. The hidden table and the API stay the same. Resize this window to see the switch.

Requests by week
  • W1
  • W2
  • W3
  • W4
  • W5
  • W6
  • W7
0 20 40 60
Requests by week
Category requests
W1 42 requests
W2 38 requests
W3 51 requests
W4 47 requests
W5 33 requests
W6 29 requests
W7 55 requests
Responsive horizontal
<%= rui_chart(type: :bar, responsive: :hbar, unit: "requests", data: @requests_by_week) %>

Bar Corners

bar_radius: rounds the value end only. The default comes from --rui-chart-bar-radius (4px). An integer overrides it in px, and 0 turns it off.

  • Vertical bars: top corners, or bottom corners for negatives.
  • Horizontal bars: right end, or left for negatives.
  • Stacked: outer ends only.

Theme Variables

Series 1 to 8 use var(--rui-chart-1) to var(--rui-chart-8), with a Tailwind theme fallback. Marks have no dark: classes, so they follow the variables.

Variable Used for Default
--rui-chart-1 to --rui-chart-8Series coloursTailwind 500 shades
--rui-chart-bar-radiusValue end of bars4px
--rui-chart-radiusTooltip, legend swatches, frame4px
--rui-chart-dim-opacityDimmed marks0.4
--rui-chart-gridGrid linesTailwind zinc

Overrides on one chart

Set the variables on any ancestor. This chart overrides the first colour and the bar radius inline.

Themed
0 5 10 15 20
2021 2022 2023
Themed
Category collisions
2021 14 collisions
2022 17 collisions
2023 9 collisions
app/assets/tailwind/application.css
:root {
  --rui-chart-1: #0f766e;
  --rui-chart-bar-radius: 2px;
}

Line and Area

type: :line and type: :area take series: with points:, as [x, y] pairs or { x:, y:, note: } hashes. Since 0.84.1 they also take the bar shapes: data: rows (label:, value:) or series: with values: plus categories:, so the same data switches between bar, hbar, line and area by changing type:.

  • projection: draws a dashed segment from the first series' last point to value at the to category.
  • band: draws a hatched band from low to high at the at category, with its label. The band stays inside the plot, and a long label wraps; at the right edge the label anchors to the plot's right edge.
  • annotations: pins a label to a category with a leader line.
  • A point's note: appears in its tooltip.
  • The axis starts at zero and covers the band and projection. Legend entries are plain labels, so lines do not toggle.
  • Fixed height, fluid width (0.77.0+). The chart is height: px tall (default 220) at any width, and height_sm: px below 480 px (default 0.75 × height:, at least 180, never taller than height:). The lines stretch to the card; axis labels, category labels, the band label, annotations, end labels and points are HTML at 12 px, so a full-width card does not blow the text up. The y-axis labels sit in a 48 px gutter left of the plot; end_labels: true adds a 6 rem gutter on the right.
Population
Census and projection
If every open or approvedapplication is built
Boundary change
  • Census
  • 2016: Boundary change
Population
Category Census
2011 81,614
2016 86,038
2021 89,040
If built 0
Line with projection and band
<%= rui_chart(type: :line, title: "Population",
      series: [{ name: "Census", points: [["2011", 81614], ["2016", 86038], ["2021", 89040]] }],
      projection: { from: "2021", to: "If built", value: 108258 },
      band: { at: "If built", low: 104525, high: 112761, label: "If every open or approved application is built" },
      annotations: [{ at: "2016", text: "Boundary change" }],
      value_format: :number) %>

From bar data (0.84.1+)

Reports per month
Illustrative
  • reports
Reports per month
Category reports
May 42 reports
Jun 55 reports
Jul 61 reports
Aug 48 reports
Sep 70 reports
Oct 66 reports
Line from data: rows
<%= rui_chart(type: :line, title: "Reports per month", unit: "reports",
      data: [{ label: "May", value: 42 }, { label: "Jun", value: 55 }, { label: "Jul", value: 61 },
             { label: "Aug", value: 48 }, { label: "Sep", value: 70 }, { label: "Oct", value: 66 }]) %>

<%# Same rows as a bar chart: change type: only %>
<%= rui_chart(type: :bar, title: "Reports per month", unit: "reports", data: monthly_rows) %>

Area

Population, area
  • Census
Population, area
Category Census
2011 81,614
2016 86,038
2021 89,040
Area with point notes
<%= rui_chart(type: :area, series: [{ name: "Census", points: [{ x: "2011", y: 81614, note: "Census" }, { x: "2016", y: 86038 }, { x: "2021", y: 89040 }] }]) %>

Donut and Pie

type: :donut (with a centre total) and type: :pie (no hole) take one series of rows.

  • center_total: overrides the centre number. The default is the sum, formatted with value_format:.
  • Slices under 3% group into Other. group_small: false keeps them all.
  • Hovering a slice pulls it out 4 px and shows its value and percent.

Donut with centre total

Applications by status
76 applications
  • Open 14 (18.4%)
  • Approved 9 (11.8%)
  • Closed 53 (69.7%)
Applications by status
CategoryValue
Open14 (18.4%)
Approved9 (11.8%)
Closed53 (69.7%)
Donut
<%= rui_chart(type: :donut, center_label: "applications", data: @status_counts) %>

Pie

Applications by status
  • Open 14 (18.4%)
  • Approved 9 (11.8%)
  • Closed 53 (69.7%)
Applications by status
CategoryValue
Open14 (18.4%)
Approved9 (11.8%)
Closed53 (69.7%)
Pie
<%= rui_chart(type: :pie, data: @status_counts) %>

Small Slices Grouped

Illustrative example. Stops by TTC route near Sheppard East, 127 in total. Slices under 3% are grouped into Other, with their combined count. Source: City of Toronto open data, TTC stops by route.

TTC stops by route
127 stops
  • 167 Pharmacy North 24 (18.9%)
  • 24 Victoria Park 21 (16.5%)
  • 169 Huntingwood 14 (11.0%)
  • 385 Sheppard East 13 (10.2%)
  • 85 Sheppard East 12 (9.4%)
  • 25 Don Mills 8 (6.3%)
  • 325 Don Mills 8 (6.3%)
  • 324 Victoria Park 5 (3.9%)
  • 904 Sheppard-Kennedy Express 5 (3.9%)
  • 985 Sheppard East Express 5 (3.9%)
  • Other 12 (9.4%)
TTC stops by route
CategoryValue
167 Pharmacy North24 (18.9%)
24 Victoria Park21 (16.5%)
169 Huntingwood14 (11.0%)
385 Sheppard East13 (10.2%)
85 Sheppard East12 (9.4%)
25 Don Mills8 (6.3%)
325 Don Mills8 (6.3%)
324 Victoria Park5 (3.9%)
904 Sheppard-Kennedy Express5 (3.9%)
985 Sheppard East Express5 (3.9%)
Other12 (9.4%)
Small slices grouped
<%= rui_chart(type: :donut, center_label: "stops", title: "TTC stops by route", data: @ttc_stops_by_route) %>

Sparkline

A tiny line (or variant: :column) for stat tiles and table cells: inline SVG, full width of its container, height: in px (default 24), no axes, no legend, tooltips off. mark_last: true (default) dots the last value. baseline: true draws a line at zero; a number draws it at that value. The aria-label reads "N values, latest X" and the hidden table lists every value.

Line with last dot

Sparkline data
IndexValue
13
25
34
48
56
69
Sparkline
<%= rui_chart(type: :sparkline, values: [3, 5, 4, 8, 6, 9]) %>

Columns with a baseline and a negative value

Sparkline data
IndexValue
14
22
36
43
51
65
Column sparkline
<%= rui_chart(type: :sparkline, values: counts, variant: :column, height: 32, baseline: true) %>

Inside a stat tile

Applications
76 +4
Sparkline data
IndexValue
152
255
361
464
570
672
776
Sparkline in rui_stat
<%= rui_stat("Applications", "76", change: "+4") do |s| %>
  <% s.with_sparkline do %>
    <div class="w-24"><%= rui_chart(type: :sparkline, values: @applications_by_week) %></div>
  <% end %>
<% end %>

Histogram

Bins numeric values: into contiguous columns. bins: (default 8) makes equal-width bins from min to max; bin_edges: sets them exactly, and values outside the edges are dropped. Labels read "0 to 29" (integer edges; the last bin includes its top edge). The tooltip title is the range, the line is the count and its share. It renders through the bar path, so column hover, show_values:, timeline: and the update API apply.

Exact edges

Days in review
0 2 4 6 8 10
0 to 29 30 to 89 90 to 179 180 to 365
Days in review
Category days
0 to 29 7 days
30 to 89 10 days
90 to 179 7 days
180 to 365 6 days
Histogram with bin_edges
<%= rui_chart(type: :histogram, values: days_in_review, bin_edges: [0, 30, 90, 180, 365], unit: "days") %>

Eight equal bins

Days in review
0 2 4 6 8 10
4 to 45 46 to 87 88 to 129 130 to 171 172 to 213 214 to 255 256 to 297 298 to 340
Days in review
Category days
4 to 45 10 days
46 to 87 7 days
88 to 129 3 days
130 to 171 3 days
172 to 213 2 days
214 to 255 2 days
256 to 297 1 days
298 to 340 2 days
Histogram with bins
<%= rui_chart(type: :histogram, values: days_in_review, bins: 8, unit: "days") %>

Crosshair

crosshair: true on :line and :area. Moving the pointer over the plot snaps a vertical guide to the nearest x and shows one card: the category, then every series with its value. Arrow keys on a focused point move it. It replaces the per-point tooltips on that chart.

Collisions by year
  • Pedestrian
  • Cyclist
Collisions by year
Category PedestrianCyclist
2021 6 collisions1 collisions
2022 8 collisions2 collisions
2023 7 collisions1 collisions
2024 9 collisions3 collisions
2025 8 collisions2 collisions
Crosshair on an area chart
<%= rui_chart(type: :area, crosshair: true, unit: "collisions",
      series: [{ name: "Pedestrian", points: @pedestrian_points },
               { name: "Cyclist", points: @cyclist_points }]) %>

End Labels

end_labels: true on :line and :area writes each series name at its last point, in the series colour, nudged apart when two lines end close together. The legend is off unless you pass legend: true.

Trips by mode
Bus Bike Walk
Trips by mode
Category BusBikeWalk
2021 420 trips310 trips180 trips
2022 440 trips350 trips200 trips
2023 410 trips390 trips230 trips
2024 460 trips450 trips240 trips
End labels, no legend
<%= rui_chart(type: :line, end_labels: true, unit: "trips",
      series: [{ name: "Bus", points: @bus_points },
               { name: "Bike", points: @bike_points },
               { name: "Walk", points: @walk_points }]) %>

Heatmap

type: :heatmap takes rows:, columns: and values: (a row-major array), or cells: as { row:, column:, value: } hashes. It renders an HTML grid: row labels left, column labels on top (thinned like an axis when crowded), one focusable cell per row and column.

  • Colour is series 1 at a strength from 8% (the minimum) to 100% (the maximum), so it themes through --rui-chart-1. Sequential scale only.
  • Zero is a real value and draws the lightest step. Only nil draws the track colour and reads "no data".
  • A scale bar shows min and max. The tooltip title is "row · column". The hidden table lists every cell.
  • rui-chart:update takes { series: [{ name: row, values: [...] }] }, with null for no data.
Reports by month and type
Jan
Feb
Mar
Apr
May
Jun
Pothole
Graffiti
Streetlight
0 12 reports
Reports by month and type
RowJanFebMarAprMayJun
Pothole4 reports0 reports9 reports12 reports7 reports3 reports
Graffitino data2 reports1 reports4 reports6 reports2 reports
Streetlight3 reports5 reports2 reports0 reports1 reports8 reports
Heatmap
<%= rui_chart(type: :heatmap, title: "Reports by month and type", unit: "reports",
      rows: ["Pothole", "Graffiti", "Streetlight"], columns: %w[Jan Feb Mar Apr May Jun],
      values: [[4, 0, 9, 12, 7, 3], [nil, 2, 1, 4, 6, 2], [3, 5, 2, 0, 1, 8]]) %>

<%# or one hash per cell %>
<%= rui_chart(type: :heatmap, rows: rows, columns: months,
      cells: [{ row: "Pothole", column: "Jan", value: 4 }, { row: "Graffiti", column: "Feb", value: 2 }]) %>

Timeline Strip

type: :timeline_strip draws one row per item and a bar per status period on a shared date axis. rows: is [{ label:, segments: [{ from:, to:, group:, note: }], markers: [{ at:, label: }] }]. A period with no end (to: nil) is open: its bar runs to the domain end with a hatched last 8 px and reads "since Mar 4, 2019, 2,780 days" (days count to today). Closed periods read "May 20, 2015 to Jan 10, 2018, 966 days". Dates are Date, Time or strings ("2019-03-04" or anything Date.parse reads); "today" works anywhere a date does. Periods with no start, an end before the start, or entirely outside the domain are dropped.

  • domain: { from:, to: }; an edge you leave out comes from the data (an open period extends it to today).
  • groups: maps a group name to a 0-based series colour index ("open" => 0 is --rui-chart-1) and sets the legend order; groups met in the data but not listed append after. A segment without group: is "Period". The legend shows when there is more than one group (legend: true forces it).
  • markers: [{ at:, label: }] draw a small diamond in the row, with the label and date in the tooltip.
  • sort: :start (earliest first), :days (longest first), :label, or nil to keep your order. max_rows: keeps the first n after sorting, with no "Other" row.
  • Axis: a grid line at every January 1 inside the domain, year labels thinned like the other axes (label_every: overrides). Below 480 px the label sits above its bar.
  • Every period and marker is focusable; arrow keys move between them, hovering one dims the other rows. Tooltip: item, group and note, then the span line. The hidden table lists item, status, from, to (or "ongoing") and days.
  • Entry motion: bars grow from their start in row order, markers fade in after. Reduced motion: none.
  • rui-chart:update takes { rows: [{ label:, segments: [{ group:, to: }] }] }, segments matched by index; only groups and ends change (to: null reopens a period). The bar's end and colour transition, text and table are rewritten. Rows, starts and the domain are fixed by the server.
  • as_of: (Date, Time or "2026-10-13", default the real today) is the "today" the strip counts to: open periods' days and "since ..." text, the hidden table, the "today" keyword in domain: and the client-side update. Pass a report's build date to freeze a saved report; the HTML is then the same on every later render. An unreadable value raises ArgumentError in development and test; in production it logs [RapidRailsUI] chart: unreadable as_of, sets data-rui-error on the figure and counts to the real today. 0.74.2+. The demo below is pinned to October 13, 2026, so its numbers match this page.
Applications by file, time in review
Illustrative data
  • File 19-114
  • File 22-301
  • File 15-207
  • File 12-038
2008 2011 2014 2017 2020 2023 2026
  • open
  • approved
  • closed
Applications by file, time in review
ItemStatusFromToDays
File 19-114openMar 4, 2019ongoing2,780
File 22-301openFeb 14, 2022ongoing1,702
File 15-207approvedMay 20, 2015Jan 10, 2018966
File 15-207closedJan 10, 2018Feb 1, 2020752
File 12-038approvedSep 12, 2012Nov 30, 2014809
File 12-038closedNov 30, 2014Apr 18, 2016505
Timeline strip
<%= rui_chart(type: :timeline_strip, title: "Applications by file, time in review",
      rows: [
        { label: "File 19-114",
          segments: [{ from: "2019-03-04", to: nil, group: "open", note: "Under review" }],
          markers: [{ at: "2021-06-02", label: "Second filing" }] },
        { label: "File 15-207",
          segments: [{ from: "2015-05-20", to: "2018-01-10", group: "approved" },
                     { from: "2018-01-10", to: "2020-02-01", group: "closed" }] }
      ],
      domain: { from: "2008-01-01", to: "today" },
      as_of: "2026-10-13",   # optional: freeze "today" for a saved report
      groups: { "open" => 0, "approved" => 1, "closed" => 2 },
      sort: :days, max_rows: 12) %>

Lollipop

type: :lollipop (0.79.0+) is a ranked list lighter than horizontal bars: per row a label, a thin rule from 0 to the value, a dot at the value and the value after it. It takes the same data: rows as :hbar (label:, value:, href:, tooltip:, note:, highlight:), so switching is one word. The longest value reaches the end of the row (y_max: sets a larger end). Below 480 px the label sits above its rule.

  • sort: :desc, :asc, or nil to keep your order (default).
  • max_rows: keeps the first n rows. rest: :hide (default) drops the others; rest: :other groups them into an "Other n" row like :hbar. A named list ("top streets") should not show "Other" as if it were one more place.
  • rest_label: is your text under the list when rows are hidden; %{count} becomes the number hidden. Without it nothing is printed.
  • Each dot is a focusable mark (tooltip, arrow keys, rui-chart:select, a link with href:), with the hidden table for screen readers. highlight: dims the other rows.
  • Negative values clamp to 0. The update API is not supported on :lollipop yet (it logs and does nothing); re-render instead.
  • Entry motion: rules grow in and the dots fade in.
Homes named, top 6
Illustrative
  • File 17-052
  • File 19-114
  • File 22-301
  • File 24-090
  • File 21-008
  • File 15-207

2 more in the records

Homes named, top 6
ItemValueShare
File 17-0522,3152,315 of 5,645 · 41%
File 19-1141,2401,240 of 5,645 · 22%
File 22-301860860 of 5,645 · 15%
File 24-090640640 of 5,645 · 11%
File 21-008410410 of 5,645 · 7%
File 15-207180180 of 5,645 · 3%
Lollipop
<%= rui_chart(type: :lollipop, title: "Homes named, top 6",
      data: files.map { |f| { label: f.number, value: f.homes, href: file_path(f) } },
      sort: :desc, max_rows: 6, rest_label: "%{count} more in the records") %>

Funnel

type: :funnel (0.80.0+) draws one centred bar per step, in your order, each sized as a share of the first step (the first is full width). Same data: rows as :hbar (label:, value:, href:, tooltip:, note:, highlight:). Below 480 px the label sits above its bar.

  • mode: :conversion (default) is for a true cohort: each step prints its count and "x% of <first>", and the drop from the previous step shows between rows. A step larger than the first clamps to full width and logs a warning in development.
  • mode: :stages is for stages that overlap or are not a subset of each other (a report can be closed without a reference number; re-reported is not a narrowing step). Bars still size against the first step for the eye, but only the count prints, with no percentages and no drop, in the hidden table too. Order is not assumed.
  • A step of 0 draws as a 2 px hairline with "0" printed; it is never dropped.
  • colors: :steps gives each step its own series colour (--rui-chart-1 onwards).
  • Each bar is a focusable mark (tooltip, arrow keys, rui-chart:select, a link with href:). Bars grow from their centre on entry. The update API is not supported on :funnel yet.

Conversion: a true cohort

Sign-up funnel
Illustrative, last 30 days
  1. Visited
    1,000
  2. Signed up
    400 · 40% of Visited
  3. Paid
    100 · 10% of Visited
Sign-up funnel
StepCountShare of first
Visited1,000100%
Signed up40040%
Paid10010%
Funnel, conversion
<%# A true cohort: each step is a subset of the one before %>
<%= rui_chart(type: :funnel, title: "Sign-up funnel",
      data: [{ label: "Visited", value: 1000 }, { label: "Signed up", value: 400 }, { label: "Paid", value: 100 }]) %>

Stages: counts only

311 reports by stage
Stages overlap; counts only
  1. Reported
    240
  2. Got a reference number
    180
  3. Closed
    150
  4. Re-reported
    60
311 reports by stage
StageCount
Reported240
Got a reference number180
Closed150
Re-reported60
Funnel, stages
<%# Overlapping stages that are not a cohort: counts only %>
<%= rui_chart(type: :funnel, mode: :stages, colors: :steps, title: "311 reports by stage",
      data: @report_stages) %>

Calendar

type: :calendar (0.81.0+) is a day grid like a contribution graph: one column per week, one row per weekday, each day coloured by its count on the first series colour. days: is a hash of Date (or Time, or a date string) to count.

  • Range: from: / to:. By default the 365 days ending on as_of: (or today). Pass as_of: for a saved report so the grid never moves; an unreadable as_of: raises in development and test. Days in range with no entry are 0; entries outside the range are dropped.
  • week_start: :monday (default) or :sunday. Weekday labels show Mon, Wed and Fri; month labels sit above each month's first week.
  • 0 is the empty track colour, not the lightest tint. The legend shows the empty cell with zero_label: (default "0" plus unit:), then the min to max ramp.
  • Phones: below 480 px the grid shows the last months: (default 2 since 0.83.0, so each day stays at least a 24 px tap target in a typical phone card; pass months: 1 in a narrower container) instead of the whole range, and the range line above the grid states each range. No horizontal scroll.
  • Each day is a focusable mark with "Tue Oct 13, 2026: 4 reports" as its label and tooltip. Left and Right arrows move a week, Up and Down a day, as the grid reads. Clicking dispatches rui-chart:select with { date, value, ... }; days are not links. The hidden table lists each month's total and busiest day. The update API is not supported yet.

The demo is pinned with as_of: "2026-10-14", so it shows the same year on every visit. The counts are illustrative.

Reports per day

Aug 15, 2026 to Oct 14, 2026

AugSepOctMonWedFri
No reports 1 9
Reports per day, Oct 15, 2025 to Oct 14, 2026
MonthTotalBusiest day
Oct 202557 reportsOct 15 (6 reports)
Nov 2025135 reportsNov 5 (8 reports)
Dec 2025154 reportsDec 3 (8 reports)
Jan 202675 reportsJan 7 (5 reports)
Feb 2026105 reportsFeb 4 (7 reports)
Mar 2026150 reportsMar 4 (8 reports)
Apr 202675 reportsApr 1 (5 reports)
May 202668 reportsMay 6 (5 reports)
Jun 2026116 reportsJun 10 (7 reports)
Jul 2026123 reportsJul 1 (7 reports)
Aug 2026173 reportsAug 5 (9 reports)
Sep 202695 reportsSep 2 (6 reports)
Oct 202637 reportsOct 7 (6 reports)
Calendar
<%= rui_chart(type: :calendar, title: "Reports per day", unit: "reports",
      days: reports.group(:reported_on).count, as_of: report.built_on,
      week_start: :sunday, zero_label: "No reports") %>

Waffle

type: :waffle (0.82.0+) is a grid of squares in data order with a legend. Same data: rows as :hbar (label:, value:, href:, tooltip:).

  • squares: :percent (default): 100 squares, 1% each. Shares round by largest remainder, so the grid always holds exactly 100. The legend prints "18 · 45%".
  • squares: :count: one square per item, for small totals where 1% squares would claim a precision the data does not have. The legend prints counts only and notes "One square for each report". Above 200 it shows percent squares and logs a note in development.
  • max_items: (default 8) and group_small: (default true): the rest, and in percent mode anything under one square, group into "Other" (axis colour). group_small: false keeps every item.
  • The squares are hidden from screen readers; each legend row is a focusable mark (tooltip, arrow keys, rui-chart:select, a link with href:) and hovering or focusing one dims the other items' squares. The hidden table lists each item's count (and share in percent mode).
  • From 480 px the legend sits beside the grid, below it on phones. Squares fade in on entry. The update API is not supported yet.

Percent

Issue mix
Illustrative
Issue mix
ItemCountShare
Pothole4553.6%
Graffiti1821.4%
Streetlight1214.3%
Noise910.7%
Waffle, percent
<%= rui_chart(type: :waffle, title: "Issue mix", data: issue_counts) %>

Count

Reports this week
Illustrative

One square for each report.

Reports this week
ItemCount
Pothole14 reports
Graffiti9 reports
Streetlight6 reports
Noise4 reports
Waffle, count
<%# Small totals: one square for each report, counts only %>
<%= rui_chart(type: :waffle, squares: :count, unit: "reports", data: issue_counts, max_items: 8) %>

Slope

type: :slope (0.83.0+) compares two columns row by row. The column names sit once in a header; each row shows its label, the left value, a small two-point slope, the right value and the change.

  • Each row is on its own scale by default, so rows in different units never share an axis. shared_axis: true puts every row on one scale (only for rows in the same unit).
  • Per row: value_format: and unit: (else the chart's), change: :percent (relative, default), :points (difference, for rows that are percentages) or :none; href:, note:. change: on the chart sets the default for every row. Equal values read "no change".
  • tone: :neutral (default) colours by column: the left dot --rui-chart-1, the right dot --rui-chart-2, the line in the axis colour, so nothing reads as better or worse. tone: :direction colours the line by up or down. tone: :good uses each row's good: :higher | :lower.
  • Each row's slope is a focusable mark whose label reads "Open share: This area 34%, Toronto 21%, 13 points lower". The hidden table lists both columns and the change.
  • Layout: from 480 px the label column takes the spare width (at least 9rem) and every row keeps a 64 px change slot, so columns line up even on rows with change: :none (0.83.3+). Below 480 px the label sits above its row, the change gets its own line, and long values cut with an ellipsis, full value in the tooltip (0.83.1+).

Neutral, each row on its own scale

This area vs the city
Illustrative
  • Open share
    34% 21% -13 pts
  • Reports per km2
    12.5 per km2 18 per km2
  • Median days to close
    9 days 9 days no change
This area vs the city
MeasureThis areaTorontoChange
Open share34%21%13 points lower
Reports per km212.5 per km218 per km2
Median days to close9 days9 daysno change
Slope, neutral
<%= rui_chart(type: :slope, columns: ["This area", "Toronto"], rows: [
      { label: "Open share", values: [34, 21], value_format: :percent, change: :points },
      { label: "Reports per km2", values: [12.5, 18], unit: "per km2", change: :none },
      { label: "Median days to close", values: [9, 9], unit: "days" }
    ]) %>

One shared axis, coloured by direction

Requests by type
Illustrative
  • Pothole
    1,210 980 -19%
  • Graffiti
    640 860 +34%
  • Noise
    380 410 +8%
Requests by type
Measure20242025Change
Pothole1,21098019% lower
Graffiti64086034% higher
Noise3804108% higher
Slope, shared axis
<%= rui_chart(type: :slope, columns: %w[2024 2025], shared_axis: true, tone: :direction, rows: [
      { label: "Pothole", values: [1210, 980] },
      { label: "Graffiti", values: [640, 860] },
      { label: "Noise", values: [380, 410] }
    ]) %>

Tooltips Off

tooltips: false turns the hover and focus card off. Hover dimming, aria-labels and the hidden table stay.

No tooltip card
0 5 10 15 20
2021 2022 2023
No tooltip card
Category collisions
2021 14 collisions
2022 17 collisions
2023 9 collisions
Tooltips off
<%= rui_chart(type: :bar, tooltips: false, data: @collisions_by_year, unit: "collisions") %>

Play Through Time

timeline: adds a play/pause button, a scrubber (arrow keys step it) and the current category, as a chip apart from the button, under the caption. Since 0.77.0 the button shows a play or pause icon with "Play"/"Pause" (swapped by aria-pressed), button: :outline by default or :solid in the first series colour, with hover and focus rings; label: is its accessible name and tooltip. It works on :bar (vertical), :line and :area, with the categories in order. The server renders the full chart, so nothing moves without JavaScript.

  • Play reveals categories one by one at step_ms (default 600): columns grow in at their slot, the line extends to the next point, and the projection and band appear on the last step.
  • The axis is fixed to the final domain, so nothing rescales mid-play. autoplay: true starts on view.
  • The chart dispatches rui-chart:timeline with { index, label, playing }.
  • Reduced motion: the controls work, steps jump with no tween, and autoplay is ignored.
  • Not on :hbar, :stacked, :donut or :pie.

Population with projection and band

Sheppard East population
Press play
If built
If every open or approvedapplication is built
  • Census
Sheppard East population
Category Census
2011 81,614
2016 86,038
2021 89,040
If built 0
Timeline on a line chart
<%= rui_chart(type: :line, timeline: { label: "Play 2011 to If built", step_ms: 600 },
      series: [{ name: "Census", points: [["2011", 81614], ["2016", 86038], ["2021", 89040]] }],
      projection: { from: "2021", to: "If built", value: 108258 },
      band: { at: "If built", low: 104525, high: 112761, label: "If every open or approved application is built" },
      value_format: :number) %>

Applications by year

Applications by year
Press play
2026
0 2 4 6 8 10
1 2 2 0 2 9 5 5 6 4 4 3 8 6 8 1 4 3 3
2008 2011 2014 2017 2020 2023 2026
Applications by year
Category OpenApprovedClosed
2008 001
2009 002
2010 002
2011 000
2012 002
2013 009
2014 005
2015 014
2016 006
2017 004
2018 004
2019 012
2020 215
2021 213
2022 431
2023 001
2024 202
2025 120
2026 300
Timeline on stacked columns
<%= rui_chart(type: :bar, layout: :stacked, timeline: { label: "Play 2008 to 2026" },
      categories: @years, series: [{ name: "Open", values: @open_by_year },
                                   { name: "Approved", values: @approved_by_year },
                                   { name: "Closed", values: @closed_by_year }]) %>

Captions and a count-up readout

  • captions: is your text, one per category (nil allowed) or a hash keyed by category label. It shows under the controls for the current step; final: replaces the last one at the end. The gem never writes a caption itself.
  • readout: shows a number that counts up on each step over 0.8 × step_ms (reduced motion jumps). mode: :cumulative (default) sums from the first category through the current step, :step sums at the step, :value shows one series' value at the step (at a category the series has no point for, the projection value when the projection starts from that series, else its last real point; 0.74.1+). series: "name" picks a series (default: every series summed), label: adds a caption after the number. Formatted with value_format:. readout: true is the cumulative default with no label.
Applications by year
Press play
2026 76 applications filed

76 applications within 400 m, 2008 to 2026

0 2 4 6 8 10
1 2 2 0 2 9 5 5 6 4 4 3 8 6 8 1 4 3 3
2008 2011 2014 2017 2020 2023 2026
Applications by year
Category OpenApprovedClosed
2008 001
2009 002
2010 002
2011 000
2012 002
2013 009
2014 005
2015 014
2016 006
2017 004
2018 004
2019 012
2020 215
2021 213
2022 431
2023 001
2024 202
2025 120
2026 300
Captions and readout
<%= rui_chart(type: :bar, layout: :stacked, categories: @years, series: @series_by_status,
      timeline: { label: "Play 2008 to 2026",
                  captions: { "2013" => "2013: the busiest year, nine applications closed",
                              "2022" => "2022: four still open, three approved" },
                  final: "76 applications within 400 m, 2008 to 2026",
                  readout: { mode: :cumulative, label: "applications filed" } }) %>

<%# one series' value at each step %>
<%= rui_chart(type: :bar, categories: @years, series: @series_by_status,
      timeline: { readout: { series: "Open", mode: :value, label: "open" } }) %>

Update From the App

Dispatch rui-chart:update on the chart element to swap its data without re-rendering HTML, for example from a filter control. Marks tween to the new values over 400 ms, and tooltips, aria-labels, value labels, stack totals, legend values and the hidden table are rewritten. rui-chart:updated fires when the motion ends.

Applications
0 1 2 3 4
2021 2022 2023
Applications
Category OpenClosed
2021 2 applications3 applications
2022 4 applications1 applications
2023 0 applications1 applications
Dispatch rui-chart:update
figure.dispatchEvent(new CustomEvent("rui-chart:update", {
  detail: { categories: ["2021", "2022"], series: [{ name: "Open", values: [3, 5] }, { name: "Closed", values: [8, 2] }] }
}))
// single series: detail: { data: [{ label: "2021", value: 3 }, ...] }

Limits:

  • Same series count and names as rendered.
  • Categories can shrink (their bars, rows, totals and hover areas hide) but cannot grow past what the server rendered, and axis labels keep their server text.
  • Built-in formats (:number, :percent, :currency, :compact) are re-applied. A lambda value_format: cannot run in the browser, so an update formats as :number.
  • The domain grows if the new values need it and never shrinks. Line and area morph only when the category count is unchanged.
  • A playing timeline is paused first. A chart not yet scrolled into view settles its entry motion instantly before the update.

The two buttons above use a small docs-side Stimulus controller that dispatches the event. In your app, wire the dispatch to whatever drives the filter.

Entry Motion

animate: true (the default; :enter is an alias) plays once when the chart first scrolls into view: bars grow from the axis, lines draw in, areas fade up after the line, donut and pie slices reveal in order, and the projection and band fade in last. animate: false turns it off. Reduced motion shows the final state.

No entry motion
0 5 10 15 20
2021 2022 2023
No entry motion
Category collisions
2021 14 collisions
2022 17 collisions
2023 9 collisions
Entry motion off
<%= rui_chart(type: :bar, animate: false, data: @collisions_by_year, unit: "collisions") %>

Column Hover and Stack Totals

Multi-series column charts use full-height column areas: hover anywhere in a column to see its whole tooltip, with every series. Stacked columns show their total above each stack. With show_share: true, each line also shows its share of that column. Both the column tooltip and the totals hide while a legend item is toggled off, since they describe every series.

0 2 4 6 8 10
7 10 8
2021 2022 2023
Chart data
Category PedestrianCyclist
2021 61
2022 82
2023 71
Stacked columns with totals
<%= rui_chart(type: :bar, layout: :stacked, show_share: true, categories: %w[2021 2022 2023],
      series: [{ name: "Pedestrian", values: [6, 8, 7] },
               { name: "Cyclist", values: [1, 2, 1] }]) %>

100% Status Bar

A single 100% bar shows shares. Hovering the bar lists every part with the total and each share.

Status share
  • Open 14
  • Approved 9
  • Closed 53
Status share
CategoryValueShare
Open1414 of 76 · 18%
Approved99 of 76 · 12%
Closed5353 of 76 · 70%
100% status bar
<%= rui_chart(type: :stacked, title: "Status share", data: @status_counts) %>

Chrome Colours

Text, muted text, tracks, tooltips and the title font are CSS variables. The chart has no dark: classes, so a subtree themed by its own colour settings works. Every fallback is a light-dark() pair and follows the element's color-scheme, so a color-scheme: dark subtree gets dark chrome with no variables set.

Variable Used for
--rui-chart-textTitles, labels, values
--rui-chart-mutedSubtitles, notes, axis labels
--rui-chart-trackHorizontal bar tracks and the 100% single bar
--rui-chart-gridGrid lines
--rui-chart-axisAxis border
--rui-chart-tooltip-bg, --rui-chart-tooltip-fgTooltip card
--rui-chart-title-fontTitle font family

Overrides on one chart

Chrome overrides
Custom text, track and tooltip colours
  • Pothole
  • Streetlight
  • Graffiti
0 50 100 150 200 250
Chrome overrides
Category Value
Pothole 210
Streetlight 75
Graffiti 40
Chrome colours
:root {
  --rui-chart-text: #0f172a;
  --rui-chart-muted: #64748b;
  --rui-chart-track: #e2e8f0;
  --rui-chart-tooltip-bg: #0f172a;
  --rui-chart-tooltip-fg: #f8fafc;
}

Sheppard East Example

Example data. Illustrative example built from aggregate figures only, 76 applications within 400 m. Sources: City of Toronto open data, including building applications, population from the 2011, 2016 and 2021 Census, and the TTC and collisions data as used in the Sheppard East dashboard. No resident reports, street addresses or Neighbourhood care data are shown.

Population, census and projection

Sheppard East population
Census and projection
If every open or approvedapplication is built
  • Census
Sheppard East population
Category Census
2011 81,614
2016 86,038
2021 89,040
If built 0

Status share

Applications by status
  • Open 14
  • Approved 9
  • Closed 53
Applications by status
CategoryValueShare
Open1414 of 76 · 18%
Approved99 of 76 · 12%
Closed5353 of 76 · 70%

Status donut

76 applications
  • Open 14 (18.4%)
  • Approved 9 (11.8%)
  • Closed 53 (69.7%)
Chart data
CategoryValue
Open14 (18.4%)
Approved9 (11.8%)
Closed53 (69.7%)

Sheppard East: Applications by Year

Illustrative example. Applications within 400 m by year and current status, 76 in total. Years with no applications are zero.

Applications by year
Open, approved and closed, within 400 m
0 2 4 6 8 10
1 2 2 0 2 9 5 5 6 4 4 3 8 6 8 1 4 3 3
2008 2011 2014 2017 2020 2023 2026
Applications by year
Category OpenApprovedClosed
2008 001
2009 002
2010 002
2011 000
2012 002
2013 009
2014 005
2015 014
2016 006
2017 004
2018 004
2019 012
2020 215
2021 213
2022 431
2023 001
2024 202
2025 120
2026 300
Applications by year
<%= rui_chart(type: :bar, layout: :stacked, show_share: true, title: "Applications by year",
      categories: %w[2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026],
      series: [
        { name: "Open", values: @open_by_year },
        { name: "Approved", values: @approved_by_year },
        { name: "Closed", values: @closed_by_year }
      ]) %>

Crowded axes

This chart has 19 categories. Vertical bar and line charts show at most 8 category labels: every nth, always the first and last. Every mark keeps its full label in its tooltip, aria-label and the hidden table. label_every: n sets the step yourself, and 1 shows all. Horizontal bars list every row.

Edge Cases

Zero values

A zero draws a zero-height mark that is still focusable.

0 1 2 3 4
Mon Tue Wed
Chart data
Category Value
Mon 0
Tue 4
Wed 0

All values zero

Shows a zero baseline, no marks, and the note "All values are zero."

0 0.2 0.4 0.6 0.8 1
Mon Tue
Chart data
Category Value
Mon 0
Tue 0

All values are zero.

Long labels

Long category labels truncate. The full text is in the tooltip and the aria-label.

  • Street lighting repair and maintenance request
  • Pothole on a residential side street
  • Noise complaint
0 20 40 60 80
Chart data
Category Value
Street lighting repair and maintenance request 64
Pothole on a residential side street 41
Noise complaint 18

One category, many series

Works. The bars share the category slot.

0 50 100 150
Week 14
Chart data
Category WalkBikeBusCar
Week 14 1208015060

No-JS and Accessibility

  • Without JavaScript the chart still renders, prints, and shows every value in the hidden table. Legend toggles and tooltips need JavaScript.
  • Every mark is focusable and has an aria-label such as "2022, Cyclist: 2 collisions".
  • A visually hidden table holds every series. The 100% bar has one too, with label, value and share.
  • Reduced motion turns off the grow-in animation.