Esc

COMARK0425 · warning

comark/charts/spec-with-data

Leave data out of a Vega-Lite spec

A chart's data is its table, which stays in the page so readers and agents can read the numbers. The table replaces any data in the spec, so numbers written there are never drawn.

Incorrect

::chart{title="Ducks per pond"}
| pond | ducks |
| --- | --: |
| north | 12 |
| south | 7 |
| east | 9 |

```vega-lite
{
  "data": { "values": [{ "pond": "north", "ducks": 12 }] },
  "mark": "bar",
  "encoding": {
    "x": { "field": "pond", "type": "nominal" },
    "y": { "field": "ducks", "type": "quantitative" }
  }
}
```
::
md
lint-comark example.mdexample.md:1:1 comark/charts/spec-with-data::chart 1: its Vega-Lite spec has data, but a chart's data is its table, so the table replaces it.Remove data from the spec.✖ 1 problem

Correct

::chart{title="Ducks per pond"}
| pond | ducks |
| --- | --: |
| north | 12 |
| south | 7 |
| east | 9 |

```vega-lite
{
  "mark": "bar",
  "encoding": {
    "x": { "field": "pond", "type": "nominal" },
    "y": { "field": "ducks", "type": "quantitative" }
  }
}
```
::
md
lint-comark example.md✔ No problems