# You draw it

> Ask readers to draw their guess for the hidden part of a line, then reveal the real data.

A you-draw-it chart hides the end of a line and asks the reader to sketch where it went before showing the data. Drag across the hatched area to draw your guess, then press the button.

```json
{
  "mark": {
    "type": "line",
    "strokeWidth": 2.5
  },
  "data": [
    {
      "date": "2019-01-01",
      "rate": 1.6
    },
    {
      "date": "2019-04-01",
      "rate": 2
    },
    {
      "date": "2019-07-01",
      "rate": 1.8
    },
    {
      "date": "2019-10-01",
      "rate": 1.8
    },
    {
      "date": "2020-01-01",
      "rate": 2.5
    },
    {
      "date": "2020-04-01",
      "rate": 0.3
    },
    {
      "date": "2020-07-01",
      "rate": 1
    },
    {
      "date": "2020-10-01",
      "rate": 1.2
    },
    {
      "date": "2021-01-01",
      "rate": 1.4
    },
    {
      "date": "2021-04-01",
      "rate": 4.2
    },
    {
      "date": "2021-07-01",
      "rate": 5.4
    },
    {
      "date": "2021-10-01",
      "rate": 6.2
    },
    {
      "date": "2022-01-01",
      "rate": 7.5
    },
    {
      "date": "2022-04-01",
      "rate": 8.3
    },
    {
      "date": "2022-07-01",
      "rate": 8.5
    },
    {
      "date": "2022-10-01",
      "rate": 7.7
    },
    {
      "date": "2023-01-01",
      "rate": 6.4
    },
    {
      "date": "2023-04-01",
      "rate": 4.9
    },
    {
      "date": "2023-07-01",
      "rate": 3.2
    },
    {
      "date": "2023-10-01",
      "rate": 3.2
    },
    {
      "date": "2024-01-01",
      "rate": 3.1
    },
    {
      "date": "2024-04-01",
      "rate": 3.4
    },
    {
      "date": "2024-07-01",
      "rate": 2.9
    },
    {
      "date": "2024-10-01",
      "rate": 2.6
    }
  ],
  "encoding": {
    "x": {
      "field": "date",
      "type": "temporal",
      "axis": {
        "tickCount": 6
      }
    },
    "y": {
      "field": "rate",
      "type": "quantitative",
      "axis": {
        "title": "Year-over-year change (%)",
        "format": ".0f",
        "grid": true
      }
    }
  },
  "youDrawIt": {
    "from": "2021-01-01",
    "prompt": "Draw inflation through 2024",
    "revealLabel": "Show the real rate"
  },
  "chrome": {
    "title": "US inflation stayed under 3% through 2019 and 2020",
    "subtitle": "Consumer price index, year-over-year change, %, quarterly 2019–2024"
  }
}
```

## Setting it up

`youDrawIt.from` is the x value where the visible line stops; it uses the same format as the data, here `"2021-01-01"`. Everything after it stays hidden behind a hatched region until the reader presses the reveal button, drawn or not. After the reveal, the reader's line and the real one sit on the same axes.

The title can only state what the visible line shows. A title about the peak would give away the answer the reader is about to draw, so this one stops at 2020 and the prompt asks for the rest.

The figure has no static image. A chart rendered at build time draws the whole line, hidden part included, so a demo like this sets `static: false` and appears only once the script runs.

## Prompt and button text

```json
{
  "mark": {
    "type": "line",
    "strokeWidth": 2.5
  },
  "data": [
    {
      "year": "1900",
      "anomaly": -0.08,
      "trend": "Cooler"
    },
    {
      "year": "1910",
      "anomaly": -0.43,
      "trend": "Cooler"
    },
    {
      "year": "1920",
      "anomaly": -0.27,
      "trend": "Cooler"
    },
    {
      "year": "1930",
      "anomaly": -0.16,
      "trend": "Cooler"
    },
    {
      "year": "1940",
      "anomaly": 0.12,
      "trend": "Warmer"
    },
    {
      "year": "1950",
      "anomaly": -0.17,
      "trend": "Cooler"
    },
    {
      "year": "1960",
      "anomaly": -0.03,
      "trend": "Cooler"
    },
    {
      "year": "1970",
      "anomaly": 0.03,
      "trend": "Warmer"
    },
    {
      "year": "1980",
      "anomaly": 0.26,
      "trend": "Warmer"
    },
    {
      "year": "1990",
      "anomaly": 0.45,
      "trend": "Warmer"
    },
    {
      "year": "2000",
      "anomaly": 0.39,
      "trend": "Warmer"
    },
    {
      "year": "2010",
      "anomaly": 0.72,
      "trend": "Warmer"
    },
    {
      "year": "2020",
      "anomaly": 1.01,
      "trend": "Warmer"
    },
    {
      "year": "2025",
      "anomaly": 1.19,
      "trend": "Warmer"
    }
  ],
  "encoding": {
    "x": {
      "field": "year",
      "type": "temporal",
      "axis": {
        "format": "%Y"
      }
    },
    "y": {
      "field": "anomaly",
      "type": "quantitative",
      "axis": {
        "title": "Difference from the 1951–1980 average (°C)",
        "format": "+.1f",
        "grid": true
      }
    }
  },
  "youDrawIt": {
    "from": "1970",
    "prompt": "Draw the line to 2025",
    "revealLabel": "Show the measurements"
  },
  "chrome": {
    "title": "From 1900 to 1970, no reading was more than 0.43°C from the 1951–1980 average",
    "subtitle": "Global surface temperature, difference from the 1951–1980 average (°C), by decade from 1900, plus 2025"
  }
}
```

`prompt` replaces "Draw your guess" in the hatched region, and `revealLabel` replaces "Show me" on the button. Write the prompt as an instruction that names the end point, so the reader knows how far to draw. Once the reader has drawn, a Clear button appears beside the reveal button; `resetLabel` renames it.

## Collecting guesses

Pass `onReveal` where the chart mounts to receive the reader's guess when the line is revealed, as `{ x, y }` points in data units:

```ts title="chart.ts"
createChart(container, spec, {
  onReveal: (guess) => sendGuess(guess),
});
```

A newsroom that stores guesses can show them back to later readers with `youDrawIt.comparisonLine`, a list of `{ x, y }` points drawn in a third style after the reveal. Only use it with guesses you collected; the charts on this page have none, so they draw no comparison line.

## Limits

You draw it works on a line chart with a single series. It works only in the default `"read"` interaction mode: with `interaction: "select"` or `"edit"`, the library warns and turns it off. The chart instance also has `revealDrawing()` and `resetDrawing()` for your own controls.

## Fields that matter

| Field | What it does |
| --- | --- |
| `youDrawIt.from` | The x value where drawing starts. Data after it is hidden until the reveal. |
| `youDrawIt.prompt` | Text in the hatched region. Default "Draw your guess". |
| `youDrawIt.revealLabel` | Text on the reveal button. Default "Show me". |
| `youDrawIt.resetLabel` | Text on the Clear button. Default "Clear". |
| `youDrawIt.comparisonLine` | Points for a third line, such as the average reader guess. |
| `onReveal` (mount option) | Receives the reader's guess at reveal. |

## Related

- [Line](/docs/change-over-time/line/) covers the line chart this builds on.
- [Edit mode](/docs/behavior/edit-mode/) lets readers drag annotations, and cannot share a chart with you draw it.
- [Vanilla API](/docs/api/vanilla/) covers `createChart` and the chart instance methods.
