Parameter values per variant
64-bitThe value each driving parameter ends up with in each variant.
value = parameter to 12 significant digits
Each value is the variant's evaluated parameter, rounded with toPrecision(12) before it is stored in the table. A value that is not finite falls back to the configuration row's own number, or 0.
/** The parameter table: a column for every driving parameter any chosen configuration sets (the part's order), and for each
* variant the value it ends up with. `variants[i].built` is the applied copy (variantPart); without it the row's own values. */
export function variantTable(part, variants) {
const set = new Set();
for (const v of variants) for (const k of Object.keys(v.row.values)) set.add(k);
const columns = (part.params?.vars || []).filter((x) => set.has(x.name)).map((x) => ({ key: x.name }));
for (const k of set) if (!columns.some((c) => c.key === k)) columns.push({ key: k });
const rows = variants.map((v) => {
const vals = v.built?.params ? PR.evaluateVars(v.built.params).values : null;
const values = {};
for (const c of columns) {
const x = vals ? vals.get(c.key) : v.row.values[c.key];
values[c.key] = Number.isFinite(x) ? Number(x.toPrecision(12)) : (Number.isFinite(v.row.values[c.key]) ? v.row.values[c.key] : 0);
}
const offIds = new Set(v.row.off || []);
return { id: v.id, name: v.name, values, off: part.features.filter((f) => offIds.has(f.id)).map((f) => f.name) };
});
return { columns, rows };
}