Function: linkIds()
linkIds<
R>(data,id?):RenderFunction
Defined in: packages/sdvplot/src/plot/link.ts:56
Plot render transform that stamps data-sdv-id on every element a one-element-per-row mark draws (dot, cell,
rect / bar, text, tick, image), so sdvplot/interact can highlight it by class toggle, never a redraw. id
defaults to the row index, which is also a linked table's id when its spec has no rowKey. Plot hands render
the source row indexes, so a row Plot drops (a null coordinate) leaves the others aligned. A mark that draws one
element per series (line, area) is left unstamped, with one warning.
Type Parameters
R
R
Parameters
data
Data<R>
id?
Channel<R>
Returns
RenderFunction
Example
import * as Plot from "@observablehq/plot";
import { linkIds } from "@sportsdataverse/sdvplot/plot";
const rows = [
{ team: "KC", wins: 15, net_epa: 0.063 },
{ team: "BUF", wins: 13, net_epa: 0.19 },
];
const svg = Plot.plot({ marks: [Plot.dot(rows, { x: "wins", y: "net_epa", render: linkIds(rows, "team") })] });
Array.from(svg.querySelectorAll("circle")).map((c) => c.getAttribute("data-sdv-id"));