Column types
Turn table columns into heatmaps, inline bars, sparklines, delta chips, images and category chips with one config field per column.
A plain table column shows a number as text. A column type adds a visual encoding to the cell, so the reader can see which values are high, which rose and how a series moved without reading every digit. Each column takes at most one visual feature.
If several are set on one column, the order of precedence is sparkline, bar, delta, heatmap, image, flag, then category colors. Start from the data table page for the base spec, and use a chart when the comparison is the whole point.
Heatmap cells
heatmap colors the cell background by value from a sequential palette, so the widest margins read darkest and the closest races palest. palette picks the colors, and domain sets the extent explicitly.
Margin of victory as a heatmap column. This chart is drawn in the browser.
{
"type": "table",
"data": [
{
"state": "Georgia",
"winner": "Republican",
"margin": 2.2,
"electoralVotes": 16
},
{
"state": "Arizona",
"winner": "Republican",
"margin": 5.5,
"electoralVotes": 11
},
{
"state": "Pennsylvania",
"winner": "Republican",
"margin": 1.7,
"electoralVotes": 19
},
{
"state": "Wisconsin",
"winner": "Republican",
"margin": 0.9,
"electoralVotes": 10
},
{
"state": "Michigan",
"winner": "Republican",
"margin": 1.4,
"electoralVotes": 15
},
{
"state": "Nevada",
"winner": "Republican",
"margin": 3.1,
"electoralVotes": 6
},
{
"state": "North Carolina",
"winner": "Republican",
"margin": 3.4,
"electoralVotes": 16
},
{
"state": "Minnesota",
"winner": "Democrat",
"margin": 4.3,
"electoralVotes": 10
}
],
"columns": [
{
"key": "state",
"label": "State",
"sortable": true
},
{
"key": "margin",
"label": "Margin (%)",
"format": ".1f",
"sortable": true,
"align": "right",
"heatmap": {
"palette": "orange"
}
},
{
"key": "electoralVotes",
"label": "Electoral votes",
"sortable": true,
"align": "right"
}
],
"chrome": {
"title": "Republicans won the four closest battleground states",
"subtitle": "Battleground states by margin of victory"
}
}import { DataTable } from "@opendata-ai/openchart-react";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "state",
"label": "State",
"sortable": true
},
{
"key": "margin",
"label": "Margin (%)",
"format": ".1f",
"sortable": true,
"align": "right",
"heatmap": {
"palette": "orange"
}
},
{
"key": "electoralVotes",
"label": "Electoral votes",
"sortable": true,
"align": "right"
}
],
"chrome": {
"title": "Republicans won the four closest battleground states",
"subtitle": "Battleground states by margin of victory"
}
};
export function Example() {
return <DataTable spec={spec} />;
}
<script setup lang="ts">
import { DataTable } from "@opendata-ai/openchart-vue";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "state",
"label": "State",
"sortable": true
},
{
"key": "margin",
"label": "Margin (%)",
"format": ".1f",
"sortable": true,
"align": "right",
"heatmap": {
"palette": "orange"
}
},
{
"key": "electoralVotes",
"label": "Electoral votes",
"sortable": true,
"align": "right"
}
],
"chrome": {
"title": "Republicans won the four closest battleground states",
"subtitle": "Battleground states by margin of victory"
}
};
</script>
<template>
<DataTable :spec="spec" />
</template>
<script lang="ts">
import { DataTable } from "@opendata-ai/openchart-svelte";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "state",
"label": "State",
"sortable": true
},
{
"key": "margin",
"label": "Margin (%)",
"format": ".1f",
"sortable": true,
"align": "right",
"heatmap": {
"palette": "orange"
}
},
{
"key": "electoralVotes",
"label": "Electoral votes",
"sortable": true,
"align": "right"
}
],
"chrome": {
"title": "Republicans won the four closest battleground states",
"subtitle": "Battleground states by margin of victory"
}
};
</script>
<DataTable {spec} />
import { createTable } from "@opendata-ai/openchart-vanilla";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "state",
"label": "State",
"sortable": true
},
{
"key": "margin",
"label": "Margin (%)",
"format": ".1f",
"sortable": true,
"align": "right",
"heatmap": {
"palette": "orange"
}
},
{
"key": "electoralVotes",
"label": "Electoral votes",
"sortable": true,
"align": "right"
}
],
"chrome": {
"title": "Republicans won the four closest battleground states",
"subtitle": "Battleground states by margin of victory"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createTable(container, spec);
Inline bars
bar draws a proportional bar inside the cell, scaled to the column’s largest value unless maxValue sets it. color sets the fill. It reads like a bar list embedded in a table.
Revenue as an inline bar column. This chart is drawn in the browser.
{
"type": "table",
"data": [
{
"company": "Amazon",
"logo": "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%220%200%2040%2040%22%3E%3Crect%20width%3D%2240%22%20height%3D%2240%22%20rx%3D%229%22%20fill%3D%22%23ff9900%22%2F%3E%3Ctext%20x%3D%2220%22%20y%3D%2227%22%20font-family%3D%22Inter%2C%20system-ui%2C%20sans-serif%22%20font-size%3D%2222%22%20font-weight%3D%22700%22%20fill%3D%22%23ffffff%22%20text-anchor%3D%22middle%22%3EA%3C%2Ftext%3E%3C%2Fsvg%3E",
"revenue": 638,
"quarterly": [
143,
148,
159,
188
]
},
{
"company": "Apple",
"logo": "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%220%200%2040%2040%22%3E%3Crect%20width%3D%2240%22%20height%3D%2240%22%20rx%3D%229%22%20fill%3D%22%23111827%22%2F%3E%3Ctext%20x%3D%2220%22%20y%3D%2227%22%20font-family%3D%22Inter%2C%20system-ui%2C%20sans-serif%22%20font-size%3D%2222%22%20font-weight%3D%22700%22%20fill%3D%22%23ffffff%22%20text-anchor%3D%22middle%22%3EA%3C%2Ftext%3E%3C%2Fsvg%3E",
"revenue": 391,
"quarterly": [
90,
86,
95,
120
]
},
{
"company": "Alphabet",
"logo": "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%220%200%2040%2040%22%3E%3Crect%20width%3D%2240%22%20height%3D%2240%22%20rx%3D%229%22%20fill%3D%22%234285f4%22%2F%3E%3Ctext%20x%3D%2220%22%20y%3D%2227%22%20font-family%3D%22Inter%2C%20system-ui%2C%20sans-serif%22%20font-size%3D%2222%22%20font-weight%3D%22700%22%20fill%3D%22%23ffffff%22%20text-anchor%3D%22middle%22%3EG%3C%2Ftext%3E%3C%2Fsvg%3E",
"revenue": 350,
"quarterly": [
80,
85,
88,
97
]
},
{
"company": "Microsoft",
"logo": "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%220%200%2040%2040%22%3E%3Crect%20width%3D%2240%22%20height%3D%2240%22%20rx%3D%229%22%20fill%3D%22%230078d4%22%2F%3E%3Ctext%20x%3D%2220%22%20y%3D%2227%22%20font-family%3D%22Inter%2C%20system-ui%2C%20sans-serif%22%20font-size%3D%2222%22%20font-weight%3D%22700%22%20fill%3D%22%23ffffff%22%20text-anchor%3D%22middle%22%3EM%3C%2Ftext%3E%3C%2Fsvg%3E",
"revenue": 245,
"quarterly": [
57,
62,
62,
64
]
},
{
"company": "Meta",
"logo": "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%220%200%2040%2040%22%3E%3Crect%20width%3D%2240%22%20height%3D%2240%22%20rx%3D%229%22%20fill%3D%22%230866ff%22%2F%3E%3Ctext%20x%3D%2220%22%20y%3D%2227%22%20font-family%3D%22Inter%2C%20system-ui%2C%20sans-serif%22%20font-size%3D%2222%22%20font-weight%3D%22700%22%20fill%3D%22%23ffffff%22%20text-anchor%3D%22middle%22%3EM%3C%2Ftext%3E%3C%2Fsvg%3E",
"revenue": 164,
"quarterly": [
36,
39,
41,
48
]
}
],
"columns": [
{
"key": "company",
"label": "Company",
"sortable": true
},
{
"key": "revenue",
"label": "FY24 revenue ($B)",
"format": ",.0f",
"sortable": true,
"align": "right",
"bar": {
"color": "#0e7490"
}
}
],
"chrome": {
"title": "Amazon still tops big tech by revenue",
"subtitle": "Full-year 2024 revenue, with an inline bar scaled to the largest value"
}
}import { DataTable } from "@opendata-ai/openchart-react";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: TableSpec = {
"type": "table",
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"columns": [
{
"key": "company",
"label": "Company",
"sortable": true
},
{
"key": "revenue",
"label": "FY24 revenue ($B)",
"format": ",.0f",
"sortable": true,
"align": "right",
"bar": {
"color": "#0e7490"
}
}
],
"chrome": {
"title": "Amazon still tops big tech by revenue",
"subtitle": "Full-year 2024 revenue, with an inline bar scaled to the largest value"
}
};
export function Example() {
return <DataTable spec={spec} />;
}
<script setup lang="ts">
import { DataTable } from "@opendata-ai/openchart-vue";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: TableSpec = {
"type": "table",
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"columns": [
{
"key": "company",
"label": "Company",
"sortable": true
},
{
"key": "revenue",
"label": "FY24 revenue ($B)",
"format": ",.0f",
"sortable": true,
"align": "right",
"bar": {
"color": "#0e7490"
}
}
],
"chrome": {
"title": "Amazon still tops big tech by revenue",
"subtitle": "Full-year 2024 revenue, with an inline bar scaled to the largest value"
}
};
</script>
<template>
<DataTable :spec="spec" />
</template>
<script lang="ts">
import { DataTable } from "@opendata-ai/openchart-svelte";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: TableSpec = {
"type": "table",
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"columns": [
{
"key": "company",
"label": "Company",
"sortable": true
},
{
"key": "revenue",
"label": "FY24 revenue ($B)",
"format": ",.0f",
"sortable": true,
"align": "right",
"bar": {
"color": "#0e7490"
}
}
],
"chrome": {
"title": "Amazon still tops big tech by revenue",
"subtitle": "Full-year 2024 revenue, with an inline bar scaled to the largest value"
}
};
</script>
<DataTable {spec} />
import { createTable } from "@opendata-ai/openchart-vanilla";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: TableSpec = {
"type": "table",
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"columns": [
{
"key": "company",
"label": "Company",
"sortable": true
},
{
"key": "revenue",
"label": "FY24 revenue ($B)",
"format": ",.0f",
"sortable": true,
"align": "right",
"bar": {
"color": "#0e7490"
}
}
],
"chrome": {
"title": "Amazon still tops big tech by revenue",
"subtitle": "Full-year 2024 revenue, with an inline bar scaled to the largest value"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createTable(container, spec);
Sparklines
A sparkline column draws an array stored in the row as a mini chart. type is "line", "column" or "bar". valuesField names a different field for the values. domain: "row" scales each row to its own extent, which keeps the cheap tickers from flattening when prices differ widely.
Line and column sparklines in one table. This chart is drawn in the browser.
{
"type": "table",
"data": [
{
"ticker": "AAPL",
"name": "Apple",
"sector": "Technology",
"price": 189.84,
"ytdChange": 48.2,
"trend": [
142,
155,
165,
170,
178,
185,
190,
189
],
"flows": [
3,
6,
-2,
8
]
},
{
"ticker": "MSFT",
"name": "Microsoft",
"sector": "Technology",
"price": 378.91,
"ytdChange": 57.8,
"trend": [
240,
275,
295,
310,
330,
345,
365,
379
],
"flows": [
12,
9,
5,
14
]
},
{
"ticker": "GOOGL",
"name": "Alphabet",
"sector": "Communication",
"price": 141.8,
"ytdChange": 58.3,
"trend": [
89,
95,
108,
120,
125,
130,
138,
142
],
"flows": [
7,
4,
9,
11
]
},
{
"ticker": "AMZN",
"name": "Amazon",
"sector": "Consumer",
"price": 153.42,
"ytdChange": 82.6,
"trend": [
84,
98,
105,
112,
128,
135,
145,
153
],
"flows": [
10,
8,
13,
20
]
},
{
"ticker": "NVDA",
"name": "NVIDIA",
"sector": "Technology",
"price": 495.22,
"ytdChange": 239,
"trend": [
146,
230,
280,
320,
390,
420,
470,
495
],
"flows": [
40,
55,
62,
88
]
},
{
"ticker": "META",
"name": "Meta",
"sector": "Communication",
"price": 353.96,
"ytdChange": 194.1,
"trend": [
120,
165,
210,
240,
290,
310,
340,
354
],
"flows": [
18,
25,
34,
40
]
},
{
"ticker": "TSLA",
"name": "Tesla",
"sector": "Consumer",
"price": 248.48,
"ytdChange": 101.7,
"trend": [
123,
180,
195,
175,
260,
240,
255,
248
],
"flows": [
15,
-6,
22,
-3
]
},
{
"ticker": "JPM",
"name": "JPMorgan",
"sector": "Financials",
"price": 170.1,
"ytdChange": 26.8,
"trend": [
134,
138,
140,
145,
150,
155,
163,
170
],
"flows": [
5,
4,
6,
7
]
}
],
"columns": [
{
"key": "ticker",
"label": "Ticker",
"sortable": true
},
{
"key": "price",
"label": "Price",
"format": "$,.2f",
"sortable": true,
"align": "right"
},
{
"key": "trend",
"label": "8-week trend",
"sparkline": {
"type": "line",
"domain": "row"
}
},
{
"key": "flows",
"label": "Fund flows",
"sparkline": {
"type": "column"
}
}
],
"chrome": {
"title": "Two ways to draw a series in a cell",
"subtitle": "The same sparkline column config with type line and column"
}
}import { DataTable } from "@opendata-ai/openchart-react";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker",
"sortable": true
},
{
"key": "price",
"label": "Price",
"format": "$,.2f",
"sortable": true,
"align": "right"
},
{
"key": "trend",
"label": "8-week trend",
"sparkline": {
"type": "line",
"domain": "row"
}
},
{
"key": "flows",
"label": "Fund flows",
"sparkline": {
"type": "column"
}
}
],
"chrome": {
"title": "Two ways to draw a series in a cell",
"subtitle": "The same sparkline column config with type line and column"
}
};
export function Example() {
return <DataTable spec={spec} />;
}
<script setup lang="ts">
import { DataTable } from "@opendata-ai/openchart-vue";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker",
"sortable": true
},
{
"key": "price",
"label": "Price",
"format": "$,.2f",
"sortable": true,
"align": "right"
},
{
"key": "trend",
"label": "8-week trend",
"sparkline": {
"type": "line",
"domain": "row"
}
},
{
"key": "flows",
"label": "Fund flows",
"sparkline": {
"type": "column"
}
}
],
"chrome": {
"title": "Two ways to draw a series in a cell",
"subtitle": "The same sparkline column config with type line and column"
}
};
</script>
<template>
<DataTable :spec="spec" />
</template>
<script lang="ts">
import { DataTable } from "@opendata-ai/openchart-svelte";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker",
"sortable": true
},
{
"key": "price",
"label": "Price",
"format": "$,.2f",
"sortable": true,
"align": "right"
},
{
"key": "trend",
"label": "8-week trend",
"sparkline": {
"type": "line",
"domain": "row"
}
},
{
"key": "flows",
"label": "Fund flows",
"sparkline": {
"type": "column"
}
}
],
"chrome": {
"title": "Two ways to draw a series in a cell",
"subtitle": "The same sparkline column config with type line and column"
}
};
</script>
<DataTable {spec} />
import { createTable } from "@opendata-ai/openchart-vanilla";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker",
"sortable": true
},
{
"key": "price",
"label": "Price",
"format": "$,.2f",
"sortable": true,
"align": "right"
},
{
"key": "trend",
"label": "8-week trend",
"sparkline": {
"type": "line",
"domain": "row"
}
},
{
"key": "flows",
"label": "Fund flows",
"sparkline": {
"type": "column"
}
}
],
"chrome": {
"title": "Two ways to draw a series in a cell",
"subtitle": "The same sparkline column config with type line and column"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createTable(container, spec);
Delta chips
delta: true renders a change value as a signed chip. The arrow carries the direction, so a sign in the formatted value is dropped. Positive is green and negative is red. delta: { invert: true } flips the colors for metrics where down is good, such as churn or cost.
Year-to-date change as delta chips. This chart is drawn in the browser.
{
"type": "table",
"data": [
{
"ticker": "AAPL",
"name": "Apple",
"sector": "Technology",
"price": 189.84,
"ytdChange": 48.2,
"trend": [
142,
155,
165,
170,
178,
185,
190,
189
],
"flows": [
3,
6,
-2,
8
]
},
{
"ticker": "MSFT",
"name": "Microsoft",
"sector": "Technology",
"price": 378.91,
"ytdChange": 57.8,
"trend": [
240,
275,
295,
310,
330,
345,
365,
379
],
"flows": [
12,
9,
5,
14
]
},
{
"ticker": "GOOGL",
"name": "Alphabet",
"sector": "Communication",
"price": 141.8,
"ytdChange": 58.3,
"trend": [
89,
95,
108,
120,
125,
130,
138,
142
],
"flows": [
7,
4,
9,
11
]
},
{
"ticker": "AMZN",
"name": "Amazon",
"sector": "Consumer",
"price": 153.42,
"ytdChange": 82.6,
"trend": [
84,
98,
105,
112,
128,
135,
145,
153
],
"flows": [
10,
8,
13,
20
]
},
{
"ticker": "NVDA",
"name": "NVIDIA",
"sector": "Technology",
"price": 495.22,
"ytdChange": 239,
"trend": [
146,
230,
280,
320,
390,
420,
470,
495
],
"flows": [
40,
55,
62,
88
]
},
{
"ticker": "META",
"name": "Meta",
"sector": "Communication",
"price": 353.96,
"ytdChange": 194.1,
"trend": [
120,
165,
210,
240,
290,
310,
340,
354
],
"flows": [
18,
25,
34,
40
]
},
{
"ticker": "TSLA",
"name": "Tesla",
"sector": "Consumer",
"price": 248.48,
"ytdChange": 101.7,
"trend": [
123,
180,
195,
175,
260,
240,
255,
248
],
"flows": [
15,
-6,
22,
-3
]
},
{
"ticker": "JPM",
"name": "JPMorgan",
"sector": "Financials",
"price": 170.1,
"ytdChange": 26.8,
"trend": [
134,
138,
140,
145,
150,
155,
163,
170
],
"flows": [
5,
4,
6,
7
]
}
],
"columns": [
{
"key": "ticker",
"label": "Ticker"
},
{
"key": "name",
"label": "Company"
},
{
"key": "price",
"label": "Price",
"format": "$,.2f"
},
{
"key": "ytdChange",
"label": "YTD",
"format": ".1f",
"delta": true
},
{
"key": "trend",
"label": "8-week trend",
"sparkline": {
"type": "line",
"domain": "row"
}
}
],
"striped": true,
"chrome": {
"title": "All eight stocks are up for the year",
"subtitle": "A delta column renders as a signed chip: direction in the arrow, valence in the color"
}
}import { DataTable } from "@opendata-ai/openchart-react";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker"
},
{
"key": "name",
"label": "Company"
},
{
"key": "price",
"label": "Price",
"format": "$,.2f"
},
{
"key": "ytdChange",
"label": "YTD",
"format": ".1f",
"delta": true
},
{
"key": "trend",
"label": "8-week trend",
"sparkline": {
"type": "line",
"domain": "row"
}
}
],
"striped": true,
"chrome": {
"title": "All eight stocks are up for the year",
"subtitle": "A delta column renders as a signed chip: direction in the arrow, valence in the color"
}
};
export function Example() {
return <DataTable spec={spec} />;
}
<script setup lang="ts">
import { DataTable } from "@opendata-ai/openchart-vue";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker"
},
{
"key": "name",
"label": "Company"
},
{
"key": "price",
"label": "Price",
"format": "$,.2f"
},
{
"key": "ytdChange",
"label": "YTD",
"format": ".1f",
"delta": true
},
{
"key": "trend",
"label": "8-week trend",
"sparkline": {
"type": "line",
"domain": "row"
}
}
],
"striped": true,
"chrome": {
"title": "All eight stocks are up for the year",
"subtitle": "A delta column renders as a signed chip: direction in the arrow, valence in the color"
}
};
</script>
<template>
<DataTable :spec="spec" />
</template>
<script lang="ts">
import { DataTable } from "@opendata-ai/openchart-svelte";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker"
},
{
"key": "name",
"label": "Company"
},
{
"key": "price",
"label": "Price",
"format": "$,.2f"
},
{
"key": "ytdChange",
"label": "YTD",
"format": ".1f",
"delta": true
},
{
"key": "trend",
"label": "8-week trend",
"sparkline": {
"type": "line",
"domain": "row"
}
}
],
"striped": true,
"chrome": {
"title": "All eight stocks are up for the year",
"subtitle": "A delta column renders as a signed chip: direction in the arrow, valence in the color"
}
};
</script>
<DataTable {spec} />
import { createTable } from "@opendata-ai/openchart-vanilla";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker"
},
{
"key": "name",
"label": "Company"
},
{
"key": "price",
"label": "Price",
"format": "$,.2f"
},
{
"key": "ytdChange",
"label": "YTD",
"format": ".1f",
"delta": true
},
{
"key": "trend",
"label": "8-week trend",
"sparkline": {
"type": "line",
"domain": "row"
}
}
],
"striped": true,
"chrome": {
"title": "All eight stocks are up for the year",
"subtitle": "A delta column renders as a signed chip: direction in the arrow, valence in the color"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createTable(container, spec);
Images
image renders the column value as an image source, with width, height and rounded for the size and a circular crop. These logos are inline SVG data URIs, so nothing is fetched.
Logos in an image column. This chart is drawn in the browser.
{
"type": "table",
"data": [
{
"company": "Amazon",
"logo": "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%220%200%2040%2040%22%3E%3Crect%20width%3D%2240%22%20height%3D%2240%22%20rx%3D%229%22%20fill%3D%22%23ff9900%22%2F%3E%3Ctext%20x%3D%2220%22%20y%3D%2227%22%20font-family%3D%22Inter%2C%20system-ui%2C%20sans-serif%22%20font-size%3D%2222%22%20font-weight%3D%22700%22%20fill%3D%22%23ffffff%22%20text-anchor%3D%22middle%22%3EA%3C%2Ftext%3E%3C%2Fsvg%3E",
"revenue": 638,
"quarterly": [
143,
148,
159,
188
]
},
{
"company": "Apple",
"logo": "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%220%200%2040%2040%22%3E%3Crect%20width%3D%2240%22%20height%3D%2240%22%20rx%3D%229%22%20fill%3D%22%23111827%22%2F%3E%3Ctext%20x%3D%2220%22%20y%3D%2227%22%20font-family%3D%22Inter%2C%20system-ui%2C%20sans-serif%22%20font-size%3D%2222%22%20font-weight%3D%22700%22%20fill%3D%22%23ffffff%22%20text-anchor%3D%22middle%22%3EA%3C%2Ftext%3E%3C%2Fsvg%3E",
"revenue": 391,
"quarterly": [
90,
86,
95,
120
]
},
{
"company": "Alphabet",
"logo": "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%220%200%2040%2040%22%3E%3Crect%20width%3D%2240%22%20height%3D%2240%22%20rx%3D%229%22%20fill%3D%22%234285f4%22%2F%3E%3Ctext%20x%3D%2220%22%20y%3D%2227%22%20font-family%3D%22Inter%2C%20system-ui%2C%20sans-serif%22%20font-size%3D%2222%22%20font-weight%3D%22700%22%20fill%3D%22%23ffffff%22%20text-anchor%3D%22middle%22%3EG%3C%2Ftext%3E%3C%2Fsvg%3E",
"revenue": 350,
"quarterly": [
80,
85,
88,
97
]
},
{
"company": "Microsoft",
"logo": "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%220%200%2040%2040%22%3E%3Crect%20width%3D%2240%22%20height%3D%2240%22%20rx%3D%229%22%20fill%3D%22%230078d4%22%2F%3E%3Ctext%20x%3D%2220%22%20y%3D%2227%22%20font-family%3D%22Inter%2C%20system-ui%2C%20sans-serif%22%20font-size%3D%2222%22%20font-weight%3D%22700%22%20fill%3D%22%23ffffff%22%20text-anchor%3D%22middle%22%3EM%3C%2Ftext%3E%3C%2Fsvg%3E",
"revenue": 245,
"quarterly": [
57,
62,
62,
64
]
},
{
"company": "Meta",
"logo": "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%220%200%2040%2040%22%3E%3Crect%20width%3D%2240%22%20height%3D%2240%22%20rx%3D%229%22%20fill%3D%22%230866ff%22%2F%3E%3Ctext%20x%3D%2220%22%20y%3D%2227%22%20font-family%3D%22Inter%2C%20system-ui%2C%20sans-serif%22%20font-size%3D%2222%22%20font-weight%3D%22700%22%20fill%3D%22%23ffffff%22%20text-anchor%3D%22middle%22%3EM%3C%2Ftext%3E%3C%2Fsvg%3E",
"revenue": 164,
"quarterly": [
36,
39,
41,
48
]
}
],
"columns": [
{
"key": "logo",
"label": "",
"image": {
"width": 28,
"height": 28,
"rounded": true
}
},
{
"key": "company",
"label": "Company",
"sortable": true
},
{
"key": "revenue",
"label": "FY24 revenue ($B)",
"format": ",.0f",
"sortable": true,
"align": "right",
"bar": {}
},
{
"key": "quarterly",
"label": "By quarter",
"sparkline": {
"type": "column"
}
}
],
"chrome": {
"title": "Any URL becomes a logo cell",
"subtitle": "Image cells render the column value as an img; here, inline SVG monograms"
}
}import { DataTable } from "@opendata-ai/openchart-react";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: TableSpec = {
"type": "table",
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"columns": [
{
"key": "logo",
"label": "",
"image": {
"width": 28,
"height": 28,
"rounded": true
}
},
{
"key": "company",
"label": "Company",
"sortable": true
},
{
"key": "revenue",
"label": "FY24 revenue ($B)",
"format": ",.0f",
"sortable": true,
"align": "right",
"bar": {}
},
{
"key": "quarterly",
"label": "By quarter",
"sparkline": {
"type": "column"
}
}
],
"chrome": {
"title": "Any URL becomes a logo cell",
"subtitle": "Image cells render the column value as an img; here, inline SVG monograms"
}
};
export function Example() {
return <DataTable spec={spec} />;
}
<script setup lang="ts">
import { DataTable } from "@opendata-ai/openchart-vue";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: TableSpec = {
"type": "table",
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"columns": [
{
"key": "logo",
"label": "",
"image": {
"width": 28,
"height": 28,
"rounded": true
}
},
{
"key": "company",
"label": "Company",
"sortable": true
},
{
"key": "revenue",
"label": "FY24 revenue ($B)",
"format": ",.0f",
"sortable": true,
"align": "right",
"bar": {}
},
{
"key": "quarterly",
"label": "By quarter",
"sparkline": {
"type": "column"
}
}
],
"chrome": {
"title": "Any URL becomes a logo cell",
"subtitle": "Image cells render the column value as an img; here, inline SVG monograms"
}
};
</script>
<template>
<DataTable :spec="spec" />
</template>
<script lang="ts">
import { DataTable } from "@opendata-ai/openchart-svelte";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: TableSpec = {
"type": "table",
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"columns": [
{
"key": "logo",
"label": "",
"image": {
"width": 28,
"height": 28,
"rounded": true
}
},
{
"key": "company",
"label": "Company",
"sortable": true
},
{
"key": "revenue",
"label": "FY24 revenue ($B)",
"format": ",.0f",
"sortable": true,
"align": "right",
"bar": {}
},
{
"key": "quarterly",
"label": "By quarter",
"sparkline": {
"type": "column"
}
}
],
"chrome": {
"title": "Any URL becomes a logo cell",
"subtitle": "Image cells render the column value as an img; here, inline SVG monograms"
}
};
</script>
<DataTable {spec} />
import { createTable } from "@opendata-ai/openchart-vanilla";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: TableSpec = {
"type": "table",
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"columns": [
{
"key": "logo",
"label": "",
"image": {
"width": 28,
"height": 28,
"rounded": true
}
},
{
"key": "company",
"label": "Company",
"sortable": true
},
{
"key": "revenue",
"label": "FY24 revenue ($B)",
"format": ",.0f",
"sortable": true,
"align": "right",
"bar": {}
},
{
"key": "quarterly",
"label": "By quarter",
"sparkline": {
"type": "column"
}
}
],
"chrome": {
"title": "Any URL becomes a logo cell",
"subtitle": "Image cells render the column value as an img; here, inline SVG monograms"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createTable(container, spec);
Category chips
categoryColors maps each value of a categorical column to a color. Each value shows as a chip with a dot in that color, so the column works as its own legend.
Sectors as category color chips. This chart is drawn in the browser.
{
"type": "table",
"data": [
{
"ticker": "AAPL",
"name": "Apple",
"sector": "Technology",
"price": 189.84,
"ytdChange": 48.2,
"trend": [
142,
155,
165,
170,
178,
185,
190,
189
],
"flows": [
3,
6,
-2,
8
]
},
{
"ticker": "MSFT",
"name": "Microsoft",
"sector": "Technology",
"price": 378.91,
"ytdChange": 57.8,
"trend": [
240,
275,
295,
310,
330,
345,
365,
379
],
"flows": [
12,
9,
5,
14
]
},
{
"ticker": "GOOGL",
"name": "Alphabet",
"sector": "Communication",
"price": 141.8,
"ytdChange": 58.3,
"trend": [
89,
95,
108,
120,
125,
130,
138,
142
],
"flows": [
7,
4,
9,
11
]
},
{
"ticker": "AMZN",
"name": "Amazon",
"sector": "Consumer",
"price": 153.42,
"ytdChange": 82.6,
"trend": [
84,
98,
105,
112,
128,
135,
145,
153
],
"flows": [
10,
8,
13,
20
]
},
{
"ticker": "NVDA",
"name": "NVIDIA",
"sector": "Technology",
"price": 495.22,
"ytdChange": 239,
"trend": [
146,
230,
280,
320,
390,
420,
470,
495
],
"flows": [
40,
55,
62,
88
]
},
{
"ticker": "META",
"name": "Meta",
"sector": "Communication",
"price": 353.96,
"ytdChange": 194.1,
"trend": [
120,
165,
210,
240,
290,
310,
340,
354
],
"flows": [
18,
25,
34,
40
]
},
{
"ticker": "TSLA",
"name": "Tesla",
"sector": "Consumer",
"price": 248.48,
"ytdChange": 101.7,
"trend": [
123,
180,
195,
175,
260,
240,
255,
248
],
"flows": [
15,
-6,
22,
-3
]
},
{
"ticker": "JPM",
"name": "JPMorgan",
"sector": "Financials",
"price": 170.1,
"ytdChange": 26.8,
"trend": [
134,
138,
140,
145,
150,
155,
163,
170
],
"flows": [
5,
4,
6,
7
]
}
],
"columns": [
{
"key": "ticker",
"label": "Ticker",
"sortable": true
},
{
"key": "name",
"label": "Company",
"sortable": true
},
{
"key": "sector",
"label": "Sector",
"sortable": true,
"categoryColors": {
"Technology": "#0e7490",
"Communication": "#7c3aed",
"Consumer": "#c2410c",
"Financials": "#15803d",
"Healthcare": "#be123c"
}
},
{
"key": "ytdChange",
"label": "YTD %",
"format": "+.1f",
"sortable": true,
"align": "right"
}
],
"chrome": {
"title": "Category colors turn a column into a legend",
"subtitle": "Each sector value maps to a fixed color chip"
}
}import { DataTable } from "@opendata-ai/openchart-react";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker",
"sortable": true
},
{
"key": "name",
"label": "Company",
"sortable": true
},
{
"key": "sector",
"label": "Sector",
"sortable": true,
"categoryColors": {
"Technology": "#0e7490",
"Communication": "#7c3aed",
"Consumer": "#c2410c",
"Financials": "#15803d",
"Healthcare": "#be123c"
}
},
{
"key": "ytdChange",
"label": "YTD %",
"format": "+.1f",
"sortable": true,
"align": "right"
}
],
"chrome": {
"title": "Category colors turn a column into a legend",
"subtitle": "Each sector value maps to a fixed color chip"
}
};
export function Example() {
return <DataTable spec={spec} />;
}
<script setup lang="ts">
import { DataTable } from "@opendata-ai/openchart-vue";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker",
"sortable": true
},
{
"key": "name",
"label": "Company",
"sortable": true
},
{
"key": "sector",
"label": "Sector",
"sortable": true,
"categoryColors": {
"Technology": "#0e7490",
"Communication": "#7c3aed",
"Consumer": "#c2410c",
"Financials": "#15803d",
"Healthcare": "#be123c"
}
},
{
"key": "ytdChange",
"label": "YTD %",
"format": "+.1f",
"sortable": true,
"align": "right"
}
],
"chrome": {
"title": "Category colors turn a column into a legend",
"subtitle": "Each sector value maps to a fixed color chip"
}
};
</script>
<template>
<DataTable :spec="spec" />
</template>
<script lang="ts">
import { DataTable } from "@opendata-ai/openchart-svelte";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker",
"sortable": true
},
{
"key": "name",
"label": "Company",
"sortable": true
},
{
"key": "sector",
"label": "Sector",
"sortable": true,
"categoryColors": {
"Technology": "#0e7490",
"Communication": "#7c3aed",
"Consumer": "#c2410c",
"Financials": "#15803d",
"Healthcare": "#be123c"
}
},
{
"key": "ytdChange",
"label": "YTD %",
"format": "+.1f",
"sortable": true,
"align": "right"
}
],
"chrome": {
"title": "Category colors turn a column into a legend",
"subtitle": "Each sector value maps to a fixed color chip"
}
};
</script>
<DataTable {spec} />
import { createTable } from "@opendata-ai/openchart-vanilla";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 8 rows, as in the Spec tab; Copy includes them */];
const spec: TableSpec = {
data,
"type": "table",
"columns": [
{
"key": "ticker",
"label": "Ticker",
"sortable": true
},
{
"key": "name",
"label": "Company",
"sortable": true
},
{
"key": "sector",
"label": "Sector",
"sortable": true,
"categoryColors": {
"Technology": "#0e7490",
"Communication": "#7c3aed",
"Consumer": "#c2410c",
"Financials": "#15803d",
"Healthcare": "#be123c"
}
},
{
"key": "ytdChange",
"label": "YTD %",
"format": "+.1f",
"sortable": true,
"align": "right"
}
],
"chrome": {
"title": "Category colors turn a column into a legend",
"subtitle": "Each sector value maps to a fixed color chip"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createTable(container, spec);
Fields that matter
| Field | What it does |
|---|---|
heatmap |
{ palette, domain, colorByField } colors the cell background by value. |
bar |
{ maxValue, color } draws a proportional bar in the cell. |
sparkline |
{ type, valuesField, color, domain } draws an array value as a mini chart. |
delta |
true shows a signed chip, { invert: true } flips the colors. |
image |
{ width, height, rounded } shows the value as an image. |
categoryColors |
Maps category values to chip colors. |
striped |
A top-level field. true adds zebra rows. |
Related
- Data table for sorting, search, paging and density.
- Sparkline for the same mini chart outside a table.
- Heatmap for a color grid drawn as a chart.
- TableSpec reference lists every table and column field.