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.
| Library | Rendering | License | Main limit |
|---|
| Chart.js | Canvas | MIT | Canvas content needs manual ARIA for screen readers |
| ApexCharts | SVG, plus an opt-in canvas renderer for dense data since 6.0 | Free under $2M revenue, paid above | Paid tier for larger organizations |
| Highcharts | SVG | Commercial | No free use in company projects |
| Apache ECharts | Canvas or SVG | Apache 2.0 | Own 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.
- Add Bootstrap’s CSS to the head, from the CDN or from npm.
- Place a canvas with an id inside a .card-body.
- Load Chart.js from jsDelivr, pinned to major version 4, before your own script.
- Call new Chart() with the canvas, a type and a data object.
- 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 rule | Bootstrap implementation | Symptom when skipped |
|---|
| Relatively positioned, dedicated parent | A div with position-relative around the canvas | Resizing breaks, canvas can keep shrinking |
| Defined height on the parent | Inline height or one custom class | Container height is ignored |
| No relative values on the canvas | Size the wrapper with Bootstrap classes, not canvas attributes | Canvas 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.
| Failure | Trigger | Fix |
|---|
| Zero-size or squished chart | Chart created inside a hidden tab, modal or collapse | Call resize() on the shown event |
| Wrong size in print | Print layout changes the container without a usable resize event | Resize before printing, restore after |
| Canvas already in use | new Chart() on a canvas that still holds a chart | destroy() 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.