Bootstrap Charts: 16 Examples Without a Chart Library

Bootstrap has no chart component. Every chart in a Bootstrap card is drawn by a JavaScript library, usually Chart.js, which logged 7,128,991 npm downloads in the week of October 12 to 18, 2026.

Below are 16 Bootstrap chart examples made from progress bars, cards and inline SVG with no library, followed by a guide to Chart.js setup, sizing, dark mode and accessibility.

By Bogdan Sandu ยท Updated October 29, 2026

Every example runs on Bootstrap 5.3.8 from the jsDelivr CDN. Add these tags to your page, then paste an example's HTML, CSS and JS.

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.2/font/bootstrap-icons.min.css" rel="stylesheet" integrity="sha384-nWN3KqaaVcbEsCjLSV+2jMjh62Iny/+mN3srM8TZeM8N6aj7eDl5wwYggjAJ4/sJ" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>

Bar charts built from the progress component

A .progress bar is a single horizontal value, so a stack of them is already a bar chart. These four use .progress, .progress-stacked and the --bs-progress-* variables for ranked bars, a budget split, bullet charts and a themed funnel.

Horizontal bar chart from progress bars

  • .progress
  • --bs-progress-height
  • --bs-progress-bar-bg
  • list-unstyled d-grid
  • text-body-secondary

Each source is a list item with its label and value in text, plus a .progress bar that is aria-hidden because the numbers are already readable. The bars are scaled to a 0 to 50% axis printed under the list, so the longest bar is not simply full width. The custom CSS only sets the bar height and colors through the --bs-progress-* variables and switches to tabular figures.

View code
<div class="card bch-traffic border-0 shadow-sm">
  <div class="card-body p-4">
    <div class="d-flex flex-wrap justify-content-between align-items-baseline gap-2 mb-4">
      <h2 class="h6 mb-0">Traffic sources</h2>
      <span class="small text-body-secondary">Last 30 days, 40,040 sessions</span>
    </div>
    <ul class="list-unstyled d-grid gap-3 mb-2">
      <li>
        <div class="d-flex justify-content-between gap-2 small mb-1"><span class="fw-medium">Organic search</span><span class="bch-num">18,420 <span class="text-body-secondary">(46%)</span></span></div>
        <div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 92%"></div></div>
      </li>
      <li>
        <div class="d-flex justify-content-between gap-2 small mb-1"><span class="fw-medium">Direct</span><span class="bch-num">9,610 <span class="text-body-secondary">(24%)</span></span></div>
        <div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 48%"></div></div>
      </li>
      <li>
        <div class="d-flex justify-content-between gap-2 small mb-1"><span class="fw-medium">Referral</span><span class="bch-num">6,020 <span class="text-body-secondary">(15%)</span></span></div>
        <div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 30%"></div></div>
      </li>
      <li>
        <div class="d-flex justify-content-between gap-2 small mb-1"><span class="fw-medium">Social</span><span class="bch-num">4,010 <span class="text-body-secondary">(10%)</span></span></div>
        <div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 20%"></div></div>
      </li>
      <li>
        <div class="d-flex justify-content-between gap-2 small mb-1"><span class="fw-medium">Email</span><span class="bch-num">1,980 <span class="text-body-secondary">(5%)</span></span></div>
        <div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 10%"></div></div>
      </li>
    </ul>
    <div class="d-flex justify-content-between small text-body-secondary bch-traffic-axis" aria-hidden="true"><span>0%</span><span>25%</span><span>50%</span></div>
  </div>
</div>

Stacked progress budget breakdown

  • .progress-stacked
  • role="progressbar"
  • aria-valuenow
  • row-cols-sm-2
  • --bs-progress-bar-bg

This is the documented 5.3 stacked markup: every segment is its own .progress with role="progressbar", an aria-label and its width, holding one .progress-bar. Each segment gets its color from --bs-progress-bar-bg on a prefixed class, a 2px border in the body color separates neighbors, and the legend repeats every value in text so nothing depends on telling the colors apart.

View code
<div class="card bch-budget border-0 shadow-sm">
  <div class="card-body p-4">
    <div class="d-flex flex-wrap justify-content-between align-items-baseline gap-2 mb-3">
      <div>
        <h2 class="h6 mb-1">Q4 marketing budget</h2>
        <p class="small text-body-secondary mb-0">Allocated by channel, October to December</p>
      </div>
      <span class="h5 mb-0 bch-num">$84,000</span>
    </div>
    <div class="progress-stacked">
      <div class="progress bch-c1" role="progressbar" aria-label="Paid media" aria-valuenow="38" aria-valuemin="0" aria-valuemax="100" style="width: 38%"><div class="progress-bar">38%</div></div>
      <div class="progress bch-c2" role="progressbar" aria-label="Content" aria-valuenow="24" aria-valuemin="0" aria-valuemax="100" style="width: 24%"><div class="progress-bar">24%</div></div>
      <div class="progress bch-c3" role="progressbar" aria-label="Events" aria-valuenow="18" aria-valuemin="0" aria-valuemax="100" style="width: 18%"><div class="progress-bar">18%</div></div>
      <div class="progress bch-c4" role="progressbar" aria-label="Tools" aria-valuenow="12" aria-valuemin="0" aria-valuemax="100" style="width: 12%"><div class="progress-bar">12%</div></div>
      <div class="progress bch-c5" role="progressbar" aria-label="Unallocated" aria-valuenow="8" aria-valuemin="0" aria-valuemax="100" style="width: 8%"><div class="progress-bar"></div></div>
    </div>
    <ul class="list-unstyled row row-cols-1 row-cols-sm-2 g-2 small mt-3 mb-0">
      <li class="col"><div class="d-flex align-items-center gap-2"><span class="bch-swatch bch-c1" aria-hidden="true"></span><span class="flex-grow-1">Paid media</span><span class="bch-num fw-medium">$31,920</span></div></li>
      <li class="col"><div class="d-flex align-items-center gap-2"><span class="bch-swatch bch-c2" aria-hidden="true"></span><span class="flex-grow-1">Content</span><span class="bch-num fw-medium">$20,160</span></div></li>
      <li class="col"><div class="d-flex align-items-center gap-2"><span class="bch-swatch bch-c3" aria-hidden="true"></span><span class="flex-grow-1">Events</span><span class="bch-num fw-medium">$15,120</span></div></li>
      <li class="col"><div class="d-flex align-items-center gap-2"><span class="bch-swatch bch-c4" aria-hidden="true"></span><span class="flex-grow-1">Tools</span><span class="bch-num fw-medium">$10,080</span></div></li>
      <li class="col"><div class="d-flex align-items-center gap-2"><span class="bch-swatch bch-c5" aria-hidden="true"></span><span class="flex-grow-1">Unallocated (8%)</span><span class="bch-num fw-medium">$6,720</span></div></li>
    </ul>
  </div>
</div>

Bullet charts with target markers

  • .progress
  • position-relative
  • badge
  • text-bg-success
  • --bs-progress-bg

A bullet chart is a progress bar plus a target line. Every bar is scaled to 125% of its target, so the marker always sits at 80% and a bar that crosses it has beaten the goal. The marker is one absolutely positioned span, and the badge spells out the percentage so the result reads without the color.

View code
<div class="card bch-bullet border-0 shadow-sm">
  <div class="card-body p-4">
    <div class="d-flex flex-wrap justify-content-between align-items-baseline gap-2 mb-4">
      <h2 class="h6 mb-0">October sales vs target</h2>
      <span class="small text-body-secondary d-inline-flex align-items-center gap-2"><span class="bch-key" aria-hidden="true"></span>Target</span>
    </div>
    <ul class="list-unstyled d-grid gap-3 mb-0">
      <li>
        <div class="d-flex justify-content-between align-items-center gap-2 small mb-2"><span class="fw-medium">North</span><span class="bch-num">$46.0k of $50k <span class="badge rounded-pill bg-body-secondary text-body">92%</span></span></div>
        <div class="bch-track"><div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 73.6%"></div></div><span class="bch-target" aria-hidden="true"></span></div>
      </li>
      <li>
        <div class="d-flex justify-content-between align-items-center gap-2 small mb-2"><span class="fw-medium">South</span><span class="bch-num">$54.0k of $50k <span class="badge rounded-pill text-bg-success">108%</span></span></div>
        <div class="bch-track"><div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 86.4%"></div></div><span class="bch-target" aria-hidden="true"></span></div>
      </li>
      <li>
        <div class="d-flex justify-content-between align-items-center gap-2 small mb-2"><span class="fw-medium">West</span><span class="bch-num">$28.4k of $40k <span class="badge rounded-pill bg-body-secondary text-body">71%</span></span></div>
        <div class="bch-track"><div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 56.8%"></div></div><span class="bch-target" aria-hidden="true"></span></div>
      </li>
      <li>
        <div class="d-flex justify-content-between align-items-center gap-2 small mb-2"><span class="fw-medium">East</span><span class="bch-num">$39.6k of $40k <span class="badge rounded-pill bg-body-secondary text-body">99%</span></span></div>
        <div class="bch-track"><div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 79.2%"></div></div><span class="bch-target" aria-hidden="true"></span></div>
      </li>
    </ul>
  </div>
</div>

Conversion funnel themed with CSS variables

  • --bs-card-bg
  • --bs-progress-bar-bg
  • justify-content-center
  • list-unstyled
  • badge

Adding justify-content-center to a .progress centers its bar, and with a transparent --bs-progress-bg the bars stack into a funnel. The whole warm look comes from --bs-card-* and --bs-progress-* variables scoped to .bch-funnel, plus a serif heading. Each step prints its count and its share of the first step.

