A grouped column chart for Bootstrap 5 that compares two regions side by side for every quarter, built with plain HTML, CSS and a small script instead of a chart library. This clustered bar chart example has value labels, dashed gridlines, a legend, keyboard tooltips and a Revenue / Profit switch, so it fits sales reports, regional dashboards and admin panels.
How it works
The root is section.gcc with a Bootstrap card inside. The header holds the title, a polite live line ([data-gcc-live]) and the .gcc-switch button group made of two btn-check radios. Below it, the dl.gcc-stats row shows the total per region, the combined total and the best quarter.
All numbers live in the DATA object at the top of script.js: categories, series (name and color) and one values matrix per metric. On DOMContentLoaded the script builds the legend, then one li.gcc-group per quarter with one button.gcc-bar per region. render() picks a rounded axis maximum with niceStep(), draws the .gcc-yaxis labels and .gcc-grid lines and sets every bar height through the --gcc-h custom property. Each bar shows its value in .gcc-val.
Hovering, focusing or tapping a bar moves the single .gcc-tip tooltip above it (or beside it when the column is tall) with the exact value and the change against the previous quarter. Switching the radio re-renders the axis, bars, totals and the visually hidden table.
Customization
DATA.metricsinscript.js: replace thevaluesarrays (one row per series) with your own figures; the axis, totals and table follow.DATA.series: rename the regions or changecolor; add a third series by adding a third row to eachvaluesmatrix and a matchingdata-gcc-stat="s2"figure in.gcc-stats.DATA.ticks: sets roughly how many gridlines the axis gets;DATA.unitchanges the label above the axis.DATA.initial: picks the column that is highlighted with its tooltip on load.--gcc-plot-hon.gcc: makes the plot taller or shorter.--gcc-radius: rounds the column tops more or less;--gcc-bgand--gcc-surfacechange the page and card colors.
Use cases
- Sales dashboards: compare two regions, teams or channels per quarter.
- Finance reports: switch between revenue and profit without reloading the page.
- SaaS admin panels: show plan A against plan B sign-ups per month.
Accessibility
Every column is a real button with an aria-label such as "Q3, Americas: $503k revenue, up 7.5% from Q2", so Tab, Left/Right arrows, Home and End move between columns, and Escape hides the tooltip. The metric switch is a labelled group of native radios. A visually hidden table inside the figcaption repeats every number, and the live line announces the new metric and combined total. Focus outlines are visible, and the height transition is turned off with prefers-reduced-motion: reduce.
Usage notes
Requires Bootstrap 5.3 CSS only. Several .gcc charts can share one page: the script gives each radio group a unique name and id.