Skip to content
OpenChart

Row inspection

Read across one row at a time, with the rowHover option on horizontal bar charts and search, sort, totals and row clicks on tables.

Row inspection is reading one record across all of its values: the bar and its label and number, or a table row and its cells. Charts support it with an opt-in mount option, and tables with built-in search, sort and a total row. Use it when readers compare a few rows closely.

When the reader only needs the overall shape, a plain bar chart is enough. For lists that need several values per row, use a data table.

Row inspection on a bar chart

rowHover is a mount option, not a spec field, so the figure below shows the spec without it. Pass { rowHover: true } to createChart, or the rowHover prop on a chart wrapper. The spec is a simple horizontal bar chart with labels.placement: "column", which prints the values in an aligned column.

020406080NorthSouthEastWest82614933Compare a rowValues by region020406080NorthSouthEastWest82614933Compare a rowValues by region
Row inspection is a mount option, so this figure shows the spec without it. Source: Illustrative data.
{
  "mark": "bar",
  "data": [
    {
      "name": "North",
      "value": 82
    },
    {
      "name": "South",
      "value": 61
    },
    {
      "name": "East",
      "value": 49
    },
    {
      "name": "West",
      "value": 33
    }
  ],
  "encoding": {
    "y": {
      "field": "name",
      "type": "nominal",
      "sort": null
    },
    "x": {
      "field": "value",
      "type": "quantitative"
    }
  },
  "labels": {
    "placement": "column"
  },
  "chrome": {
    "title": "Compare a row",
    "subtitle": "Values by region"
  }
}
import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const spec: ChartSpec = {
  "mark": "bar",
  "data": [/* 4 rows, as in the Spec tab; Copy includes them */],
  "encoding": {
    "y": {
      "field": "name",
      "type": "nominal",
      "sort": null
    },
    "x": {
      "field": "value",
      "type": "quantitative"
    }
  },
  "labels": {
    "placement": "column"
  },
  "chrome": {
    "title": "Compare a row",
    "subtitle": "Values by region"
  }
};

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 spec: ChartSpec = {
  "mark": "bar",
  "data": [/* 4 rows, as in the Spec tab; Copy includes them */],
  "encoding": {
    "y": {
      "field": "name",
      "type": "nominal",
      "sort": null
    },
    "x": {
      "field": "value",
      "type": "quantitative"
    }
  },
  "labels": {
    "placement": "column"
  },
  "chrome": {
    "title": "Compare a row",
    "subtitle": "Values by region"
  }
};
</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 spec: ChartSpec = {
  "mark": "bar",
  "data": [/* 4 rows, as in the Spec tab; Copy includes them */],
  "encoding": {
    "y": {
      "field": "name",
      "type": "nominal",
      "sort": null
    },
    "x": {
      "field": "value",
      "type": "quantitative"
    }
  },
  "labels": {
    "placement": "column"
  },
  "chrome": {
    "title": "Compare a row",
    "subtitle": "Values by region"
  }
};
</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 spec: ChartSpec = {
  "mark": "bar",
  "data": [/* 4 rows, as in the Spec tab; Copy includes them */],
  "encoding": {
    "y": {
      "field": "name",
      "type": "nominal",
      "sort": null
    },
    "x": {
      "field": "value",
      "type": "quantitative"
    }
  },
  "labels": {
    "placement": "column"
  },
  "chrome": {
    "title": "Compare a row",
    "subtitle": "Values by region"
  }
};

const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
createChart(container, spec, { rowHover: true });
<Chart spec={spec} rowHover />

Where row hover applies

Pointer inspection spans the category, the plot and the value column. Keyboard navigation highlights the same row. It applies to simple horizontal bars. Grouped, stacked, layered and faceted charts keep their existing behavior, and the option yields to edit mode. Without the option, no hover styling is added. The highlight is transient and does not appear in settled chart exports.

On a table, search: true adds a filter box above the rows. pagination splits what remains into pages, so a long list still opens on a short first page.

Finding a row with search. This chart is drawn in the browser.