View code
<div class="card bch-funnel">
  <div class="card-body p-4">
    <h2 class="bch-funnel-title mb-1">Trial funnel</h2>
    <p class="small bch-funnel-sub mb-4">Fieldnote for Teams, October 2026</p>
    <ol class="list-unstyled d-grid gap-3 mb-4">
      <li>
        <div class="d-flex justify-content-between gap-2 small mb-1"><span>Visited pricing</span><span class="bch-num fw-semibold">12,400 <span class="fw-normal bch-funnel-sub">(100%)</span></span></div>
        <div class="progress justify-content-center" aria-hidden="true"><div class="progress-bar" style="width: 100%"></div></div>
      </li>
      <li>
        <div class="d-flex justify-content-between gap-2 small mb-1"><span>Started a trial</span><span class="bch-num fw-semibold">3,720 <span class="fw-normal bch-funnel-sub">(30%)</span></span></div>
        <div class="progress justify-content-center" aria-hidden="true"><div class="progress-bar" style="width: 30%"></div></div>
      </li>
      <li>
        <div class="d-flex justify-content-between gap-2 small mb-1"><span>Invited a teammate</span><span class="bch-num fw-semibold">2,232 <span class="fw-normal bch-funnel-sub">(18%)</span></span></div>
        <div class="progress justify-content-center" aria-hidden="true"><div class="progress-bar" style="width: 18%"></div></div>
      </li>
      <li>
        <div class="d-flex justify-content-between gap-2 small mb-1"><span>Paid</span><span class="bch-num fw-semibold">868 <span class="fw-normal bch-funnel-sub">(7%)</span></span></div>
        <div class="progress justify-content-center" aria-hidden="true"><div class="progress-bar" style="width: 7%"></div></div>
      </li>
    </ol>
    <div class="d-flex flex-wrap align-items-center justify-content-between gap-2 pt-3 bch-funnel-foot">
      <span class="small">Visit to paid conversion</span>
      <span class="badge rounded-pill bch-funnel-badge">7.0%, up from 5.8%</span>
    </div>
  </div>
</div>

KPI cards, gauges and dashboard panels

Dashboard pieces made from cards, badges, tables and a little inline SVG: sparklines, a gauge driven by a range input, a dark realtime panel and data bars inside table cells.

KPI cards with inline SVG sparklines

  • row-cols-md-3
  • card
  • bg-success-subtle
  • visually-hidden
  • Bootstrap Icons

Three cards in a row-cols-md-3 grid, each with a big number, a subtle badge for the change and a sparkline drawn with one polyline and a flat translucent area. The SVG uses preserveAspectRatio="none" with vector-effect: non-scaling-stroke so it stretches to any card width without thickening the line, and role="img" with an aria-label that states the trend. The badge arrows are aria-hidden, a visually-hidden word says up or down.

View code
<div class="bch-kpi row row-cols-1 row-cols-md-3 g-3">
  <div class="col">
    <div class="card h-100 border-0 shadow-sm">
      <div class="card-body p-4">
        <p class="small text-body-secondary mb-1">Revenue</p>
        <div class="d-flex flex-wrap align-items-center gap-2 mb-3">
          <span class="h3 mb-0 bch-num">$48,210</span>
          <span class="badge rounded-pill bg-success-subtle text-success-emphasis"><i class="bi bi-arrow-up-right" aria-hidden="true"></i><span class="visually-hidden">Up</span> 12.4%</span>
        </div>
        <svg class="bch-spark bch-spark-1" viewBox="0 0 110 32" preserveAspectRatio="none" role="img" aria-label="Weekly revenue for 12 weeks, rising from $31k to $48k">
          <polygon points="0,32 0,28.6 10,24.4 20,25.8 30,21.6 40,23 50,17.4 60,18.8 70,14.6 80,11.8 90,13.2 100,7.6 110,4.8 110,32"></polygon>
          <polyline points="0,28.6 10,24.4 20,25.8 30,21.6 40,23 50,17.4 60,18.8 70,14.6 80,11.8 90,13.2 100,7.6 110,4.8"></polyline>
        </svg>
        <p class="small text-body-secondary mb-0 mt-2">vs September</p>
      </div>
    </div>
  </div>
  <div class="col">
    <div class="card h-100 border-0 shadow-sm">
      <div class="card-body p-4">
        <p class="small text-body-secondary mb-1">Orders</p>
        <div class="d-flex flex-wrap align-items-center gap-2 mb-3">
          <span class="h3 mb-0 bch-num">1,284</span>
          <span class="badge rounded-pill bg-success-subtle text-success-emphasis"><i class="bi bi-arrow-up-right" aria-hidden="true"></i><span class="visually-hidden">Up</span> 3.1%</span>
        </div>
        <svg class="bch-spark bch-spark-2" viewBox="0 0 110 32" preserveAspectRatio="none" role="img" aria-label="Weekly orders for 12 weeks, between 1,180 and 1,284 with a slow climb">
          <polygon points="0,32 0,24.4 10,18.8 20,21.6 30,13.2 40,16 50,15.1 60,9.5 70,17.9 80,11.3 90,7.6 100,8.5 110,5 110,32"></polygon>
          <polyline points="0,24.4 10,18.8 20,21.6 30,13.2 40,16 50,15.1 60,9.5 70,17.9 80,11.3 90,7.6 100,8.5 110,5"></polyline>
        </svg>
        <p class="small text-body-secondary mb-0 mt-2">vs September</p>
      </div>
    </div>
  </div>
  <div class="col">
    <div class="card h-100 border-0 shadow-sm">
      <div class="card-body p-4">
        <p class="small text-body-secondary mb-1">Refund rate</p>
        <div class="d-flex flex-wrap align-items-center gap-2 mb-3">
          <span class="h3 mb-0 bch-num">2.3%</span>
          <span class="badge rounded-pill bg-success-subtle text-success-emphasis"><i class="bi bi-arrow-down-right" aria-hidden="true"></i><span class="visually-hidden">Down</span> 0.4 pts</span>
        </div>
        <svg class="bch-spark bch-spark-3" viewBox="0 0 110 32" preserveAspectRatio="none" role="img" aria-label="Weekly refund rate for 12 weeks, falling from 2.9% to 2.3%">
          <polygon points="0,32 0,4.8 10,7.6 20,4.8 30,10.4 40,7.6 50,13.2 60,13.2 70,16 80,18.8 90,16 100,18.8 110,21.6 110,32"></polygon>
          <polyline points="0,4.8 10,7.6 20,4.8 30,10.4 40,7.6 50,13.2 60,13.2 70,16 80,18.8 90,16 100,18.8 110,21.6"></polyline>
        </svg>
        <p class="small text-body-secondary mb-0 mt-2">Lower is better</p>
      </div>
    </div>
  </div>
</div>

Gauge meter with zones

  • form-range
  • badge
  • text-bg-warning
  • stroke-dasharray
  • aria-valuetext

Drag the slider.

The arc is an SVG path with pathLength="100", so stroke-dasharray takes the value directly as a percent. The range input drives it: JavaScript updates the dash, the number, the zone badge (Normal, High, Critical in words, not only in color), the SVG aria-label and the input aria-valuetext. The arc color transition runs only when the reader allows motion.

View code
<div class="card bch-gauge border-0 shadow-sm text-center">
  <div class="card-body p-4">
    <h2 class="h6 mb-1">CPU load, api-eu-2</h2>
    <p class="small text-body-secondary mb-3">Five-minute average</p>
    <div class="bch-gauge-dial position-relative mx-auto">
      <svg id="bch-gauge-svg" viewBox="0 0 120 66" role="img" aria-label="CPU load 72%, High">
        <path class="bch-gauge-track" d="M10 60 A50 50 0 0 1 110 60" pathLength="100"></path>
        <path class="bch-gauge-value" id="bch-gauge-arc" d="M10 60 A50 50 0 0 1 110 60" pathLength="100" stroke-dasharray="72 100"></path>
      </svg>
      <div class="bch-gauge-readout" aria-hidden="true">
        <span class="bch-gauge-num" id="bch-gauge-num">72%</span>
        <span class="badge rounded-pill text-bg-warning" id="bch-gauge-status">High</span>
      </div>
    </div>
    <div class="d-flex justify-content-between small text-body-secondary bch-gauge-scale mx-auto" aria-hidden="true"><span>0%</span><span>100%</span></div>
    <label for="bch-gauge-range" class="form-label small fw-medium mt-4 mb-1">Simulate load</label>
    <input type="range" class="form-range" id="bch-gauge-range" min="0" max="100" value="72" aria-valuetext="72%, High">
    <p class="small text-body-secondary mb-0">Normal below 60%, Critical from 85%</p>
  </div>
</div>

Dark realtime analytics panel

  • data-bs-theme="dark"
  • .progress-stacked
  • row g-4
  • col-md-7
  • role="img"

The panel inherits Bootstrap dark mode, so the card, hr, progress tracks and secondary text all pick up the dark variables without extra CSS. The per-minute bars are 30 flex children with inline heights inside one role="img" element whose label summarizes them. Series colors are light tints chosen for at least 3:1 against the dark card, and the live dot pulses only when motion is allowed.

