Snippets Animation

Bootstrap 5 Responsive Bar Chart with Trend Line

A responsive bar-and-line chart drawn in plain SVG, comparing two revenue streams by month against a trend line. Legend buttons toggle each series and hovering or focusing a month shows its values.

Bootstrap 5 No jQuery Feb 2020 2.6K views

<section class="wdw-stage">
  <div class="container" style="max-width:960px">
    <div class="wdw-card p-4 p-md-5">
      <div class="d-flex flex-wrap align-items-start justify-content-between gap-3 mb-4">
        <div>
          <span class="wdw-eyebrow">Revenue overview</span>
          <h1 class="wdw-heading h3 mt-1 mb-1">Monthly performance</h1>
          <p class="wdw-muted small mb-0">Subscriptions and one-off sales against the 3-month trend.</p>
        </div>
        <div class="d-flex flex-wrap gap-2" role="group" aria-label="Toggle datasets" id="chartLegend">
          <button type="button" class="btn rounded-pill legend-btn active" data-series="0" aria-pressed="true"><span class="dot dot-a"></span>Subscriptions</button>
          <button type="button" class="btn rounded-pill legend-btn active" data-series="1" aria-pressed="true"><span class="dot dot-b"></span>One-off</button>
          <button type="button" class="btn rounded-pill legend-btn active" data-series="2" aria-pressed="true"><span class="dot dot-c"></span>Trend</button>
        </div>
      </div>
      <div class="chart-wrap position-relative">
        <svg id="barChart" class="w-100" role="group" aria-label="Bar chart of subscriptions and one-off revenue by month, with a trend line"></svg>
        <div class="chart-tip" id="chartTip" role="status" aria-live="polite"></div>
      </div>
    </div>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.