Finding a row with search. Source: Illustrative data.
{
  "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
      ]
    },
    {
      "ticker": "V",
      "name": "Visa",
      "sector": "Financials",
      "price": 260.38,
      "ytdChange": 25.2,
      "trend": [
        208,
        218,
        225,
        230,
        240,
        248,
        255,
        260
      ],
      "flows": [
        4,
        5,
        5,
        6
      ]
    },
    {
      "ticker": "JNJ",
      "name": "Johnson & Johnson",
      "sector": "Healthcare",
      "price": 156.74,
      "ytdChange": -11.3,
      "trend": [
        177,
        170,
        162,
        155,
        160,
        158,
        155,
        157
      ],
      "flows": [
        -3,
        -5,
        2,
        -1
      ]
    },
    {
      "ticker": "WMT",
      "name": "Walmart",
      "sector": "Consumer",
      "price": 162.5,
      "ytdChange": 14.8,
      "trend": [
        141,
        145,
        148,
        150,
        155,
        158,
        160,
        163
      ],
      "flows": [
        2,
        3,
        3,
        4
      ]
    },
    {
      "ticker": "PG",
      "name": "Procter & Gamble",
      "sector": "Consumer",
      "price": 154.3,
      "ytdChange": 2.1,
      "trend": [
        151,
        150,
        148,
        152,
        153,
        150,
        152,
        154
      ],
      "flows": [
        1,
        -2,
        2,
        1
      ]
    }
  ],
  "columns": [
    {
      "key": "ticker",
      "label": "Ticker",
      "sortable": true
    },
    {
      "key": "name",
      "label": "Company",
      "sortable": true
    },
    {
      "key": "sector",
      "label": "Sector",
      "sortable": true
    },
    {
      "key": "price",
      "label": "Price",
      "format": "$,.2f",
      "sortable": true,
      "align": "right"
    }
  ],
  "search": true,
  "pagination": {
    "pageSize": 6
  },
  "chrome": {
    "title": "Type to filter the rows",
    "subtitle": "Search matches any column; the pager covers the rest"
  }
}
import { DataTable } from "@opendata-ai/openchart-react";
import type { TableSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 12 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
    },
    {
      "key": "price",
      "label": "Price",
      "format": "$,.2f",
      "sortable": true,
      "align": "right"
    }
  ],
  "search": true,
  "pagination": {
    "pageSize": 6
  },
  "chrome": {
    "title": "Type to filter the rows",
    "subtitle": "Search matches any column; the pager covers the rest"
  }
};

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 = [/* 12 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
    },
    {
      "key": "price",
      "label": "Price",
      "format": "$,.2f",
      "sortable": true,
      "align": "right"
    }
  ],
  "search": true,
  "pagination": {
    "pageSize": 6
  },
  "chrome": {
    "title": "Type to filter the rows",
    "subtitle": "Search matches any column; the pager covers the rest"
  }
};
</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 = [/* 12 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
    },
    {
      "key": "price",
      "label": "Price",
      "format": "$,.2f",
      "sortable": true,
      "align": "right"
    }
  ],
  "search": true,
  "pagination": {
    "pageSize": 6
  },
  "chrome": {
    "title": "Type to filter the rows",
    "subtitle": "Search matches any column; the pager covers the rest"
  }
};
</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 = [/* 12 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
    },
    {
      "key": "price",
      "label": "Price",
      "format": "$,.2f",
      "sortable": true,
      "align": "right"
    }
  ],
  "search": true,
  "pagination": {
    "pageSize": 6
  },
  "chrome": {
    "title": "Type to filter the rows",
    "subtitle": "Search matches any column; the pager covers the rest"
  }
};

const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createTable(container, spec);

Sorting to compare extremes

Rows with sortable columns reorder when the reader clicks a header. sort sets the starting order, here the lowest life expectancy first. A heatmap column keeps the size of the gap visible while the order changes.

Sorting to compare extremes. This chart is drawn in the browser.

Sorting to compare extremes. Source: World Bank WDI, OWID (PPP GDP), WHO Global Health Observatory.
{
  "type": "table",
  "data": [
    {
      "code": "IN",
      "country": "India",
      "population": 1438069596,
      "gdpPerCapita": 9818,
      "lifeExpectancy": 68.3
    },
    {
      "code": "CN",
      "country": "China",
      "population": 1410710000,
      "gdpPerCapita": 23846,
      "lifeExpectancy": 76.1
    },
    {
      "code": "US",
      "country": "United States",
      "population": 336806231,
      "gdpPerCapita": 75489,
      "lifeExpectancy": 79.2
    },
    {
      "code": "ID",
      "country": "Indonesia",
      "population": 281190067,
      "gdpPerCapita": 14470,
      "lifeExpectancy": 69
    },
    {
      "code": "BR",
      "country": "Brazil",
      "population": 211140729,
      "gdpPerCapita": 19652,
      "lifeExpectancy": 75.3
    },
    {
      "code": "MX",
      "country": "Mexico",
      "population": 129739759,
      "gdpPerCapita": 22040,
      "lifeExpectancy": 76.9
    },
    {
      "code": "JP",
      "country": "Japan",
      "population": 124516650,
      "gdpPerCapita": 46107,
      "lifeExpectancy": 83.6
    },
    {
      "code": "DE",
      "country": "Germany",
      "population": 83287273,
      "gdpPerCapita": 63676,
      "lifeExpectancy": 80.8
    }
  ],
  "columns": [
    {
      "key": "country",
      "label": "Country",
      "sortable": true
    },
    {
      "key": "gdpPerCapita",
      "label": "GDP/capita (PPP)",
      "format": "$,.0f",
      "sortable": true,
      "align": "right",
      "heatmap": {
        "palette": "green"
      }
    },
    {
      "key": "lifeExpectancy",
      "label": "Life exp.",
      "format": ".1f",
      "sortable": true,
      "align": "right"
    }
  ],
  "sort": {
    "column": "lifeExpectancy",
    "direction": "asc"
  },
  "chrome": {
    "title": "Lowest life expectancy first",
    "subtitle": "Click a header to reorder; the heatmap keeps the income gap visible"
  }
}
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": "country",
      "label": "Country",
      "sortable": true
    },
    {
      "key": "gdpPerCapita",
      "label": "GDP/capita (PPP)",
      "format": "$,.0f",
      "sortable": true,
      "align": "right",
      "heatmap": {
        "palette": "green"
      }
    },
    {
      "key": "lifeExpectancy",
      "label": "Life exp.",
      "format": ".1f",
      "sortable": true,
      "align": "right"
    }
  ],
  "sort": {
    "column": "lifeExpectancy",
    "direction": "asc"
  },
  "chrome": {
    "title": "Lowest life expectancy first",
    "subtitle": "Click a header to reorder; the heatmap keeps the income gap visible"
  }
};

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": "country",
      "label": "Country",
      "sortable": true
    },
    {
      "key": "gdpPerCapita",
      "label": "GDP/capita (PPP)",
      "format": "$,.0f",
      "sortable": true,
      "align": "right",
      "heatmap": {
        "palette": "green"
      }
    },
    {
      "key": "lifeExpectancy",
      "label": "Life exp.",
      "format": ".1f",
      "sortable": true,
      "align": "right"
    }
  ],
  "sort": {
    "column": "lifeExpectancy",
    "direction": "asc"
  },
  "chrome": {
    "title": "Lowest life expectancy first",
    "subtitle": "Click a header to reorder; the heatmap keeps the income gap visible"
  }
};
</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": "country",
      "label": "Country",
      "sortable": true
    },
    {
      "key": "gdpPerCapita",
      "label": "GDP/capita (PPP)",
      "format": "$,.0f",
      "sortable": true,
      "align": "right",
      "heatmap": {
        "palette": "green"
      }
    },
    {
      "key": "lifeExpectancy",
      "label": "Life exp.",
      "format": ".1f",
      "sortable": true,
      "align": "right"
    }
  ],
  "sort": {
    "column": "lifeExpectancy",
    "direction": "asc"
  },
  "chrome": {
    "title": "Lowest life expectancy first",
    "subtitle": "Click a header to reorder; the heatmap keeps the income gap visible"
  }
};
</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": "country",
      "label": "Country",
      "sortable": true
    },
    {
      "key": "gdpPerCapita",
      "label": "GDP/capita (PPP)",
      "format": "$,.0f",
      "sortable": true,
      "align": "right",
      "heatmap": {
        "palette": "green"
      }
    },
    {
      "key": "lifeExpectancy",
      "label": "Life exp.",
      "format": ".1f",
      "sortable": true,
      "align": "right"
    }
  ],
  "sort": {
    "column": "lifeExpectancy",
    "direction": "asc"
  },
  "chrome": {
    "title": "Lowest life expectancy first",
    "subtitle": "Click a header to reorder; the heatmap keeps the income gap visible"
  }
};

const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createTable(container, spec);

Totals over the filtered rows

totalRow: true adds a sticky total. Type in the search box and the total covers only the rows that match. It follows search and sort, not the current page.

A total that follows the search. This chart is drawn in the browser.

A total that follows the search. Source: Company annual reports (SEC 10-K filings); quarterly split illustrative.
{
  "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,
      "bar": {}
    }
  ],
  "search": true,
  "totalRow": true,
  "density": "condensed",
  "chrome": {
    "title": "Search, then read the sum",
    "subtitle": "The total row covers the rows left after filtering"
  }
}
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,
      "bar": {}
    }
  ],
  "search": true,
  "totalRow": true,
  "density": "condensed",
  "chrome": {
    "title": "Search, then read the sum",
    "subtitle": "The total row covers the rows left after filtering"
  }
};

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,
      "bar": {}
    }
  ],
  "search": true,
  "totalRow": true,
  "density": "condensed",
  "chrome": {
    "title": "Search, then read the sum",
    "subtitle": "The total row covers the rows left after filtering"
  }
};
</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,
      "bar": {}
    }
  ],
  "search": true,
  "totalRow": true,
  "density": "condensed",
  "chrome": {
    "title": "Search, then read the sum",
    "subtitle": "The total row covers the rows left after filtering"
  }
};
</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,
      "bar": {}
    }
  ],
  "search": true,
  "totalRow": true,
  "density": "condensed",
  "chrome": {
    "title": "Search, then read the sum",
    "subtitle": "The total row covers the rows left after filtering"
  }
};

const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createTable(container, spec);

Reacting to a row click

A table calls onRowClick with the clicked row’s data, which is the hook for drill-down views. The same handler list includes onSortChange, onSearchChange and onPageChange for controlled tables.

<DataTable spec={spec} onRowClick={(row) => openDetail(row)} />

Fields that matter

Field What it does
rowHover A mount option on createChart and the chart wrappers. Turns on row inspection for simple horizontal bars.
labels.placement "column" prints values in an aligned column on a bar chart.
search true adds a filter box to a table.
pagination { pageSize } splits table rows into pages.
sort { column, direction } sets the starting order of a table.
totalRow true adds a sticky total over the filtered rows.
onRowClick A table handler that receives the clicked row.