View code
<div class="card bch-dark">
  <div class="card-body p-4">
    <div class="d-flex flex-wrap justify-content-between align-items-start gap-3 mb-3">
      <div>
        <h2 class="h6 fw-normal text-body-secondary mb-1">Active users right now</h2>
        <p class="bch-dark-big mb-0">1,482</p>
      </div>
      <span class="badge rounded-pill bch-dark-live"><span class="bch-dark-dot" aria-hidden="true"></span>Live</span>
    </div>
    <p class="small text-body-secondary mb-2">Sessions started per minute</p>
    <div class="bch-dark-bars" role="img" aria-label="Sessions started per minute over the last 30 minutes, rising from 52 to 86, peak of 92 two minutes ago">
      <span style="height: 52%"></span><span style="height: 58%"></span><span style="height: 49%"></span><span style="height: 61%"></span><span style="height: 66%"></span><span style="height: 57%"></span><span style="height: 63%"></span><span style="height: 70%"></span><span style="height: 68%"></span><span style="height: 59%"></span><span style="height: 55%"></span><span style="height: 62%"></span><span style="height: 71%"></span><span style="height: 74%"></span><span style="height: 69%"></span><span style="height: 64%"></span><span style="height: 60%"></span><span style="height: 67%"></span><span style="height: 72%"></span><span style="height: 78%"></span><span style="height: 75%"></span><span style="height: 70%"></span><span style="height: 66%"></span><span style="height: 73%"></span><span style="height: 80%"></span><span style="height: 84%"></span><span style="height: 79%"></span><span style="height: 88%"></span><span style="height: 92%"></span><span style="height: 86%"></span>
    </div>
    <div class="d-flex justify-content-between small text-body-secondary mt-2" aria-hidden="true"><span>30 min ago</span><span>Now</span></div>
    <hr class="my-4">
    <div class="row g-4">
      <div class="col-md-7">
        <h3 class="h6 mb-3">Top pages</h3>
        <ul class="list-unstyled d-grid gap-3 mb-0 small">
          <li><div class="d-flex justify-content-between gap-2 mb-1"><span class="text-truncate">/pricing</span><span class="bch-num">412</span></div><div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 100%"></div></div></li>
          <li><div class="d-flex justify-content-between gap-2 mb-1"><span class="text-truncate">/blog/dark-mode-tips</span><span class="bch-num">288</span></div><div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 70%"></div></div></li>
          <li><div class="d-flex justify-content-between gap-2 mb-1"><span class="text-truncate">/docs/getting-started</span><span class="bch-num">201</span></div><div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 49%"></div></div></li>
          <li><div class="d-flex justify-content-between gap-2 mb-1"><span class="text-truncate">/changelog</span><span class="bch-num">136</span></div><div class="progress" aria-hidden="true"><div class="progress-bar" style="width: 33%"></div></div></li>
        </ul>
      </div>
      <div class="col-md-5">
        <h3 class="h6 mb-3">Devices</h3>
        <div class="progress-stacked mb-3">
          <div class="progress bch-dark-c1" role="progressbar" aria-label="Mobile" aria-valuenow="64" aria-valuemin="0" aria-valuemax="100" style="width: 64%"><div class="progress-bar"></div></div>
          <div class="progress bch-dark-c2" role="progressbar" aria-label="Desktop" aria-valuenow="31" aria-valuemin="0" aria-valuemax="100" style="width: 31%"><div class="progress-bar"></div></div>
          <div class="progress bch-dark-c3" role="progressbar" aria-label="Tablet" aria-valuenow="5" aria-valuemin="0" aria-valuemax="100" style="width: 5%"><div class="progress-bar"></div></div>
        </div>
        <ul class="list-unstyled d-grid gap-2 mb-0 small">
          <li class="d-flex align-items-center gap-2"><span class="bch-dark-key bch-dark-c1" aria-hidden="true"></span><span class="flex-grow-1">Mobile</span><span class="bch-num">64%</span></li>
          <li class="d-flex align-items-center gap-2"><span class="bch-dark-key bch-dark-c2" aria-hidden="true"></span><span class="flex-grow-1">Desktop</span><span class="bch-num">31%</span></li>
          <li class="d-flex align-items-center gap-2"><span class="bch-dark-key bch-dark-c3" aria-hidden="true"></span><span class="flex-grow-1">Tablet</span><span class="bch-num">5%</span></li>
        </ul>
      </div>
    </div>
  </div>
</div>

Comparison table with inline data bars

  • .table
  • table-responsive
  • .progress
  • th scope="row"
  • d-none d-sm-table-cell

A regular Bootstrap table where the rate column holds a slim .progress next to the number, so the table stays sortable, copyable and readable by screen readers while still showing the ranking at a glance. Bars are scaled to the highest rate and hidden from assistive tech, the change column says plus or minus in text, and lower-priority columns drop out below the sm and md breakpoints.

View code
<div class="card bch-tbars border-0 shadow-sm">
  <div class="card-header bg-body py-3 d-flex flex-wrap justify-content-between align-items-baseline gap-2">
    <h2 class="h6 mb-0">Landing page conversion</h2>
    <span class="small text-body-secondary">October 2026</span>
  </div>
  <div class="table-responsive">
    <table class="table align-middle mb-0">
      <thead>
        <tr>
          <th scope="col">Page</th>
          <th scope="col" class="text-end d-none d-sm-table-cell">Visitors</th>
          <th scope="col" class="bch-tbars-rate">Conversion rate</th>
          <th scope="col" class="text-end d-none d-md-table-cell">vs Sep</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row" class="fw-medium">Pricing</th>
          <td class="text-end d-none d-sm-table-cell bch-num">8,940</td>
          <td><div class="d-flex align-items-center gap-2"><div class="progress flex-grow-1" aria-hidden="true"><div class="progress-bar" style="width: 100%"></div></div><span class="bch-num bch-tbars-val">6.2%</span></div></td>
          <td class="text-end d-none d-md-table-cell bch-num text-success-emphasis">+0.8 pts</td>
        </tr>
        <tr>
          <th scope="row" class="fw-medium">Templates</th>
          <td class="text-end d-none d-sm-table-cell bch-num">5,310</td>
          <td><div class="d-flex align-items-center gap-2"><div class="progress flex-grow-1" aria-hidden="true"><div class="progress-bar" style="width: 77.4%"></div></div><span class="bch-num bch-tbars-val">4.8%</span></div></td>
          <td class="text-end d-none d-md-table-cell bch-num text-success-emphasis">+1.1 pts</td>
        </tr>
        <tr>
          <th scope="row" class="fw-medium">Home</th>
          <td class="text-end d-none d-sm-table-cell bch-num">21,480</td>
          <td><div class="d-flex align-items-center gap-2"><div class="progress flex-grow-1" aria-hidden="true"><div class="progress-bar" style="width: 50%"></div></div><span class="bch-num bch-tbars-val">3.1%</span></div></td>
          <td class="text-end d-none d-md-table-cell bch-num text-danger-emphasis">-0.2 pts</td>
        </tr>
        <tr>
          <th scope="row" class="fw-medium">Case study</th>
          <td class="text-end d-none d-sm-table-cell bch-num">1,260</td>
          <td><div class="d-flex align-items-center gap-2"><div class="progress flex-grow-1" aria-hidden="true"><div class="progress-bar" style="width: 41.9%"></div></div><span class="bch-num bch-tbars-val">2.6%</span></div></td>
          <td class="text-end d-none d-md-table-cell bch-num text-success-emphasis">+0.3 pts</td>
        </tr>
        <tr>
          <th scope="row" class="fw-medium">Blog</th>
          <td class="text-end d-none d-sm-table-cell bch-num">12,050</td>
          <td><div class="d-flex align-items-center gap-2"><div class="progress flex-grow-1" aria-hidden="true"><div class="progress-bar" style="width: 22.6%"></div></div><span class="bch-num bch-tbars-val">1.4%</span></div></td>
          <td class="text-end d-none d-md-table-cell bch-num text-danger-emphasis">-0.1 pts</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

Column, line and donut charts in inline SVG

When a chart needs axes or more than one series, inline SVG inside a Bootstrap card does the drawing and a few lines of vanilla JavaScript add tooltips, readouts and toggles. No chart library is loaded.

Column chart with a tooltip on every bar

  • data-bs-toggle="tooltip"
  • bootstrap.Tooltip
  • tabindex="0"
  • role="img"
  • d-sm-none

Hover or tab to a bar.

The columns are flex children with percentage heights inside fixed-height boxes, with gridlines as absolutely positioned spans. Each bar is focusable, has role="img" and an aria-label with its value, and carries a Bootstrap tooltip, so the exact number shows on hover and on keyboard focus. Month labels shrink to single letters below the sm breakpoint.

View code
<div class="card bch-cols border-0 shadow-sm">
  <div class="card-body p-3 p-sm-4">
    <div class="d-flex flex-wrap justify-content-between align-items-baseline gap-2 mb-4">
      <h2 class="h6 mb-0" id="bch-cols-title">Monthly signups</h2>
      <span class="small text-body-secondary">Nov 2025 to Oct 2026, 15,445 total</span>
    </div>
    <div class="bch-cols-chart">
      <div class="bch-cols-grid" aria-hidden="true"><span style="bottom: 100%">2k</span><span style="bottom: 50%">1k</span><span style="bottom: 0%">0</span></div>
      <ul class="bch-cols-plot list-unstyled mb-0" aria-labelledby="bch-cols-title">
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="November 2025: 820 signups" data-bs-toggle="tooltip" data-bs-title="Nov 2025: 820" style="height: 41%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">N</span><span class="d-none d-sm-inline">Nov</span></span></li>
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="December 2025: 760 signups" data-bs-toggle="tooltip" data-bs-title="Dec 2025: 760" style="height: 38%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">D</span><span class="d-none d-sm-inline">Dec</span></span></li>
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="January 2026: 940 signups" data-bs-toggle="tooltip" data-bs-title="Jan 2026: 940" style="height: 47%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">J</span><span class="d-none d-sm-inline">Jan</span></span></li>
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="February 2026: 1,105 signups" data-bs-toggle="tooltip" data-bs-title="Feb 2026: 1,105" style="height: 55.25%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">F</span><span class="d-none d-sm-inline">Feb</span></span></li>
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="March 2026: 1,240 signups" data-bs-toggle="tooltip" data-bs-title="Mar 2026: 1,240" style="height: 62%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">M</span><span class="d-none d-sm-inline">Mar</span></span></li>
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="April 2026: 1,180 signups" data-bs-toggle="tooltip" data-bs-title="Apr 2026: 1,180" style="height: 59%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">A</span><span class="d-none d-sm-inline">Apr</span></span></li>
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="May 2026: 1,380 signups" data-bs-toggle="tooltip" data-bs-title="May 2026: 1,380" style="height: 69%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">M</span><span class="d-none d-sm-inline">May</span></span></li>
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="June 2026: 1,510 signups" data-bs-toggle="tooltip" data-bs-title="Jun 2026: 1,510" style="height: 75.5%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">J</span><span class="d-none d-sm-inline">Jun</span></span></li>
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="July 2026: 1,290 signups" data-bs-toggle="tooltip" data-bs-title="Jul 2026: 1,290" style="height: 64.5%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">J</span><span class="d-none d-sm-inline">Jul</span></span></li>
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="August 2026: 1,720 signups" data-bs-toggle="tooltip" data-bs-title="Aug 2026: 1,720" style="height: 86%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">A</span><span class="d-none d-sm-inline">Aug</span></span></li>
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="September 2026: 1,640 signups" data-bs-toggle="tooltip" data-bs-title="Sep 2026: 1,640" style="height: 82%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">S</span><span class="d-none d-sm-inline">Sep</span></span></li>
        <li><div class="bch-col-box"><span class="bch-col" tabindex="0" role="img" aria-label="October 2026: 1,860 signups" data-bs-toggle="tooltip" data-bs-title="Oct 2026: 1,860" style="height: 93%"></span></div><span class="bch-col-x" aria-hidden="true"><span class="d-sm-none">O</span><span class="d-none d-sm-inline">Oct</span></span></li>
      </ul>
    </div>
  </div>
