# 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](/docs/the-spec/scales/).

Use a [bar chart](/docs/comparison/bar/) when the filled length should dominate, and a [range chart](/docs/comparison/range/) 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.

```json
{
  "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)"
  }
}
```

## 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.

```json
{
  "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
    },
    {
      "state": "Georgia",
      "change": 4.1
    },
    {
      "state": "Colorado",
      "change": 3.2
    },
    {
      "state": "California",
      "change": -0.5
    },
    {
      "state": "Illinois",
      "change": -0.8
    },
    {
      "state": "New York",
      "change": -1
    },
    {
      "state": "Hawaii",
      "change": -1.5
    },
    {
      "state": "West Virginia",
      "change": -1.5
    }
  ],
  "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"
  }
}
```

## 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](/docs/comparison/range/) instead.

```json
{
  "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"
    },
    {
      "country": "Sweden",
      "years": 81.6,
      "gender": "Male"
    },
    {
      "country": "Sweden",
      "years": 85,
      "gender": "Female"
    },
    {
      "country": "Canada",
      "years": 80.6,
      "gender": "Male"
    },
    {
      "country": "Canada",
      "years": 84.5,
      "gender": "Female"
    },
    {
      "country": "Germany",
      "years": 78.9,
      "gender": "Male"
    },
    {
      "country": "Germany",
      "years": 83.5,
      "gender": "Female"
    },
    {
      "country": "UK",
      "years": 79.5,
      "gender": "Male"
    },
    {
      "country": "UK",
      "years": 83.2,
      "gender": "Female"
    },
    {
      "country": "USA",
      "years": 76.4,
      "gender": "Male"
    },
    {
      "country": "USA",
      "years": 81.3,
      "gender": "Female"
    },
    {
      "country": "China",
      "years": 75.5,
      "gender": "Male"
    },
    {
      "country": "China",
      "years": 81,
      "gender": "Female"
    },
    {
      "country": "Brazil",
      "years": 73.1,
      "gender": "Male"
    },
    {
      "country": "Brazil",
      "years": 80.3,
      "gender": "Female"
    },
    {
      "country": "India",
      "years": 69.8,
      "gender": "Male"
    },
    {
      "country": "India",
      "years": 72.8,
      "gender": "Female"
    },
    {
      "country": "Russia",
      "years": 68.2,
      "gender": "Male"
    },
    {
      "country": "Russia",
      "years": 78.2,
      "gender": "Female"
    }
  ],
  "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"
  }
}
```

## 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](/docs/comparison/bar/) for the filled form.
- [Range](/docs/comparison/range/) for a start and an end value per category.
- [Scatter](/docs/correlation/scatter/) for two quantitative axes instead of a category axis.
- [Marks reference](/docs/spec/marks/) lists the channels and options each mark type takes.
