Mathwords logoMathwords

Sparkline — Definition, Formula & Example

A sparkline is a very small line graph, about the size of a word, that shows how a value changes over time without axes, gridlines, or labels. It is designed to show the overall trend at a glance, often inside a sentence or a table cell.

A sparkline is a compact time-series graphic in which an ordered sequence of values x1,x2,…,xnx_1, x_2, \dots, x_n is plotted as a connected line. The horizontal positions are equally spaced, and the vertical positions are rescaled so that the minimum value sits at the bottom and the maximum sits at the top of a fixed height HH. Axes and tick marks are omitted, so the graphic conveys shape and direction rather than exact values. The term was coined by statistician Edward Tufte.

Key Formula

hi=xi−xmin⁡xmax⁡−xmin⁡⋅Hh_i = \frac{x_i - x_{\min}}{x_{\max} - x_{\min}} \cdot H
Where:
  • hih_i = Height of the i-th point above the bottom of the sparkline
  • xix_i = The i-th data value
  • xmin⁡,xmax⁡x_{\min}, x_{\max} = Smallest and largest values in the data (they must differ)
  • HH = Total height available for the sparkline, such as 10 pixels

Worked Example

Problem: The daily high temperatures in a town for one week were 60, 64, 62, 70, 68, 74, and 80 degrees Fahrenheit. You want to place a sparkline 10 pixels tall next to the word "Temperature" in a weather report. Find the height of each point.
Step 1: Find the minimum, maximum, and range. The minimum (60) goes at the bottom, and the maximum (80) goes at the top.
xmax⁡−xmin⁡=80−60=20∘Fx_{\max} - x_{\min} = 80 - 60 = 20^\circ\text{F}
Step 2: Scale each value into the 10-pixel height. Every 2 degrees above 60 becomes 1 pixel.
hi=xi−6020⋅10=xi−602⇒0, 2, 1, 5, 4, 7, 10h_i = \frac{x_i - 60}{20} \cdot 10 = \frac{x_i - 60}{2} \quad\Rightarrow\quad 0,\ 2,\ 1,\ 5,\ 4,\ 7,\ 10
Step 3: Plot the seven heights at equally spaced positions and connect them. Do not draw axes. A common habit is to mark the final point with a small dot and write its value, 80°F, beside it so the reader has one exact reference.
Answer: The point heights are 0, 2, 1, 5, 4, 7, and 10 pixels. The sparkline climbs from bottom to top with two small dips, showing at a glance that the week warmed by 20°F overall.

Why It Matters

Sparklines appear in stock tickers, sports stat tables, and spreadsheet dashboards. Excel and Google Sheets have built-in sparkline functions. They let you compare the trends of dozens of rows, such as monthly sales for 50 stores, without drawing 50 full-sized graphs.

Common Mistakes

Mistake: Comparing the steepness of two sparklines to decide which quantity changed more.
Correction: Each sparkline is usually scaled to its own minimum and maximum. A 2°F change and a 40°F change can both fill the full height. To compare sizes of change, check the actual values or put both sparklines on a shared vertical scale.

Related Terms

  • Box Plot — Another compact display, summarizing spread instead of trend over time
  • Box-and-Whisker Plot — Shows a five-number summary where a sparkline shows sequence
  • Stemplot — Compact display that keeps every value readable, unlike sparklines
  • Line Graphs — Sparkline is a miniature version of this graph type
  • Time Series — Sparklines usually display this kind of data over time
  • Data Graph — Sparkline is one compact kind of data graph