Lollipop
Compare values across categories with a dot on a thin stem, then plot negatives or show two values per category.
A lollipop chart is a bar chart with the bar thinned to a stem and a dot at the end. The reader still judges each value by its distance from the baseline, with less ink. It uses less ink than bars, which helps on a long list. The stems are still lengths, so keep the axis at zero; for dots on an axis that starts elsewhere, use a dot plot with mark: { type: "point", trendline: false } and no stems, as on the scales page.
Use a bar chart when the filled length should dominate, and a range chart when each category has a start and an end value.
A basic lollipop chart
Set mark to "lollipop", put the number on x and the category on y. Each stem runs from the zero baseline to its dot.
{
"mark": "lollipop",
"data": [
{
"city": "New York",
"minutes": 40.6
},
{
"city": "Chicago",
"minutes": 33.5
},
{
"city": "Philadelphia",
"minutes": 33.2
},
{
"city": "San Francisco",
"minutes": 32.2
},
{
"city": "Boston",
"minutes": 31.7
},
{
"city": "Los Angeles",
"minutes": 31.7
},
{
"city": "Baltimore",
"minutes": 30.2
},
{
"city": "Seattle",
"minutes": 28.8
},
{
"city": "Houston",
"minutes": 28.4
},
{
"city": "Denver",
"minutes": 26.1
},
{
"city": "Phoenix",
"minutes": 25.8
},
{
"city": "Tulsa",
"minutes": 19.7
}
],
"encoding": {
"x": {
"field": "minutes",
"type": "quantitative",
"axis": {
"title": "Average one-way commute (minutes)"
}
},
"y": {
"field": "city",
"type": "nominal"
}
},
"chrome": {
"title": "New Yorkers commute twice as long as Tulsans",
"subtitle": "Average one-way commute time by major US metro area, 2024 (minutes)"
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "lollipop",
"encoding": {
"x": {
"field": "minutes",
"type": "quantitative",
"axis": {
"title": "Average one-way commute (minutes)"
}
},
"y": {
"field": "city",
"type": "nominal"
}
},
"chrome": {
"title": "New Yorkers commute twice as long as Tulsans",
"subtitle": "Average one-way commute time by major US metro area, 2024 (minutes)"
}
};
export function Example() {
return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "lollipop",
"encoding": {
"x": {
"field": "minutes",
"type": "quantitative",
"axis": {
"title": "Average one-way commute (minutes)"
}
},
"y": {
"field": "city",
"type": "nominal"
}
},
"chrome": {
"title": "New Yorkers commute twice as long as Tulsans",
"subtitle": "Average one-way commute time by major US metro area, 2024 (minutes)"
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "lollipop",
"encoding": {
"x": {
"field": "minutes",
"type": "quantitative",
"axis": {
"title": "Average one-way commute (minutes)"
}
},
"y": {
"field": "city",
"type": "nominal"
}
},
"chrome": {
"title": "New Yorkers commute twice as long as Tulsans",
"subtitle": "Average one-way commute time by major US metro area, 2024 (minutes)"
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "lollipop",
"encoding": {
"x": {
"field": "minutes",
"type": "quantitative",
"axis": {
"title": "Average one-way commute (minutes)"
}
},
"y": {
"field": "city",
"type": "nominal"
}
},
"chrome": {
"title": "New Yorkers commute twice as long as Tulsans",
"subtitle": "Average one-way commute time by major US metro area, 2024 (minutes)"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Positive and negative values
Stems run left of zero for negative values, so a lollipop chart shows decline as clearly as growth. A solid refline at x: 0 marks the baseline.
{
"mark": "lollipop",
"data": [
{
"state": "Idaho",
"change": 10.4
},
{
"state": "Florida",
"change": 8.9
},
{
"state": "Texas",
"change": 8.8
},
{
"state": "Montana",
"change": 7.5
},
{
"state": "South Carolina",
"change": 6.8
},
{
"state": "North Carolina",
"change": 5.9
},
// … 7 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "change",
"type": "quantitative",
"axis": {
"title": "Population change (%)",
"format": "+.0f"
}
},
"y": {
"field": "state",
"type": "nominal"
}
},
"annotations": [
{
"type": "refline",
"x": 0,
"style": "solid",
"stroke": "#334155",
"strokeWidth": 1.5
}
],
"chrome": {
"title": "Idaho grew fastest, and five of these 13 states lost people",
"subtitle": "Percent population change by state, April 2020 to July 2024"
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 13 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "lollipop",
"encoding": {
"x": {
"field": "change",
"type": "quantitative",
"axis": {
"title": "Population change (%)",
"format": "+.0f"
}
},
"y": {
"field": "state",
"type": "nominal"
}
},
"annotations": [
{
"type": "refline",
"x": 0,
"style": "solid",
"stroke": "#334155",
"strokeWidth": 1.5
}
],
"chrome": {
"title": "Idaho grew fastest, and five of these 13 states lost people",
"subtitle": "Percent population change by state, April 2020 to July 2024"
}
};
export function Example() {
return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 13 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "lollipop",
"encoding": {
"x": {
"field": "change",
"type": "quantitative",
"axis": {
"title": "Population change (%)",
"format": "+.0f"
}
},
"y": {
"field": "state",
"type": "nominal"
}
},
"annotations": [
{
"type": "refline",
"x": 0,
"style": "solid",
"stroke": "#334155",
"strokeWidth": 1.5
}
],
"chrome": {
"title": "Idaho grew fastest, and five of these 13 states lost people",
"subtitle": "Percent population change by state, April 2020 to July 2024"
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 13 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "lollipop",
"encoding": {
"x": {
"field": "change",
"type": "quantitative",
"axis": {
"title": "Population change (%)",
"format": "+.0f"
}
},
"y": {
"field": "state",
"type": "nominal"
}
},
"annotations": [
{
"type": "refline",
"x": 0,
"style": "solid",
"stroke": "#334155",
"strokeWidth": 1.5
}
],
"chrome": {
"title": "Idaho grew fastest, and five of these 13 states lost people",
"subtitle": "Percent population change by state, April 2020 to July 2024"
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 13 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "lollipop",
"encoding": {
"x": {
"field": "change",
"type": "quantitative",
"axis": {
"title": "Population change (%)",
"format": "+.0f"
}
},
"y": {
"field": "state",
"type": "nominal"
}
},
"annotations": [
{
"type": "refline",
"x": 0,
"style": "solid",
"stroke": "#334155",
"strokeWidth": 1.5
}
],
"chrome": {
"title": "Idaho grew fastest, and five of these 13 states lost people",
"subtitle": "Percent population change by state, April 2020 to July 2024"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Two values per category
On the dot mark, a categorical color field switches the chart to dumbbell mode, which joins each category’s dots from lowest to highest and drops the stems from zero. Set scale: { zero: false } on x so the axis spans the data instead of starting at zero. When your data already has a start and an end column per row, use the range mark instead.
{
"mark": "circle",
"data": [
{
"country": "Japan",
"years": 81.9,
"gender": "Male"
},
{
"country": "Japan",
"years": 87.9,
"gender": "Female"
},
{
"country": "Switzerland",
"years": 82,
"gender": "Male"
},
{
"country": "Switzerland",
"years": 85.9,
"gender": "Female"
},
{
"country": "Australia",
"years": 81.7,
"gender": "Male"
},
{
"country": "Australia",
"years": 85.6,
"gender": "Female"
},
// … 18 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "years",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
},
"scale": {
"zero": false
}
},
"y": {
"field": "country",
"type": "nominal"
},
"color": {
"field": "gender",
"type": "nominal"
}
},
"chrome": {
"title": "Women outlive men in all 12 countries, by 3 to 10 years",
"subtitle": "Life expectancy at birth by gender, selected countries, 2023"
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 24 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "circle",
"encoding": {
"x": {
"field": "years",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
},
"scale": {
"zero": false
}
},
"y": {
"field": "country",
"type": "nominal"
},
"color": {
"field": "gender",
"type": "nominal"
}
},
"chrome": {
"title": "Women outlive men in all 12 countries, by 3 to 10 years",
"subtitle": "Life expectancy at birth by gender, selected countries, 2023"
}
};
export function Example() {
return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 24 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "circle",
"encoding": {
"x": {
"field": "years",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
},
"scale": {
"zero": false
}
},
"y": {
"field": "country",
"type": "nominal"
},
"color": {
"field": "gender",
"type": "nominal"
}
},
"chrome": {
"title": "Women outlive men in all 12 countries, by 3 to 10 years",
"subtitle": "Life expectancy at birth by gender, selected countries, 2023"
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 24 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "circle",
"encoding": {
"x": {
"field": "years",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
},
"scale": {
"zero": false
}
},
"y": {
"field": "country",
"type": "nominal"
},
"color": {
"field": "gender",
"type": "nominal"
}
},
"chrome": {
"title": "Women outlive men in all 12 countries, by 3 to 10 years",
"subtitle": "Life expectancy at birth by gender, selected countries, 2023"
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 24 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "circle",
"encoding": {
"x": {
"field": "years",
"type": "quantitative",
"axis": {
"title": "Life expectancy (years)"
},
"scale": {
"zero": false
}
},
"y": {
"field": "country",
"type": "nominal"
},
"color": {
"field": "gender",
"type": "nominal"
}
},
"chrome": {
"title": "Women outlive men in all 12 countries, by 3 to 10 years",
"subtitle": "Life expectancy at birth by gender, selected countries, 2023"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Fields that matter
| Field | What it does |
|---|---|
mark |
"lollipop" and "circle" draw dots on stems. |
encoding.x |
The value channel. Required, type: "quantitative". |
encoding.y |
The category channel. Required, type: "nominal" or "ordinal". |
encoding.color |
A categorical field switches to dumbbell mode (dots joined per category, no stems); a quantitative field colors the dots on a sequential scale and keeps the stems. |
encoding.x.scale.zero |
false stops the axis from including zero. |
annotations |
A refline draws a reference value in data units. |
Related
- Bar for the filled form.
- Range for a start and an end value per category.
- Scatter for two quantitative axes instead of a category axis.
- Marks reference lists the channels and options each mark type takes.