A stacked bar chart built with Tailwind CSS utilities and plain JavaScript, with no chart library and no canvas. This stacked column chart example shows weekly support tickets split into new, in progress and resolved, with a value axis, tooltips on every segment and checkbox chips that filter the series. Use it in helpdesk dashboards, admin panels and status reports.
How it works
The root section.sbc-root contains a header with three chips (label.sbc-chip wrapping a visually hidden checkbox with data-sbc-toggle), a row of figures and the chart. The chart is a small grid: [data-sbc-axis] holds the value labels, .sbc-plot holds the gridlines [data-sbc-grid], the bars [data-sbc-bars] and one shared tooltip [data-sbc-tip], and [data-sbc-labels] shows the weeks.
The script reads the DATA object at the top of script.js. It computes the Monday of each of the last eight weeks from today (shown as "Nov 3", or "11/3" on narrow screens, never with a year) and builds one .sbc-col per week with a .sbc-stack of button.sbc-seg elements. Each stack is as tall as its week total relative to the axis maximum, and each segment takes its share of the stack.
Hovering, tapping or focusing a segment marks it .is-active and places the tooltip next to it with the week, the status, the count and its share of the week. Unchecking a chip hides that status, recalculates the totals and the busiest week and rescales the axis; with motion allowed, the bars animate to their new height.
Customization
DATA.seriesinscript.js: replacevalueswith your weekly counts, or rename and recolor each status withnameandcolor.DATA.ticks: roughly how many gridlines the value axis gets (default4).DATA.unit: the word used in tooltips and announcements, for exampleordersorhours..sbc-plotheight instyle.css:15remon phones and17remfrom 640px.max-w-12on.sbc-stack(set inscript.js): wider or slimmer bars.- The chip colors in
style.css(.sbc-chip input[data-sbc-toggle="new"]:checked): keep them in sync withDATA.series[].color.
Use cases
- Helpdesk and customer support dashboards: weekly ticket volume by status.
- Project management tools: tasks opened, in review and done per sprint.
- Operations reports: orders received, packed and shipped per week.
Accessibility
The chips are real checkboxes inside a fieldset with a hidden legend, so Space toggles them and the focus ring follows the checkbox. The bars group uses a roving tabindex: only one segment is in the tab order, Left and Right move between weeks, Up and Down between statuses, and Home and End jump to the first or last week. Each segment has an aria-label with the full value. A polite live region announces which series are shown and the new axis maximum, the last visible status cannot be hidden, and a visually hidden table lists every number. Reduced motion turns off the height animation.
Usage notes
The Inter font loads from Google Fonts. Every query is scoped to its .sbc-root, so several charts can share a page.