UNPKG

@tanstack/charts

Version:

A chart grammar for TypeScript and JavaScript. Marks consume your data directly, channels describe visual encodings, and the engine compiles them into a renderer-neutral keyed scene. TanStack's compact scales cover common numeric and categorical mappings.

15 lines (14 loc) 557 B
import { compareChartKey, valueKey } from "./scales.js"; function groupRowsByChartKey(rows) { const groups = /* @__PURE__ */ new Map(); for (const row of rows) { const identity = valueKey(row.group); const existing = groups.get(identity); if (existing) existing.rows.push(row); else groups.set(identity, { group: row.group, rows: [row] }); } return [...groups.entries()].sort(([, left], [, right]) => compareChartKey(left.group, right.group)).map(([identity, group]) => ({ identity, ...group })); } export { groupRowsByChartKey };