</div>

Line chart with hover and keyboard readout

  • inline SVG
  • aria-live="polite"
  • roving tabindex
  • card
  • d-none d-sm-block

Hover the chart, or tab in and use the arrow keys.

The plot is an SVG with preserveAspectRatio="none" so it fills the card, while the axis labels and the 12 data points are HTML positioned with percentages, so text stays sharp at every width. Moving the pointer snaps to the nearest week, and the points use a roving tabindex: Tab enters the chart, arrow keys, Home and End move along it, and the readout above is an aria-live region.

View code
<div class="card bch-line border-0 shadow-sm">
  <div class="card-body p-3 p-sm-4">
    <div class="d-flex flex-wrap justify-content-between align-items-start gap-3 mb-4">
      <div>
        <h2 class="h6 mb-1">Weekly active users</h2>
        <p class="small text-body-secondary mb-0">Last 12 weeks, scale 0 to 8,000</p>
      </div>
      <div class="bch-line-readout text-sm-end" aria-live="polite">
        <span class="d-block small text-body-secondary" id="bch-line-week">Week 12</span>
        <span class="d-block h5 mb-0" id="bch-line-value">6,480 users</span>
        <span class="d-block small" id="bch-line-delta">+11.5% vs previous week</span>
      </div>
    </div>
    <div class="bch-line-chart">
      <div class="bch-line-y" aria-hidden="true"><span style="bottom: 100%">8k</span><span style="bottom: 75%">6k</span><span style="bottom: 50%">4k</span><span style="bottom: 25%">2k</span><span style="bottom: 0%">0</span></div>
      <div class="bch-line-area" id="bch-line-area">
        <svg viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden="true">
          <line class="bch-line-grid" x1="0" y1="0" x2="100" y2="0"></line>
          <line class="bch-line-grid" x1="0" y1="25" x2="100" y2="25"></line>
          <line class="bch-line-grid" x1="0" y1="50" x2="100" y2="50"></line>
          <line class="bch-line-grid" x1="0" y1="75" x2="100" y2="75"></line>
          <line class="bch-line-grid" x1="0" y1="100" x2="100" y2="100"></line>
          <polygon class="bch-line-fill" points="0,100 0,59.87 9.09,56.5 18.18,57.62 27.27,52.25 36.36,48.69 45.45,50.5 54.55,44.87 63.64,39.12 72.73,41.37 81.82,33.5 90.91,27.37 100,19 100,100"></polygon>
          <polyline class="bch-line-path" points="0,59.87 9.09,56.5 18.18,57.62 27.27,52.25 36.36,48.69 45.45,50.5 54.55,44.87 63.64,39.12 72.73,41.37 81.82,33.5 90.91,27.37 100,19"></polyline>
        </svg>
        <span class="bch-line-guide" id="bch-line-guide" aria-hidden="true"></span>
        <span class="bch-pt" role="img" tabindex="-1" aria-label="Week 1: 3,210 users" data-label="Week 1" data-value="3210" style="left: 0%; bottom: 40.13%"></span>
        <span class="bch-pt" role="img" tabindex="-1" aria-label="Week 2: 3,480 users" data-label="Week 2" data-value="3480" style="left: 9.09%; bottom: 43.5%"></span>
        <span class="bch-pt" role="img" tabindex="-1" aria-label="Week 3: 3,390 users" data-label="Week 3" data-value="3390" style="left: 18.18%; bottom: 42.38%"></span>
        <span class="bch-pt" role="img" tabindex="-1" aria-label="Week 4: 3,820 users" data-label="Week 4" data-value="3820" style="left: 27.27%; bottom: 47.75%"></span>
        <span class="bch-pt" role="img" tabindex="-1" aria-label="Week 5: 4,105 users" data-label="Week 5" data-value="4105" style="left: 36.36%; bottom: 51.31%"></span>
        <span class="bch-pt" role="img" tabindex="-1" aria-label="Week 6: 3,960 users" data-label="Week 6" data-value="3960" style="left: 45.45%; bottom: 49.5%"></span>
        <span class="bch-pt" role="img" tabindex="-1" aria-label="Week 7: 4,410 users" data-label="Week 7" data-value="4410" style="left: 54.55%; bottom: 55.13%"></span>
        <span class="bch-pt" role="img" tabindex="-1" aria-label="Week 8: 4,870 users" data-label="Week 8" data-value="4870" style="left: 63.64%; bottom: 60.88%"></span>
        <span class="bch-pt" role="img" tabindex="-1" aria-label="Week 9: 4,690 users" data-label="Week 9" data-value="4690" style="left: 72.73%; bottom: 58.63%"></span>
        <span class="bch-pt" role="img" tabindex="-1" aria-label="Week 10: 5,320 users" data-label="Week 10" data-value="5320" style="left: 81.82%; bottom: 66.5%"></span>
        <span class="bch-pt" role="img" tabindex="-1" aria-label="Week 11: 5,810 users" data-label="Week 11" data-value="5810" style="left: 90.91%; bottom: 72.63%"></span>
        <span class="bch-pt" role="img" tabindex="0" aria-label="Week 12: 6,480 users" data-label="Week 12" data-value="6480" style="left: 100%; bottom: 81%"></span>
      </div>
      <div class="bch-line-x" aria-hidden="true"><span style="left: 0%">W1</span><span class="d-none d-sm-block" style="left: 18.18%">W3</span><span style="left: 36.36%">W5</span><span class="d-none d-sm-block" style="left: 54.55%">W7</span><span style="left: 72.73%">W9</span><span class="d-none d-sm-block" style="left: 90.91%">W11</span><span class="d-sm-none" style="left: 100%">W12</span></div>
    </div>
  </div>
</div>

Donut chart with a list-group legend

  • list-group-item-action
  • aria-pressed
  • stroke-dasharray
  • pathLength
  • col-sm-5

Pick a file type in the legend.

Every segment is a circle with pathLength="100", so stroke-dasharray and stroke-dashoffset take plain percentages and a 1-unit gap separates the slices. The legend is a flush list-group of buttons with the size and share in text; pressing one sets aria-pressed, highlights its slice and writes the value into the center. Press it again to return to the total.

View code
<div class="card bch-donut border-0 shadow-sm">
  <div class="card-body p-4">
    <div class="d-flex flex-wrap justify-content-between align-items-baseline gap-2 mb-3">
      <h2 class="h6 mb-0">Storage by file type</h2>
      <span class="small text-body-secondary">412 of 512 GB used</span>
    </div>
    <div class="row g-4 align-items-center">
      <div class="col-sm-5">
        <div class="bch-donut-ring position-relative mx-auto" id="bch-donut-ring">
          <svg viewBox="0 0 42 42" role="img" aria-label="Donut chart of 412 GB by file type: video 40%, photos 25%, documents 15%, backups 12%, other 8%">
            <g transform="rotate(-90 21 21)">
              <circle class="bch-donut-track" cx="21" cy="21" r="16" pathLength="100"></circle>
              <circle class="bch-seg bch-c1" cx="21" cy="21" r="16" pathLength="100" stroke-dasharray="39 61" stroke-dashoffset="0"></circle>
              <circle class="bch-seg bch-c2" cx="21" cy="21" r="16" pathLength="100" stroke-dasharray="24 76" stroke-dashoffset="-40"></circle>
              <circle class="bch-seg bch-c3" cx="21" cy="21" r="16" pathLength="100" stroke-dasharray="14 86" stroke-dashoffset="-65"></circle>
              <circle class="bch-seg bch-c4" cx="21" cy="21" r="16" pathLength="100" stroke-dasharray="11 89" stroke-dashoffset="-80"></circle>
              <circle class="bch-seg bch-c5" cx="21" cy="21" r="16" pathLength="100" stroke-dasharray="7 93" stroke-dashoffset="-92"></circle>
            </g>
          </svg>
          <div class="bch-donut-center" aria-hidden="true">
            <span class="bch-donut-big" id="bch-donut-big">412 GB</span>
            <span class="small text-body-secondary" id="bch-donut-name">used</span>
          </div>
        </div>
      </div>
      <div class="col-sm-7">
        <div class="list-group list-group-flush bch-donut-legend">
          <button type="button" class="list-group-item list-group-item-action d-flex align-items-center gap-2" aria-pressed="false" data-name="Video" data-size="164.8 GB"><span class="bch-swatch bch-c1" aria-hidden="true"></span><span class="flex-grow-1">Video</span><span class="bch-num">164.8 GB</span><span class="bch-num bch-share">40%</span></button>
          <button type="button" class="list-group-item list-group-item-action d-flex align-items-center gap-2" aria-pressed="false" data-name="Photos" data-size="103.0 GB"><span class="bch-swatch bch-c2" aria-hidden="true"></span><span class="flex-grow-1">Photos</span><span class="bch-num">103.0 GB</span><span class="bch-num bch-share">25%</span></button>
          <button type="button" class="list-group-item list-group-item-action d-flex align-items-center gap-2" aria-pressed="false" data-name="Documents" data-size="61.8 GB"><span class="bch-swatch bch-c3" aria-hidden="true"></span><span class="flex-grow-1">Documents</span><span class="bch-num">61.8 GB</span><span class="bch-num bch-share">15%</span></button>
          <button type="button" class="list-group-item list-group-item-action d-flex align-items-center gap-2" aria-pressed="false" data-name="Backups" data-size="49.4 GB"><span class="bch-swatch bch-c4" aria-hidden="true"></span><span class="flex-grow-1">Backups</span><span class="bch-num">49.4 GB</span><span class="bch-num bch-share">12%</span></button>
          <button type="button" class="list-group-item list-group-item-action d-flex align-items-center gap-2" aria-pressed="false" data-name="Other" data-size="33.0 GB"><span class="bch-swatch bch-c5" aria-hidden="true"></span><span class="flex-grow-1">Other</span><span class="bch-num">33.0 GB</span><span class="bch-num bch-share">8%</span></button>
        </div>
      </div>
    </div>
  </div>
