@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.
19 lines (18 loc) • 447 B
JavaScript
function intern(value) {
return value instanceof Date ? `date:${value.getTime()}` : `${typeof value}:${String(value)}`;
}
function uniqueDomain(values) {
const domain = [];
const index = /* @__PURE__ */ new Map();
for (const value of values) {
const key = intern(value);
if (index.has(key)) continue;
index.set(key, domain.length);
domain.push(value);
}
return { domain, index };
}
export {
intern,
uniqueDomain
};