ApexCharts Likert Survey Stacked Bar Chart — Free 100% Stacked Snippet

ApexCharts Likert Survey Stacked Bar Chart · Charts · Plain HTML, CSS & JS · Live preview

CategoryCharts

What's included

Features

100% stacked bars
stackType converts counts to row shares.
Diverging palette
Red to grey to blue, avoiding red-green.
Smart data labels
Hidden on segments under 7%.
Per-series label colours
Readable text on every fill.
Counts in tooltips
Percent plus raw response count.
Agreement sort
Rank by combined agree share.
Long labels handled
yaxis maxWidth wraps statement text.
Accessible sort control
Buttons expose aria-pressed.

About this UI Snippet

ApexCharts Likert Chart — Comparing Survey Answers Across Statements

Screenshot of the ApexCharts Likert Survey Stacked Bar Chart snippet rendered live

Likert questions ("strongly disagree" to "strongly agree") produce five numbers per statement. The standard way to compare many statements is a 100% stacked horizontal bar: every row is the same length, split by answer, so the eye compares the size of the blue (agree) and red (disagree) regions across rows.

stackType '100%' does the maths

The series hold raw response counts, one series per answer option. chart.stacked: true with stackType: '100%' makes ApexCharts convert each row into shares. That matters when rows have different numbers of responses: 180 "agree" out of 412 and 180 out of 300 are not the same result, and percentages make them comparable.

A diverging, colour-blind-friendlier palette

Disagreement uses two reds, neutral a light grey, agreement two blues. A red-to-green scale is common but hard to read for people with red-green colour deficiency; red-to-blue keeps the "negative/positive" reading while staying distinguishable.

Labels that know when to stay quiet

Data labels show percentages, but the formatter returns an empty string for segments under 7%. A "3%" squeezed into a 10-pixel segment is unreadable and overlaps its neighbours. Label colours are set per series so text contrasts with each segment's fill.

Counts in the tooltip

The axis and labels show percentages; the tooltip shows the raw count as well, so readers can judge whether a percentage is based on many or few responses.

Sorting by agreement

"Most agreed" reorders statements by their combined agree + strongly agree share. Survey order is kept as the default, because the order questions were asked in can itself affect answers.

Step by step

How to Use

  1. 1
    Load ApexChartsInclude apexcharts.min.js from the CDN.
  2. 2
    Paste the snippetSix survey statements render as 100% stacked bars.
  3. 3
    Hover a segmentThe tooltip shows the count and its share of that statement.
  4. 4
    SortSwitch to "Most agreed" to rank statements by agreement.
  5. 5
    Add your surveyEdit ROWS with statements and five counts each.

Real-world uses

Common Use Cases

Employee engagement pulse surveys
Compare twenty statements at once on a 100% stacked bar. Every row is the same length, so HR can spot the weakest agree share instantly. Swap the statements array for your own survey questions.
Customer satisfaction results
Turn a post-purchase or support questionnaire into a diverging blue-to-red chart. Percentage labels hide on segments under 7%, so thin answers stay clean while the large ones stay readable.
Course and training evaluations
Show how students rated teaching clarity, pacing and materials across modules. The "most agreed" sort, driven by agreeShare, puts the best and worst rated items at the top of the report.
UX research and SUS questionnaires
Plot usability statements on the same five-point scale so a stakeholder deck reads at a glance. The red, grey and blue palette avoids the red-green trap in shared slides.
Converting counts to percentages
Feed the chart raw response counts and let stackType: '100%' convert each row to shares, so statements with different numbers of respondents still compare fairly side by side.
Related: Stacked Bar Chart
A no-library version: Stacked Bar Chart.
Related: NPS Survey Widget
Collect the answers with NPS Survey Widget.

Got questions?

Frequently Asked Questions

Set chart.type to 'bar', chart.stacked to true and chart.stackType to '100%'. Pass raw values; ApexCharts converts each category to shares that add up to 100%. Add plotOptions.bar.horizontal: true for horizontal bars.

Statements can have different numbers of responses, for example when a question is optional. Percentages make rows comparable. Keep counts available, for example in a tooltip, so readers can see the base size.

Red-green colour vision deficiency is common, and it makes a red-to-green scale hard to read. Red-to-blue keeps a clear negative-to-positive meaning while remaining distinguishable.

Return an empty string from dataLabels.formatter when the value is below a threshold. With stackType '100%', the value passed to the formatter is the percentage.

Some Likert charts centre the neutral segment on a zero line to create a diverging bar. That emphasises the agree-disagree balance; the 100% stack shown here is simpler and keeps every row aligned at the left.

Build with AI

Build, Understand, Optimize, and Extend It With AI

Paste this snippet into an AI assistant like Claude and ask how stackType '100%' changes the values passed to formatters and why the palette avoids red-green. Ask it to convert the chart into a centred diverging Likert chart, add a net-agreement score column, filter by department, or compare this quarter with the last. It can also review your statement wording for leading questions.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a Likert survey results chart with ApexCharts (loaded from a CDN) in plain HTML, CSS and JavaScript.

Requirements:
- Six survey statements, each with raw response counts for five answers from "Strongly disagree" to "Strongly agree".
- Render a horizontal 100% stacked bar chart with one series per answer option, so each row shows answer shares.
- Use a diverging palette: two reds, a light grey for neutral and two blues.
- Show percentage data labels inside segments, hiding them on segments under 7%, with label colours chosen to contrast with each fill.
- Show the raw count and its percentage of that statement in the tooltip.
- Add a toggle between survey order and sorting by combined agree + strongly agree share, updating categories and series together.
- Put the legend at the top and allow long statement labels to wrap.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

Source Code

Requires
<div class="alk-wrap">
  <div class="alk-card">
    <div class="alk-head">
      <div>
        <div class="alk-title">Employee Survey 2026 — Q3</div>
        <div class="alk-sub">Share of responses per statement · n = 412</div>
      </div>
      <div class="alk-sort" role="group" aria-label="Sort statements">
        <button type="button" data-sort="survey" aria-pressed="true">Survey order</button>
        <button type="button" data-sort="agree" aria-pressed="false">Most agreed</button>
      </div>
    </div>
    <div id="alkChart"></div>
  </div>
</div>