</div>

Two-series line chart with legend switches

  • form-switch
  • role="switch"
  • visually-hidden table
  • d-none
  • inline SVG

Turn a series off and on.

This year is a solid line and last year a dashed one, so the series differ by pattern as well as color, and the legend shows the same line styles. The legend entries are Bootstrap form switches that add or remove .d-none on their polyline. A visually-hidden table with a caption carries every monthly value for screen readers.

View code
<div class="card bch-cmp border-0 shadow-sm">
  <div class="card-body p-3 p-sm-4">
    <div class="d-flex flex-wrap justify-content-between align-items-start gap-3 mb-3">
      <div>
        <h2 class="h6 mb-1">Bookings, 2026 vs 2025</h2>
        <p class="small text-body-secondary mb-0">4,702 so far this year, up 22.3%</p>
      </div>
      <div class="d-flex flex-wrap gap-3 small">
        <div class="form-check form-switch mb-0">
          <input class="form-check-input bch-cmp-toggle" type="checkbox" role="switch" id="bch-cmp-2026" data-series="bch-cmp-line-2026" checked>
          <label class="form-check-label d-inline-flex align-items-center gap-2" for="bch-cmp-2026"><span class="bch-cmp-key bch-cmp-key-a" aria-hidden="true"></span>2026</label>
        </div>
        <div class="form-check form-switch mb-0">
          <input class="form-check-input bch-cmp-toggle" type="checkbox" role="switch" id="bch-cmp-2025" data-series="bch-cmp-line-2025" checked>
          <label class="form-check-label d-inline-flex align-items-center gap-2" for="bch-cmp-2025"><span class="bch-cmp-key bch-cmp-key-b" aria-hidden="true"></span>2025</label>
        </div>
      </div>
    </div>
    <div class="bch-cmp-chart" aria-hidden="true">
      <div class="bch-cmp-y"><span style="bottom: 100%">800</span><span style="bottom: 75%">600</span><span style="bottom: 50%">400</span><span style="bottom: 25%">200</span><span style="bottom: 0%">0</span></div>
      <div class="bch-cmp-area">
        <svg viewBox="0 0 100 100" preserveAspectRatio="none">
          <line class="bch-cmp-grid" x1="0" y1="0" x2="100" y2="0"></line>
          <line class="bch-cmp-grid" x1="0" y1="25" x2="100" y2="25"></line>
          <line class="bch-cmp-grid" x1="0" y1="50" x2="100" y2="50"></line>
          <line class="bch-cmp-grid" x1="0" y1="75" x2="100" y2="75"></line>
          <line class="bch-cmp-grid" x1="0" y1="100" x2="100" y2="100"></line>
          <polyline class="bch-cmp-b" id="bch-cmp-line-2025" points="0,65 11.11,63.13 22.22,58.75 33.33,55 44.44,53.5 55.56,48.75 66.67,46.25 77.78,44.38 88.89,43.5 100,41.25"></polyline>
          <polyline class="bch-cmp-a" id="bch-cmp-line-2026" points="0,61.25 11.11,57.25 22.22,50.25 33.33,47.5 44.44,41.88 55.56,36 66.67,31.5 77.78,33.75 88.89,28.13 100,24.75"></polyline>
        </svg>
      </div>
      <div class="bch-cmp-x"><span style="left: 0%">Jan</span><span class="d-none d-sm-block" style="left: 22.22%">Mar</span><span style="left: 44.44%">May</span><span class="d-none d-sm-block" style="left: 66.67%">Jul</span><span class="d-none d-sm-block" style="left: 88.89%">Sep</span><span class="d-sm-none" style="left: 100%">Oct</span></div>
    </div>
    <table class="visually-hidden">
      <caption>Monthly bookings, January to October</caption>
      <thead><tr><th scope="col">Month</th><th scope="col">2026</th><th scope="col">2025</th></tr></thead>
      <tbody>
        <tr><th scope="row">January</th><td>310</td><td>280</td></tr>
        <tr><th scope="row">February</th><td>342</td><td>295</td></tr>
        <tr><th scope="row">March</th><td>398</td><td>330</td></tr>
        <tr><th scope="row">April</th><td>420</td><td>360</td></tr>
        <tr><th scope="row">May</th><td>465</td><td>372</td></tr>
        <tr><th scope="row">June</th><td>512</td><td>410</td></tr>
        <tr><th scope="row">July</th><td>548</td><td>430</td></tr>
        <tr><th scope="row">August</th><td>530</td><td>445</td></tr>
        <tr><th scope="row">September</th><td>575</td><td>452</td></tr>
        <tr><th scope="row">October</th><td>602</td><td>470</td></tr>
      </tbody>
    </table>
  </div>
</div>

Period switchers, tabs, data tables and color modes

The patterns from the guide below in working form: a btn-group that rerenders the data, charts inside tabs, a collapsible data table for screen reader and keyboard users, and a chart that follows data-bs-theme.

Week, month and year switcher that rerenders

  • btn-group
  • btn-check
  • btn-outline-secondary
  • createElement
  • aria-live

Switch between Week, Month and Year.

The period control is a btn-group of btn-check radios, so it is one tab stop with arrow-key selection and a real checked state. On change, a small render function rebuilds the bars with createElement and textContent only, scales them to the highest value, marks the busiest bar and updates the total in an aria-live paragraph. Each bar has a visually-hidden label with its full value.

View code
<div class="card bch-period border-0 shadow-sm">
  <div class="card-header bg-body py-3 d-flex flex-wrap justify-content-between align-items-center gap-2">
    <h2 class="h6 mb-0" id="bch-period-title">Orders</h2>
    <div class="btn-group btn-group-sm" role="group" aria-label="Time period">
      <input type="radio" class="btn-check bch-period-opt" name="bch-period" id="bch-period-week" value="week" checked>
      <label class="btn btn-outline-secondary" for="bch-period-week">Week</label>
      <input type="radio" class="btn-check bch-period-opt" name="bch-period" id="bch-period-month" value="month">
      <label class="btn btn-outline-secondary" for="bch-period-month">Month</label>
      <input type="radio" class="btn-check bch-period-opt" name="bch-period" id="bch-period-year" value="year">
      <label class="btn btn-outline-secondary" for="bch-period-year">Year</label>
    </div>
  </div>
  <div class="card-body p-3 p-sm-4">
    <div aria-live="polite" class="mb-3">
      <p class="h4 mb-0 bch-period-total" id="bch-period-total">1,340 orders</p>
      <p class="small text-body-secondary mb-0" id="bch-period-peak">Last 7 days</p>
    </div>
    <ul class="bch-period-chart list-unstyled mb-0" id="bch-period-chart" aria-labelledby="bch-period-title"></ul>
  </div>
</div>

Trend charts inside card header tabs

  • card-header-tabs
  • data-bs-toggle="tab"
  • tab-pane fade
  • shown.bs.tab
  • row-cols-3

Switch tabs.

Three metrics share one card through nav-tabs in the card header, wired with data-bs-toggle="tab" and the documented role, aria-controls and aria-selected markup. Each pane holds an SVG trend with an aria-label, plus low, high and average values in a row-cols-3 grid so the numbers are always in text. Because these SVGs size with CSS they render correctly in a hidden pane, which is the problem a canvas library needs shown.bs.tab for.

