Tick strip
Draw one short tick per observation along a shared axis to show the spread of values in each group, then color the strips and add a reference line.
A tick strip draws one short line per observation along a value axis, so the whole spread of a group reads at once: where values cluster, where they thin out and where the extremes sit. Stacking one strip per group lets you compare spreads directly.
Ticks overlap when the data is dense. Switch to a beeswarm to dodge the points apart, or to a histogram when counts matter more than individual values. To compare one summary number per group, use a bar chart.
A basic tick strip
Set mark to "tick", put the value on x and the group on y. Each row of the data becomes one tick. The tick mark needs a y channel; the spec fails validation without one.
{
"mark": "tick",
"data": [
{
"group": "20-29",
"hours": 3.1
},
{
"group": "20-29",
"hours": 3.4
},
{
"group": "20-29",
"hours": 3.6
},
{
"group": "20-29",
"hours": 3.8
},
{
"group": "20-29",
"hours": 4
},
{
"group": "20-29",
"hours": 4.3
},
// … 29 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
}
},
"chrome": {
"title": "26 of 35 finishers took five hours or less",
"subtitle": "Individual marathon finishers by age group. Each tick is one runner."
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
}
},
"chrome": {
"title": "26 of 35 finishers took five hours or less",
"subtitle": "Individual marathon finishers by age group. Each tick is one runner."
}
};
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 = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
}
},
"chrome": {
"title": "26 of 35 finishers took five hours or less",
"subtitle": "Individual marathon finishers by age group. Each tick is one runner."
}
};
</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 = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
}
},
"chrome": {
"title": "26 of 35 finishers took five hours or less",
"subtitle": "Individual marathon finishers by age group. Each tick is one runner."
}
};
</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 = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
}
},
"chrome": {
"title": "26 of 35 finishers took five hours or less",
"subtitle": "Individual marathon finishers by age group. Each tick is one runner."
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Colored strips
A color channel on the same field as y gives each strip its own color. The strips are already labeled on the axis, so legend: { show: false } drops the legend.
{
"mark": "tick",
"data": [
{
"group": "20-29",
"hours": 3.1
},
{
"group": "20-29",
"hours": 3.4
},
{
"group": "20-29",
"hours": 3.6
},
{
"group": "20-29",
"hours": 3.8
},
{
"group": "20-29",
"hours": 4
},
{
"group": "20-29",
"hours": 4.3
},
// … 29 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
},
"color": {
"field": "group",
"type": "nominal"
}
},
"legend": {
"show": false
},
"chrome": {
"title": "Finish times spread wider with age",
"subtitle": "Individual marathon finishers by age group. Each tick is one runner."
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
},
"color": {
"field": "group",
"type": "nominal"
}
},
"legend": {
"show": false
},
"chrome": {
"title": "Finish times spread wider with age",
"subtitle": "Individual marathon finishers by age group. Each tick is one runner."
}
};
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 = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
},
"color": {
"field": "group",
"type": "nominal"
}
},
"legend": {
"show": false
},
"chrome": {
"title": "Finish times spread wider with age",
"subtitle": "Individual marathon finishers by age group. Each tick is one runner."
}
};
</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 = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
},
"color": {
"field": "group",
"type": "nominal"
}
},
"legend": {
"show": false
},
"chrome": {
"title": "Finish times spread wider with age",
"subtitle": "Individual marathon finishers by age group. Each tick is one runner."
}
};
</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 = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
},
"color": {
"field": "group",
"type": "nominal"
}
},
"legend": {
"show": false
},
"chrome": {
"title": "Finish times spread wider with age",
"subtitle": "Individual marathon finishers by age group. Each tick is one runner."
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
A reference line
A refline annotation draws a threshold in data units across every strip, so you can read how many ticks fall on each side. Here the line marks four hours.
{
"mark": "tick",
"data": [
{
"group": "20-29",
"hours": 3.1
},
{
"group": "20-29",
"hours": 3.4
},
{
"group": "20-29",
"hours": 3.6
},
{
"group": "20-29",
"hours": 3.8
},
{
"group": "20-29",
"hours": 4
},
{
"group": "20-29",
"hours": 4.3
},
// … 29 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
},
"color": {
"field": "group",
"type": "nominal"
}
},
"legend": {
"show": false
},
"annotations": [
{
"type": "refline",
"x": 4,
"label": "4 hours",
"style": "dashed"
}
],
"chrome": {
"title": "Few runners over 50 break four hours",
"subtitle": "Individual marathon finishers by age group"
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
},
"color": {
"field": "group",
"type": "nominal"
}
},
"legend": {
"show": false
},
"annotations": [
{
"type": "refline",
"x": 4,
"label": "4 hours",
"style": "dashed"
}
],
"chrome": {
"title": "Few runners over 50 break four hours",
"subtitle": "Individual marathon finishers by age group"
}
};
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 = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
},
"color": {
"field": "group",
"type": "nominal"
}
},
"legend": {
"show": false
},
"annotations": [
{
"type": "refline",
"x": 4,
"label": "4 hours",
"style": "dashed"
}
],
"chrome": {
"title": "Few runners over 50 break four hours",
"subtitle": "Individual marathon finishers by age group"
}
};
</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 = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
},
"color": {
"field": "group",
"type": "nominal"
}
},
"legend": {
"show": false
},
"annotations": [
{
"type": "refline",
"x": 4,
"label": "4 hours",
"style": "dashed"
}
],
"chrome": {
"title": "Few runners over 50 break four hours",
"subtitle": "Individual marathon finishers by age group"
}
};
</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 = [/* 35 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "hours",
"type": "quantitative",
"axis": {
"title": "Finish time (hours)"
}
},
"y": {
"field": "group",
"type": "nominal",
"axis": {
"title": "Age group"
}
},
"color": {
"field": "group",
"type": "nominal"
}
},
"legend": {
"show": false
},
"annotations": [
{
"type": "refline",
"x": 4,
"label": "4 hours",
"style": "dashed"
}
],
"chrome": {
"title": "Few runners over 50 break four hours",
"subtitle": "Individual marathon finishers by age group"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Another dataset
The same spec works on any one-number-per-row data. This one shows invented household incomes in four Census regions, with the strips wider where incomes vary more.
{
"mark": "tick",
"data": [
{
"income": 22,
"region": "South"
},
{
"income": 28,
"region": "South"
},
{
"income": 31,
"region": "South"
},
{
"income": 35,
"region": "South"
},
{
"income": 38,
"region": "South"
},
{
"income": 42,
"region": "South"
},
// … 38 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "income",
"type": "quantitative",
"axis": {
"title": "Household income ($K)"
}
},
"y": {
"field": "region",
"type": "nominal"
},
"color": {
"field": "region",
"type": "nominal"
}
},
"legend": {
"show": false
},
"chrome": {
"title": "The West and Northeast reach the highest incomes",
"subtitle": "Sampled households by Census region. Each tick is one household."
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 44 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "income",
"type": "quantitative",
"axis": {
"title": "Household income ($K)"
}
},
"y": {
"field": "region",
"type": "nominal"
},
"color": {
"field": "region",
"type": "nominal"
}
},
"legend": {
"show": false
},
"chrome": {
"title": "The West and Northeast reach the highest incomes",
"subtitle": "Sampled households by Census region. Each tick is one household."
}
};
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 = [/* 44 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "income",
"type": "quantitative",
"axis": {
"title": "Household income ($K)"
}
},
"y": {
"field": "region",
"type": "nominal"
},
"color": {
"field": "region",
"type": "nominal"
}
},
"legend": {
"show": false
},
"chrome": {
"title": "The West and Northeast reach the highest incomes",
"subtitle": "Sampled households by Census region. Each tick is one household."
}
};
</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 = [/* 44 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "income",
"type": "quantitative",
"axis": {
"title": "Household income ($K)"
}
},
"y": {
"field": "region",
"type": "nominal"
},
"color": {
"field": "region",
"type": "nominal"
}
},
"legend": {
"show": false
},
"chrome": {
"title": "The West and Northeast reach the highest incomes",
"subtitle": "Sampled households by Census region. Each tick is one household."
}
};
</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 = [/* 44 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "tick",
"encoding": {
"x": {
"field": "income",
"type": "quantitative",
"axis": {
"title": "Household income ($K)"
}
},
"y": {
"field": "region",
"type": "nominal"
},
"color": {
"field": "region",
"type": "nominal"
}
},
"legend": {
"show": false
},
"chrome": {
"title": "The West and Northeast reach the highest incomes",
"subtitle": "Sampled households by Census region. Each tick is one household."
}
};
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 |
"tick" draws one short line per row. |
encoding.x |
The quantitative value each tick is placed at. |
encoding.y |
A nominal field that names each strip. Required for the tick mark. |
encoding.color |
Optional. Colors each strip by group. |
legend.show |
Set to false to hide a legend the axis labels already replace. |
annotations |
A refline with x draws a reference value across the strips. |
Related
- Beeswarm: dodge dense points apart.
- Histogram: count values in bins.
- Error bars: show an interval instead of every observation.
- Range: compare a start and an end per category.
- Scatter: place observations by two numbers.
- Marks reference: the channels and options each mark type takes.