Histogram Sparklines
Histogram sparklines display the frequency distribution of a dataset using vertical bars. They are useful for visualizing how values are grouped within defined intervals.
When to use histogram sparklines
- Visualizing data distribution: Show how values are grouped across ranges, such as the frequency of items in age bands or revenue intervals.
- Spotting patterns or outliers: Identify clusters and outliers in the data without building a full chart.
- Quick comparison of distributions: Compare how multiple datasets are distributed in a compact format.
Key visual elements
| Element | Description |
|---|---|
| Bin | Groups values into defined ranges based on the histogram type (continuous or discrete). |
| Bar | Visually represents a bin. The height is calculated as:
|
| Edge | Draws the border around each bar. If the calculated font size exceeds the available height, it is rounded down to the largest integer that fits. If the cell is too short, the font size defaults to 12px. |
| Data Label | Displays the value range inside each bar. The label font size is based on Math.floor(cellRowHeight / 3). It follows the same rounding and fallback logic as the bar edge. |
Create histogram sparklines
- On the Insert tab, select Sparklines.
- Under Bar Sparkline, select Insert Histogram Sparkline. The Create Sparklines dialog opens.
- In Data Range, select a continuous range of cells (in the same row or column).
- In Location Range, select the cell where the sparkline will appear.
- Click Ok. The sparkline is inserted into the selected cell.
Edit histogram sparklines
- Select the histogram sparkline in your workbook.
- On the Sparkline tab, select Settings. The HistogramSparkline Setting dialog opens.
- Adjust the parameters, then click Ok.
- Copy and paste the sparkline cell to duplicate the configuration in another location, as needed.
Histogram sparkline parameters
The histogram sparkline formula supports the following format:
=HISTOGRAMSPARKLINE(dataRange,continuous?,paintLabel?,scale?,barWidth?,barColor?,labelFontStyle?,labelColor,edgeColor?)
| Parameter | Description |
|---|---|
| Data Range | Defines the data source as a cell range or array, such as A1:C6 or {1, 2, 2, 3, 3}. Non-numeric values are ignored. |
| Continuous | (Optional) Determines the histogram type.
|
| PaintLabel | (Optional) Shows or hides the data label inside each bar. |
| Scale | Sets the bin width for continuous histograms. Must be greater than 0. |
| BarWidth | Sets the bar width as a percentage of the average bar width. Enter a value between 1% and 100%. |
| BarColor | Sets the fill color of the bars. |
| EdgeColor | Sets the color of the bar borders. |
| LabelFontStyle | Defines the font style for data labels. Accepts custom values for font family, size, weight, and style. |