View code
<div class="card bch-tabs border-0 shadow-sm">
  <div class="card-header bg-body pt-3">
    <ul class="nav nav-tabs card-header-tabs" role="tablist">
      <li class="nav-item" role="presentation"><button class="nav-link active" id="bch-tab-revenue" data-bs-toggle="tab" data-bs-target="#bch-pane-revenue" type="button" role="tab" aria-controls="bch-pane-revenue" aria-selected="true">Revenue</button></li>
      <li class="nav-item" role="presentation"><button class="nav-link" id="bch-tab-orders" data-bs-toggle="tab" data-bs-target="#bch-pane-orders" type="button" role="tab" aria-controls="bch-pane-orders" aria-selected="false">Orders</button></li>
      <li class="nav-item" role="presentation"><button class="nav-link" id="bch-tab-aov" data-bs-toggle="tab" data-bs-target="#bch-pane-aov" type="button" role="tab" aria-controls="bch-pane-aov" aria-selected="false">Avg. order</button></li>
    </ul>
  </div>
  <div class="card-body p-3 p-sm-4">
    <div class="tab-content">
      <div class="tab-pane fade show active" id="bch-pane-revenue" role="tabpanel" aria-labelledby="bch-tab-revenue" tabindex="0">
        <div class="d-flex flex-wrap align-items-baseline gap-2 mb-3"><span class="h3 mb-0 bch-num">$57.3k</span><span class="small text-body-secondary">Oct 16 to Oct 29</span></div>
        <svg class="bch-trend bch-trend-1" viewBox="0 0 100 100" preserveAspectRatio="none" role="img" aria-label="Daily revenue over 14 days, rising from $3.2k to $5.2k">
          <line x1="0" y1="100" x2="100" y2="100"></line>
          <polygon points="0,100 0,46.67 7.69,41.67 15.38,48.33 23.08,36.67 30.77,33.33 38.46,26.67 46.15,35 53.85,40 61.54,31.67 69.23,25 76.92,20 84.62,28.33 92.31,18.33 100,13.33 100,100"></polygon>
          <polyline points="0,46.67 7.69,41.67 15.38,48.33 23.08,36.67 30.77,33.33 38.46,26.67 46.15,35 53.85,40 61.54,31.67 69.23,25 76.92,20 84.62,28.33 92.31,18.33 100,13.33"></polyline>
        </svg>
        <dl class="row row-cols-3 g-2 small mb-0 mt-3 text-center">
          <div class="col"><dt class="fw-normal text-body-secondary">Low</dt><dd class="fw-semibold mb-0 bch-num">$3.1k</dd></div>
          <div class="col"><dt class="fw-normal text-body-secondary">High</dt><dd class="fw-semibold mb-0 bch-num">$5.2k</dd></div>
          <div class="col"><dt class="fw-normal text-body-secondary">Daily avg</dt><dd class="fw-semibold mb-0 bch-num">$4.1k</dd></div>
        </dl>
      </div>
      <div class="tab-pane fade" id="bch-pane-orders" role="tabpanel" aria-labelledby="bch-tab-orders" tabindex="0">
        <div class="d-flex flex-wrap align-items-baseline gap-2 mb-3"><span class="h3 mb-0 bch-num">1,540</span><span class="small text-body-secondary">Oct 16 to Oct 29</span></div>
        <svg class="bch-trend bch-trend-2" viewBox="0 0 100 100" preserveAspectRatio="none" role="img" aria-label="Daily orders over 14 days, rising from 88 to 139">
          <line x1="0" y1="100" x2="100" y2="100"></line>
          <polygon points="0,100 0,45 7.69,40.63 15.38,47.5 23.08,36.25 30.77,31.25 38.46,26.25 46.15,35 53.85,39.38 61.54,31.88 69.23,24.38 76.92,20 84.62,28.75 92.31,18.13 100,13.13 100,100"></polygon>
          <polyline points="0,45 7.69,40.63 15.38,47.5 23.08,36.25 30.77,31.25 38.46,26.25 46.15,35 53.85,39.38 61.54,31.88 69.23,24.38 76.92,20 84.62,28.75 92.31,18.13 100,13.13"></polyline>
        </svg>
        <dl class="row row-cols-3 g-2 small mb-0 mt-3 text-center">
          <div class="col"><dt class="fw-normal text-body-secondary">Low</dt><dd class="fw-semibold mb-0 bch-num">84</dd></div>
          <div class="col"><dt class="fw-normal text-body-secondary">High</dt><dd class="fw-semibold mb-0 bch-num">139</dd></div>
          <div class="col"><dt class="fw-normal text-body-secondary">Daily avg</dt><dd class="fw-semibold mb-0 bch-num">110</dd></div>
        </dl>
      </div>
      <div class="tab-pane fade" id="bch-pane-aov" role="tabpanel" aria-labelledby="bch-tab-aov" tabindex="0">
        <div class="d-flex flex-wrap align-items-baseline gap-2 mb-3"><span class="h3 mb-0 bch-num">$37.21</span><span class="small text-body-secondary">Oct 16 to Oct 29, axis from $30</span></div>
        <svg class="bch-trend bch-trend-3" viewBox="0 0 100 100" preserveAspectRatio="none" role="img" aria-label="Average order value over 14 days, steady between $36.40 and $37.70">
          <line x1="0" y1="100" x2="100" y2="100"></line>
          <polygon points="0,100 0,36 7.69,32 15.38,31 23.08,27 30.77,36 38.46,27 46.15,25 53.85,29 61.54,24 69.23,28 76.92,25 84.62,23 92.31,26 100,26 100,100"></polygon>
          <polyline points="0,36 7.69,32 15.38,31 23.08,27 30.77,36 38.46,27 46.15,25 53.85,29 61.54,24 69.23,28 76.92,25 84.62,23 92.31,26 100,26"></polyline>
        </svg>
        <dl class="row row-cols-3 g-2 small mb-0 mt-3 text-center">
          <div class="col"><dt class="fw-normal text-body-secondary">Low</dt><dd class="fw-semibold mb-0 bch-num">$36.40</dd></div>
          <div class="col"><dt class="fw-normal text-body-secondary">High</dt><dd class="fw-semibold mb-0 bch-num">$37.70</dd></div>
          <div class="col"><dt class="fw-normal text-body-secondary">Period avg</dt><dd class="fw-semibold mb-0 bch-num">$37.21</dd></div>
        </dl>
      </div>
    </div>
  </div>
</div>

Grouped columns with a collapsible data table

  • collapse
  • aria-expanded
  • shown.bs.collapse
  • table-sm
  • caption

Open the data table.

The chart is one role="img" element with a summary label, and the two series differ by fill (solid versus outlined), not only by color. A btn-outline-secondary toggles a Bootstrap collapse holding the full table with a caption and scope attributes, and listeners on shown.bs.collapse and hidden.bs.collapse swap the button text.

View code
<div class="card bch-dt border-0 shadow-sm">
  <div class="card-body p-3 p-sm-4">
    <div class="d-flex flex-wrap justify-content-between align-items-start gap-3 mb-4">
      <div>
        <h2 class="h6 mb-1">Signups by channel, 2025</h2>
        <p class="small text-body-secondary mb-0">Per quarter</p>
      </div>
      <ul class="list-unstyled d-flex gap-3 small mb-0">
        <li class="d-flex align-items-center gap-2"><span class="bch-dt-key bch-dt-a" aria-hidden="true"></span>Organic</li>
        <li class="d-flex align-items-center gap-2"><span class="bch-dt-key bch-dt-b" aria-hidden="true"></span>Paid</li>
      </ul>
    </div>
    <div class="bch-dt-chart" role="img" aria-label="Grouped column chart. Organic signups grew every quarter, from 2,140 in Q1 to 3,360 in Q4. Paid signups stayed between 1,580 and 1,940. Full values are in the data table.">
      <div class="bch-dt-q"><div class="bch-dt-bars"><span class="bch-dt-a" style="height: 53.5%"><b>2,140</b></span><span class="bch-dt-b" style="height: 40.5%"><b>1,620</b></span></div><span class="bch-dt-x">Q1</span></div>
      <div class="bch-dt-q"><div class="bch-dt-bars"><span class="bch-dt-a" style="height: 62%"><b>2,480</b></span><span class="bch-dt-b" style="height: 43.75%"><b>1,750</b></span></div><span class="bch-dt-x">Q2</span></div>
      <div class="bch-dt-q"><div class="bch-dt-bars"><span class="bch-dt-a" style="height: 72.75%"><b>2,910</b></span><span class="bch-dt-b" style="height: 39.5%"><b>1,580</b></span></div><span class="bch-dt-x">Q3</span></div>
      <div class="bch-dt-q"><div class="bch-dt-bars"><span class="bch-dt-a" style="height: 84%"><b>3,360</b></span><span class="bch-dt-b" style="height: 48.5%"><b>1,940</b></span></div><span class="bch-dt-x">Q4</span></div>
    </div>
    <button class="btn btn-outline-secondary btn-sm mt-4 d-inline-flex align-items-center gap-2" type="button" data-bs-toggle="collapse" data-bs-target="#bch-dt-table" aria-expanded="false" aria-controls="bch-dt-table"><i class="bi bi-table" aria-hidden="true"></i><span id="bch-dt-label">Show data table</span></button>
    <div class="collapse" id="bch-dt-table">
      <div class="table-responsive mt-3">
        <table class="table table-sm mb-0">
          <caption class="caption-top">Signups by channel and quarter, 2025</caption>
          <thead><tr><th scope="col">Quarter</th><th scope="col" class="text-end">Organic</th><th scope="col" class="text-end">Paid</th><th scope="col" class="text-end">Total</th></tr></thead>
          <tbody>
            <tr><th scope="row">Q1</th><td class="text-end">2,140</td><td class="text-end">1,620</td><td class="text-end">3,760</td></tr>
            <tr><th scope="row">Q2</th><td class="text-end">2,480</td><td class="text-end">1,750</td><td class="text-end">4,230</td></tr>
            <tr><th scope="row">Q3</th><td class="text-end">2,910</td><td class="text-end">1,580</td><td class="text-end">4,490</td></tr>
            <tr><th scope="row">Q4</th><td class="text-end">3,360</td><td class="text-end">1,940</td><td class="text-end">5,300</td></tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>

Chart that follows the color mode

  • data-bs-theme
  • form-switch
  • --bs-border-color
  • --bs-secondary-color
  • CSS custom properties

Flip the dark mode switch.

The switch sets data-bs-theme on the card, and because every chart color is a CSS variable (Bootstrap ones for gridlines and labels, prefixed ones for the series and the budget line) the SVG rethemes with no redraw code. The light and dark values of --bch-mode-line and --bch-mode-limit are both picked for at least 3:1 against their card, and the budget line is dashed so it reads without color.

