Mini Chart Card
Visually represent major data trends at a glance with this dynamic, data-driven mini chart card.
This is a convenient dashboard component for displaying metrics like user growth, revenue, or traffic sources. It pairs a key statistic with a chart graphic that is rendered from actual data using the popular Chart.js library.

About this Component
Unlike a static graphic, this template uses a JavaScript charting library called Chart.js to draw real, data-driven charts. This means you can easily feed it your own numbers to generate visualizations. The example provides the setup for a line, bar, and pie chart, all styled for a minimal "mini chart" look suitable for dashboards.
Features
- Data-Driven Charts: Renders charts from data you provide in the JavaScript.
- Powered by Chart.js: Relies on a popular, reliable, and lightweight charting library loaded from a CDN for ease of use.
- Multiple Chart Types: The example includes the configuration for a line chart, bar chart, and pie chart.
- Minimalist Design: The chart options are configured to hide legends and axes, creating the clean "sparkline" look perfect for dashboards.
Code Breakdown
HTML Structure
Each card is a simple div
containing a header for the text and a container for the chart. Inside the chart container is a single canvas
element with a unique id
(e.g., id="lineChart"
). The JavaScript will use this id
to find the canvas and draw the chart on it.
JavaScript Logic
The functionality requires two script
tags, placed at the end of your body
.
- Chart.js Library: The first script tag imports the Chart.js library from a CDN. This must be included for the charts to work.
- Chart Configuration: The second script contains your custom logic. It finds each
canvas
element by itsid
. For each one, it creates a newChart
instance, passing it the canvas context and a configuration object. This object specifies the charttype
(e.g.,'line'
), thedata
(includinglabels
for the axes anddatasets
with your numbers), and theoptions
for customizing the appearance. Thedata
property is where you will insert your own data.
Code
Here is the complete code. To adapt it, replace the placeholder data inside the data
properties in the JavaScript with your own values and labels.