View code
<div class="card bch-mode" data-bs-theme="light" id="bch-mode-card">
  <div class="card-body p-3 p-sm-4">
    <div class="d-flex flex-wrap justify-content-between align-items-start gap-3 mb-3">
      <div>
        <h2 class="h6 mb-1">API response time, p95</h2>
        <p class="small text-body-secondary mb-0">Last 24 hours, checkout-api</p>
      </div>
      <div class="form-check form-switch mb-0">
        <input class="form-check-input" type="checkbox" role="switch" id="bch-mode-switch">
        <label class="form-check-label small" for="bch-mode-switch">Dark mode</label>
      </div>
    </div>
    <div class="bch-mode-chart">
      <div class="bch-mode-y" aria-hidden="true"><span style="bottom: 100%">400</span><span style="bottom: 75%">300</span><span style="bottom: 50%">200</span><span style="bottom: 25%">100</span><span style="bottom: 0%">0 ms</span></div>
      <div class="bch-mode-area">
        <svg viewBox="0 0 100 100" preserveAspectRatio="none" role="img" aria-label="p95 response time over 24 hours, from 168 to 318 milliseconds, above the 300 millisecond budget only at 14:00">
          <line class="bch-mode-grid" x1="0" y1="0" x2="100" y2="0"></line>
          <line class="bch-mode-grid" x1="0" y1="50" x2="100" y2="50"></line>
          <line class="bch-mode-grid" x1="0" y1="75" x2="100" y2="75"></line>
          <line class="bch-mode-grid" x1="0" y1="100" x2="100" y2="100"></line>
          <polygon class="bch-mode-fill" points="0,100 0,54.5 4.35,56 8.7,57.5 13.04,58 17.39,57.25 21.74,52.5 26.09,44 30.43,34.5 34.78,28 39.13,31 43.48,36.5 47.83,38 52.17,34.5 56.52,29.75 60.87,20.5 65.22,26 69.57,32.5 73.91,39 78.26,42 82.61,43.5 86.96,46.5 91.3,48.75 95.65,51 100,53 100,100"></polygon>
          <polyline class="bch-mode-line" points="0,54.5 4.35,56 8.7,57.5 13.04,58 17.39,57.25 21.74,52.5 26.09,44 30.43,34.5 34.78,28 39.13,31 43.48,36.5 47.83,38 52.17,34.5 56.52,29.75 60.87,20.5 65.22,26 69.57,32.5 73.91,39 78.26,42 82.61,43.5 86.96,46.5 91.3,48.75 95.65,51 100,53"></polyline>
          <line class="bch-mode-limit" x1="0" y1="25" x2="100" y2="25"></line>
        </svg>
        <span class="bch-mode-tag" aria-hidden="true">Budget 300 ms</span>
      </div>
      <div class="bch-mode-x" aria-hidden="true"><span style="left: 0%">00:00</span><span class="d-none d-sm-block" style="left: 26.09%">06:00</span><span style="left: 52.17%">12:00</span><span class="d-none d-sm-block" style="left: 78.26%">18:00</span></div>
    </div>
    <dl class="row row-cols-1 row-cols-sm-3 g-2 small mb-0 mt-3">
      <div class="col"><dt class="fw-normal text-body-secondary">Now</dt><dd class="fw-semibold mb-0">188 ms</dd></div>
      <div class="col"><dt class="fw-normal text-body-secondary">Peak</dt><dd class="fw-semibold mb-0">318 ms at 14:00</dd></div>
      <div class="col"><dt class="fw-normal text-body-secondary">Over budget</dt><dd class="fw-semibold mb-0">1 of 24 hours</dd></div>
    </dl>
  </div>
</div>

Does Bootstrap have a built-in chart component?

No. Nothing in Bootstrap core draws a chart, so every chart on a page comes from a separate library. That library paints inside Bootstrap’s grid, cards and color modes, which is why the chart resizes and themes along with the rest of the page.

The Bootstrap 5.3 documentation (v5.3.8) lists 24 built-in components, from accordion to tooltips, and none of them draws a chart.

The nearest thing is the progress component, which draws a single horizontal bar for one value. Need axes, a legend or more than one dataset? Then you need a library.

Bootstrap handles the layout side: a twelve-column grid with six breakpoints, card containers, color modes through the data-bs-theme attribute (since v5.3.0), and the spacing, sizing and position utilities. Drawing is left to the library, along with axes, scales, legends, tooltips, chart types and datasets.

Bootstrap Studio, a visual design app, does include a Chart component. Chart.js runs it internally, and it belongs to the app, not to Bootstrap itself (Bootstrap Studio documentation).

Which charting library works best with Bootstrap?

For most projects I’d pick Chart.js. It’s MIT-licensed, draws on canvas, and needs neither jQuery nor a build step. ApexCharts, Highcharts and Apache ECharts are worth weighing too, although licensing separates them more than features do.

LibraryRenderingLicenseMain limit
Chart.jsCanvasMITCanvas content needs manual ARIA for screen readers
ApexChartsSVG, plus an opt-in canvas renderer for dense data since 6.0Free under $2M revenue, paid abovePaid tier for larger organizations
HighchartsSVGCommercialNo free use in company projects
Apache EChartsCanvas or SVGApache 2.0Own theme system, so Bootstrap colors need mapping

Rendering decides how a library behaves under load. SVG charts keep every element in the DOM, so they’re easy to style and inspect. Canvas charts paint a bitmap instead, and they hold up better as the point count climbs.

ApexCharts 6.0 added an opt-in canvas renderer for dense series, so the SVG versus canvas split is no longer absolute for that library.

A standard dashboard built by a small team should just use Chart.js. If you want interactive cards with SVG output, ApexCharts works, as long as your organization sits under the license threshold. Very large datasets point to Apache ECharts or Chart.js, since both draw on canvas. A commercial product that needs vendor support is where Highcharts makes sense, once the license cost is budgeted, because it allows free use only for non-commercial projects, under separate terms.

ApexCharts’ Community license covers organizations under $2 million USD in annual revenue, budget or funding (ApexCharts, 2026).

Version 6.0.0, released July 17, 2026, put seven features behind a Premium license at any organization size, including Storyboard and Linked Views. The current license, for version 8.5.0, lists more Premium items, such as Trellis small multiples.

Put those two facts side by side and a small team gets the standard chart types for free, but the newest features cost money no matter how small the team is.

Ready-made kits that already include charts

For an admin dashboard, check the kits before wiring a library by hand.

  • The CoreUI Free Bootstrap Admin Template is MIT-licensed and comes with Chart.js charts built in. Its v5.6.0 shipped August 10, 2026 (CoreUI).
  • MDB Bootstrap 5 charts use their own mdb.Chart constructor, with data-mdb-chart attributes set directly on the canvas (MDB documentation).

A kit helps when the whole dashboard is the goal. For one chart on an existing page, install the library directly.

How to add Chart.js to a Bootstrap page

The short version is a canvas with an id inside a card, the Chart.js script, and a new Chart() call with a type and a data object. A CDN script tag covers a static page. npm suits projects that already run a bundler.

  1. Add Bootstrap’s CSS to the head, from the CDN or from npm.
  2. Place a canvas with an id inside a .card-body.
  3. Load Chart.js from jsDelivr, pinned to major version 4, before your own script.
  4. Call new Chart() with the canvas, a type and a data object.
  5. Reload the page and confirm the chart fills the card width.
<div class="card">
<div class="card-body">
<canvas id="visits"></canvas>
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/chart.js@4"></script>
<script>
new Chart(document.getElementById('visits'), {
  type: 'bar',
  data: {
    labels: ['Mon', 'Tue', 'Wed'],
    datasets: [{ label: 'Visits', data: [120, 150, 90] }]
  }
});
</script>

The chart needs only Bootstrap’s CSS. Chart.js has no dependency on Bootstrap’s JavaScript bundle.

The CDN route is the fastest for a static page or a prototype, and the Chart.js documentation lists both cdnjs and jsDelivr. Once a bundler is in place, npm is the better route because it allows tree-shaking and version locking.

Tree-shaking has a measurable payoff. In the Chart.js documentation’s own step-by-step example, registering only the bar and bubble chart components cut the bundle from 265.48 KB to 208.66 KB.

A single import from chart.js/auto anywhere in the project switches tree-shaking off again. And if you forget a controller on the other path, the console reports that “bar” is not a registered controller.

Placing a chart inside Bootstrap grid columns and cards

One canvas goes in a .card-body, the card goes in a .col-* column, and every column sits in a .row.

Bootstrap’s grid system has twelve columns and six breakpoints, from xs to xxl, so the column classes decide how wide each chart gets at each screen size.

Use col-12 for one chart across the full width, which is the usual choice for a time series. col-12 col-lg-6 puts two charts side by side from the lg breakpoint (992px and up). col-12 col-md-6 col-xl-4 gives two across from md (768px) and three across from xl (1200px).

A Bootstrap card gives the chart a header for the title, a body for the canvas and a footer for notes. Chart.js asks for a dedicated container per canvas, so the card body holds the canvas and nothing else (Chart.js documentation).

Bootstrap Studio’s documentation makes the same point from the design side. Drop the Chart component into a Column to use the grid.

A period dropdown (week, month, year) in the card header is a common dashboard pattern. Wire it to chart.update() instead of building a new chart on each selection.

How to make Bootstrap charts responsive

Chart.js watches the parent container and resizes the chart whenever that container changes size. A Bootstrap chart therefore stays responsive as long as the canvas sits in a relatively positioned wrapper that nothing else shares. Give the wrapper position-relative and a set height, then set maintainAspectRatio to false.

This works with Bootstrap’s responsive design layer. The column classes change the container width, and Chart.js follows the container.

<div class="card-body">
<div class="position-relative chart-box" style="height: 320px;">
<canvas id="visits"></canvas>
</div>
</div>

// in the Chart.js config
options: { maintainAspectRatio: false }
Chart.js ruleBootstrap implementationSymptom when skipped
Relatively positioned, dedicated parentA div with position-relative around the canvasResizing breaks, canvas can keep shrinking
Defined height on the parentInline height or one custom classContainer height is ignored
No relative values on the canvasSize the wrapper with Bootstrap classes, not canvas attributesCanvas stops resizing or turns blurry

Putting viewport units on the canvas itself is the usual trap. Chart.js documents vh and vw values in the canvas width and height attributes as invalid, and a style with the same units resizes the canvas but leaves it blurry.

The Chart.js documentation sets these defaults:

  • responsive: true
  • maintainAspectRatio: true
  • aspectRatio: 1 for radial charts (doughnut, pie, polarArea, radar), 2 for every other type
  • resizeDelay: 0 ms

A pie in a full-width column grows as tall as it is wide at the 1:1 default. Cap it with a fixed-height wrapper.

Choosing a chart type for Bootstrap dashboards

Start from the question the data answers. Change over time wants a line, and comparing categories wants bars. A part-to-whole split with few slices suits a pie or doughnut, radar covers profiles across several axes, and scatter or bubble charts show relationships between variables.

Line and bar charts take labels on one axis and one dataset per series. Line is the type Chart.js documents for trend data, and setting indexAxis to ‘y’ turns bars horizontal.

Pie and doughnut charts read one dataset of plain numbers, which Chart.js totals into shares. The only default difference is the cutout, 0 for pie and 50% for doughnut.

Every label on a radar chart becomes an axis, so two or three series stay readable and ten do not.

Scatter and bubble data points are objects. Scatter uses x and y, and bubble adds an r radius.

A doughnut earns its place in a KPI card that shows one share, such as the completion rate of a task. Past five or six slices, switch to a bar chart.

Polar area charts, where every segment has the same angle and the radius carries the value, rarely beat a bar chart on a dashboard.

How to match chart colors to Bootstrap color modes

Chart.js never reads Bootstrap’s CSS variables, which is why a chart keeps its light-mode colors after the data-bs-theme attribute flips to dark. The fix is to copy the variables into Chart.defaults with getComputedStyle, then call update() on every chart each time the attribute changes.

The defaults assume a light page: font color #666 and gridline border color rgba(0, 0, 0, 0.1), per the Chart.js documentation. On a dark body the text loses contrast and the gridlines disappear.

function syncChartTheme() {
  const style = getComputedStyle(document.documentElement);
  Chart.defaults.color = style.getPropertyValue('--bs-body-color').trim();
  Chart.defaults.borderColor = style.getPropertyValue('--bs-border-color').trim();
  Object.values(Chart.instances).forEach(chart => chart.update('none'));
}

syncChartTheme(); // run before the first new Chart()
new MutationObserver(syncChartTheme).observe(document.documentElement, {
  attributes: true,
  attributeFilter: ['data-bs-theme']
});

The toggler in Bootstrap’s docs only sets the attribute and fires no event of its own, so the observer is the hook. The ‘none’ mode skips the animation on redraw (Chart.js API documentation).

Color modes arrived with Bootstrap 5.3.0 on May 30, 2023 (Bootstrap blog). Projects still on 5.0 to 5.2 have no data-bs-theme attribute to observe.

If you want a different mode per card, data-bs-theme works on any element and CSS custom properties inherit, so read the variables from the chart’s wrapper and observe that element instead of html.

Builds compiled with $color-mode-type set to media-query work differently. That setting ties dark mode to prefers-color-scheme and removes per-component themes (Bootstrap docs), so listen with matchMedia instead.

Dataset colors need the same treatment. Pull series colors from variables such as –bs-primary, then check their color contrast against the card background in both modes.

When the brand palette fails in one mode, an accessible color palette generator produces a replacement set to test.

AdminLTE 4 ships its switcher as a ColorMode module inside adminlte.js (light, dark and auto) in 4.1 and in the current 4.10.0, and it sets the same attribute on the html element. Whichever switcher a project uses, the chart handler stays the same.

How to make Bootstrap charts accessible

Screen readers can’t see a canvas chart until text is added for it. Give the canvas role=”img” and an aria-label that states the finding, or place a data table next to it, because Chart.js leaves that work to the developer.

Start with the accessible name, which is role=”img” plus aria-label on the canvas. The Chart.js documentation marks a canvas with both as accessible and one with neither as inaccessible.

Fallback content goes between the canvas tags. The line “Your browser does not support the canvas element” counts as inaccessible there, because it says nothing about the data. Anything with more than one series should also get a real data table beside the chart.

ARIA labels work best as one sentence about the finding, such as “Bar chart of signups by quarter, highest in the last quarter”. They cannot carry a dozen data points, which is the job of the table.

Wrap the table in a details element under the card, with a caption and th cells marked scope=”col”, following the pattern for accessible tables.

Color, contrast and keyboard access

WCAG 1.4.11 (Level AA) asks for a contrast ratio of at least 3:1 on the parts of a graphic needed to understand the content, which covers bars, lines and pie slices (W3C, WCAG 2.1 Understanding docs).

W3C guidance also marks a pie chart with visible labels and values as not applicable, since the slices are then no longer required for understanding.

Keyboard access is the bigger gap. Chart.js listens for mousemove, mouseout, click, touchstart and touchmove by default (Chart.js documentation), so hover tooltips cannot open from the keyboard.

The chartjs-plugin-a11y package adds keyboard navigation and screen reader announcements. Its README calls it an early release and leaves color and font-size rules to the developer, so treat it as an extra layer on top of the label and the table, not a replacement.

Where Bootstrap charts fail: hidden tabs, modals and print

Most Bootstrap chart bugs come from a canvas measured while its tab, modal or collapse is hidden, from a print layout that changes the page size, or from a second chart built on a canvas that still holds the first. Charts that are visible at first paint need none of the fixes below.

FailureTriggerFix
Zero-size or squished chartChart created inside a hidden tab, modal or collapseCall resize() on the shown event
Wrong size in printPrint layout changes the container without a usable resize eventResize before printing, restore after
Canvas already in usenew Chart() on a canvas that still holds a chartdestroy() the old chart, or update() it

Charts inside tabs, modals and collapses

A chart built while its container is hidden measures a container with no size. Hook the shown events that Bootstrap tabs and the other plugins fire, because those fire only once the pane is visible.

Sources disagree on how much damage a hidden container does. The Chart.js documentation says responsive charts follow their parent container, while issue reports in the Chart.js repository describe charts squished after a hidden container was shown (number 4659) or failing to grow again when their container widens (number 11005).

A resize call costs nothing, so add it either way.

document.getElementById('revenue-tab')
.addEventListener('shown.bs.tab', () => {
  Chart.getChart('revenue')?.resize();
});

For a Bootstrap modal, listen for shown.bs.modal on the modal element, which waits for the CSS transition to finish (Bootstrap 5.3 documentation). Collapse panes work the same way with shown.bs.collapse.

Printing a chart

Chart.js cannot always resize for the print layout, because the browser lays out the document for printing and fires resize events at different moments (Chart.js documentation).

Loop over Chart.instances and call resize() from a beforeprint handler. If you’d rather set an explicit size, pass fixed dimensions to resize() before printing, then call resize() with no arguments in an afterprint handler to restore automatic sizing.

Rebuilding a chart on the same canvas

Calling new Chart() on a canvas that still holds a chart throws a canvas-already-in-use error. The API documentation requires destroy() before the canvas is reused.

For a filter or period change, edit chart.data and call update(). In a framework re-render, run Chart.getChart(‘visits’)?.destroy() before new Chart(). A card removed from the page deserves a destroy() as well, since that also clears the event listeners Chart.js attached.

Bootstrap Charts FAQ

Do Bootstrap charts need jQuery?

No. Chart.js has no jQuery dependency, and Bootstrap 5 plugins run on plain JavaScript.

Only Bootstrap 4 and older chart tutorials rely on jQuery.

Can I use Bootstrap charts in React with React-Bootstrap?

Yes. Put a Chart.js wrapper such as @coreui/react-chartjs, which targets Chart.js 4.x, inside React-Bootstrap’s Card and Col components.

The wrapper takes type, data and options as props, so the manual canvas and destroy() calls disappear.

How do I update a chart with live data?

Push the new label and value onto the arrays, drop the oldest point with shift() to keep a fixed window, then call update(‘none’).

The ‘none’ mode skips the animation, so the chart does not replay its transition on every tick.

Can charts be built with CSS only, without JavaScript?

Yes, for simple cases. Bootstrap progress bars draw horizontal bars, and a conic-gradient background draws a pie.

You give up tooltips, axes and data-driven updates, because every value is fixed in the markup.

Is Chart.js free for commercial projects?

Yes. Chart.js ships under the MIT license, which allows commercial use without fees, and Bootstrap uses the same license.

Check ApexCharts and Highcharts terms separately, since their licenses differ.

Where Chart.js Stops Being Enough

Bootstrap charts outgrow Chart.js when a dataset holds more points than the canvas can show. The fix runs in a fixed order: decimate, trim rendering work, move to a worker, then change library.

Once the decimation plugin is enabled (it is off by default), it triggers above 4 times the canvas width, so column width sets the limit. A 500 px canvas decimates past 2,000 points, and a 1,000 px canvas past 4,000 (Chart.js documentation).

Only line series with a linear or time x axis and parsing set to false qualify.

  • Decimate before passing data in, because automatic decimation runs late
  • Switch off animation and set parsing to false
  • Render in a web worker, which puts mouse interactions at risk

Past those steps, main-thread canvas rendering is the ceiling, and Apache ECharts, with its large-mode and progressive rendering options, takes over. Checked against the Chart.js 4.6.1 documentation on October 29, 2026.